Updated hide item layout
This commit is contained in:
parent
169e9ab5ad
commit
f1427e9279
@ -1,6 +1,5 @@
|
|||||||
package com.topjohnwu.magisk.model.entity.recycler
|
package com.topjohnwu.magisk.model.entity.recycler
|
||||||
|
|
||||||
import android.view.MenuItem
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
@ -43,13 +42,12 @@ class HideItem(val item: ProcessHideApp) : ComparableRvItem<HideItem>() {
|
|||||||
isExpanded.value = false
|
isExpanded.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun expand(v: View) {
|
fun toggle(v: View) {
|
||||||
(v.parent as? ViewGroup)?.startAnimations()
|
(v.parent as? ViewGroup)?.startAnimations()
|
||||||
isExpanded.value = true
|
isExpanded.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggle(menuItem: MenuItem, viewModel: HideViewModel): Boolean {
|
fun toggle(viewModel: HideViewModel): Boolean {
|
||||||
if (menuItem.itemId != R.id.action_toggle) return false
|
|
||||||
// contract implies that isHidden == all checked
|
// contract implies that isHidden == all checked
|
||||||
if (!isHidden) {
|
if (!isHidden) {
|
||||||
items.filterNot { it.isHidden.value }
|
items.filterNot { it.isHidden.value }
|
||||||
|
12
app/src/main/res/drawable/ic_close.xml
Normal file
12
app/src/main/res/drawable/ic_close.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="?colorOnSurface"
|
||||||
|
android:pathData="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"
|
||||||
|
tools:fillColor="#000" />
|
||||||
|
</vector>
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
|
<import type="com.topjohnwu.magisk.R" />
|
||||||
|
|
||||||
<variable
|
<variable
|
||||||
name="item"
|
name="item"
|
||||||
type="com.topjohnwu.magisk.model.entity.recycler.HideItem" />
|
type="com.topjohnwu.magisk.model.entity.recycler.HideItem" />
|
||||||
@ -22,23 +24,43 @@
|
|||||||
tools:layout_gravity="center"
|
tools:layout_gravity="center"
|
||||||
tools:layout_marginBottom="@dimen/l1">
|
tools:layout_marginBottom="@dimen/l1">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
invisible="@{item.isExpanded}"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?selectableItemBackground"
|
android:background="?selectableItemBackground"
|
||||||
android:onClick="@{(v) -> item.expand(v)}">
|
android:onClick="@{(v) -> item.toggle(v)}">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/hide_icon"
|
android:id="@+id/hide_icon"
|
||||||
style="?styleImageNormal"
|
style="?styleImageNormal"
|
||||||
android:layout_margin="@dimen/l1"
|
android:layout_margin="@dimen/l1"
|
||||||
|
android:alpha="@{item.isExpanded ? 0.1f : 1f}"
|
||||||
android:src="@{item.item.info.icon}"
|
android:src="@{item.item.info.icon}"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0"
|
||||||
tools:src="@drawable/ic_magisk" />
|
tools:src="@drawable/ic_magisk" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/hide_action"
|
||||||
|
style="?styleImageNormal"
|
||||||
|
goneUnless="@{item.isExpanded}"
|
||||||
|
android:layout_margin="@dimen/l1"
|
||||||
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
|
android:onClick="@{() -> item.toggle(viewModel)}"
|
||||||
|
android:padding="@dimen/l_25"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/hide_icon"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/hide_icon"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/hide_icon"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/hide_icon"
|
||||||
|
app:srcCompat="@drawable/ic_hide_md2" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/hide_name"
|
android:id="@+id/hide_name"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
@ -58,10 +80,10 @@
|
|||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/hide_package"
|
android:id="@+id/hide_package"
|
||||||
android:layout_width="0dp"
|
|
||||||
gone="@{item.item.info.info.packageName.empty}"
|
gone="@{item.item.info.info.packageName.empty}"
|
||||||
android:text="@{item.item.info.info.packageName}"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@{item.item.info.info.packageName}"
|
||||||
android:textAppearance="?appearanceTextCaptionVariant"
|
android:textAppearance="?appearanceTextCaptionVariant"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/hide_name"
|
app:layout_constraintEnd_toEndOf="@+id/hide_name"
|
||||||
@ -73,40 +95,27 @@
|
|||||||
android:id="@+id/hide_expand_icon"
|
android:id="@+id/hide_expand_icon"
|
||||||
style="?styleIconNormal"
|
style="?styleIconNormal"
|
||||||
invisible="@{item.item.processes.empty}"
|
invisible="@{item.item.processes.empty}"
|
||||||
|
srcCompat="@{item.isExpanded ? R.drawable.ic_close : R.drawable.ic_back_md2}"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:rotation="180"
|
android:rotation="180"
|
||||||
|
android:rotationX="@{item.isExpanded ? 180 : 0}"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:srcCompat="@drawable/ic_back_md2" />
|
tools:srcCompat="@drawable/ic_back_md2" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
goneUnless="@{item.isExpanded}"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
|
||||||
style="?styleToolbar"
|
|
||||||
onNavigationClick="@{(v) -> item.collapse(v)}"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
onMenuClick="@{(it) -> item.toggle(it, viewModel)}"
|
|
||||||
app:menu="@menu/menu_hide_item"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
app:navigationIcon="@drawable/ic_back_md2"
|
|
||||||
app:title="Processes"
|
|
||||||
app:titleTextAppearance="?appearanceTextBodyNormal" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
goneUnless="@{item.isExpanded}"
|
||||||
itemBinding="@{viewModel.itemInternalBinding}"
|
itemBinding="@{viewModel.itemInternalBinding}"
|
||||||
items="@{item.items}"
|
items="@{item.items}"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:itemCount="2"
|
android:background="?colorSurfaceVariant"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:itemCount="2"
|
||||||
tools:listitem="@layout/item_hide_process_md2" />
|
tools:listitem="@layout/item_hide_process_md2" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user