From 0f34457a109e6650d360cebe5b02c4d289b2cd06 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 31 Oct 2019 15:33:13 -0400 Subject: [PATCH] Directly store strings in viewmodel --- .../com/topjohnwu/magisk/ui/home/HomeViewModel.kt | 12 ++++++------ app/src/main/res/layout/fragment_magisk.xml | 4 +--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt index 899632f7f..a84b5c2fe 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt @@ -77,7 +77,7 @@ class HomeViewModel( "" } - val safetyNetTitle = KObservableField(R.string.safetyNet_check_text) + val safetyNetTitle = KObservableField(R.string.safetyNet_check_text.res()) val ctsState = KObservableField(SafetyNetState.IDLE) val basicIntegrityState = KObservableField(SafetyNetState.IDLE) val safetyNetState = Observer(ctsState, basicIntegrityState) { @@ -135,7 +135,7 @@ class HomeViewModel( fun safetyNetPressed() { ctsState.value = SafetyNetState.LOADING basicIntegrityState.value = SafetyNetState.LOADING - safetyNetTitle.value = R.string.checking_safetyNet_status + safetyNetTitle.value = R.string.checking_safetyNet_status.res() UpdateSafetyNetEvent().publish() } @@ -144,7 +144,7 @@ class HomeViewModel( response and 0x0F == 0 -> { val hasCtsPassed = response and SafetyNetHelper.CTS_PASS != 0 val hasBasicIntegrityPassed = response and SafetyNetHelper.BASIC_PASS != 0 - safetyNetTitle.value = R.string.safetyNet_check_success + safetyNetTitle.value = R.string.safetyNet_check_success.res() ctsState.value = if (hasCtsPassed) { SafetyNetState.PASS } else { @@ -164,8 +164,8 @@ class HomeViewModel( ctsState.value = SafetyNetState.IDLE basicIntegrityState.value = SafetyNetState.IDLE safetyNetTitle.value = when (response) { - SafetyNetHelper.RESPONSE_ERR -> R.string.safetyNet_res_invalid - else -> R.string.safetyNet_api_error + SafetyNetHelper.RESPONSE_ERR -> R.string.safetyNet_res_invalid.res() + else -> R.string.safetyNet_api_error.res() } } } @@ -192,7 +192,7 @@ class HomeViewModel( _managerState.value = MagiskState.LOADING ctsState.value = SafetyNetState.IDLE basicIntegrityState.value = SafetyNetState.IDLE - safetyNetTitle.value = R.string.safetyNet_check_text + safetyNetTitle.value = R.string.safetyNet_check_text.res() }.subscribeK { updateSelf() ensureEnv() diff --git a/app/src/main/res/layout/fragment_magisk.xml b/app/src/main/res/layout/fragment_magisk.xml index 399aa75a2..366867ead 100644 --- a/app/src/main/res/layout/fragment_magisk.xml +++ b/app/src/main/res/layout/fragment_magisk.xml @@ -15,8 +15,6 @@ - - @@ -239,7 +237,7 @@ android:layout_marginRight="@dimen/margin_generic" android:gravity="center" android:maxLines="1" - android:text="@{XStringKt.res(viewModel.safetyNetTitle)}" + android:text="@{viewModel.safetyNetTitle}" android:textStyle="bold" app:autoSizeMaxTextSize="14sp" app:autoSizeTextType="uniform"