mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-26 05:05:15 +00:00
ManagerAccentColorDialog migrate to view binding
This commit is contained in:
parent
00d3003498
commit
a7545071a1
2 changed files with 86 additions and 85 deletions
|
@ -10,28 +10,36 @@ import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
|||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.android.material.radiobutton.MaterialRadioButton
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.DialogInstallationFilesDetectedBinding
|
||||
import com.vanced.manager.databinding.DialogManagerAccentColorBinding
|
||||
import com.vanced.manager.ui.core.BindingBottomSheetDialogFragment
|
||||
import com.vanced.manager.utils.Extensions.getCheckedButtonTag
|
||||
|
||||
class ManagerAccentColorDialog : BottomSheetDialogFragment() {
|
||||
class ManagerAccentColorDialog : BindingBottomSheetDialogFragment<DialogManagerAccentColorBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): ManagerAccentColorDialog = ManagerAccentColorDialog().apply {
|
||||
arguments = Bundle()
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var binding: DialogManagerAccentColorBinding
|
||||
private val prefs by lazy { getDefaultSharedPreferences(requireActivity()) }
|
||||
|
||||
override fun onCreateView(
|
||||
override fun binding(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.dialog_manager_accent_color, container, false)
|
||||
return binding.root
|
||||
) = DialogManagerAccentColorBinding.inflate(inflater, container, false)
|
||||
|
||||
override fun otherSetups() {
|
||||
bindData()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
private fun bindData() {
|
||||
with(binding) {
|
||||
val accent = prefs.getString("manager_accent", "Blue")
|
||||
view.findViewWithTag<MaterialRadioButton>(accent).isChecked = true
|
||||
binding.accentSave.setOnClickListener {
|
||||
root.findViewWithTag<MaterialRadioButton>(accent).isChecked = true
|
||||
accentSave.setOnClickListener {
|
||||
val newPref = binding.accentRadiogroup.getCheckedButtonTag()
|
||||
if (accent != newPref) {
|
||||
prefs.edit { putString("manager_accent", newPref) }
|
||||
|
@ -42,5 +50,5 @@ class ManagerAccentColorDialog : BottomSheetDialogFragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/BottomDialogCard">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -10,8 +9,8 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/BottomDialogCardTitle"
|
||||
android:text="@string/accent_color" />
|
||||
android:text="@string/accent_color"
|
||||
style="@style/BottomDialogCardTitle"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -56,18 +55,12 @@
|
|||
android:tag="Purple"
|
||||
android:text="@string/accent_purple"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/accent_save"
|
||||
style="@style/BottomDialogButtonStyle"
|
||||
android:text="@string/save" />
|
||||
|
||||
android:text="@string/save"
|
||||
style="@style/BottomDialogButtonStyle"/>
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</layout>
|
||||
|
|
Loading…
Reference in a new issue