mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-26 09:16:48 +00:00
Removed grid scale gestures and reverted back to * simple list as a default
* disgusting (:
This commit is contained in:
committed by
John Wu
parent
740559e3bc
commit
e9fc40d285
@@ -56,7 +56,7 @@ object Config : PreferenceModel, DBConfig {
|
||||
const val SAFETY = "safety_notice"
|
||||
const val THEME_ORDINAL = "theme_ordinal"
|
||||
const val BOOT_ID = "boot_id"
|
||||
const val LIST_SPAN_COUNT = "list_span_count"
|
||||
const val LIST_SPAN_COUNT = "column_count"
|
||||
|
||||
// system state
|
||||
const val MAGISKHIDE = "magiskhide"
|
||||
@@ -147,7 +147,8 @@ object Config : PreferenceModel, DBConfig {
|
||||
@JvmStatic
|
||||
var coreOnly by preference(Key.COREONLY, false)
|
||||
var showSystemApp by preference(Key.SHOW_SYSTEM_APP, false)
|
||||
var listSpanCount by preference(Key.LIST_SPAN_COUNT, 2)
|
||||
@JvmStatic
|
||||
var listSpanCount by preference(Key.LIST_SPAN_COUNT, 1)
|
||||
|
||||
var customChannelUrl by preference(Key.CUSTOM_CHANNEL, "")
|
||||
var locale by preference(Key.LOCALE, "")
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.topjohnwu.magisk.ui.ReselectionTarget
|
||||
import com.topjohnwu.magisk.ui.base.BaseUIFragment
|
||||
import com.topjohnwu.magisk.utils.EndlessRecyclerScrollListener
|
||||
import com.topjohnwu.magisk.utils.MotionRevealHelper
|
||||
import com.topjohnwu.magisk.utils.PinchZoomTouchListener
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
class ModuleFragment : BaseUIFragment<ModuleViewModel, FragmentModuleMd2Binding>(),
|
||||
@@ -66,9 +65,6 @@ class ModuleFragment : BaseUIFragment<ModuleViewModel, FragmentModuleMd2Binding>
|
||||
if (newState != RecyclerView.SCROLL_STATE_IDLE) hideKeyboard()
|
||||
}
|
||||
})
|
||||
|
||||
PinchZoomTouchListener.attachTo(binding.moduleFilterInclude.moduleFilterList)
|
||||
PinchZoomTouchListener.attachTo(binding.moduleList)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
@@ -76,8 +72,6 @@ class ModuleFragment : BaseUIFragment<ModuleViewModel, FragmentModuleMd2Binding>
|
||||
binding.moduleList.removeOnScrollListener(it)
|
||||
binding.moduleFilterInclude.moduleFilterList.removeOnScrollListener(it)
|
||||
}
|
||||
PinchZoomTouchListener.clear(binding.moduleList)
|
||||
PinchZoomTouchListener.clear(binding.moduleFilterInclude.moduleFilterList)
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.topjohnwu.magisk.ui.settings
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.databinding.FragmentSettingsMd2Binding
|
||||
import com.topjohnwu.magisk.ui.base.BaseUIFragment
|
||||
import com.topjohnwu.magisk.utils.PinchZoomTouchListener
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
class SettingsFragment : BaseUIFragment<SettingsViewModel, FragmentSettingsMd2Binding>() {
|
||||
@@ -19,16 +16,6 @@ class SettingsFragment : BaseUIFragment<SettingsViewModel, FragmentSettingsMd2Bi
|
||||
activity.title = resources.getString(R.string.settings)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
PinchZoomTouchListener.attachTo(binding.settingsList)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
PinchZoomTouchListener.clear(binding.settingsList)
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.items.forEach { it.refresh() }
|
||||
|
||||
@@ -126,11 +126,11 @@ object DownloadPath : SettingsItem.Input() {
|
||||
|
||||
object GridSize : SettingsItem.Selector() {
|
||||
override var value by bindableValue(Config.listSpanCount - 1) {
|
||||
Config.listSpanCount = max(1, min(3, it + 1))
|
||||
Config.listSpanCount = max(1, min(2, it + 1))
|
||||
}
|
||||
|
||||
override val title = R.string.settings_grid_span_count_title.asTransitive()
|
||||
override val description = R.string.settings_grid_span_count_summary.asTransitive()
|
||||
override val title = R.string.settings_grid_column_count_title.asTransitive()
|
||||
override val description = R.string.settings_grid_column_count_summary.asTransitive()
|
||||
override val entries = resources.getStringArray(R.array.span_count)
|
||||
override val entryValues = resources.getStringArray(R.array.value_array)
|
||||
}
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package com.topjohnwu.magisk.ui.superuser
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.databinding.FragmentSuperuserMd2Binding
|
||||
import com.topjohnwu.magisk.model.navigation.Navigation
|
||||
import com.topjohnwu.magisk.ui.base.BaseUIFragment
|
||||
import com.topjohnwu.magisk.utils.PinchZoomTouchListener
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
class SuperuserFragment : BaseUIFragment<SuperuserViewModel, FragmentSuperuserMd2Binding>() {
|
||||
@@ -23,16 +20,6 @@ class SuperuserFragment : BaseUIFragment<SuperuserViewModel, FragmentSuperuserMd
|
||||
setHasOptionsMenu(true)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
PinchZoomTouchListener.attachTo(binding.superuserList)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
PinchZoomTouchListener.clear(binding.superuserList)
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.menu_superuser_md2, menu)
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ import androidx.databinding.InverseBindingAdapter
|
||||
import androidx.databinding.InverseBindingListener
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.*
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
@@ -485,4 +483,12 @@ fun View.setPopupMenu(popupMenu: Int, listener: OnPopupMenuItemClickListener) {
|
||||
setOnClickListener {
|
||||
(tag as PopupMenu).show()
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("spanCount")
|
||||
fun RecyclerView.setSpanCount(count: Int) {
|
||||
when (val lama = layoutManager) {
|
||||
is GridLayoutManager -> lama.spanCount = count
|
||||
is StaggeredGridLayoutManager -> lama.spanCount = count
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import android.view.ScaleGestureDetector
|
||||
|
||||
abstract class PinchGestureCallback : ScaleGestureDetector.SimpleOnScaleGestureListener() {
|
||||
|
||||
private var startFactor: Float = 1f
|
||||
|
||||
override fun onScaleBegin(detector: ScaleGestureDetector?): Boolean {
|
||||
startFactor = detector?.scaleFactor ?: 1f
|
||||
return super.onScaleBegin(detector)
|
||||
}
|
||||
|
||||
override fun onScaleEnd(detector: ScaleGestureDetector?) {
|
||||
val endFactor = detector?.scaleFactor ?: 1f
|
||||
|
||||
if (endFactor > startFactor) onZoom()
|
||||
else if (endFactor < startFactor) onPinch()
|
||||
}
|
||||
|
||||
abstract fun onPinch()
|
||||
abstract fun onZoom()
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.MotionEvent
|
||||
import android.view.ScaleGestureDetector
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import androidx.transition.TransitionManager
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
class PinchZoomTouchListener private constructor(
|
||||
private val view: RecyclerView,
|
||||
private val max: Int = 3,
|
||||
private val min: Int = 1
|
||||
) : View.OnTouchListener {
|
||||
|
||||
private val layoutManager
|
||||
get() = view.layoutManager
|
||||
|
||||
private val pinchListener = object : PinchGestureCallback() {
|
||||
override fun onPinch() = updateSpanCount(Config.listSpanCount + 1)
|
||||
override fun onZoom() = updateSpanCount(Config.listSpanCount - 1)
|
||||
}
|
||||
|
||||
private val gestureDetector by lazy { ScaleGestureDetector(view.context, pinchListener) }
|
||||
|
||||
init {
|
||||
updateSpanCount(Config.listSpanCount, false)
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
|
||||
gestureDetector.onTouchEvent(event)
|
||||
return false
|
||||
}
|
||||
|
||||
private fun updateSpanCount(count: Int, animate: Boolean = true) {
|
||||
if (animate) {
|
||||
TransitionManager.beginDelayedTransition(view)
|
||||
}
|
||||
|
||||
val boundCount = max(min, min(max, count))
|
||||
|
||||
when (val l = layoutManager) {
|
||||
is StaggeredGridLayoutManager -> l.spanCount = boundCount
|
||||
is GridLayoutManager -> l.spanCount = boundCount
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
Config.listSpanCount = boundCount
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
fun attachTo(view: RecyclerView) = view.setOnTouchListener(PinchZoomTouchListener(view))
|
||||
|
||||
fun clear(view: View) = view.setOnTouchListener(null)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user