diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c8df26640..9cc0729ee 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -82,7 +82,7 @@ dependencies { implementation(project(":app:signing")) implementation("com.github.topjohnwu:jtar:1.0.0") - implementation("com.github.topjohnwu:indeterminate-checkbox:1.0.6") + implementation("com.github.topjohnwu:indeterminate-checkbox:1.0.7") implementation("com.jakewharton.timber:timber:4.7.1") implementation(kotlin("stdlib")) diff --git a/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/SettingsItem.kt b/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/SettingsItem.kt index c7a62594d..26de77b57 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/SettingsItem.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/SettingsItem.kt @@ -10,6 +10,7 @@ import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.R import com.topjohnwu.magisk.databinding.ObservableItem import com.topjohnwu.magisk.utils.TransitiveText +import com.topjohnwu.magisk.utils.asTransitive import com.topjohnwu.magisk.utils.set import com.topjohnwu.magisk.view.MagiskDialog import org.koin.core.KoinComponent @@ -94,22 +95,20 @@ sealed class SettingsItem : ObservableItem() { } } - abstract class Input : Value(), KoinComponent { + abstract class Input : Value() { override val layoutRes = R.layout.item_settings_input - open val showStrip = true - protected val resources get() = get() - protected abstract val intermediate: String? + protected abstract val inputResult: String? override fun onPressed(view: View) { MagiskDialog(view.context) - .applyTitle(title.getText(resources)) + .applyTitle(title.getText(view.resources)) .applyView(getView(view.context)) .applyButton(MagiskDialog.ButtonType.POSITIVE) { titleRes = android.R.string.ok onClick { - intermediate?.let { result -> + inputResult?.let { result -> preventDismiss = false value = result it.dismiss() @@ -125,7 +124,6 @@ sealed class SettingsItem : ObservableItem() { } abstract fun getView(context: Context): View - } abstract class Selector : Value(), KoinComponent { @@ -141,12 +139,12 @@ sealed class SettingsItem : ObservableItem() { open val entryValues get() = resources.getArrayOrEmpty(entryValRes) @get:Bindable - val selectedEntry - get() = entries.getOrNull(value) + override val description: TransitiveText + get() = entries.getOrNull(value)?.asTransitive() ?: TransitiveText.EMPTY protected inline fun setS( new: T, old: T, setter: (T) -> Unit, afterChanged: (T) -> Unit = {}) { - setV(new, old, setter, BR.selectedEntry, BR.description, afterChanged = afterChanged) + setV(new, old, setter, BR.description, afterChanged = afterChanged) } private fun Resources.getArrayOrEmpty(id: Int): Array = diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt index be5a4736b..a6003bdfe 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt @@ -79,15 +79,15 @@ object ClearRepoCache : SettingsItem.Blank() { object Hide : SettingsItem.Input() { override val title = R.string.settings_hide_manager_title.asTransitive() override val description = R.string.settings_hide_manager_summary.asTransitive() - override val showStrip = false - override var value = resources.getString(R.string.re_app_name) + + @get:Bindable + override var value = "Manager" set(value) = setV(value, field, { field = it }, BR.error) @get:Bindable val isError get() = value.length > 14 || value.isBlank() - override val intermediate: String? - get() = if (isError) null else value + override val inputResult get() = if (isError) null else value override fun getView(context: Context) = DialogSettingsAppNameBinding .inflate(LayoutInflater.from(context)).also { it.data = this }.root @@ -105,8 +105,11 @@ fun HideOrRestore() = object DownloadPath : SettingsItem.Input() { override var value = Config.downloadPath set(value) = setV(value, field, { field = it }) { Config.downloadPath = it } + override val title = R.string.settings_download_path_title.asTransitive() - override val intermediate: String? + override val description get() = path.asTransitive() + + override val inputResult: String? get() = if (Utils.ensureDownloadPath(result) != null) result else null @get:Bindable @@ -135,7 +138,8 @@ object UpdateChannelUrl : SettingsItem.Input() { override val title = R.string.settings_update_custom.asTransitive() override var value = Config.customChannelUrl set(value) = setV(value, field, { field = it }) { Config.customChannelUrl = it } - override val intermediate: String? get() = result + + override val inputResult get() = result @get:Bindable var result = value diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt b/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt index d10686fad..3961ef098 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt +++ b/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt @@ -259,7 +259,6 @@ fun setState(view: IndeterminateCheckBox, state: Boolean?) { @InverseBindingAdapter(attribute = "state") fun getState(view: IndeterminateCheckBox) = view.state - @BindingAdapter("stateAttrChanged") fun setListeners( view: IndeterminateCheckBox, diff --git a/app/src/main/res/layout/dialog_settings_download_path.xml b/app/src/main/res/layout/dialog_settings_download_path.xml index f05ff5a43..cd12cbc10 100644 --- a/app/src/main/res/layout/dialog_settings_download_path.xml +++ b/app/src/main/res/layout/dialog_settings_download_path.xml @@ -17,7 +17,7 @@ android:orientation="vertical" android:padding="@dimen/margin_generic"> - diff --git a/app/src/main/res/layout/item_settings_blank.xml b/app/src/main/res/layout/item_settings_blank.xml index 7065e39a0..4c5cb8a42 100644 --- a/app/src/main/res/layout/item_settings_blank.xml +++ b/app/src/main/res/layout/item_settings_blank.xml @@ -29,7 +29,7 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - - - - @@ -61,12 +60,12 @@ android:orientation="vertical" android:paddingTop="@dimen/l1" android:paddingBottom="@dimen/l1" - app:layout_constraintBottom_toTopOf="@+id/input_divider" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/input_indicator" app:layout_constraintStart_toEndOf="@+id/input_icon" app:layout_constraintTop_toTopOf="parent"> - - - - - - - \ No newline at end of file + diff --git a/app/src/main/res/layout/item_settings_section.xml b/app/src/main/res/layout/item_settings_section.xml index be304a526..e083c9cf7 100644 --- a/app/src/main/res/layout/item_settings_section.xml +++ b/app/src/main/res/layout/item_settings_section.xml @@ -17,7 +17,7 @@ android:paddingTop="@dimen/l1" android:paddingBottom="@dimen/l_50"> - - - - @@ -61,12 +60,12 @@ android:orientation="vertical" android:paddingTop="@dimen/l1" android:paddingBottom="@dimen/l1" - app:layout_constraintBottom_toTopOf="@+id/selector_divider" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/selector_indicator" app:layout_constraintStart_toEndOf="@+id/selector_icon" app:layout_constraintTop_toTopOf="parent"> - - - - - - - \ No newline at end of file + diff --git a/app/src/main/res/layout/item_settings_toggle.xml b/app/src/main/res/layout/item_settings_toggle.xml index 20720ffc6..1925d4d9b 100644 --- a/app/src/main/res/layout/item_settings_toggle.xml +++ b/app/src/main/res/layout/item_settings_toggle.xml @@ -31,7 +31,7 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - - - \ No newline at end of file +