diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt index 91a532e43..c17c5be56 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt @@ -1,9 +1,13 @@ package com.topjohnwu.magisk.redesign.home +import com.skoumal.teanity.util.KObservableField import com.topjohnwu.magisk.redesign.compat.CompatViewModel class HomeViewModel : CompatViewModel() { + val stateTextMagisk = KObservableField("is up to date") + val stateTextManager = KObservableField("is up to date") + fun onDeletePressed() {} } \ No newline at end of file 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 7e2e93770..b7efa39f6 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt +++ b/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt @@ -1,7 +1,9 @@ package com.topjohnwu.magisk.utils import android.view.View +import android.widget.TextSwitcher import android.widget.TextView +import android.widget.ViewSwitcher import androidx.annotation.ColorInt import androidx.annotation.DrawableRes import androidx.appcompat.widget.AppCompatImageView @@ -245,4 +247,22 @@ fun View.setOnSelectClickListener(listener: View.OnClickListener, resetTime: Lon } } } +} + +@BindingAdapter("textCaptionVariant") +fun TextSwitcher.setTextBinding(text: CharSequence) { + tag as? ViewSwitcher.ViewFactory ?: ViewSwitcher.ViewFactory { + View.inflate(context, R.layout.swicher_caption_variant, null) + }.also { + tag = it + setFactory(it) + setInAnimation(context, R.anim.switcher_bottom_up) + setOutAnimation(context, R.anim.switcher_center_up) + } + + + val currentText = (currentView as? TextView)?.text + if (currentText != text) { + setText(text) + } } \ No newline at end of file diff --git a/app/src/main/res/anim/switcher_bottom_up.xml b/app/src/main/res/anim/switcher_bottom_up.xml new file mode 100644 index 000000000..266ec3aa1 --- /dev/null +++ b/app/src/main/res/anim/switcher_bottom_up.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/switcher_center_up.xml b/app/src/main/res/anim/switcher_center_up.xml new file mode 100644 index 000000000..a19a366e9 --- /dev/null +++ b/app/src/main/res/anim/switcher_center_up.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home_md2.xml b/app/src/main/res/layout/fragment_home_md2.xml index dd547cba6..2d8ad9fca 100644 --- a/app/src/main/res/layout/fragment_home_md2.xml +++ b/app/src/main/res/layout/fragment_home_md2.xml @@ -41,7 +41,7 @@ style="?styleIconPrimary" onSelectClick="@{() -> viewModel.onDeletePressed()}" onSelectReset="@{10000L}" - android:padding="@dimen/l_50" + android:padding="@dimen/l_25" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:srcCompat="@drawable/ic_magisk_delete" @@ -60,12 +60,11 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_chainStyle="packed" /> - - + \ No newline at end of file