Don't do layered cards

This commit is contained in:
topjohnwu 2020-02-27 01:43:00 -08:00
parent 0ce7da1bf6
commit b90e0430f8
4 changed files with 164 additions and 217 deletions

View File

@ -31,6 +31,8 @@ class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() {
// Set barrier reference IDs in code, since resource IDs will be stripped in release mode // Set barrier reference IDs in code, since resource IDs will be stripped in release mode
binding.homeMagiskWrapper.homeMagiskTitleBarrier.referencedIds = binding.homeMagiskWrapper.homeMagiskTitleBarrier.referencedIds =
intArrayOf(R.id.home_magisk_action, R.id.home_magisk_title, R.id.home_magisk_icon) intArrayOf(R.id.home_magisk_action, R.id.home_magisk_title, R.id.home_magisk_icon)
binding.homeMagiskWrapper.homeMagiskBarrier.referencedIds =
intArrayOf(R.id.home_magisk_latest_version, R.id.home_magisk_installed_version, R.id.home_magisk_mode)
binding.homeManagerWrapper.homeManagerTitleBarrier.referencedIds = binding.homeManagerWrapper.homeManagerTitleBarrier.referencedIds =
intArrayOf(R.id.home_manager_action, R.id.home_manager_title, R.id.home_manager_icon) intArrayOf(R.id.home_manager_action, R.id.home_manager_title, R.id.home_manager_icon)

View File

@ -13,7 +13,6 @@ import com.topjohnwu.magisk.core.model.ManagerJson
import com.topjohnwu.magisk.core.model.UpdateInfo import com.topjohnwu.magisk.core.model.UpdateInfo
import com.topjohnwu.magisk.data.repository.MagiskRepository import com.topjohnwu.magisk.data.repository.MagiskRepository
import com.topjohnwu.magisk.extensions.* import com.topjohnwu.magisk.extensions.*
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Magisk
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Manager import com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Manager
import com.topjohnwu.magisk.model.entity.recycler.DeveloperItem import com.topjohnwu.magisk.model.entity.recycler.DeveloperItem
import com.topjohnwu.magisk.model.entity.recycler.HomeItem import com.topjohnwu.magisk.model.entity.recycler.HomeItem
@ -48,7 +47,6 @@ class HomeViewModel(
val stateMagiskInstalledVersion get() = val stateMagiskInstalledVersion get() =
"${Info.env.magiskVersionString} (${Info.env.magiskVersionCode})" "${Info.env.magiskVersionString} (${Info.env.magiskVersionCode})"
val stateMagiskMode get() = (if (Config.coreOnly) R.string.home_status_safe else R.string.home_status_normal).res() val stateMagiskMode get() = (if (Config.coreOnly) R.string.home_status_safe else R.string.home_status_normal).res()
val stateMagiskProgress = KObservableField(0)
val stateManagerRemoteVersion = KObservableField(R.string.loading.res()) val stateManagerRemoteVersion = KObservableField(R.string.loading.res())
val stateManagerInstalledVersion = Info.stub?.let { val stateManagerInstalledVersion = Info.stub?.let {
@ -70,8 +68,6 @@ class HomeViewModel(
init { init {
RemoteFileService.progressBroadcast.observeForever { RemoteFileService.progressBroadcast.observeForever {
when (it?.second) { when (it?.second) {
is Magisk.Download,
is Magisk.Flash -> stateMagiskProgress.value = it.first.times(100f).roundToInt()
is Manager -> stateManagerProgress.value = it.first.times(100f).roundToInt() is Manager -> stateManagerProgress.value = it.first.times(100f).roundToInt()
} }
} }

View File

@ -76,7 +76,6 @@
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/WidgetFoundation.Button" style="@style/WidgetFoundation.Button"
gone="@{viewModel.stateMagisk != MagiskState.OBSOLETE}" gone="@{viewModel.stateMagisk != MagiskState.OBSOLETE}"
isEnabled="@{viewModel.stateManager == MagiskState.UP_TO_DATE &amp;&amp; (viewModel.stateMagiskProgress == 0 || viewModel.stateMagiskProgress == 100)}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:onClick="@{() -> viewModel.onMagiskPressed()}" android:onClick="@{() -> viewModel.onMagiskPressed()}"
@ -87,7 +86,6 @@
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/WidgetFoundation.Button.Text" style="@style/WidgetFoundation.Button.Text"
gone="@{viewModel.stateMagisk == MagiskState.OBSOLETE}" gone="@{viewModel.stateMagisk == MagiskState.OBSOLETE}"
isEnabled="@{viewModel.stateManager == MagiskState.UP_TO_DATE &amp;&amp; (viewModel.stateMagiskProgress == 0 || viewModel.stateMagiskProgress == 100)}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:onClick="@{() -> viewModel.onMagiskPressed()}" android:onClick="@{() -> viewModel.onMagiskPressed()}"
@ -102,7 +100,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:barrierDirection="bottom" app:barrierDirection="bottom"
app:constraint_referenced_ids="home_magisk_action,home_magisk_title,home_magisk_icon" /> tools:constraint_referenced_ids="home_magisk_action,home_magisk_title,home_magisk_icon" />
<HorizontalScrollView <HorizontalScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -118,155 +116,120 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<com.google.android.material.card.MaterialCardView <androidx.constraintlayout.widget.ConstraintLayout
style="@style/W.Home.Card.First"
android:layout_height="wrap_content"
android:layout_width="wrap_content" >
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
style="@style/W.Home.Section"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/home_magisk_latest_version"
style="@style/W.Home.Item.Top"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" >
<TextView
style="@style/W.Home.ItemContent"
android:text="@string/module_section_remote" />
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{viewModel.isConnected ? viewModel.stateMagiskRemoteVersion : @string/not_available}"
tools:text="20.1 (12345)" />
</LinearLayout>
<LinearLayout
android:id="@+id/home_magisk_installed_version"
style="@style/W.Home.Item"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_magisk_latest_version">
<TextView
style="@style/W.Home.ItemContent"
android:text="@string/installed" />
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.env.isActive ? viewModel.stateMagiskInstalledVersion : @string/not_available}"
tools:text="20.1 (12345)" />
</LinearLayout>
<LinearLayout
android:id="@+id/home_magisk_mode"
style="@style/W.Home.Item.Bottom"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_magisk_installed_version">
<TextView
style="@style/W.Home.ItemContent"
android:text="@string/status" />
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.env.isActive ? viewModel.stateMagiskMode : @string/not_available}"
tools:text="Normal" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<ProgressBar
style="@style/WidgetFoundation.ProgressBar"
gone="@{viewModel.stateMagiskProgress == 0 || viewModel.stateMagiskProgress == 100}"
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:max="100"
android:progress="@{viewModel.stateMagiskProgress}" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
style="@style/W.Home.Card"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout <LinearLayout
android:id="@+id/home_magisk_latest_version"
style="@style/W.Home.Item.Top"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" >
<TextView
style="@style/W.Home.ItemContent"
android:text="@string/module_section_remote" />
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{viewModel.isConnected ? viewModel.stateMagiskRemoteVersion : @string/not_available}"
tools:text="20.1 (12345)" />
</LinearLayout>
<LinearLayout
android:id="@+id/home_magisk_installed_version"
style="@style/W.Home.Item"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_magisk_latest_version">
<TextView
style="@style/W.Home.ItemContent"
android:text="@string/installed" />
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.env.isActive ? viewModel.stateMagiskInstalledVersion : @string/not_available}"
tools:text="20.1 (12345)" />
</LinearLayout>
<LinearLayout
android:id="@+id/home_magisk_mode"
style="@style/W.Home.Item.Bottom"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_magisk_installed_version">
<TextView
style="@style/W.Home.ItemContent"
android:text="@string/status" />
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.env.isActive ? viewModel.stateMagiskMode : @string/not_available}"
tools:text="Normal" />
</LinearLayout>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/home_magisk_barrier"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
app:barrierDirection="end"
tools:constraint_referenced_ids="home_magisk_latest_version,home_magisk_installed_version,home_magisk_mode"/>
<View <LinearLayout
style="@style/W.Home.Section" android:id="@+id/home_device_details_ab"
app:layout_constraintBottom_toBottomOf="parent" style="@style/W.Home.Item.Top"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="@id/home_magisk_barrier"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"/>
<LinearLayout <TextView
android:id="@+id/home_device_details_ab" style="@style/W.Home.ItemContent"
style="@style/W.Home.Item.Top" android:text="A/B" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView <TextView
style="@style/W.Home.ItemContent" style="@style/W.Home.ItemContent.Right"
android:text="A/B" /> android:text="@{Info.isAB ? @string/yes : @string/no}"
tools:text="Yes" />
<TextView </LinearLayout>
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.isAB ? @string/yes : @string/no}"
tools:text="Yes" />
</LinearLayout> <LinearLayout
android:id="@+id/home_device_details_sar"
style="@style/W.Home.Item"
app:layout_constraintStart_toStartOf="@+id/home_device_details_ab"
app:layout_constraintTop_toBottomOf="@+id/home_device_details_ab">
<LinearLayout <TextView
android:id="@+id/home_device_details_sar" style="@style/W.Home.ItemContent"
style="@style/W.Home.Item" android:text="SAR" />
app:layout_constraintStart_toStartOf="@+id/home_device_details_ab"
app:layout_constraintTop_toBottomOf="@+id/home_device_details_ab">
<TextView <TextView
style="@style/W.Home.ItemContent" style="@style/W.Home.ItemContent.Right"
android:text="SAR" /> android:text="@{Info.isSAR ? @string/yes : @string/no}"
tools:text="Yes" />
<TextView </LinearLayout>
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.isSAR ? @string/yes : @string/no}"
tools:text="Yes" />
</LinearLayout> <LinearLayout
android:id="@+id/home_device_details_recovery"
style="@style/W.Home.Item.Bottom"
app:layout_constraintStart_toStartOf="@+id/home_device_details_sar"
app:layout_constraintTop_toBottomOf="@+id/home_device_details_sar">
<LinearLayout <TextView
android:id="@+id/home_device_details_recovery" style="@style/W.Home.ItemContent"
style="@style/W.Home.Item.Bottom" android:text="Ramdisk" />
app:layout_constraintStart_toStartOf="@+id/home_device_details_sar"
app:layout_constraintTop_toBottomOf="@+id/home_device_details_sar">
<TextView <TextView
style="@style/W.Home.ItemContent" style="@style/W.Home.ItemContent.Right"
android:text="Ramdisk" /> android:text="@{Info.ramdisk ? @string/yes : @string/no }"
tools:text="Yes" />
<TextView </LinearLayout>
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.ramdisk ? @string/yes : @string/no }"
tools:text="Yes" />
</LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout> </LinearLayout>

