Updated home info cards to be more compressed

This commit is contained in:
Viktor De Pasquale 2019-10-26 15:14:20 +02:00
parent df3a37b0a3
commit 60a2e9b5dc
3 changed files with 132 additions and 101 deletions

View File

@ -36,13 +36,15 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/l2">
android:clipToPadding="false"
android:paddingTop="@dimen/l1">
<com.google.android.material.card.MaterialCardView
android:id="@+id/home_magisk_wrapper"
style="?styleCardVariant"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:maxWidth="200dp"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toStartOf="@+id/home_manager_wrapper"
@ -50,11 +52,14 @@
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@drawable/bg_card"
android:padding="@dimen/l1"
android:paddingStart="@dimen/l_50"
android:paddingTop="@dimen/l1"
android:paddingEnd="@dimen/l1"
android:paddingBottom="@dimen/l1"
app:layout_constraintEnd_toStartOf="@+id/home_manager_wrapper"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
@ -66,7 +71,7 @@
onSelectClick="@{() -> viewModel.onDeletePressed()}"
onSelectReset="@{7000L}"
android:padding="@dimen/l_25"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_magisk_delete"
@ -74,78 +79,43 @@
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/home_magisk_title"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l1"
android:gravity="center"
android:layout_marginStart="@dimen/l_50"
android:gravity="start|center_vertical"
android:text="@string/magisk"
android:textAppearance="?appearanceTextTitleNormal"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/home_magisk_status"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_magisk_icon" />
app:layout_constraintStart_toEndOf="@+id/home_magisk_icon"
app:layout_constraintTop_toTopOf="@+id/home_magisk_icon"
app:layout_constraintVertical_chainStyle="packed" />
<TextSwitcher
android:id="@+id/home_magisk_status"
gone="@{viewModel.stateTextMagisk.empty}"
textCaptionVariant="@{viewModel.stateTextMagisk}"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/home_magisk_version"
app:layout_constraintEnd_toEndOf="@+id/home_magisk_title"
app:layout_constraintStart_toStartOf="@+id/home_magisk_title"
app:layout_constraintTop_toBottomOf="@+id/home_magisk_title" />
<TextSwitcher
android:id="@+id/home_magisk_version"
gone="@{viewModel.stateVersionUpdateMagisk.empty}"
textCaptionVariant="@{viewModel.stateVersionUpdateMagisk}"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="@+id/home_magisk_icon"
app:layout_constraintEnd_toEndOf="@+id/home_magisk_title"
app:layout_constraintStart_toStartOf="@+id/home_magisk_title"
app:layout_constraintTop_toBottomOf="@+id/home_magisk_status" />
<FrameLayout
gone="@{viewModel.stateMagisk == MagiskState.LOADING || !viewModel.isConnected}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l1"
android:animateLayoutChanges="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_magisk_version">
<com.google.android.material.button.MaterialButton
style="?styleButtonDefault"
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_height="wrap_content"
android:layout_gravity="center"
android:onClick="@{() -> viewModel.onMagiskPressed()}"
android:text="@string/update"
app:icon="@drawable/ic_update_md2"
app:iconGravity="textEnd"
app:iconPadding="@dimen/l_50"
app:iconSize="18dp"
tools:visibility="gone" />
<com.google.android.material.button.MaterialButton
style="?styleButtonText"
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_height="wrap_content"
android:layout_gravity="center"
android:onClick="@{() -> viewModel.onMagiskPressed()}"
android:text="@string/install"
app:icon="@drawable/ic_install"
app:iconGravity="textEnd"
app:iconPadding="@dimen/l_50"
app:iconSize="18dp" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<ProgressBar
@ -158,12 +128,55 @@
</com.google.android.material.card.MaterialCardView>
<FrameLayout
gone="@{viewModel.stateMagisk == MagiskState.LOADING || !viewModel.isConnected}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l_50"
android:animateLayoutChanges="true"
app:layout_constraintEnd_toEndOf="@+id/home_magisk_wrapper"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toStartOf="@+id/home_magisk_wrapper"
app:layout_constraintTop_toBottomOf="@+id/home_magisk_wrapper">
<com.google.android.material.button.MaterialButton
style="?styleButtonDefault"
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_height="wrap_content"
android:layout_gravity="center"
android:onClick="@{() -> viewModel.onMagiskPressed()}"
android:text="@string/update"
app:icon="@drawable/ic_update_md2"
app:iconGravity="textEnd"
app:iconPadding="@dimen/l_50"
app:iconSize="18dp"
tools:visibility="gone" />
<com.google.android.material.button.MaterialButton
style="?styleButtonText"
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_height="wrap_content"
android:layout_gravity="center"
android:onClick="@{() -> viewModel.onMagiskPressed()}"
android:text="@string/install"
app:icon="@drawable/ic_install"
app:iconGravity="textEnd"
app:iconPadding="@dimen/l_50"
app:iconSize="18dp" />
</FrameLayout>
<com.google.android.material.card.MaterialCardView
android:id="@+id/home_manager_wrapper"
style="?styleCardVariant"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:layout_marginEnd="@dimen/l1"
android:maxWidth="200dp"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toEndOf="parent"
@ -171,10 +184,13 @@
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_card"
android:padding="@dimen/l1"
android:paddingStart="@dimen/l_50"
android:paddingTop="@dimen/l1"
android:paddingEnd="@dimen/l1"
android:paddingBottom="@dimen/l1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/home_magisk_wrapper"
app:layout_constraintTop_toTopOf="parent">
@ -183,81 +199,51 @@
android:id="@+id/home_manager_icon"
style="?styleIconPrimary"
android:padding="@dimen/l_50"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_manager" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/home_manager_title"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l1"
android:gravity="center"
android:layout_marginStart="@dimen/l_50"
android:gravity="start|center_vertical"
android:text="@{viewModel.stateHideManagerName}"
android:textAppearance="?appearanceTextTitleNormal"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/home_manager_status"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_manager_icon"
app:layout_constraintStart_toEndOf="@+id/home_manager_icon"
app:layout_constraintTop_toTopOf="@+id/home_manager_icon"
app:layout_constraintVertical_chainStyle="packed"
tools:text="@string/manager" />
<TextSwitcher
android:id="@+id/home_manager_status"
gone="@{viewModel.stateTextManager.empty}"
textCaptionVariant="@{viewModel.stateTextManager}"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/home_manager_version"
app:layout_constraintEnd_toEndOf="@+id/home_manager_title"
app:layout_constraintStart_toStartOf="@+id/home_manager_title"
app:layout_constraintTop_toBottomOf="@+id/home_manager_title" />
<TextSwitcher
android:id="@+id/home_manager_version"
gone="@{viewModel.stateVersionUpdateManager.empty}"
textCaptionVariant="@{viewModel.stateVersionUpdateManager}"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="@+id/home_manager_icon"
app:layout_constraintEnd_toEndOf="@+id/home_manager_title"
app:layout_constraintStart_toStartOf="@+id/home_manager_title"
app:layout_constraintTop_toBottomOf="@+id/home_manager_status" />
<FrameLayout
gone="@{viewModel.stateManager == MagiskState.LOADING || !viewModel.isConnected}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l1"
app:layout_constraintTop_toBottomOf="@+id/home_manager_version">
<com.google.android.material.button.MaterialButton
style="?styleButtonDefault"
gone="@{viewModel.stateManager != MagiskState.OBSOLETE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:onClick="@{() -> viewModel.onManagerPressed()}"
android:text="@string/update"
app:icon="@drawable/ic_update_md2"
app:iconGravity="textEnd"
app:iconPadding="@dimen/l_50"
app:iconSize="18dp" />
<com.google.android.material.button.MaterialButton
style="?styleButtonText"
gone="@{viewModel.stateManager == MagiskState.OBSOLETE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:onClick="@{() -> viewModel.onManagerPressed()}"
android:text="@string/install"
app:icon="@drawable/ic_install"
app:iconGravity="textEnd"
app:iconPadding="@dimen/l_50"
app:iconSize="18dp"
tools:visibility="gone" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<ProgressBar
@ -270,6 +256,45 @@
</com.google.android.material.card.MaterialCardView>
<FrameLayout
gone="@{viewModel.stateManager == MagiskState.LOADING || !viewModel.isConnected}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l_50"
app:layout_constraintEnd_toEndOf="@+id/home_manager_wrapper"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toStartOf="@+id/home_manager_wrapper"
app:layout_constraintTop_toBottomOf="@+id/home_manager_wrapper">
<com.google.android.material.button.MaterialButton
style="?styleButtonDefault"
gone="@{viewModel.stateManager != MagiskState.OBSOLETE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:onClick="@{() -> viewModel.onManagerPressed()}"
android:text="@string/update"
app:icon="@drawable/ic_update_md2"
app:iconGravity="textEnd"
app:iconPadding="@dimen/l_50"
app:iconSize="18dp" />
<com.google.android.material.button.MaterialButton
style="?styleButtonText"
gone="@{viewModel.stateManager == MagiskState.OBSOLETE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:onClick="@{() -> viewModel.onManagerPressed()}"
android:text="@string/install"
app:icon="@drawable/ic_install"
app:iconGravity="textEnd"
app:iconPadding="@dimen/l_50"
app:iconSize="18dp"
tools:visibility="gone" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView

View File

@ -2,5 +2,9 @@
<androidx.appcompat.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
xmlns:tools="http://schemas.android.com/tools"
android:ellipsize="middle"
android:gravity="start|center_vertical"
android:singleLine="true"
tools:text="@string/magisk"
android:textAppearance="?appearanceTextCaptionVariant" />

View File

@ -38,7 +38,9 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml.
<style name="WidgetFoundation.Card.Elevated" parent="Widget.MaterialComponents.CardView">
<item name="cardBackgroundColor">?colorSurface</item>
<item name="cardCornerRadius">@dimen/l_50</item>
<item name="cardElevation">@dimen/l_125</item>
<item name="cardPreventCornerOverlap">true</item>
</style>
<style name="WidgetFoundation.Card.OnPrimary" parent="Widget.MaterialComponents.CardView">