Skip to content

Commit 7fb3219

Browse files
Merge pull request #549 from appdevforall/refactor/K2GO-385-remaining-dialogs
K2GO-385 refactor(ui): remaining confirm dialogs and single-choice picker roles
2 parents 3b75ed6 + 1463844 commit 7fb3219

7 files changed

Lines changed: 54 additions & 17 deletions

File tree

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/BackupRestoreFragment.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,16 @@ private View hairline() {
207207

208208
/** ADFA-5023: strong confirm before a from-scratch reinstall (wipes everything), then the wizard. */
209209
private void confirmReinstall() {
210-
new com.google.android.material.dialog.MaterialAlertDialogBuilder(requireContext())
210+
// K2GO-385: destructive from-scratch reinstall confirm -> the shared BrandDialog (clay destructive).
211+
new org.appdevforall.k2go.ui.dialog.BrandDialog(requireContext())
211212
.setTitle(R.string.k2go_reinstall_confirm_title)
212213
.setMessage(R.string.k2go_reinstall_confirm_msg)
213-
.setNegativeButton(android.R.string.cancel, null)
214-
.setPositiveButton(R.string.k2go_reinstall_confirm_yes, (d, w) -> {
214+
.setDestructive(R.string.k2go_reinstall_confirm_yes, () -> {
215215
if (getActivity() instanceof SetupLibraryActivity) {
216216
((SetupLibraryActivity) getActivity()).openReinstallWizard();
217217
}
218218
})
219+
.setNegative(android.R.string.cancel, null)
219220
.show();
220221
}
221222

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/LibraryActivity.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,13 +728,14 @@ private void onDownloadToggle() {
728728
* second copy of it here would be a second place formatting the same fact.
729729
*/
730730
private void confirmCancelDownload() {
731-
new com.google.android.material.dialog.MaterialAlertDialogBuilder(this)
731+
// K2GO-385: cancel-the-download confirm -> the shared BrandDialog (destructive: it stops + starts over).
732+
new org.appdevforall.k2go.ui.dialog.BrandDialog(this)
732733
.setTitle(R.string.k2go_dl_cancel_title)
733734
.setMessage(R.string.k2go_dl_cancel_body)
734-
.setNegativeButton(R.string.k2go_dl_cancel_keep, null)
735-
.setPositiveButton(R.string.k2go_dl_cancel_confirm, (d, w) ->
735+
.setDestructive(R.string.k2go_dl_cancel_confirm, () ->
736736
sendToInstallService(
737737
org.appdevforall.k2go.install.presentation.InstallService.ACTION_CANCEL))
738+
.setNegative(R.string.k2go_dl_cancel_keep, null)
738739
.show();
739740
}
740741

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/SettingsFragment.java‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import android.widget.TextView;
1212
import androidx.annotation.NonNull;
1313
import androidx.annotation.Nullable;
14-
import androidx.appcompat.app.AlertDialog;
1514
import androidx.appcompat.app.AppCompatDelegate;
1615
import androidx.core.content.ContextCompat;
1716
import androidx.fragment.app.Fragment;
@@ -107,11 +106,17 @@ private void chooseTheme() {
107106
AppCompatDelegate.MODE_NIGHT_NO,
108107
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM,
109108
AppCompatDelegate.MODE_NIGHT_YES};
110-
new AlertDialog.Builder(requireContext())
109+
int cur = prefs().getInt("k2go_theme", AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
110+
int checked = cur == AppCompatDelegate.MODE_NIGHT_NO ? 0 : (cur == AppCompatDelegate.MODE_NIGHT_YES ? 2 : 1);
111+
// K2GO-385 (pill roles Q3): a single-choice list picker -- a themed M3 dialog with a leading
112+
// filled radio on the current theme, not a bare setItems list. Tap applies and closes, as before.
113+
new com.google.android.material.dialog.MaterialAlertDialogBuilder(
114+
new android.view.ContextThemeWrapper(requireContext(), R.style.Theme_K2Go))
111115
.setTitle(getString(R.string.k2go_settings_theme))
112-
.setItems(labels, (d, w) -> {
116+
.setSingleChoiceItems(labels, checked, (d, w) -> {
113117
prefs().edit().putInt("k2go_theme", modes[w]).apply();
114118
AppCompatDelegate.setDefaultNightMode(modes[w]);
119+
d.dismiss();
115120
})
116121
.show();
117122
}
@@ -143,15 +148,16 @@ private void buildFooter(Context ctx, LinearLayout footer) {
143148
}
144149

145150
private void confirmTurnOff() {
146-
new AlertDialog.Builder(requireContext())
147-
.setTitle(getString(R.string.k2go_settings_turnoff_title))
148-
.setMessage(getString(R.string.k2go_settings_turnoff_msg))
149-
.setNegativeButton(getString(R.string.k2go_cancel), null)
150-
.setPositiveButton(getString(R.string.k2go_settings_turnoff_confirm), (d, w) -> {
151+
// K2GO-385: turn-off confirm -> the shared BrandDialog (destructive, matching the clay "Turn off" button).
152+
new org.appdevforall.k2go.ui.dialog.BrandDialog(requireContext())
153+
.setTitle(R.string.k2go_settings_turnoff_title)
154+
.setMessage(R.string.k2go_settings_turnoff_msg)
155+
.setDestructive(R.string.k2go_settings_turnoff_confirm, () -> {
151156
if (getActivity() instanceof LibraryActivity) {
152157
((LibraryActivity) getActivity()).turnOffK2Go();
153158
}
154159
})
160+
.setNegative(R.string.k2go_cancel, null)
155161
.show();
156162
}
157163

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/SetupProgressActivity.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,13 +1389,14 @@ private void configureDetailBar() {
13891389
* flag and marks the module failed; the base system is untouched and the server restarts.
13901390
*/
13911391
private void confirmCancelModule() {
1392-
new com.google.android.material.dialog.MaterialAlertDialogBuilder(this)
1392+
// K2GO-385: cancel-running-install confirm -> the shared BrandDialog (destructive).
1393+
new org.appdevforall.k2go.ui.dialog.BrandDialog(this)
13931394
.setTitle(R.string.k2go_mod_cancel_title)
13941395
.setMessage(R.string.k2go_mod_cancel_body)
1395-
.setNegativeButton(R.string.k2go_mod_cancel_dismiss, null)
1396-
.setPositiveButton(R.string.k2go_mod_cancel_confirm, (d, w) ->
1396+
.setDestructive(R.string.k2go_mod_cancel_confirm, () ->
13971397
startService(new android.content.Intent(this, org.appdevforall.k2go.install.presentation.InstallService.class)
13981398
.setAction(org.appdevforall.k2go.install.presentation.InstallService.ACTION_CANCEL)))
1399+
.setNegative(R.string.k2go_mod_cancel_dismiss, null)
13991400
.show();
14001401
}
14011402

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- K2GO-385: Material "language" (globe), tinted by the caller (drawableTint teal on the selector). -->
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="24dp" android:height="24dp"
4+
android:viewportWidth="24" android:viewportHeight="24">
5+
<path android:fillColor="@android:color/white"
6+
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12 22,6.48 17.52,2 11.99,2zM18.92,8h-2.95c-0.32,-1.25 -0.78,-2.45 -1.38,-3.56 1.84,0.63 3.37,1.9 4.33,3.56zM12,4.04c0.83,1.2 1.48,2.53 1.91,3.96h-3.82c0.43,-1.43 1.08,-2.76 1.91,-3.96zM4.26,14C4.1,13.36 4,12.69 4,12s0.1,-1.36 0.26,-2h3.38c-0.08,0.66 -0.14,1.32 -0.14,2 0,0.68 0.06,1.34 0.14,2H4.26zM5.08,16h2.95c0.32,1.25 0.78,2.45 1.38,3.56 -1.84,-0.63 -3.37,-1.9 -4.33,-3.56zM8.03,8H5.08c0.96,-1.65 2.49,-2.93 4.33,-3.56C8.81,5.55 8.35,6.75 8.03,8zM12,19.96c-0.83,-1.2 -1.48,-2.53 -1.91,-3.96h3.82c-0.43,1.43 -1.08,2.76 -1.91,3.96zM14.34,14H9.66c-0.09,-0.66 -0.16,-1.32 -0.16,-2 0,-0.68 0.07,-1.35 0.16,-2h4.68c0.09,0.65 0.16,1.32 0.16,2 0,0.68 -0.07,1.34 -0.16,2zM14.36,19.56c0.6,-1.11 1.06,-2.31 1.38,-3.56h2.95c-0.96,1.65 -2.49,2.93 -4.33,3.56zM16.36,14c0.08,-0.66 0.14,-1.32 0.14,-2 0,-0.68 -0.06,-1.34 -0.14,-2h3.38c0.16,0.64 0.26,1.31 0.26,2s-0.1,1.36 -0.26,2h-3.38z"/>
7+
</vector>

‎controller/app/src/main/res/layout/fragment_k2go_books_landing.xml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
android:textColor="@color/k2go_ink"
4747
android:textColorHint="@color/k2go_muted" />
4848

49+
<!-- K2GO-385 (pill roles Q3B): the language selector is a dropdown / menu button, not a filter
50+
chip. A leading globe and a trailing caret frame the current value, and a tap opens the
51+
single-choice picker; no check or selected-fill (that is the chip language). -->
4952
<TextView
5053
android:id="@+id/k2go_books_lang"
5154
android:layout_width="wrap_content"
@@ -56,6 +59,11 @@
5659
android:paddingTop="8dp"
5760
android:paddingBottom="8dp"
5861
android:background="@drawable/k2go_pill_bg"
62+
android:drawableStart="@drawable/ic_language"
63+
android:drawableEnd="@drawable/ic_expand_more"
64+
android:drawableTint="@color/k2go_teal"
65+
android:drawablePadding="6dp"
66+
android:gravity="center_vertical"
5967
android:textAppearance="?attr/textAppearanceBodySmall"
6068
android:textColor="@color/k2go_ink" />
6169

‎controller/app/src/main/res/values/themes_k2go.xml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@
1010
<item name="android:windowBackground">@color/k2go_paper</item>
1111
<item name="colorSurface">@color/k2go_paper</item>
1212
<item name="colorSurfaceContainer">@color/k2go_surface</item>
13+
<!-- K2GO-385: define the full surface-container ladder so M3 dialogs and menus take a K2Go
14+
surface, not the Material3 baseline lilac. A themed MaterialAlertDialog (e.g. the theme
15+
picker) reads colorSurfaceContainerHigh for its card. The tokens carry their own -night
16+
twins, so DayNight is handled. -->
17+
<item name="colorSurfaceContainerLowest">@color/k2go_paper</item>
18+
<item name="colorSurfaceContainerLow">@color/k2go_paper</item>
19+
<item name="colorSurfaceContainerHigh">@color/k2go_surface</item>
20+
<item name="colorSurfaceContainerHighest">@color/k2go_surface</item>
21+
<!-- K2GO-385: interactive controls (the single-choice radio in the theme picker, checkboxes,
22+
switches) take K2Go teal, not the Material3 / dynamic default (which read purple). The
23+
android-namespace attr is the one the platform radio in setSingleChoiceItems uses. -->
24+
<item name="colorControlActivated">@color/k2go_teal</item>
25+
<item name="android:colorControlActivated">@color/k2go_teal</item>
1326
<item name="colorOnBackground">@color/k2go_ink</item>
1427
<item name="colorOnSurface">@color/k2go_ink</item>
1528
<item name="colorOnSurfaceVariant">@color/k2go_muted</item>

0 commit comments

Comments
 (0)