mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-31 20:11:01 +00:00
feat: WIP new settings UI
This commit is contained in:
@@ -7,6 +7,7 @@ import android.view.ViewGroup
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.ActivitySettingsThemeBinding
|
||||
import ani.dantotsu.initActivity
|
||||
@@ -58,7 +59,7 @@ class SettingsThemeActivity : AppCompatActivity(), SimpleDialog.OnDialogResultLi
|
||||
}
|
||||
|
||||
settingsUiLight.setOnClickListener {
|
||||
settingsUseOLED.isChecked = false
|
||||
PrefManager.setVal(PrefName.UseOLED, false)
|
||||
uiTheme(1, it)
|
||||
}
|
||||
|
||||
@@ -89,64 +90,85 @@ class SettingsThemeActivity : AppCompatActivity(), SimpleDialog.OnDialogResultLi
|
||||
restartApp(binding.root)
|
||||
}
|
||||
}
|
||||
settingsUseOLED.apply {
|
||||
isChecked = PrefManager.getVal(PrefName.UseOLED)
|
||||
setOnCheckedChangeListener { _, isChecked ->
|
||||
PrefManager.setVal(PrefName.UseOLED, isChecked)
|
||||
restartApp(binding.root)
|
||||
}
|
||||
}
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
|
||||
|
||||
settingsUseMaterialYou.apply {
|
||||
isChecked = PrefManager.getVal(PrefName.UseMaterialYou)
|
||||
setOnCheckedChangeListener { _, isChecked ->
|
||||
PrefManager.setVal(PrefName.UseMaterialYou, isChecked)
|
||||
if (isChecked) settingsUseCustomTheme.isChecked = false
|
||||
restartApp(binding.root)
|
||||
}
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
settingsUseSourceTheme.apply {
|
||||
isChecked = PrefManager.getVal(PrefName.UseSourceTheme)
|
||||
setOnCheckedChangeListener { _, isChecked ->
|
||||
PrefManager.setVal(PrefName.UseSourceTheme, isChecked)
|
||||
restartApp(binding.root)
|
||||
}
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
settingsUseCustomTheme.apply {
|
||||
isChecked = PrefManager.getVal(PrefName.UseCustomTheme)
|
||||
setOnCheckedChangeListener { _, isChecked ->
|
||||
PrefManager.setVal(PrefName.UseCustomTheme, isChecked)
|
||||
if (isChecked) {
|
||||
settingsUseMaterialYou.isChecked = false
|
||||
settingsRecyclerView.adapter = SettingsAdapter(
|
||||
arrayListOf(
|
||||
Settings(
|
||||
type = 2,
|
||||
name = getString(R.string.oled_theme_variant),
|
||||
desc = getString(R.string.oled_theme_variant),
|
||||
icon = R.drawable.ic_round_brightness_4_24,
|
||||
isChecked = PrefManager.getVal(PrefName.UseOLED),
|
||||
switch = { isChecked, _ ->
|
||||
PrefManager.setVal(PrefName.UseOLED, isChecked)
|
||||
restartApp(binding.root)
|
||||
}
|
||||
restartApp(binding.root)
|
||||
}
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
customTheme.apply {
|
||||
setOnClickListener {
|
||||
val originalColor: Int = PrefManager.getVal(PrefName.CustomThemeInt)
|
||||
class CustomColorDialog : SimpleColorDialog() {
|
||||
override fun onPositiveButtonClick() {
|
||||
restartApp(binding.root)
|
||||
super.onPositiveButtonClick()
|
||||
),
|
||||
Settings(
|
||||
type = 2,
|
||||
name = getString(R.string.use_material_you),
|
||||
desc = getString(R.string.use_material_you),
|
||||
icon = R.drawable.ic_round_new_releases_24,
|
||||
isChecked = PrefManager.getVal(PrefName.UseMaterialYou),
|
||||
switch = { isChecked, _ ->
|
||||
PrefManager.setVal(PrefName.UseMaterialYou, isChecked)
|
||||
if (isChecked) PrefManager.setVal(PrefName.UseCustomTheme, false)
|
||||
restartApp(binding.root)
|
||||
},
|
||||
isVisible = Build.VERSION.SDK_INT > Build.VERSION_CODES.R
|
||||
),
|
||||
Settings(
|
||||
type = 2,
|
||||
name = getString(R.string.use_unique_theme_for_each_item),
|
||||
desc = getString(R.string.use_unique_theme_for_each_item),
|
||||
icon = R.drawable.ic_palette,
|
||||
isChecked = PrefManager.getVal(PrefName.UseSourceTheme),
|
||||
switch = { isChecked, _ ->
|
||||
PrefManager.setVal(PrefName.UseSourceTheme, isChecked)
|
||||
restartApp(binding.root)
|
||||
},
|
||||
isVisible = Build.VERSION.SDK_INT > Build.VERSION_CODES.R
|
||||
),
|
||||
Settings(
|
||||
type = 2,
|
||||
name = getString(R.string.use_custom_theme),
|
||||
desc = getString(R.string.use_custom_theme),
|
||||
icon = R.drawable.ic_palette,
|
||||
isChecked = PrefManager.getVal(PrefName.UseCustomTheme),
|
||||
switch = { isChecked, _ ->
|
||||
PrefManager.setVal(PrefName.UseCustomTheme, isChecked)
|
||||
if (isChecked) PrefManager.setVal(PrefName.UseMaterialYou, false)
|
||||
restartApp(binding.root)
|
||||
},
|
||||
isVisible = Build.VERSION.SDK_INT > Build.VERSION_CODES.R
|
||||
),
|
||||
Settings(
|
||||
type = 1,
|
||||
name = getString(R.string.color_picker),
|
||||
desc = getString(R.string.color_picker),
|
||||
icon = R.drawable.ic_palette,
|
||||
onClick = {
|
||||
val originalColor: Int = PrefManager.getVal(PrefName.CustomThemeInt)
|
||||
class CustomColorDialog : SimpleColorDialog() {
|
||||
override fun onPositiveButtonClick() {
|
||||
restartApp(binding.root)
|
||||
super.onPositiveButtonClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
val tag = "colorPicker"
|
||||
CustomColorDialog().title(R.string.custom_theme).colorPreset(originalColor)
|
||||
.colors(context, SimpleColorDialog.MATERIAL_COLOR_PALLET)
|
||||
.allowCustom(true).showOutline(0x46000000).gridNumColumn(5)
|
||||
.choiceMode(SimpleColorDialog.SINGLE_CHOICE).neg()
|
||||
.show(context, tag)
|
||||
}
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
customThemeTitle.visibility = View.VISIBLE
|
||||
val tag = "colorPicker"
|
||||
CustomColorDialog().title(R.string.custom_theme).colorPreset(originalColor)
|
||||
.colors(context, SimpleColorDialog.MATERIAL_COLOR_PALLET)
|
||||
.allowCustom(true).showOutline(0x46000000).gridNumColumn(5)
|
||||
.choiceMode(SimpleColorDialog.SINGLE_CHOICE).neg()
|
||||
.show(context, tag)
|
||||
},
|
||||
isVisible = Build.VERSION.SDK_INT > Build.VERSION_CODES.R
|
||||
)
|
||||
)
|
||||
)
|
||||
settingsRecyclerView.apply {
|
||||
layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
|
||||
setHasFixedSize(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user