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/java/com/drdisagree/iconify/ui/views/ClockCarouselView.kt b/app/src/main/java/com/drdisagree/iconify/ui/views/ClockCarouselView.kt
index 3fb95e119..904904723 100644
--- a/app/src/main/java/com/drdisagree/iconify/ui/views/ClockCarouselView.kt
+++ b/app/src/main/java/com/drdisagree/iconify/ui/views/ClockCarouselView.kt
@@ -8,6 +8,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
+import android.widget.TextView
import androidx.constraintlayout.helper.widget.Carousel
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.view.doOnPreDraw
@@ -33,6 +34,8 @@ class ClockCarouselView(
private var offCenterClockScaleView: View? = null
private var toCenterCardView: View? = null
private var offCenterCardView: View? = null
+ private var toCenterTextView: View? = null
+ private var offCenterTextView: View? = null
init {
val clockCarousel = LayoutInflater.from(context).inflate(R.layout.clock_carousel, this)
@@ -143,6 +146,12 @@ class ClockCarouselView(
if (endId == R.id.next) R.id.clock_scale_view_3
else R.id.clock_scale_view_1
)
+ offCenterTextView = motionLayout.findViewById(R.id.clock_style_2)
+ toCenterTextView =
+ motionLayout.findViewById(
+ if (endId == R.id.next) R.id.clock_style_3
+ else R.id.clock_style_1
+ )
}
private fun prepareCardView(motionLayout: MotionLayout, endId: Int) {
@@ -151,11 +160,19 @@ class ClockCarouselView(
motionLayout.findViewById(
if (endId == R.id.next) R.id.item_card_3 else R.id.item_card_1
)
+ offCenterTextView = motionLayout.findViewById(R.id.clock_style_2)
+ toCenterTextView =
+ motionLayout.findViewById(
+ if (endId == R.id.next) R.id.clock_style_3
+ else R.id.clock_style_1
+ )
}
private fun onCardViewTransition(progress: Float) {
offCenterCardView?.alpha = getShowingAlpha(progress)
toCenterCardView?.alpha = getHidingAlpha(progress)
+ toCenterTextView?.alpha = getShowingAlphaText(progress)
+ offCenterTextView?.alpha = getHidingAlphaText(progress)
}
private fun onDynamicClockViewTransition(progress: Float) {
@@ -232,6 +249,9 @@ class ClockCarouselView(
val clockHostView =
getClockHostViewId(viewRoot.id)?.let { viewRoot.findViewById(it) as? ClockHostView }
?: return
+ val clockTextView =
+ getClockTextId(viewRoot.id)?.let { viewRoot.findViewById(it) as? View }
+ ?: return
// Add the clock view to the clock host view
clockHostView.removeAllViews()
@@ -247,19 +267,23 @@ class ClockCarouselView(
// Accessibility
viewRoot.contentDescription = getContentDescription(index)
viewRoot.isSelected = isMiddleView
+ (clockTextView as TextView).text = clocks[index].clockName
initializeDynamicClockView(
isMiddleView,
clockScaleView,
- clockHostView
+ clockHostView,
+ clockTextView
)
cardView.alpha = if (isMiddleView) 0f else 1f
+ clockTextView.alpha = if (isMiddleView) 1f else 0f
}
private fun initializeDynamicClockView(
isMiddleView: Boolean,
clockScaleView: View,
clockHostView: ClockHostView,
+ clockTextView: View
) {
clockHostView.doOnPreDraw {
it.pivotX = it.width / 2F
@@ -269,9 +293,11 @@ class ClockCarouselView(
if (isMiddleView) {
clockScaleView.scaleX = 1f
clockScaleView.scaleY = 1f
+ clockTextView.alpha = 1f
} else {
clockScaleView.scaleX = CLOCK_CAROUSEL_VIEW_SCALE
clockScaleView.scaleY = CLOCK_CAROUSEL_VIEW_SCALE
+ clockTextView.alpha = 0f
}
}
@@ -308,6 +334,14 @@ class ClockCarouselView(
// card won't overlap the preview.
fun getHidingAlpha(progress: Float) = max(1f - progress * 4, 0f)
+ // This makes the card only starts to reveal in the last quarter of the trip so
+ // the card won't overlap the preview.
+ fun getShowingAlphaText(progress: Float) = max(progress - 0.75f, 0f) * 4
+
+ // This makes the card starts to hide in the first quarter of the trip so the
+ // card won't overlap the preview.
+ fun getHidingAlphaText(progress: Float) = max(1f - progress * 4, 0f)
+
fun getClockHostViewId(rootViewId: Int): Int? {
return when (rootViewId) {
R.id.item_view_0 -> R.id.clock_host_view_0
@@ -341,6 +375,17 @@ class ClockCarouselView(
}
}
+ fun getClockTextId(rootViewId: Int): Int? {
+ return when (rootViewId) {
+ R.id.item_view_0 -> R.id.clock_style_0
+ R.id.item_view_1 -> R.id.clock_style_1
+ R.id.item_view_2 -> R.id.clock_style_2
+ R.id.item_view_3 -> R.id.clock_style_3
+ R.id.item_view_4 -> R.id.clock_style_4
+ else -> null
+ }
+ }
+
fun isMiddleView(rootViewId: Int): Boolean {
return rootViewId == R.id.item_view_2
}
diff --git a/app/src/main/res/layout/clock_carousel.xml b/app/src/main/res/layout/clock_carousel.xml
index 1dffca57b..83df2448b 100644
--- a/app/src/main/res/layout/clock_carousel.xml
+++ b/app/src/main/res/layout/clock_carousel.xml
@@ -38,6 +38,14 @@
android:layout_gravity="center"
android:clipChildren="false" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+