diff --git a/app/src/main/java/com/drdisagree/iconify/ui/base/BaseFragment.kt b/app/src/main/java/com/drdisagree/iconify/ui/base/BaseFragment.kt index 62788544e..f83cfdedf 100644 --- a/app/src/main/java/com/drdisagree/iconify/ui/base/BaseFragment.kt +++ b/app/src/main/java/com/drdisagree/iconify/ui/base/BaseFragment.kt @@ -138,15 +138,11 @@ abstract class BaseFragment : Fragment() { }, viewLifecycleOwner, Lifecycle.State.RESUMED) } - fun onSearchResultClicked(result: SearchPreferenceResult) { + open fun onSearchResultClicked(result: SearchPreferenceResult) { for (searchableFragment in searchableFragments) { if (searchableFragment.xml == result.resourceFile) { replaceFragment(parentFragmentManager, searchableFragment.fragment) - var finalFragment: ControlledPreferenceFragmentCompat? = null - if (searchableFragment.fragment is LockscreenClockParent) { - finalFragment = LockscreenClockParent.getPreferenceFragment() - } - SearchPreferenceResult.highlight(finalFragment, result.key); + SearchPreferenceResult.highlight(parentFragmentManager as ControlledPreferenceFragmentCompat, result.key); break } } diff --git a/app/src/main/java/com/drdisagree/iconify/ui/base/ControlledPreferenceFragmentCompat.kt b/app/src/main/java/com/drdisagree/iconify/ui/base/ControlledPreferenceFragmentCompat.kt index 257745563..10620f232 100644 --- a/app/src/main/java/com/drdisagree/iconify/ui/base/ControlledPreferenceFragmentCompat.kt +++ b/app/src/main/java/com/drdisagree/iconify/ui/base/ControlledPreferenceFragmentCompat.kt @@ -222,6 +222,7 @@ abstract class ControlledPreferenceFragmentCompat : PreferenceFragmentCompat() { var resultFragment: ControlledPreferenceFragmentCompat? = null if (fragment is LockscreenClockParent) { resultFragment = LockscreenClockParent.getPreferenceFragment() + fragment.scrollToPreference() } SearchPreferenceResult.highlight(resultFragment, result.key); break diff --git a/app/src/main/java/com/drdisagree/iconify/ui/fragments/xposed/LockscreenClockParent.kt b/app/src/main/java/com/drdisagree/iconify/ui/fragments/xposed/LockscreenClockParent.kt index c39e40a0d..ec6794200 100644 --- a/app/src/main/java/com/drdisagree/iconify/ui/fragments/xposed/LockscreenClockParent.kt +++ b/app/src/main/java/com/drdisagree/iconify/ui/fragments/xposed/LockscreenClockParent.kt @@ -17,14 +17,17 @@ import com.drdisagree.iconify.R import com.drdisagree.iconify.common.Preferences.LSCLOCK_STYLE import com.drdisagree.iconify.common.Preferences.LSCLOCK_SWITCH import com.drdisagree.iconify.common.Resources.LOCKSCREEN_CLOCK_LAYOUT +import com.drdisagree.iconify.common.Resources.searchableFragments import com.drdisagree.iconify.config.RPrefs.getBoolean import com.drdisagree.iconify.config.RPrefs.getInt import com.drdisagree.iconify.config.RPrefs.putBoolean import com.drdisagree.iconify.config.RPrefs.putInt import com.drdisagree.iconify.databinding.FragmentXposedLockscreenClockBinding +import com.drdisagree.iconify.ui.activities.MainActivity.Companion.replaceFragment import com.drdisagree.iconify.ui.base.BaseFragment import com.drdisagree.iconify.ui.base.ControlledPreferenceFragmentCompat import com.drdisagree.iconify.ui.models.ClockCarouselItemViewModel +import com.drdisagree.iconify.ui.preferences.preferencesearch.SearchPreferenceResult import com.drdisagree.iconify.ui.utils.ViewHelper.setHeader import com.drdisagree.iconify.ui.views.ClockCarouselView import com.drdisagree.iconify.utils.SystemUtils @@ -147,6 +150,17 @@ class LockscreenClockParent : BaseFragment() { }, 50) } + override fun onSearchResultClicked(result: SearchPreferenceResult) { + for (searchableFragment in searchableFragments) { + if (searchableFragment.xml == result.resourceFile) { + replaceFragment(parentFragmentManager, searchableFragment.fragment) + scrollToPreference() + SearchPreferenceResult.highlight(lockscreenClockFragment, result.key); + break + } + } + } + private fun loadAndSetWallpaper() { viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) { val bitmap = loadWallpaper(requireContext(), isLockscreen = true).await() @@ -172,6 +186,12 @@ class LockscreenClockParent : BaseFragment() { requireActivity().requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED } + fun scrollToPreference() { + Handler(Looper.getMainLooper()).postDelayed({ + binding?.scrollView!!.smoothScrollTo(0, binding.fragmentContainer.top) + }, 180) + } + companion object { private val lockscreenClockFragment = LockscreenClock() diff --git a/app/src/main/res/layout/fragment_xposed_lockscreen_clock.xml b/app/src/main/res/layout/fragment_xposed_lockscreen_clock.xml index 837e74f3a..640c81692 100644 --- a/app/src/main/res/layout/fragment_xposed_lockscreen_clock.xml +++ b/app/src/main/res/layout/fragment_xposed_lockscreen_clock.xml @@ -8,6 +8,7 @@ tools:context=".ui.fragments.xposed.LockscreenClockParent">