diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0bf228d..6788a4c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -6,8 +6,7 @@ plugins { alias(libs.plugins.kotlin.android) } -val keystores: Map = - mapOf("release" to loadKeystoreProperties("keystore.properties")) +val keystores: Properties? = loadKeystoreProperties("keystore.properties") android { namespace = "com.yuanxuan.rokid" @@ -25,13 +24,13 @@ android { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - keystores["release"]?.let { proerties -> + keystores?.let { signingConfigs { create("release") { - storeFile = rootProject.file(proerties["storeFile"] as String) - storePassword = proerties["storePassword"] as String - keyAlias = proerties["keyAlias"] as String - keyPassword = proerties["keyPassword"] as String + storeFile = rootProject.file(it["storeFile"] as String) + storePassword = it["storePassword"] as String + keyAlias = it["keyAlias"] as String + keyPassword = it["keyPassword"] as String } } } @@ -58,6 +57,7 @@ android { } buildFeatures { viewBinding = true + buildConfig = true } } diff --git a/app/src/main/java/com/yuanxuan/rokid/MainActivity.kt b/app/src/main/java/com/yuanxuan/rokid/MainActivity.kt index 47a266b..7e7f133 100644 --- a/app/src/main/java/com/yuanxuan/rokid/MainActivity.kt +++ b/app/src/main/java/com/yuanxuan/rokid/MainActivity.kt @@ -1,5 +1,6 @@ package com.yuanxuan.rokid +import android.os.Build import android.os.Bundle import android.view.KeyEvent import androidx.activity.addCallback @@ -14,6 +15,7 @@ import com.yuanxuan.rokid.device.DeviceServiceManager import com.yuanxuan.rokid.extension.fadeIn import com.yuanxuan.rokid.extension.fadeOut import kotlinx.coroutines.launch +import timber.log.Timber class MainActivity : AppCompatActivity() { @@ -37,18 +39,11 @@ class MainActivity : AppCompatActivity() { /** * 拦截返回键事件,防止返回到桌面 */ - onBackPressedDispatcher.addCallback { - - } + onBackPressedDispatcher.addCallback {} } - /** - * 触摸板事件 - * [KeyEvent.KEYCODE_DPAD_DOWN] 和 [KeyEvent.KEYCODE_DPAD_RIGHT] 同时响应 - * 所以直接消费掉一个 - */ override fun dispatchKeyEvent(event: KeyEvent): Boolean { return if (AppDependencies.deviceServiceManager.instructState.value == DeviceServiceManager.InstructState.WaitingInstructState @@ -68,7 +63,7 @@ class MainActivity : AppCompatActivity() { * 监听电量 */ AppDependencies.deviceServiceManager.batteryPercentage.collect { - binding.batteryLevel.text = "${it}%" + binding.batteryLevel.text = resources.getString(R.string.status_bar_battery, it) binding.batteryLevelIv.setImageLevel(it) } } diff --git a/app/src/main/java/com/yuanxuan/rokid/RokidApplication.kt b/app/src/main/java/com/yuanxuan/rokid/RokidApplication.kt index 459d56a..7c83cb3 100644 --- a/app/src/main/java/com/yuanxuan/rokid/RokidApplication.kt +++ b/app/src/main/java/com/yuanxuan/rokid/RokidApplication.kt @@ -2,6 +2,7 @@ package com.yuanxuan.rokid import android.app.Application import android.content.Intent +import android.os.Build import com.yuanxuan.rokid.dependencies.AppDependencies import com.yuanxuan.rokid.dependencies.ApplicationDependencyProvider import com.yuanxuan.rokid.keeplive.KeepLiveService @@ -17,7 +18,8 @@ class RokidApplication : Application() { override fun onCreate() { super.onCreate() - Timber.plant(Timber.DebugTree()) + if (BuildConfig.DEBUG) + Timber.plant(tree = Timber.DebugTree()) AppDependencies.init(this, ApplicationDependencyProvider(this, applicationScope)) /** * 启动APP必须先获取到SN 后面网络依赖 diff --git a/app/src/main/java/com/yuanxuan/rokid/ui/SnFragment.kt b/app/src/main/java/com/yuanxuan/rokid/ui/SnFragment.kt index 7958bd1..1c3c92b 100644 --- a/app/src/main/java/com/yuanxuan/rokid/ui/SnFragment.kt +++ b/app/src/main/java/com/yuanxuan/rokid/ui/SnFragment.kt @@ -5,9 +5,10 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import com.yuanxuan.rokid.BuildConfig +import com.yuanxuan.rokid.R import com.yuanxuan.rokid.databinding.FragmentSnBinding import com.yuanxuan.rokid.dependencies.AppDependencies -import timber.log.Timber class SnFragment : Fragment() { @@ -24,16 +25,9 @@ class SnFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - try { - binding.sn.text = "SN:${AppDependencies.deviceServiceManager.sn}" - } catch (e: Exception) { - e.printStackTrace() - } + binding.sn.text = + resources.getString(R.string.device_info_sn, AppDependencies.deviceServiceManager.sn) + binding.appVersion.text = + resources.getString(R.string.device_info_app_version, BuildConfig.VERSION_NAME) } - - override fun onDestroy() { - super.onDestroy() - Timber.d("onDestroy") - } - } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_sn.xml b/app/src/main/res/layout/fragment_sn.xml index c8432f5..d0f0d30 100644 --- a/app/src/main/res/layout/fragment_sn.xml +++ b/app/src/main/res/layout/fragment_sn.xml @@ -16,5 +16,16 @@ app:layout_constraintTop_toTopOf="parent" tools:text="askjdhkjashdkjhsad" /> + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0b543d3..110d296 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -8,4 +8,7 @@ 音量 亮度 SN + %d%% + 设备SN:%s + APP版本:%s \ No newline at end of file