Dialog improvement, prep dialog

This commit is contained in:
Kelvin 2024-09-06 16:29:24 +02:00
commit 6a43568369
3 changed files with 24 additions and 4 deletions

View file

@ -485,12 +485,15 @@ class Settings : FragmentedStorageFileJson() {
var comments = CommentSettings(); var comments = CommentSettings();
@Serializable @Serializable
class CommentSettings { class CommentSettings {
var didAskPolycentricDefault: Boolean = false;
@FormField(R.string.default_comment_section, FieldForm.DROPDOWN, -1, 0) @FormField(R.string.default_comment_section, FieldForm.DROPDOWN, -1, 0)
@DropdownFieldOptionsId(R.array.comment_sections) @DropdownFieldOptionsId(R.array.comment_sections)
var defaultCommentSection: Int = 1; var defaultCommentSection: Int = 1;
@FormField(R.string.bad_reputation_comments_fading, FieldForm.TOGGLE, R.string.bad_reputation_comments_fading_description, 0) @FormField(R.string.bad_reputation_comments_fading, FieldForm.TOGGLE, R.string.bad_reputation_comments_fading_description, 0)
var badReputationCommentsFading: Boolean = true; var badReputationCommentsFading: Boolean = true;
} }
@FormField(R.string.downloads, "group", R.string.configure_downloading_of_videos, 7) @FormField(R.string.downloads, "group", R.string.configure_downloading_of_videos, 7)

View file

@ -229,14 +229,15 @@ class UIDialogs {
} }
}; };
view.findViewById<LinearLayout>(R.id.dialog_buttons).apply { view.findViewById<LinearLayout>(R.id.dialog_buttons).apply {
val center = actions.any { it?.center == true };
val buttons = actions.map<Action, TextView> { act -> val buttons = actions.map<Action, TextView> { act ->
val buttonView = TextView(context); val buttonView = TextView(context);
val dp10 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10f, resources.displayMetrics).toInt(); val dp10 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10f, resources.displayMetrics).toInt();
val dp28 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28f, resources.displayMetrics).toInt(); val dp28 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28f, resources.displayMetrics).toInt();
val dp14 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14.0f, resources.displayMetrics).toInt(); val dp14 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14.0f, resources.displayMetrics).toInt();
buttonView.layoutParams = LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply { buttonView.layoutParams = LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply {
if(actions.size > 1) this.marginStart = if(actions.size >= 2) dp14 / 2 else dp28 / 2;
this.marginEnd = if(actions.size > 2) dp14 else dp28; this.marginEnd = if(actions.size >= 2) dp14 / 2 else dp28 / 2;
}; };
buttonView.setTextColor(Color.WHITE); buttonView.setTextColor(Color.WHITE);
buttonView.textSize = 14f; buttonView.textSize = 14f;
@ -258,7 +259,7 @@ class UIDialogs {
return@map buttonView; return@map buttonView;
}; };
if(actions.size <= 1) if(actions.size <= 1 || center)
this.gravity = Gravity.CENTER; this.gravity = Gravity.CENTER;
else else
this.gravity = Gravity.END; this.gravity = Gravity.END;
@ -509,11 +510,13 @@ class UIDialogs {
val text: String; val text: String;
val action: ()->Unit; val action: ()->Unit;
val style: ActionStyle; val style: ActionStyle;
var center: Boolean;
constructor(text: String, action: ()->Unit, style: ActionStyle = ActionStyle.NONE) { constructor(text: String, action: ()->Unit, style: ActionStyle = ActionStyle.NONE, center: Boolean = false) {
this.text = text; this.text = text;
this.action = action; this.action = action;
this.style = style; this.style = style;
this.center = center;
} }
} }
enum class ActionStyle { enum class ActionStyle {

View file

@ -612,6 +612,20 @@ class StateApp {
Settings.instance.didFirstStart = true; Settings.instance.didFirstStart = true;
Settings.instance.save(); Settings.instance.save();
} }
/*
if(!Settings.instance.comments.didAskPolycentricDefault) {
UIDialogs.showDialog(context, R.drawable.neopass, "Default Comment Section", "Grayjay supports 2 comment sections, the Platform comments and Polycentric comments. You can easily toggle between them, but which would you like to be selected by default? This choice can be changed in settings.\n\nPolycentric is still under active development.", null, 1,
UIDialogs.Action("Polycentric", {
Settings.instance.comments.didAskPolycentricDefault = true;
Settings.instance.comments.defaultCommentSection = 0;
Settings.instance.save();
}, UIDialogs.ActionStyle.PRIMARY, true),
UIDialogs.Action("Platform", {
Settings.instance.comments.didAskPolycentricDefault = true;
Settings.instance.comments.defaultCommentSection = 1;
Settings.instance.save();
}, UIDialogs.ActionStyle.PRIMARY, true))
}*/
if(Settings.instance.backup.shouldAutomaticBackup()) { if(Settings.instance.backup.shouldAutomaticBackup()) {
try { try {
StateBackup.startAutomaticBackup(); StateBackup.startAutomaticBackup();