| 
					
				 | 
			
			
				@@ -1,6 +1,9 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package eu.kanade.tachiyomi.ui.setting 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.animation.ArgbEvaluator 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.animation.ValueAnimator 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.content.Context 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.graphics.Color 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.os.Bundle 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.util.TypedValue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.view.ContextThemeWrapper 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -9,6 +12,7 @@ import android.view.View 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.view.ViewGroup 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.appcompat.app.AppCompatActivity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.preference.PreferenceController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.preference.PreferenceGroup 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.preference.PreferenceScreen 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.bluelinelabs.conductor.ControllerChangeHandler 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.bluelinelabs.conductor.ControllerChangeType 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -26,6 +30,7 @@ import uy.kohesive.injekt.api.get 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 abstract class SettingsController : PreferenceController() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    var preferenceKey: String? = null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     val preferences: PreferencesHelper = Injekt.get() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     val scope = CoroutineScope(Job() + Dispatchers.Main) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -39,6 +44,24 @@ abstract class SettingsController : PreferenceController() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return super.onCreateView(inflater, container, savedInstanceState) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    override fun onAttach(view: View) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.onAttach(view) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        preferenceKey?.let { prefKey -> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            val adapter = listView.adapter 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            scrollToPreference(prefKey) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            listView.post { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (adapter is PreferenceGroup.PreferencePositionCallback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    val pos = adapter.getPreferenceAdapterPosition(prefKey) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    listView.findViewHolderForAdapterPosition(pos)?.let { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        animatePreferenceHighlight(it.itemView) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     override fun onDestroyView(view: View) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         super.onDestroyView(view) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         untilDestroySubscriptions.unsubscribe() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -58,6 +81,17 @@ abstract class SettingsController : PreferenceController() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ContextThemeWrapper(activity, tv.resourceId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private fun animatePreferenceHighlight(view: View) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        val duration = 500L 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        val repeat = 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        val colorAnimation = ValueAnimator.ofObject(ArgbEvaluator(), Color.TRANSPARENT, Color.WHITE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        colorAnimation.duration = duration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        colorAnimation.repeatCount = repeat 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        colorAnimation.addUpdateListener { animator -> view.setBackgroundColor(animator.animatedValue as Int) } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        colorAnimation.reverse() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     open fun getTitle(): String? { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return preferenceScreen?.title?.toString() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |