diff --git a/app/apk/build.gradle.kts b/app/apk/build.gradle.kts index 8f628c863..10106c73e 100644 --- a/app/apk/build.gradle.kts +++ b/app/apk/build.gradle.kts @@ -4,7 +4,6 @@ plugins { kotlin("plugin.compose") kotlin("plugin.serialization") alias(libs.plugins.legacy.kapt) - alias(libs.plugins.navigation.safeargs) } setupMainApk() @@ -44,19 +43,11 @@ dependencies { implementation(project(":core")) coreLibraryDesugaring(libs.jdk.libs) - implementation(libs.indeterminate.checkbox) implementation(libs.rikka.layoutinflater) implementation(libs.rikka.insets) - implementation(libs.rikka.recyclerview) - - implementation(libs.navigation.fragment.ktx) - implementation(libs.navigation.ui.ktx) implementation(libs.constraintlayout) - implementation(libs.swiperefreshlayout) implementation(libs.recyclerview) - implementation(libs.transition) - implementation(libs.fragment.ktx) implementation(libs.appcompat) implementation(libs.material) diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/arch/UIActivity.kt b/app/apk/src/main/java/com/topjohnwu/magisk/arch/UIActivity.kt index db6056aef..f1609ce42 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/arch/UIActivity.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/arch/UIActivity.kt @@ -6,15 +6,11 @@ import android.graphics.Color import android.os.Build import android.os.Bundle import android.view.View -import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate import androidx.core.content.res.use import androidx.core.view.WindowCompat import androidx.databinding.ViewDataBinding -import androidx.interpolator.view.animation.FastOutSlowInInterpolator -import androidx.transition.AutoTransition -import androidx.transition.TransitionManager import com.google.android.material.snackbar.Snackbar import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Config @@ -115,13 +111,3 @@ abstract class UIActivity else -> Unit } } - -fun ViewGroup.startAnimations() { - val transition = AutoTransition() - .setInterpolator(FastOutSlowInInterpolator()) - .setDuration(400) - TransitionManager.beginDelayedTransition( - this, - transition - ) -} diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt b/app/apk/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt index 9cc6084d9..95e67f221 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt @@ -8,11 +8,9 @@ import android.text.Spanned import android.util.TypedValue import android.view.View import android.view.ViewGroup -import android.widget.ArrayAdapter import android.widget.Button import android.widget.ImageView import android.widget.ProgressBar -import android.widget.Spinner import android.widget.TextView import androidx.annotation.DrawableRes import androidx.appcompat.widget.Toolbar @@ -22,9 +20,6 @@ import androidx.core.view.isInvisible import androidx.core.view.updateLayoutParams import androidx.core.widget.ImageViewCompat import androidx.databinding.BindingAdapter -import androidx.databinding.InverseBindingAdapter -import androidx.databinding.InverseBindingListener -import androidx.databinding.InverseMethod import androidx.interpolator.view.animation.FastOutSlowInInterpolator import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.GridLayoutManager @@ -33,15 +28,11 @@ import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.StaggeredGridLayoutManager import com.google.android.material.button.MaterialButton import com.google.android.material.card.MaterialCardView -import com.google.android.material.chip.Chip -import com.google.android.material.slider.Slider import com.google.android.material.textfield.TextInputLayout import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.di.ServiceLocator -import com.topjohnwu.magisk.core.model.su.SuPolicy import com.topjohnwu.magisk.utils.TextHolder import com.topjohnwu.superuser.internal.UiThreadHandler -import com.topjohnwu.widget.IndeterminateCheckBox import kotlin.math.roundToInt @BindingAdapter("gone") @@ -208,11 +199,6 @@ fun Toolbar.setOnMenuClickListener(listener: Toolbar.OnMenuItemClickListener) { setOnMenuItemClickListener(listener) } -@BindingAdapter("onCloseClicked") -fun Chip.setOnCloseClickedListenerBinding(listener: View.OnClickListener) { - setOnCloseIconClickListener(listener) -} - @BindingAdapter("progressAnimated") fun ProgressBar.setProgressAnimated(newProgress: Int) { val animator = tag as? ValueAnimator @@ -255,25 +241,6 @@ fun RecyclerView.setSpanCount(count: Int) { } } -@BindingAdapter("state") -fun setState(view: IndeterminateCheckBox, state: Boolean?) { - if (view.state != state) - view.state = state -} - -@InverseBindingAdapter(attribute = "state") -fun getState(view: IndeterminateCheckBox) = view.state - -@BindingAdapter("stateAttrChanged") -fun setListeners( - view: IndeterminateCheckBox, - attrChange: InverseBindingListener -) { - view.setOnStateChangedListener { _, _ -> - attrChange.onChange() - } -} - @BindingAdapter("cardBackgroundColorAttr") fun CardView.setCardBackgroundColorAttr(attr: Int) { val tv = TypedValue() @@ -305,42 +272,3 @@ fun TextView.setText(text: TextHolder) { this.text = text.getText(context.resources) } -@BindingAdapter("items", "layout") -fun Spinner.setAdapter(items: Array, layoutRes: Int) { - adapter = ArrayAdapter(context, layoutRes, items) -} - -@BindingAdapter("labelFormatter") -fun Slider.setLabelFormatter(formatter: (Float) -> Int) { - setLabelFormatter { value -> resources.getString(formatter(value)) } -} - -@InverseBindingAdapter(attribute = "android:value") -fun Slider.getValueBinding() = value - -@BindingAdapter("android:valueAttrChanged") -fun Slider.setListener(attrChange: InverseBindingListener) { - addOnSliderTouchListener(object : Slider.OnSliderTouchListener { - override fun onStartTrackingTouch(slider: Slider) = Unit - override fun onStopTrackingTouch(slider: Slider) = attrChange.onChange() - }) -} - -@InverseMethod("sliderValueToPolicy") -fun policyToSliderValue(policy: Int): Float { - return when (policy) { - SuPolicy.DENY -> 1f - SuPolicy.RESTRICT -> 2f - SuPolicy.ALLOW -> 3f - else -> 1f - } -} - -fun sliderValueToPolicy(value: Float): Int { - return when (value) { - 1f -> SuPolicy.DENY - 2f -> SuPolicy.RESTRICT - 3f -> SuPolicy.ALLOW - else -> SuPolicy.DENY - } -} diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/databinding/DiffObservableList.kt b/app/apk/src/main/java/com/topjohnwu/magisk/databinding/DiffObservableList.kt deleted file mode 100644 index 96262122e..000000000 --- a/app/apk/src/main/java/com/topjohnwu/magisk/databinding/DiffObservableList.kt +++ /dev/null @@ -1,156 +0,0 @@ -package com.topjohnwu.magisk.databinding - -import androidx.annotation.MainThread -import androidx.annotation.WorkerThread -import androidx.databinding.ListChangeRegistry -import androidx.databinding.ObservableList -import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListUpdateCallback -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext -import java.util.AbstractList - -// Only expose the immutable List types -interface DiffList> : List { - fun calculateDiff(newItems: List): DiffUtil.DiffResult - - @MainThread - fun update(newItems: List, diffResult: DiffUtil.DiffResult) - - @WorkerThread - suspend fun update(newItems: List) -} - -interface FilterList> : List { - fun filter(filter: (T) -> Boolean) - - @MainThread - fun set(newItems: List) -} - -fun > diffList(): DiffList = DiffObservableList() - -fun > filterList(scope: CoroutineScope): FilterList = - FilterableDiffObservableList(scope) - -private open class DiffObservableList> - : AbstractList(), ObservableList, DiffList, ListUpdateCallback { - - protected var list: List = emptyList() - private val listeners = ListChangeRegistry() - - override val size: Int get() = list.size - - override fun get(index: Int) = list[index] - - override fun calculateDiff(newItems: List): DiffUtil.DiffResult { - return doCalculateDiff(list, newItems) - } - - protected fun doCalculateDiff(oldItems: List, newItems: List): DiffUtil.DiffResult { - return DiffUtil.calculateDiff(object : DiffUtil.Callback() { - override fun getOldListSize() = oldItems.size - - override fun getNewListSize() = newItems.size - - @Suppress("UNCHECKED_CAST") - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { - val oldItem = oldItems[oldItemPosition] - val newItem = newItems[newItemPosition] - return (oldItem as DiffItem).itemSameAs(newItem) - } - - @Suppress("UNCHECKED_CAST") - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { - val oldItem = oldItems[oldItemPosition] - val newItem = newItems[newItemPosition] - return (oldItem as DiffItem).contentSameAs(newItem) - } - }, true) - } - - @MainThread - override fun update(newItems: List, diffResult: DiffUtil.DiffResult) { - list = ArrayList(newItems) - diffResult.dispatchUpdatesTo(this) - } - - @WorkerThread - override suspend fun update(newItems: List) { - val diffResult = calculateDiff(newItems) - withContext(Dispatchers.Main) { - update(newItems, diffResult) - } - } - - override fun addOnListChangedCallback(listener: ObservableList.OnListChangedCallback>) { - listeners.add(listener) - } - - override fun removeOnListChangedCallback(listener: ObservableList.OnListChangedCallback>) { - listeners.remove(listener) - } - - override fun onChanged(position: Int, count: Int, payload: Any?) { - listeners.notifyChanged(this, position, count) - } - - override fun onMoved(fromPosition: Int, toPosition: Int) { - listeners.notifyMoved(this, fromPosition, toPosition, 1) - } - - override fun onInserted(position: Int, count: Int) { - modCount += 1 - listeners.notifyInserted(this, position, count) - } - - override fun onRemoved(position: Int, count: Int) { - modCount += 1 - listeners.notifyRemoved(this, position, count) - } -} - -private class FilterableDiffObservableList>( - private val scope: CoroutineScope -) : DiffObservableList(), FilterList { - - private var sublist: List = emptyList() - private var job: Job? = null - private var lastFilter: ((T) -> Boolean)? = null - - // --- - - override fun filter(filter: (T) -> Boolean) { - lastFilter = filter - job?.cancel() - job = scope.launch(Dispatchers.Default) { - val oldList = sublist - val newList = list.filter(filter) - val diff = doCalculateDiff(oldList, newList) - withContext(Dispatchers.Main) { - sublist = newList - diff.dispatchUpdatesTo(this@FilterableDiffObservableList) - } - } - } - - // --- - - override fun get(index: Int): T { - return sublist[index] - } - - override val size: Int - get() = sublist.size - - @MainThread - override fun set(newItems: List) { - onRemoved(0, sublist.size) - list = newItems - sublist = emptyList() - lastFilter?.let { filter(it) } - } -} diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/databinding/MergeObservableList.kt b/app/apk/src/main/java/com/topjohnwu/magisk/databinding/MergeObservableList.kt deleted file mode 100644 index 4d06f1d7d..000000000 --- a/app/apk/src/main/java/com/topjohnwu/magisk/databinding/MergeObservableList.kt +++ /dev/null @@ -1,162 +0,0 @@ -package com.topjohnwu.magisk.databinding - -import androidx.databinding.ListChangeRegistry -import androidx.databinding.ObservableList -import androidx.databinding.ObservableList.OnListChangedCallback -import java.util.AbstractList - -@Suppress("UNCHECKED_CAST") -class MergeObservableList : AbstractList(), ObservableList { - - private val lists: MutableList> = mutableListOf() - private val listeners = ListChangeRegistry() - private val callback = Callback() - - override fun addOnListChangedCallback(callback: OnListChangedCallback>) { - listeners.add(callback) - } - - override fun removeOnListChangedCallback(callback: OnListChangedCallback>) { - listeners.remove(callback) - } - - override fun get(index: Int): T { - if (index < 0) - throw IndexOutOfBoundsException() - var idx = index - for (list in lists) { - val size = list.size - if (idx < size) { - return list[idx] - } - idx -= size - } - throw IndexOutOfBoundsException() - } - - override val size: Int - get() = lists.fold(0) { i, it -> i + it.size } - - - fun insertItem(obj: T): MergeObservableList { - val idx = size - lists.add(listOf(obj)) - ++modCount - listeners.notifyInserted(this, idx, 1) - return this - } - - fun insertList(list: List): MergeObservableList { - val idx = size - lists.add(list) - ++modCount - (list as? ObservableList)?.addOnListChangedCallback(callback) - if (list.isNotEmpty()) - listeners.notifyInserted(this, idx, list.size) - return this - } - - fun removeItem(obj: T): Boolean { - var idx = 0 - for ((i, list) in lists.withIndex()) { - if (list !is ObservableList<*>) { - if (obj == list[0]) { - lists.removeAt(i) - ++modCount - listeners.notifyRemoved(this, idx, 1) - return true - } - } - idx += list.size - } - return false - } - - fun removeList(listToRemove: List): Boolean { - var idx = 0 - for ((i, list) in lists.withIndex()) { - if (listToRemove === list) { - (list as? ObservableList)?.removeOnListChangedCallback(callback) - lists.removeAt(i) - ++modCount - listeners.notifyRemoved(this, idx, list.size) - return true - } - idx += list.size - } - return false - } - - override fun clear() { - val sz = size - for (list in lists) { - if (list is ObservableList) { - list.removeOnListChangedCallback(callback) - } - } - ++modCount - lists.clear() - if (sz > 0) - listeners.notifyRemoved(this, 0, sz) - } - - private fun subIndexToIndex(subList: List<*>, index: Int): Int { - if (index < 0) - throw IndexOutOfBoundsException() - var idx = 0 - for (list in lists) { - if (subList === list) { - return idx + index - } - idx += list.size - } - throw IllegalArgumentException() - } - - inner class Callback : OnListChangedCallback>() { - override fun onChanged(sender: ObservableList) { - ++modCount - listeners.notifyChanged(this@MergeObservableList) - } - - override fun onItemRangeChanged( - sender: ObservableList, - positionStart: Int, - itemCount: Int - ) { - listeners.notifyChanged(this@MergeObservableList, - subIndexToIndex(sender, positionStart), itemCount) - } - - override fun onItemRangeInserted( - sender: ObservableList, - positionStart: Int, - itemCount: Int - ) { - ++modCount - listeners.notifyInserted(this@MergeObservableList, - subIndexToIndex(sender, positionStart), itemCount) - } - - override fun onItemRangeMoved( - sender: ObservableList, - fromPosition: Int, - toPosition: Int, - itemCount: Int - ) { - val idx = subIndexToIndex(sender, 0) - listeners.notifyMoved(this@MergeObservableList, - idx + fromPosition, idx + toPosition, itemCount) - } - - override fun onItemRangeRemoved( - sender: ObservableList, - positionStart: Int, - itemCount: Int - ) { - ++modCount - listeners.notifyRemoved(this@MergeObservableList, - subIndexToIndex(sender, positionStart), itemCount) - } - } -} diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/databinding/RecyclerViewItems.kt b/app/apk/src/main/java/com/topjohnwu/magisk/databinding/RecyclerViewItems.kt index 7b26f832d..37742038d 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/databinding/RecyclerViewItems.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/databinding/RecyclerViewItems.kt @@ -1,6 +1,5 @@ package com.topjohnwu.magisk.databinding -import androidx.databinding.PropertyChangeRegistry import androidx.databinding.ViewDataBinding import androidx.recyclerview.widget.RecyclerView @@ -8,10 +7,6 @@ abstract class RvItem { abstract val layoutRes: Int } -abstract class ObservableRvItem : RvItem(), ObservableHost { - override var callbacks: PropertyChangeRegistry? = null -} - interface ItemWrapper { val item: E } diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/view/TextItem.kt b/app/apk/src/main/java/com/topjohnwu/magisk/view/TextItem.kt deleted file mode 100644 index 6056e466b..000000000 --- a/app/apk/src/main/java/com/topjohnwu/magisk/view/TextItem.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.topjohnwu.magisk.view - -import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.databinding.DiffItem -import com.topjohnwu.magisk.databinding.ItemWrapper -import com.topjohnwu.magisk.databinding.RvItem - -class TextItem(override val item: Int) : RvItem(), DiffItem, ItemWrapper { - override val layoutRes = R.layout.item_text -} diff --git a/app/apk/src/main/res/anim/fragment_enter.xml b/app/apk/src/main/res/anim/fragment_enter.xml deleted file mode 100644 index affbb54b9..000000000 --- a/app/apk/src/main/res/anim/fragment_enter.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/apk/src/main/res/anim/fragment_enter_pop.xml b/app/apk/src/main/res/anim/fragment_enter_pop.xml deleted file mode 100644 index 6a1d9f37c..000000000 --- a/app/apk/src/main/res/anim/fragment_enter_pop.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/apk/src/main/res/anim/fragment_exit.xml b/app/apk/src/main/res/anim/fragment_exit.xml deleted file mode 100644 index 59ca28476..000000000 --- a/app/apk/src/main/res/anim/fragment_exit.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/apk/src/main/res/anim/fragment_exit_pop.xml b/app/apk/src/main/res/anim/fragment_exit_pop.xml deleted file mode 100644 index c39aaf6fb..000000000 --- a/app/apk/src/main/res/anim/fragment_exit_pop.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/apk/src/main/res/layout/item_spinner.xml b/app/apk/src/main/res/layout/item_spinner.xml deleted file mode 100644 index 0776ef859..000000000 --- a/app/apk/src/main/res/layout/item_spinner.xml +++ /dev/null @@ -1,14 +0,0 @@ - - diff --git a/app/apk/src/main/res/layout/item_text.xml b/app/apk/src/main/res/layout/item_text.xml deleted file mode 100644 index 1ea722ea7..000000000 --- a/app/apk/src/main/res/layout/item_text.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - -