feat: app 签名

This commit is contained in:
yangxisong 2025-11-21 14:18:22 +08:00
parent ae8209e025
commit 4712855f6c
6 changed files with 34 additions and 29 deletions

View File

@ -6,8 +6,7 @@ plugins {
alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.android)
} }
val keystores: Map<String, Properties?> = val keystores: Properties? = loadKeystoreProperties("keystore.properties")
mapOf("release" to loadKeystoreProperties("keystore.properties"))
android { android {
namespace = "com.yuanxuan.rokid" namespace = "com.yuanxuan.rokid"
@ -25,13 +24,13 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
} }
keystores["release"]?.let { proerties -> keystores?.let {
signingConfigs { signingConfigs {
create("release") { create("release") {
storeFile = rootProject.file(proerties["storeFile"] as String) storeFile = rootProject.file(it["storeFile"] as String)
storePassword = proerties["storePassword"] as String storePassword = it["storePassword"] as String
keyAlias = proerties["keyAlias"] as String keyAlias = it["keyAlias"] as String
keyPassword = proerties["keyPassword"] as String keyPassword = it["keyPassword"] as String
} }
} }
} }
@ -58,6 +57,7 @@ android {
} }
buildFeatures { buildFeatures {
viewBinding = true viewBinding = true
buildConfig = true
} }
} }

View File

@ -1,5 +1,6 @@
package com.yuanxuan.rokid package com.yuanxuan.rokid
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.view.KeyEvent import android.view.KeyEvent
import androidx.activity.addCallback 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.fadeIn
import com.yuanxuan.rokid.extension.fadeOut import com.yuanxuan.rokid.extension.fadeOut
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import timber.log.Timber
class MainActivity : AppCompatActivity() { 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 { override fun dispatchKeyEvent(event: KeyEvent): Boolean {
return if (AppDependencies.deviceServiceManager.instructState.value == return if (AppDependencies.deviceServiceManager.instructState.value ==
DeviceServiceManager.InstructState.WaitingInstructState DeviceServiceManager.InstructState.WaitingInstructState
@ -68,7 +63,7 @@ class MainActivity : AppCompatActivity() {
* 监听电量 * 监听电量
*/ */
AppDependencies.deviceServiceManager.batteryPercentage.collect { AppDependencies.deviceServiceManager.batteryPercentage.collect {
binding.batteryLevel.text = "${it}%" binding.batteryLevel.text = resources.getString(R.string.status_bar_battery, it)
binding.batteryLevelIv.setImageLevel(it) binding.batteryLevelIv.setImageLevel(it)
} }
} }

View File

@ -2,6 +2,7 @@ package com.yuanxuan.rokid
import android.app.Application import android.app.Application
import android.content.Intent import android.content.Intent
import android.os.Build
import com.yuanxuan.rokid.dependencies.AppDependencies import com.yuanxuan.rokid.dependencies.AppDependencies
import com.yuanxuan.rokid.dependencies.ApplicationDependencyProvider import com.yuanxuan.rokid.dependencies.ApplicationDependencyProvider
import com.yuanxuan.rokid.keeplive.KeepLiveService import com.yuanxuan.rokid.keeplive.KeepLiveService
@ -17,7 +18,8 @@ class RokidApplication : Application() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
Timber.plant(Timber.DebugTree()) if (BuildConfig.DEBUG)
Timber.plant(tree = Timber.DebugTree())
AppDependencies.init(this, ApplicationDependencyProvider(this, applicationScope)) AppDependencies.init(this, ApplicationDependencyProvider(this, applicationScope))
/** /**
* 启动APP必须先获取到SN 后面网络依赖 * 启动APP必须先获取到SN 后面网络依赖

View File

@ -5,9 +5,10 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment 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.databinding.FragmentSnBinding
import com.yuanxuan.rokid.dependencies.AppDependencies import com.yuanxuan.rokid.dependencies.AppDependencies
import timber.log.Timber
class SnFragment : Fragment() { class SnFragment : Fragment() {
@ -24,16 +25,9 @@ class SnFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
try { binding.sn.text =
binding.sn.text = "SN:${AppDependencies.deviceServiceManager.sn}" resources.getString(R.string.device_info_sn, AppDependencies.deviceServiceManager.sn)
} catch (e: Exception) { binding.appVersion.text =
e.printStackTrace() resources.getString(R.string.device_info_app_version, BuildConfig.VERSION_NAME)
} }
}
override fun onDestroy() {
super.onDestroy()
Timber.d("onDestroy")
}
} }

View File

@ -16,5 +16,16 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:text="askjdhkjashdkjhsad" /> tools:text="askjdhkjashdkjhsad" />
<TextView
android:id="@+id/app_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sn"
tools:text="APP版本号" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -8,4 +8,7 @@
<string name="home_item_volume">音量</string> <string name="home_item_volume">音量</string>
<string name="home_item_brightness">亮度</string> <string name="home_item_brightness">亮度</string>
<string name="home_item_sn">SN</string> <string name="home_item_sn">SN</string>
<string name="status_bar_battery">%d%%</string>
<string name="device_info_sn">设备SN:%s</string>
<string name="device_info_app_version">APP版本:%s</string>
</resources> </resources>