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