View File

@ -89,7 +89,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:barrierDirection="bottom" app:barrierDirection="bottom"
app:constraint_referenced_ids="home_manager_action,home_manager_title,home_manager_icon" /> tools:constraint_referenced_ids="home_manager_action,home_manager_title,home_manager_icon" />
<HorizontalScrollView <HorizontalScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -103,104 +103,90 @@
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="vertical">
<com.google.android.material.card.MaterialCardView <androidx.constraintlayout.widget.ConstraintLayout
style="@style/W.Home.Card.First"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout <LinearLayout
android:layout_width="wrap_content" android:id="@+id/home_manager_latest_version"
android:layout_height="wrap_content"> style="@style/W.Home.Item.Top"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" >
<View <TextView
style="@style/W.Home.Section" style="@style/W.Home.ItemContent"
app:layout_constraintBottom_toBottomOf="parent" android:text="@string/module_section_remote" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout <TextView
android:id="@+id/home_manager_latest_version" style="@style/W.Home.ItemContent.Right"
style="@style/W.Home.Item.Top" android:text="@{viewModel.isConnected ? viewModel.stateManagerRemoteVersion : @string/not_available}"
app:layout_constraintStart_toStartOf="parent" tools:text="8.0.0 (123) (10)" />
app:layout_constraintTop_toTopOf="parent" >
<TextView </LinearLayout>
style="@style/W.Home.ItemContent"
android:text="@string/module_section_remote" />
<TextView <LinearLayout
style="@style/W.Home.ItemContent.Right" android:id="@+id/home_manager_installed_version"
android:text="@{viewModel.isConnected ? viewModel.stateManagerRemoteVersion : @string/not_available}" style="@style/W.Home.Item"
tools:text="8.0.0 (123) (10)" /> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_manager_latest_version">
</LinearLayout> <TextView
style="@style/W.Home.ItemContent"
android:text="@string/installed" />
<LinearLayout <TextView
android:id="@+id/home_manager_installed_version" style="@style/W.Home.ItemContent.Right"
style="@style/W.Home.Item" android:text="@{viewModel.stateManagerInstalledVersion}"
app:layout_constraintStart_toStartOf="parent" tools:text="8.0.0 (123) (10)" />
app:layout_constraintTop_toBottomOf="@+id/home_manager_latest_version">
<TextView </LinearLayout>
style="@style/W.Home.ItemContent"
android:text="@string/installed" />
<TextView <LinearLayout
style="@style/W.Home.ItemContent.Right" android:id="@+id/home_manager_internal_mode"
android:text="@{viewModel.stateManagerInstalledVersion}" style="@style/W.Home.Item"
tools:text="8.0.0 (123) (10)" /> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_manager_installed_version">
</LinearLayout> <TextView
style="@style/W.Home.ItemContent"
android:text="@string/status" />
<LinearLayout <TextView
android:id="@+id/home_manager_internal_mode" style="@style/W.Home.ItemContent.Right"
style="@style/W.Home.Item" android:text="@{InfoKt.isRunningAsStub ? @string/home_status_stub : @string/home_status_normal}"
app:layout_constraintStart_toStartOf="parent" tools:text="Normal" />
app:layout_constraintTop_toBottomOf="@+id/home_manager_installed_version">
<TextView </LinearLayout>
style="@style/W.Home.ItemContent"
android:text="@string/status" />
<TextView <LinearLayout
style="@style/W.Home.ItemContent.Right" android:id="@+id/home_manager_internal_connection"
android:text="@{InfoKt.isRunningAsStub ? @string/home_status_stub : @string/home_status_normal}" style="@style/W.Home.Item.Bottom"
tools:text="Normal" /> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_manager_internal_mode">
</LinearLayout> <TextView
style="@style/W.Home.ItemContent"
android:text="@string/home_package" />
<LinearLayout <TextView
android:id="@+id/home_manager_internal_connection" android:id="@+id/home_manager_extra_connection_value"
style="@style/W.Home.Item.Bottom" style="@style/W.Home.ItemContent.Right"
app:layout_constraintStart_toStartOf="parent" android:text="@{viewModel.statePackageName}"
app:layout_constraintTop_toBottomOf="@+id/home_manager_internal_mode"> tools:text="com.topjohnwu.magisk" />
<TextView </LinearLayout>
style="@style/W.Home.ItemContent"
android:text="@string/home_package" />
<TextView </androidx.constraintlayout.widget.ConstraintLayout>
android:id="@+id/home_manager_extra_connection_value"
style="@style/W.Home.ItemContent.Right"
android:text="@{viewModel.statePackageName}"
tools:text="com.topjohnwu.magisk" />
</LinearLayout> <ProgressBar
style="@style/WidgetFoundation.ProgressBar"
</androidx.constraintlayout.widget.ConstraintLayout> gone="@{viewModel.stateManagerProgress == 0 || viewModel.stateManagerProgress == 100}"
android:layout_width="match_parent"
<ProgressBar android:layout_gravity="bottom"
style="@style/WidgetFoundation.ProgressBar" android:max="100"
gone="@{viewModel.stateManagerProgress == 0 || viewModel.stateManagerProgress == 100}" android:progress="@{viewModel.stateManagerProgress}" />
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:max="100"
android:progress="@{viewModel.stateManagerProgress}" />
</com.google.android.material.card.MaterialCardView>
</LinearLayout> </LinearLayout>