|
|
@ -3,14 +3,13 @@ package io.legado.app.lib.theme.prefs |
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
import android.os.Build |
|
|
|
import android.os.Build |
|
|
|
import android.util.AttributeSet |
|
|
|
import android.util.AttributeSet |
|
|
|
import android.view.ViewGroup |
|
|
|
|
|
|
|
import android.widget.Switch |
|
|
|
|
|
|
|
import androidx.annotation.RequiresApi |
|
|
|
import androidx.annotation.RequiresApi |
|
|
|
|
|
|
|
import androidx.appcompat.widget.SwitchCompat |
|
|
|
import androidx.preference.PreferenceViewHolder |
|
|
|
import androidx.preference.PreferenceViewHolder |
|
|
|
import androidx.preference.SwitchPreferenceCompat |
|
|
|
import androidx.preference.SwitchPreferenceCompat |
|
|
|
|
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.lib.theme.ATH |
|
|
|
import io.legado.app.lib.theme.ATH |
|
|
|
import io.legado.app.lib.theme.ThemeStore |
|
|
|
import io.legado.app.lib.theme.ThemeStore |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ATESwitchPreference : SwitchPreferenceCompat { |
|
|
|
class ATESwitchPreference : SwitchPreferenceCompat { |
|
|
|
|
|
|
|
|
|
|
@ -31,21 +30,9 @@ class ATESwitchPreference : SwitchPreferenceCompat { |
|
|
|
override fun onBindViewHolder(holder: PreferenceViewHolder?) { |
|
|
|
override fun onBindViewHolder(holder: PreferenceViewHolder?) { |
|
|
|
super.onBindViewHolder(holder) |
|
|
|
super.onBindViewHolder(holder) |
|
|
|
holder?.let { |
|
|
|
holder?.let { |
|
|
|
val view = it.itemView |
|
|
|
val view = it.findViewById(R.id.switchWidget) |
|
|
|
if (view is ViewGroup) { |
|
|
|
if (view is SwitchCompat) { |
|
|
|
val queue = LinkedList<ViewGroup>() |
|
|
|
ATH.setTint(view, ThemeStore.accentColor(view.getContext())) |
|
|
|
queue.add(view) |
|
|
|
|
|
|
|
while (!queue.isEmpty()) { |
|
|
|
|
|
|
|
val current = queue.removeFirst() |
|
|
|
|
|
|
|
for (i in 0 until current.childCount) { |
|
|
|
|
|
|
|
if (current.getChildAt(i) is Switch) { |
|
|
|
|
|
|
|
ATH.setTint(current.getChildAt(i), ThemeStore.accentColor(view.getContext())) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} else if (current.getChildAt(i) is ViewGroup) { |
|
|
|
|
|
|
|
queue.addLast(current.getChildAt(i) as ViewGroup) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|