From 6a4356836962fb6352dc396fab4db7cc9c00f943 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Fri, 6 Sep 2024 16:29:24 +0200 Subject: [PATCH] Dialog improvement, prep dialog --- .../main/java/com/futo/platformplayer/Settings.kt | 3 +++ .../main/java/com/futo/platformplayer/UIDialogs.kt | 11 +++++++---- .../com/futo/platformplayer/states/StateApp.kt | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/Settings.kt b/app/src/main/java/com/futo/platformplayer/Settings.kt index 4c205620..e75a9de8 100644 --- a/app/src/main/java/com/futo/platformplayer/Settings.kt +++ b/app/src/main/java/com/futo/platformplayer/Settings.kt @@ -485,12 +485,15 @@ class Settings : FragmentedStorageFileJson() { var comments = CommentSettings(); @Serializable class CommentSettings { + var didAskPolycentricDefault: Boolean = false; + @FormField(R.string.default_comment_section, FieldForm.DROPDOWN, -1, 0) @DropdownFieldOptionsId(R.array.comment_sections) var defaultCommentSection: Int = 1; @FormField(R.string.bad_reputation_comments_fading, FieldForm.TOGGLE, R.string.bad_reputation_comments_fading_description, 0) var badReputationCommentsFading: Boolean = true; + } @FormField(R.string.downloads, "group", R.string.configure_downloading_of_videos, 7) diff --git a/app/src/main/java/com/futo/platformplayer/UIDialogs.kt b/app/src/main/java/com/futo/platformplayer/UIDialogs.kt index eed5f891..7c975bf0 100644 --- a/app/src/main/java/com/futo/platformplayer/UIDialogs.kt +++ b/app/src/main/java/com/futo/platformplayer/UIDialogs.kt @@ -229,14 +229,15 @@ class UIDialogs { } }; view.findViewById(R.id.dialog_buttons).apply { + val center = actions.any { it?.center == true }; val buttons = actions.map { act -> val buttonView = TextView(context); 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 dp14 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14.0f, resources.displayMetrics).toInt(); buttonView.layoutParams = LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply { - if(actions.size > 1) - this.marginEnd = if(actions.size > 2) dp14 else dp28; + this.marginStart = if(actions.size >= 2) dp14 / 2 else dp28 / 2; + this.marginEnd = if(actions.size >= 2) dp14 / 2 else dp28 / 2; }; buttonView.setTextColor(Color.WHITE); buttonView.textSize = 14f; @@ -258,7 +259,7 @@ class UIDialogs { return@map buttonView; }; - if(actions.size <= 1) + if(actions.size <= 1 || center) this.gravity = Gravity.CENTER; else this.gravity = Gravity.END; @@ -509,11 +510,13 @@ class UIDialogs { val text: String; val action: ()->Unit; 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.action = action; this.style = style; + this.center = center; } } enum class ActionStyle { diff --git a/app/src/main/java/com/futo/platformplayer/states/StateApp.kt b/app/src/main/java/com/futo/platformplayer/states/StateApp.kt index 6194bd6b..cea2c090 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StateApp.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StateApp.kt @@ -612,6 +612,20 @@ class StateApp { Settings.instance.didFirstStart = true; 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()) { try { StateBackup.startAutomaticBackup();