feat: WIP new settings UI

This commit is contained in:
aayush262
2024-04-17 01:51:56 +05:30
parent f8a6fad513
commit 91d1d2cf1d
20 changed files with 1061 additions and 1503 deletions

View File

@@ -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)
}
}
}