Magisk/app/src/main/res/layout/item_repo_md2.xml
nikk f575155a41
Fix focus on main elements in Modern UI
Co-authored-by: John Wu <topjohnwu@gmail.com>
2020-09-21 03:27:29 -07:00

158 lines
6.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="com.topjohnwu.magisk.R" />
<variable
name="item"
type="com.topjohnwu.magisk.ui.module.RepoItem" />
<variable
name="viewModel"
type="com.topjohnwu.magisk.ui.module.ModuleViewModel" />
</data>
<com.google.android.material.card.MaterialCardView
android:id="@+id/module_card"
style="@style/WidgetFoundation.Card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:nextFocusRight="@id/module_info"
android:onClick="@{() -> viewModel.downloadPressed(item)}"
tools:layout_gravity="center"
tools:layout_marginBottom="@dimen/l1"
tools:layout_marginEnd="@dimen/l1">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/module_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:layout_marginTop="@dimen/l1"
android:layout_marginEnd="@dimen/l1"
android:text="@{item.item.name}"
android:textAppearance="@style/AppearanceFoundation.Body"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@tools:sample/lorem" />
<TextView
android:id="@+id/module_version_author"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{@string/module_version_author(item.item.version ?? `?`, item.item.author ?? `?`)}"
android:textAppearance="@style/AppearanceFoundation.Caption.Variant"
app:layout_constraintEnd_toEndOf="@+id/module_title"
app:layout_constraintStart_toStartOf="@+id/module_title"
app:layout_constraintTop_toBottomOf="@+id/module_title"
tools:text="v1 by topjohnwu" />
<TextView
android:id="@+id/module_description"
gone="@{item.item.description.empty}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:layout_marginTop="@dimen/l1"
android:layout_marginEnd="@dimen/l1"
android:text="@{item.item.description}"
android:textAppearance="@style/AppearanceFoundation.Caption.Variant"
app:layout_constraintTop_toBottomOf="@+id/module_version_author"
tools:lines="4"
tools:text="@tools:sample/lorem/random" />
<View
android:id="@+id/module_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/l1"
android:background="?colorSurfaceSurfaceVariant"
app:layout_constraintTop_toBottomOf="@+id/module_description" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:text="@{item.item.lastUpdateString}"
android:textAppearance="@style/AppearanceFoundation.Caption.Variant"
android:textSize="11sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/module_info"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/module_divider"
tools:ignore="SmallSp"
tools:text="@tools:sample/date/ddmmyy" />
<ImageView
android:id="@+id/module_info"
style="@style/WidgetFoundation.Icon"
android:layout_width="wrap_content"
android:alpha=".5"
android:nextFocusLeft="@id/module_card"
android:onClick="@{() -> viewModel.infoPressed(item)}"
android:paddingEnd="@dimen/l_50"
app:layout_constraintBottom_toBottomOf="@+id/module_download"
app:layout_constraintEnd_toStartOf="@+id/module_download"
app:layout_constraintTop_toTopOf="@+id/module_download"
app:srcCompat="@drawable/ic_info" />
<ImageView
android:id="@+id/module_download"
style="@style/WidgetFoundation.Icon.Primary"
isEnabled="@{!(item.progress == -100 || (item.progress > 0 &amp;&amp; item.progress &lt; 100))}"
srcCompat="@{item.isUpdate ? R.drawable.ic_update_md2 : R.drawable.ic_download_md2}"
android:layout_width="wrap_content"
android:contentDescription="@string/download"
android:nextFocusLeft="@id/module_info"
android:onClick="@{() -> viewModel.downloadPressed(item)}"
android:paddingStart="@dimen/l_50"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/module_divider"
tools:srcCompat="@drawable/ic_download_md2" />
</androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<ProgressBar
style="@style/WidgetFoundation.ProgressBar"
goneUnless="@{item.progress > 0 &amp;&amp; item.progress &lt; 100}"
progressAnimated="@{item.progress}"
android:layout_width="match_parent"
android:layout_gravity="bottom"
tools:progress="40" />
<androidx.core.widget.ContentLoadingProgressBar
style="@style/WidgetFoundation.ProgressBar.Indeterminate"
goneUnless="@{item.progress == -100}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="-4dp"
android:layout_marginBottom="-5dp"
tools:progress="40" />
</FrameLayout>
</com.google.android.material.card.MaterialCardView>
</layout>