forked from geode-sdk/android-launcher
cleanup some warnings
This commit is contained in:
6 files changed
+36
-22
No files matched your search
@@ -18,6 +18,7 @@ import androidx.core.view.WindowInsetsControllerCompat
|
|||||||
import com.customRobTop.JniToCpp.resumeSound
|
import com.customRobTop.JniToCpp.resumeSound
|
||||||
import org.cocos2dx.lib.Cocos2dxGLSurfaceView.Companion.closeIMEKeyboard
|
import org.cocos2dx.lib.Cocos2dxGLSurfaceView.Companion.closeIMEKeyboard
|
||||||
import org.cocos2dx.lib.Cocos2dxGLSurfaceView.Companion.openIMEKeyboard
|
import org.cocos2dx.lib.Cocos2dxGLSurfaceView.Companion.openIMEKeyboard
|
||||||
|
import java.lang.ref.WeakReference
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
@@ -30,12 +31,12 @@ open class BaseRobTopActivity : DefaultRobTopActivity() {
|
|||||||
|
|
||||||
private var isPaused_ = false
|
private var isPaused_ = false
|
||||||
|
|
||||||
lateinit var me: Activity
|
lateinit var me: WeakReference<Activity>
|
||||||
private var receiver_: BroadcastReceiver? = null
|
private var receiver_: BroadcastReceiver? = null
|
||||||
private var shouldResumeSound_ = true
|
private var shouldResumeSound_ = true
|
||||||
|
|
||||||
fun setCurrentActivity(currentActivity: Activity) {
|
fun setCurrentActivity(currentActivity: Activity) {
|
||||||
me = currentActivity
|
me = WeakReference(currentActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@@ -48,7 +49,7 @@ open class BaseRobTopActivity : DefaultRobTopActivity() {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getUserID(): String {
|
fun getUserID(): String {
|
||||||
// this is how RobTop does it in 2.2, based on the meltdown leaks
|
// this is how RobTop does it in 2.2, based on the meltdown leaks
|
||||||
val androidId = Settings.Secure.getString(me.contentResolver, Settings.Secure.ANDROID_ID)
|
val androidId = Settings.Secure.getString(me.get()?.contentResolver, Settings.Secure.ANDROID_ID)
|
||||||
return if ("9774d56d682e549c" != androidId) {
|
return if ("9774d56d682e549c" != androidId) {
|
||||||
UUID.nameUUIDFromBytes(androidId.toByteArray()).toString()
|
UUID.nameUUIDFromBytes(androidId.toByteArray()).toString()
|
||||||
} else return UUID.randomUUID().toString()
|
} else return UUID.randomUUID().toString()
|
||||||
@@ -56,7 +57,7 @@ open class BaseRobTopActivity : DefaultRobTopActivity() {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun isNetworkAvailable(): Boolean {
|
fun isNetworkAvailable(): Boolean {
|
||||||
val connectivityManager = me.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
val connectivityManager = me.get()?.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
|
|
||||||
val activeNetwork = connectivityManager.activeNetwork
|
val activeNetwork = connectivityManager.activeNetwork
|
||||||
val networkCapabilities = connectivityManager.getNetworkCapabilities(activeNetwork) ?: return false
|
val networkCapabilities = connectivityManager.getNetworkCapabilities(activeNetwork) ?: return false
|
||||||
@@ -75,8 +76,8 @@ open class BaseRobTopActivity : DefaultRobTopActivity() {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun openURL(url: String) {
|
fun openURL(url: String) {
|
||||||
Log.d("MAIN", "Open URL")
|
Log.d("MAIN", "Open URL")
|
||||||
me.runOnUiThread {
|
me.get()?.runOnUiThread {
|
||||||
me.startActivity(
|
me.get()?.startActivity(
|
||||||
Intent(
|
Intent(
|
||||||
"android.intent.action.VIEW",
|
"android.intent.action.VIEW",
|
||||||
Uri.parse(url)
|
Uri.parse(url)
|
||||||
@@ -87,17 +88,17 @@ open class BaseRobTopActivity : DefaultRobTopActivity() {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun sendMail(subject: String, body: String, to: String) {
|
fun sendMail(subject: String, body: String, to: String) {
|
||||||
me.runOnUiThread {
|
me.get()?.runOnUiThread {
|
||||||
val i = Intent("android.intent.action.SEND")
|
val i = Intent("android.intent.action.SEND")
|
||||||
i.type = "message/rfc822"
|
i.type = "message/rfc822"
|
||||||
i.putExtra("android.intent.extra.EMAIL", arrayOf(to))
|
i.putExtra("android.intent.extra.EMAIL", arrayOf(to))
|
||||||
i.putExtra("android.intent.extra.SUBJECT", subject)
|
i.putExtra("android.intent.extra.SUBJECT", subject)
|
||||||
i.putExtra("android.intent.extra.TEXT", body)
|
i.putExtra("android.intent.extra.TEXT", body)
|
||||||
try {
|
try {
|
||||||
me.startActivity(Intent.createChooser(i, "Send mail..."))
|
me.get()?.startActivity(Intent.createChooser(i, "Send mail..."))
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
me,
|
me.get(),
|
||||||
"There are no email clients installed.",
|
"There are no email clients installed.",
|
||||||
Toast.LENGTH_SHORT,
|
Toast.LENGTH_SHORT,
|
||||||
).show()
|
).show()
|
||||||
@@ -122,7 +123,7 @@ open class BaseRobTopActivity : DefaultRobTopActivity() {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun onToggleKeyboard() {
|
fun onToggleKeyboard() {
|
||||||
me.runOnUiThread {
|
me.get()?.runOnUiThread {
|
||||||
if (keyboardActive_) {
|
if (keyboardActive_) {
|
||||||
openIMEKeyboard()
|
openIMEKeyboard()
|
||||||
} else {
|
} else {
|
||||||
@@ -161,7 +162,7 @@ open class BaseRobTopActivity : DefaultRobTopActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
me = this
|
me = WeakReference(this)
|
||||||
|
|
||||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||||
|
|
||||||
@@ -170,7 +171,7 @@ open class BaseRobTopActivity : DefaultRobTopActivity() {
|
|||||||
|
|
||||||
open fun registerReceiver() {
|
open fun registerReceiver() {
|
||||||
if (receiver_ != null) {
|
if (receiver_ != null) {
|
||||||
me.unregisterReceiver(receiver_)
|
me.get()?.unregisterReceiver(receiver_)
|
||||||
receiver_ = null
|
receiver_ = null
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -197,7 +198,7 @@ open class BaseRobTopActivity : DefaultRobTopActivity() {
|
|||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
Intent.ACTION_SCREEN_ON -> {
|
Intent.ACTION_SCREEN_ON -> {
|
||||||
Log.d("TAG", "ACTION_SCREEN_ON")
|
Log.d("TAG", "ACTION_SCREEN_ON")
|
||||||
if (!(me.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).isKeyguardLocked) {
|
if (!(me.get()?.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).isKeyguardLocked) {
|
||||||
shouldResumeSound_ = true
|
shouldResumeSound_ = true
|
||||||
}
|
}
|
||||||
if (!isPaused_ && shouldResumeSound_) {
|
if (!isPaused_ && shouldResumeSound_) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.customRobTop
|
package com.customRobTop
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
object JniToCpp {
|
object JniToCpp {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
external fun didCacheInterstitial(str: String?)
|
external fun didCacheInterstitial(str: String?)
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import androidx.compose.foundation.Image
|
|||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.PlayArrow
|
import androidx.compose.material.icons.filled.PlayArrow
|
||||||
import androidx.compose.material.icons.filled.Settings
|
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.cocos2dx.lib
|
package org.cocos2dx.lib
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.*
|
import android.graphics.*
|
||||||
import android.graphics.Paint.FontMetricsInt
|
import android.graphics.Paint.FontMetricsInt
|
||||||
@@ -8,19 +7,21 @@ import android.text.TextPaint
|
|||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import java.lang.ref.WeakReference
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.nio.ByteOrder
|
import java.nio.ByteOrder
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
|
||||||
object Cocos2dxBitmap {
|
object Cocos2dxBitmap {
|
||||||
private lateinit var sContext: Context
|
private lateinit var sContext: WeakReference<Context>
|
||||||
private external fun nativeInitBitmapDC(i: Int, i2: Int, bArr: ByteArray)
|
|
||||||
|
@JvmStatic
|
||||||
|
private external fun nativeInitBitmapDC(pWidth: Int, pHeight: Int, pPixels: ByteArray)
|
||||||
|
|
||||||
fun setContext(pContext: Context) {
|
fun setContext(pContext: Context) {
|
||||||
sContext = pContext
|
sContext = WeakReference(pContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createTextBitmap(
|
fun createTextBitmap(
|
||||||
@@ -54,6 +55,7 @@ object Cocos2dxBitmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@Suppress("unused")
|
||||||
fun createTextBitmapShadowStroke(
|
fun createTextBitmapShadowStroke(
|
||||||
pString: String,
|
pString: String,
|
||||||
pFontName: String,
|
pFontName: String,
|
||||||
@@ -168,7 +170,9 @@ object Cocos2dxBitmap {
|
|||||||
paint.isAntiAlias = true
|
paint.isAntiAlias = true
|
||||||
if (pFontName.endsWith(".ttf")) {
|
if (pFontName.endsWith(".ttf")) {
|
||||||
try {
|
try {
|
||||||
paint.typeface = Cocos2dxTypefaces[sContext, pFontName]
|
sContext.get()?.apply {
|
||||||
|
paint.typeface = Cocos2dxTypefaces[this, pFontName]
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("Cocos2dxBitmap", "error to create ttf type face: $pFontName")
|
Log.e("Cocos2dxBitmap", "error to create ttf type face: $pFontName")
|
||||||
paint.typeface = Typeface.create(pFontName, Typeface.NORMAL)
|
paint.typeface = Typeface.create(pFontName, Typeface.NORMAL)
|
||||||
@@ -349,6 +353,8 @@ object Cocos2dxBitmap {
|
|||||||
return pixels
|
return pixels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@JvmStatic
|
||||||
private fun getFontSizeAccordingHeight(height: Int): Int {
|
private fun getFontSizeAccordingHeight(height: Int): Int {
|
||||||
val paint = Paint()
|
val paint = Paint()
|
||||||
val bounds = Rect()
|
val bounds = Rect()
|
||||||
@@ -367,6 +373,8 @@ object Cocos2dxBitmap {
|
|||||||
return incrTextSize
|
return incrTextSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@JvmStatic
|
||||||
private fun getStringWithEllipsis(pString: String, width: Float, fontSize: Float): String {
|
private fun getStringWithEllipsis(pString: String, width: Float, fontSize: Float): String {
|
||||||
if (TextUtils.isEmpty(pString)) {
|
if (TextUtils.isEmpty(pString)) {
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ class Cocos2dxHelper {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
external fun nativeSetApkPath(pApkPath: String)
|
external fun nativeSetApkPath(pApkPath: String)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
private external fun nativeSetEditTextDialogResult(pBytes: ByteArray)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getCocos2dxWritablePath(): String? {
|
fun getCocos2dxWritablePath(): String? {
|
||||||
return sFileDirectory
|
return sFileDirectory
|
||||||
|
|||||||
@@ -51,12 +51,14 @@ class Cocos2dxRenderer : GLSurfaceView.Renderer {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
private external fun nativeTouchesMove(pIDs: IntArray, pXs: FloatArray, pYs: FloatArray)
|
private external fun nativeTouchesMove(pIDs: IntArray, pXs: FloatArray, pYs: FloatArray)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
private external fun nativeInit(pWidth: Int, pHeight: Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var mLastTickInNanoSeconds: Long = 0
|
private var mLastTickInNanoSeconds: Long = 0
|
||||||
private var mScreenWidth = 0
|
private var mScreenWidth = 0
|
||||||
private var mScreenHeight = 0
|
private var mScreenHeight = 0
|
||||||
private external fun nativeInit(pWidth: Int, pHeight: Int)
|
|
||||||
|
|
||||||
fun setScreenWidthAndHeight(pSurfaceWidth: Int, pSurfaceHeight: Int) {
|
fun setScreenWidthAndHeight(pSurfaceWidth: Int, pSurfaceHeight: Int) {
|
||||||
mScreenWidth = pSurfaceWidth
|
mScreenWidth = pSurfaceWidth
|
||||||
|
|||||||
Reference in new issue
Block a user