diff --git a/app/src/main/java/com/shuwei/intelligent/shelves/HomeActivity.kt b/app/src/main/java/com/shuwei/intelligent/shelves/HomeActivity.kt index 6ed74c3..c2ed619 100644 --- a/app/src/main/java/com/shuwei/intelligent/shelves/HomeActivity.kt +++ b/app/src/main/java/com/shuwei/intelligent/shelves/HomeActivity.kt @@ -88,6 +88,7 @@ class HomeActivity : BaseActivity() { super.onCreate(savedInstanceState) binding = ActivityHomeBinding.inflate(layoutInflater) EventBus.getDefault().register(this) + setBackground() setContentView(binding.root) updateLeftStatus("1-1冷藏柜 -°C / -%") diff --git a/app/src/main/java/com/shuwei/intelligent/shelves/InitActivity.kt b/app/src/main/java/com/shuwei/intelligent/shelves/InitActivity.kt index 0c48b00..1b05cd0 100644 --- a/app/src/main/java/com/shuwei/intelligent/shelves/InitActivity.kt +++ b/app/src/main/java/com/shuwei/intelligent/shelves/InitActivity.kt @@ -50,31 +50,32 @@ class InitActivity : BaseActivity() { super.onCreate(savedInstanceState) binding = ActivityInitBinding.inflate(layoutInflater) setContentView(binding.root) + hideStatusBar() +// // 获取 ANDROID_ID +// val androidId = +// Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID) +// App.deviceId = androidId +// SpTool.put(SpTool.DEVICE_ID, androidId) +// App.configUrl = UrlConfig.BASE_URL +// App.canteenId = "0" - // 获取 ANDROID_ID - val androidId = - Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID) - App.deviceId = androidId - SpTool.put(SpTool.DEVICE_ID, androidId) - App.configUrl = UrlConfig.BASE_URL - App.canteenId = "0" + var deviceId = AppUtil.getUDID(this) + Log.d(TAG, "onCreate: deviceId=$deviceId") +// deviceId = "39a7abdd06b3c7ab" +// deviceId = "3ea47dc0-3cf0-3c2f-909c-265a9a65572e" + deviceId = "6ce7cd59-b875-38b2-b73d-88a570be3212" + App.deviceId = deviceId -// var deviceId = AppUtil.getUDID(this) -// Log.d(TAG, "onCreate: deviceId=$deviceId") -//// deviceId = "39a7abdd06b3c7ab" -//// deviceId = "3ea47dc0-3cf0-3c2f-909c-265a9a65572e" -// App.deviceId = deviceId -// -// SpTool.put(SpTool.DEVICE_ID, deviceId) -// val deviceConfigCache = SpTool.getString(SpTool.DEVICE_CONFIG_CACHE) -// val checkResult = checkConfigData(deviceConfigCache) -// if (checkResult.not()) { -// binding.ivQrCode.visible() -// binding.btnInit.visible() -// //进行初始化操作 -// initConfig() -// return -// } + SpTool.put(SpTool.DEVICE_ID, deviceId) + val deviceConfigCache = SpTool.getString(SpTool.DEVICE_CONFIG_CACHE) + val checkResult = checkConfigData(deviceConfigCache) + if (checkResult.not()) { + binding.ivQrCode.visible() + binding.btnInit.visible() + //进行初始化操作 + initConfig() + return + } binding.ivQrCode.invisible() binding.btnInit.invisible() diff --git a/app/src/main/java/com/shuwei/intelligent/shelves/ShelfActivity.kt b/app/src/main/java/com/shuwei/intelligent/shelves/ShelfActivity.kt index 2235132..a6f9b0c 100644 --- a/app/src/main/java/com/shuwei/intelligent/shelves/ShelfActivity.kt +++ b/app/src/main/java/com/shuwei/intelligent/shelves/ShelfActivity.kt @@ -80,6 +80,7 @@ class ShelfActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityShelfBinding.inflate(layoutInflater) + setBackground() setContentView(binding.root) EventBus.getDefault().register(this) // tvFoodWeight =binding.tvFoodWeight diff --git a/app/src/main/java/com/shuwei/intelligent/shelves/base/BaseActivity.kt b/app/src/main/java/com/shuwei/intelligent/shelves/base/BaseActivity.kt index 9796a88..f923321 100644 --- a/app/src/main/java/com/shuwei/intelligent/shelves/base/BaseActivity.kt +++ b/app/src/main/java/com/shuwei/intelligent/shelves/base/BaseActivity.kt @@ -46,14 +46,14 @@ open class BaseActivity : AppCompatActivity() { } } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - window.setDecorFitsSystemWindows(false) - window.insetsController?.apply { - hide(WindowInsets.Type.statusBars()) // 隐藏状态栏 - systemBarsBehavior = - WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // 滑动时临时显示 - } - } +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { +// window.setDecorFitsSystemWindows(false) +// window.insetsController?.apply { +// hide(WindowInsets.Type.statusBars()) // 隐藏状态栏 +// systemBarsBehavior = +// WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // 滑动时临时显示 +// } +// } } @@ -75,6 +75,10 @@ open class BaseActivity : AppCompatActivity() { binding.tvRightStatus.setTextColor(color) } + fun setBackground() { + binding.root.setBackgroundColor(ContextCompat.getColor(this,R.color.bg_page)) + } + override fun setContentView(view: View?) { if (view == binding.root) { super.setContentView(view) diff --git a/app/src/main/java/com/shuwei/intelligent/shelves/net/NetViewModel.kt b/app/src/main/java/com/shuwei/intelligent/shelves/net/NetViewModel.kt index 6ffb63f..21eb7f1 100644 --- a/app/src/main/java/com/shuwei/intelligent/shelves/net/NetViewModel.kt +++ b/app/src/main/java/com/shuwei/intelligent/shelves/net/NetViewModel.kt @@ -57,16 +57,16 @@ class NetViewModel : ViewModel() { fun getDeviceConfig(deviceId: String, deviceToken: String) { viewModelScope.launch { - _getDeviceTokenUiState.value = UiState.Loading + _getDeviceConfigUiState.value = UiState.Loading runCatching { val response = apiService.getDeviceInfo(equipmentCode = deviceId, token = deviceToken) if (response.success) { - _getDeviceTokenUiState.value = UiState.Success(response) + _getDeviceConfigUiState.value = UiState.Success(response) } else { - _getDeviceTokenUiState.value = UiState.Error(response.message ?: "请求失败") + _getDeviceConfigUiState.value = UiState.Error(response.message ?: "请求失败") } }.onFailure { - _getDeviceTokenUiState.value = UiState.Error(it.message ?: "请求异常") + _getDeviceConfigUiState.value = UiState.Error(it.message ?: "请求异常") } } } diff --git a/app/src/main/res/drawable-sw600dp/bg_splash.xml b/app/src/main/res/drawable-sw600dp/bg_splash.xml new file mode 100644 index 0000000..ca24da3 --- /dev/null +++ b/app/src/main/res/drawable-sw600dp/bg_splash.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_splash.xml b/app/src/main/res/drawable/bg_splash.xml new file mode 100644 index 0000000..ef87bfd --- /dev/null +++ b/app/src/main/res/drawable/bg_splash.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp/activity_base.xml b/app/src/main/res/layout-sw600dp/activity_base.xml index 82afe0a..4726d73 100644 --- a/app/src/main/res/layout-sw600dp/activity_base.xml +++ b/app/src/main/res/layout-sw600dp/activity_base.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:background="@color/bg_page"> + tools:background="@color/bg_page"> + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_base.xml b/app/src/main/res/layout/activity_base.xml index 61f3bc4..72840e5 100644 --- a/app/src/main/res/layout/activity_base.xml +++ b/app/src/main/res/layout/activity_base.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent" android:orientation="vertical" android:fitsSystemWindows="false" - android:background="@color/bg_page"> + tools:background="@color/bg_page"> + tools:ignore="ContentDescription" + android:visibility="invisible"/> @@ -39,10 +38,10 @@ diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 2515de4..e7eb8f4 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -12,6 +12,7 @@ @color/white + @drawable/bg_splash \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index dbbabfc..bb70a94 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -10,7 +10,9 @@ @color/teal_700 @color/black - ?attr/colorPrimaryVariant + @color/bg_page + + @drawable/bg_splash