diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/FqrController.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/FqrController.java index ab42de623..192d9b98b 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/FqrController.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/FqrController.java @@ -20,8 +20,9 @@ * building them through a ContextThemeWrapper(Theme.K2Go) — a Material3.DayNight theme * carrying the app palette — without touching PortalActivity's global theme. Colors come * from theme attributes (colorSurface/onSurface/primary/error/…) so they follow light/dark; - * dialogs use MaterialAlertDialogBuilder, buttons MaterialButton, and the progress bars - * the Material progress indicators. All user-facing text lives in string resources. + * confirm/error dialogs use the shared BrandDialog (K2GO-385), buttons MaterialButton, and + * the progress bars the Material progress indicators. All user-facing text lives in string + * resources. * * ADFA-5062: in the operation model (ADR-5061) this FQR region fetch is * Operation.content("maps") — a CONTENT / LIVE operation. Unlike the banked ContentType @@ -55,11 +56,11 @@ import com.google.android.material.button.MaterialButton; import com.google.android.material.color.MaterialColors; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.progressindicator.CircularProgressIndicator; import com.google.android.material.progressindicator.LinearProgressIndicator; import org.appdevforall.k2go.R; +import org.appdevforall.k2go.ui.dialog.BrandDialog; import org.appdevforall.k2go.util.M3Text; import org.json.JSONArray; import org.json.JSONObject; @@ -81,6 +82,9 @@ public final class FqrController { // theme: build every view/dialog through this wrapper so ?attr colors + the app font resolve. private final Context themed; private final int cSurface, cSurfaceContainer, cSurfaceHighest, cOnSurface, cOnSurfaceVariant, cPrimary, cError; + // K2GO-385 (C1): state colours for the download bar -- amber = stopped (halted, not live), leaf = done. + // Fixed tokens (same in day/night), so a halted or finished job reads the same on either theme. + private final int cAmber, cLeaf; private volatile boolean active = false; // written on UI thread, read on the WebView binder thread private AlertDialog dialog; // "calculating" / consent (one at a time) @@ -132,6 +136,8 @@ public FqrController(Activity activity, WebView webView) { // Material3-specific surface roles above; read them from the appcompat namespace. this.cPrimary = attr(androidx.appcompat.R.attr.colorPrimary, 0xFF4CAF7D); this.cError = attr(androidx.appcompat.R.attr.colorError, 0xFFE05353); + this.cAmber = androidx.core.content.ContextCompat.getColor(themed, R.color.k2go_amber); + this.cLeaf = androidx.core.content.ContextCompat.getColor(themed, R.color.k2go_leaf); } private int attr(int attrId, int fallback) { @@ -235,11 +241,7 @@ private void handleExtract(String name, String box) { @Override public void onError(String message) { if (estimateCanceled) return; dismissDialog(); - new MaterialAlertDialogBuilder(themed) - .setTitle(R.string.k2go_fqr_estimate_error_title) - .setMessage(message) - .setPositiveButton(android.R.string.ok, null) - .show(); + errorDialog(R.string.k2go_fqr_estimate_error_title, message); } }); } @@ -270,7 +272,9 @@ private void resetMapSelection() { // ---- Consent ----------------------------------------------------------------------------- private void showCalculating() { dismissDialog(); - LinearLayout row = dialogContent(dp(24)); // ADFA-5027: M3 dialog inset (4dp grid) + // hpad 0: BrandDialog's content host already sits at the card's horizontal inset (double-inset + // otherwise). Vertical 8dp keeps the 4dp grid (ADFA-5027). + LinearLayout row = dialogContent(0, dp(8)); row.setOrientation(LinearLayout.HORIZONTAL); row.setGravity(Gravity.CENTER_VERTICAL); CircularProgressIndicator spin = new CircularProgressIndicator(themed); @@ -285,17 +289,18 @@ private void showCalculating() { row.addView(t); // ADFA-5043: canceling while estimating must drop the pending estimate AND clear the map's // selection — otherwise the crosshair lingers and a late estimate could still pop the consent. - dialog = new MaterialAlertDialogBuilder(themed) - .setView(row) + dialog = new BrandDialog(themed) + .setContentView(row) .setCancelable(true) - .setOnCancelListener(d -> { estimateCanceled = true; resetMapSelection(); }) - .show(); + .setOnCancel(() -> { estimateCanceled = true; resetMapSelection(); }) + .show() + .getDialog(); } private void showConsent(String name, String box, long transfer, long archive, long free, long freeAfter) { - // ADFA-5027: M3 dialog spacing — content aligned to the title (24dp) with 4dp-grid vertical - // breathing room, so it isn't cramped against the edges/title/buttons. - LinearLayout body = dialogContent(dp(24), dp(8)); + // ADFA-5027: 4dp-grid vertical breathing room. hpad 0: BrandDialog's content host already + // carries the card's horizontal inset (aligned to the title), so no inset is added here. + LinearLayout body = dialogContent(0, dp(8)); TextView sub = new TextView(themed); sub.setText(str(R.string.k2go_fqr_consent_sub, name, human(transfer), human(archive))); @@ -337,17 +342,18 @@ private void showConsent(String name, String box, long transfer, long archive, l body.addView(warn); } - dialog = new MaterialAlertDialogBuilder(themed) + // ADFA-5043: bailing out here (Not now / tap-outside) must also clear the map's FQR selection + // + tool -- the same reset the name dialog's Cancel does -- or the crosshair and the drawn area + // linger with a stale "download this region" button on top. + dialog = new BrandDialog(themed) .setTitle(R.string.k2go_fqr_consent_title) - .setView(body) - // ADFA-5043: bailing out here (Not now / tap-outside) must also clear the map's FQR - // selection + tool — the same reset the name dialog's Cancel does — or the crosshair and - // the drawn area linger with a stale "download this region" button on top. - .setNegativeButton(R.string.k2go_fqr_not_now, (d, w) -> { d.dismiss(); resetMapSelection(); }) - .setPositiveButton(R.string.k2go_fqr_download, (d, w) -> startDownload(name)) - .setOnCancelListener(d -> resetMapSelection()) + .setContentView(body) + .setPositive(R.string.k2go_fqr_download, () -> startDownload(name)) + .setNegative(R.string.k2go_fqr_not_now, () -> resetMapSelection()) + .setOnCancel(() -> resetMapSelection()) .setCancelable(true) - .show(); + .show() + .getDialog(); // Kick off the actual download only after consent; the box already re-validates. // (startDownload is invoked from the positive button above.) @@ -364,9 +370,10 @@ private void startDownload(String name) { showOverlay(name, pendingArchive); client.download(name, box, new MapsRegionClient.DownloadListener() { @Override public void onProgress(int percent, long speed) { - if (overlayStopped) { // retried/running again: back to Stop + if (overlayStopped) { // retried/running again: back to Stop, live teal bar overlayStopped = false; if (overlayStop != null) overlayStop.setText(R.string.k2go_clone_stop_confirm); + setBarState(cPrimary, true); } if (overlayStop != null) overlayStop.setEnabled(true); // re-enable after a Stop/Retry tap updateOverlay(percent, speed); @@ -381,8 +388,10 @@ private void startDownload(String name) { // #2: freeze the bar (determinate, no animation) so it doesn't keep animating under "Stopped". if (overlayBar != null && overlayBar.isIndeterminate()) setBarMode(false); if (overlayBar != null && percent >= 0) overlayBar.setProgressCompat(percent, false); + setBarState(cAmber, false); // amber + dimmed: a halted job must not look live } @Override public void onDone() { + setBarState(cLeaf, true); // done: a full leaf bar reads as success updateOverlay(100, 0); if (overlayTitle != null) overlayTitle.setText(R.string.k2go_fqr_region_added); // may be gone if hidden webView.postDelayed(() -> { hideOverlay(); webView.reload(); }, 1200); @@ -390,9 +399,7 @@ private void startDownload(String name) { @Override public void onError(String message) { hideOverlay(); if (!"canceled".equals(message)) { - new MaterialAlertDialogBuilder(themed) - .setTitle(R.string.k2go_fqr_download_failed).setMessage(message) - .setPositiveButton(android.R.string.ok, null).show(); + errorDialog(R.string.k2go_fqr_download_failed, message); } } }); @@ -443,15 +450,18 @@ private void showOverlay(String name, long sizeBytes) { // ADFA-4896: Stop/Retry beside Cancel. The label follows the reported state; the tap fires the // matching verb and the poll (onPaused/onProgress) is the source of truth. overlayStopped = false; - // K2GO-385 (PR3): the download controls use the app button system (K2Go outlined stadium) via the - // shared overlay, not a bare Material3 outlined button. FQR's overlay is a themed (day/night) - // surface, so the K2Go outlined style's theme teal is right here -- not the fixed boot tokens. - ContextThemeWrapper btnCtx = new ContextThemeWrapper(themed, R.style.ThemeOverlay_K2Go_Button_Outlined); - overlayStop = new MaterialButton(btnCtx, null); + // K2GO-385: download-controls role ladder (design k2go-download-card-style-sizes-v1) -- the + // keep-the-download primary (Stop/Retry) is the FILLED teal button; Cancel, which discards the + // transfer, is a TEXT button in clay. Never two equal outline pills. FQR's overlay is a themed + // (day/night) surface, so the app button styles' theme teal/clay are right here -- not the fixed + // boot tokens. The role look lives only in the styles; no colour is set in Java. + ContextThemeWrapper filledCtx = new ContextThemeWrapper(themed, R.style.ThemeOverlay_K2Go_Button_Filled); + overlayStop = new MaterialButton(filledCtx, null); overlayStop.setText(R.string.k2go_clone_stop_confirm); overlayStop.setOnClickListener(v -> toggleStop()); row.addView(overlayStop); - MaterialButton cancel = new MaterialButton(btnCtx, null); + ContextThemeWrapper textDangerCtx = new ContextThemeWrapper(themed, R.style.ThemeOverlay_K2Go_Button_Text_Destructive); + MaterialButton cancel = new MaterialButton(textDangerCtx, null); cancel.setText(R.string.k2go_cancel); cancel.setOnClickListener(v -> { client.cancel(); hideOverlay(); }); row.addView(cancel); @@ -509,6 +519,14 @@ private void setBarMode(boolean indeterminate) { overlayBar.setVisibility(vis == View.GONE ? View.VISIBLE : vis); } + /** K2GO-385 (C1): colour the download bar by state and dim it when the job is not live, so a stopped + * job never looks like a running one (teal = downloading, amber = stopped, leaf = done). */ + private void setBarState(int color, boolean live) { + if (overlayBar == null) return; + overlayBar.setIndicatorColor(color); + overlayBar.setAlpha(live ? 1f : 0.55f); + } + /** bytes/sec -> "2.4 MB/s". Empty for non-positive (speed not reported yet). */ private static String humanRate(long bps) { if (bps <= 0) return ""; @@ -674,11 +692,14 @@ private void flyTo(Region r) { } private void confirmDelete(String name) { - new MaterialAlertDialogBuilder(themed) + // K2GO-385: a destructive region delete uses the shared BrandDialog (clay outlined destructive + + // text Cancel), like the other from-scratch/erase confirms, instead of a flat MaterialAlertDialog + // with two equal text buttons. themed (not the host activity) carries Theme_K2Go, which the dialog + // frame needs -- PortalActivity's own theme is not K2Go. + new BrandDialog(themed) .setTitle(str(R.string.k2go_fqr_delete_confirm_title, name)) .setMessage(R.string.k2go_fqr_delete_confirm_msg) - .setNegativeButton(R.string.k2go_cancel, null) - .setPositiveButton(R.string.k2go_fqr_delete, (d, w) -> client.deleteRegion(name, new MapsRegionClient.DeleteListener() { + .setDestructive(R.string.k2go_fqr_delete, () -> client.deleteRegion(name, new MapsRegionClient.DeleteListener() { @Override public void onOk() { toast(str(R.string.k2go_fqr_deleted, name)); highlight = null; @@ -686,10 +707,10 @@ private void confirmDelete(String name) { refreshRegions(); // and the list drops it } @Override public void onError(String m) { - new MaterialAlertDialogBuilder(themed).setTitle(R.string.k2go_fqr_delete_failed).setMessage(m) - .setPositiveButton(android.R.string.ok, null).show(); + errorDialog(R.string.k2go_fqr_delete_failed, m); } })) + .setNegative(R.string.k2go_cancel, null) .show(); } @@ -712,7 +733,17 @@ private void closeDeleteSheetAndTool() { } // ---- helpers ----------------------------------------------------------------------------- - /** Padded, transparent container for MaterialAlertDialog setView (the dialog paints the surface). */ + /** K2GO-385: a single-button (OK) error dialog on the shared BrandDialog, so the three FQR error + * cases (estimate / download / delete) share one recipe. */ + private void errorDialog(int titleRes, CharSequence message) { + new BrandDialog(themed) + .setTitle(titleRes) + .setMessage(message) + .setPositive(android.R.string.ok, (BrandDialog.OnClick) null) + .show(); + } + + /** Padded, transparent container for the dialog body (BrandDialog paints the surface). */ private LinearLayout dialogContent(int pad) { return dialogContent(pad, pad); } /** Vertical content holder with horizontal/vertical insets (4dp grid). */ diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/LibraryActivity.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/LibraryActivity.java index 9d6852e6f..b5d19bcbe 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/LibraryActivity.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/LibraryActivity.java @@ -78,14 +78,6 @@ public class LibraryActivity extends AppCompatActivity implements ServerControll // ADFA-5119: the two controls that end the wait. One button, three labels; one confirmation. private View dlActions; private com.google.android.material.button.MaterialButton dlToggle, dlCancel; - /** - * The outlined button's own tint, remembered so the filled state can be undone. - * - *

Setting it to null does not mean "back to the default" — it means no tint at all, and a - * MaterialButton with no tint paints its shape opaque instead of transparent. That is how Pause - * came out as a black pill with dark text on it. - */ - private android.content.res.ColorStateList dlToggleTint; private android.widget.ProgressBar installBar; private boolean gateDismissed = false; private boolean closing = false; @@ -177,7 +169,6 @@ protected void onCreate(Bundle savedInstanceState) { dlActions = findViewById(R.id.k2go_dl_actions); dlToggle = findViewById(R.id.k2go_dl_toggle); dlCancel = findViewById(R.id.k2go_dl_cancel); - dlToggleTint = dlToggle.getBackgroundTintList(); // the outlined style's own value dlToggle.setOnClickListener(v -> onDownloadToggle()); dlCancel.setOnClickListener(v -> confirmCancelDownload()); // ADFA-4947: shared ellipsis animators (fixed-width so the centered lines don't shift). @@ -606,25 +597,16 @@ private void renderDownloadActions(InstallState st) { // thing that distinguishes "you stopped this" from "something stopped this". dlToggle.setText(st.isSoftFailed() ? R.string.k2go_dl_retry : st.isPaused() ? R.string.k2go_dl_resume : R.string.k2go_dl_pause); - // ADFA-5119: Material 3 says "this is the action now" with emphasis, not with movement — - // filled outranks tonal outranks outlined outranks text. During a download, Pause is a - // secondary offer beside a transfer doing fine, so it stays outlined. Once the download has - // stopped on its own, Retry IS the primary action and takes the filled treatment. + // K2GO-385: the toggle is the FILLED primary in every state (Pause / Resume / Retry), matching + // the FQR download card and the download-card design ladder (k2go-library-download-sizes-v1: + // "primary = filled, secondary = text in clay"). The colour lives entirely in the filled boot + // style (Widget.K2Go.Button.OnBootPaper, fixed k2go_boot_accent teal so it does not flip pale at + // night on this fixed paper), so no per-state tint is set in code -- only the label changes. // - // Deliberately not an attention animation. A pulsing button says "hurry", and the moment the - // user reaches for it the hurry is gone — the first touch cancels the window and the state - // then waits as long as they like. It would be pressuring someone we have just given - // unlimited time, which is the same reason nothing draws a countdown. - boolean primary = st.isSoftFailed(); - // Brand teal, not ink: a filled primary action is the same gesture the wizard's "Internet - // download" makes, and it should look like the same app. k2go_boot_accent rather than - // k2go_teal because that one flips to a pale turquoise at night and this paper does not. - dlToggle.setBackgroundTintList(primary - ? android.content.res.ColorStateList.valueOf( - androidx.core.content.ContextCompat.getColor(this, R.color.k2go_boot_accent)) - : dlToggleTint); - dlToggle.setTextColor(androidx.core.content.ContextCompat.getColor(this, - primary ? R.color.k2go_boot_bg : R.color.k2go_boot_ink)); + // This intentionally REMOVES the ADFA-5119 emphasis rule (Pause / Resume stayed outlined and + // only Retry took the filled treatment). K2GO-385 homogenizes the two download surfaces (library + // and FQR) onto one ladder, so the primary action is filled in every state. Homogenization of the + // content wins over the earlier per-state emphasis; that ADFA-5119 behavior is deliberately gone. // Both controls, always. A first pass hid Pause during the IPv4/IPv6 probe on the assumption // that the probe carries no rate — the device showed otherwise: it reports "Test IPv6" in // the rate slot, so the guard never fired. Dropped rather than repaired, because what it was @@ -968,33 +950,32 @@ private void evaluateRecovery() { * Both paths work without a healthy rootfs. Blocking, non-cancelable; "Close" still exits. */ private void showDamagedDialog() { if (isFinishing()) return; - androidx.appcompat.app.AlertDialog d = new androidx.appcompat.app.AlertDialog.Builder(this) - .setCancelable(false) + // K2GO-385: the interrupted/damaged error uses the shared BrandDialog, like the other confirms + // (design k2go-install-interrupted-dialog). A clay error icon carries the state (the title stays + // ink); Recover is the filled primary; Close the text secondary; "Report the problem" a quiet + // muted tertiary. Non-cancelable: the user must pick recover or close. + // + // ADFA-5119: report it from here, where the user is standing when it matters. The app knows what + // happened and they do not, so the description is filled from the install log. The screenshot the + // report captures is this dialog, which is the right picture (routing is ADFA-5130's: email keeps + // the attachment, Slack gets the text). setDismissOnNeutral(false) keeps the dialog up so the two + // real choices -- recover, or close -- are still there after reporting. + new org.appdevforall.k2go.ui.dialog.BrandDialog(this) + .setIcon(R.drawable.ic_error_outline_24, R.color.k2go_clay) .setTitle(R.string.k2go_damaged_title) .setMessage(R.string.k2go_damaged_body) - .setPositiveButton(R.string.k2go_damaged_recover, (dlg, w) -> { + .setPositive(R.string.k2go_damaged_recover, () -> { SetupLibraryActivity.recover(this); // ADFA-5150: the shared route finish(); // the dialog closes so the user can't fall back onto the held gate }) - // ADFA-5119: report it from here, where the user is standing when it matters. The app - // knows what happened and they do not, so the description is filled from the install - // log rather than left as a blank box in front of someone who just watched a download - // give up. The screenshot the report captures is this dialog, which is the right - // picture. Routing is ADFA-5130's, so email keeps the attachment and Slack gets the - // text. - .setNeutralButton(R.string.k2go_damaged_report, null) - .setNegativeButton(R.string.k2go_damaged_close, (dlg, w) -> finishAffinity()) - .create(); - // Attached after show() so the neutral button does NOT dismiss: reporting is not a decision - // about the system, and the two that are — recover, or close — must still be there - // afterwards. A dialog that vanished on "Report" would leave the user behind a closed gate - // with nothing to press. - d.setOnShowListener(dlg -> d.getButton(androidx.appcompat.app.AlertDialog.BUTTON_NEUTRAL) - .setOnClickListener(v -> org.appdevforall.k2go.feedback.presentation.FeedbackFab + .setNegative(R.string.k2go_damaged_close, () -> finishAffinity()) + .setNeutral(R.string.k2go_damaged_report, () -> org.appdevforall.k2go.feedback.presentation.FeedbackFab .sendFeedback(this, "install-failed", org.appdevforall.k2go.feedback.domain.FeedbackType.BUG, - installFailureReport()))); - d.show(); + installFailureReport())) + .setDismissOnNeutral(false) + .setCancelable(false) + .show(); } /** diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/MapsChooseFragment.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/MapsChooseFragment.java index 8d7b0b8cb..c34454f5a 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/MapsChooseFragment.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/MapsChooseFragment.java @@ -200,24 +200,35 @@ private void buildGroups(LinearLayout host) { pillViews[gi] = new LinearLayout[g.opts.length]; for (int oi = 0; oi < g.opts.length; oi++) { final int gg = gi, oo = oi; + // K2GO-385 (01): selectable option card -- a leading radio + a label/size column. + // Single-select is marked by the radio + a tonal fill (applyGroupSelection), NOT a check + // and NOT a solid teal pill (design k2go-component-roles-decisions Q1/Q2). LinearLayout pill = new LinearLayout(requireContext()); - pill.setOrientation(LinearLayout.VERTICAL); - pill.setGravity(Gravity.CENTER); - pill.setPadding(px(14), px(8), px(14), px(8)); + pill.setOrientation(LinearLayout.HORIZONTAL); + pill.setGravity(Gravity.CENTER_VERTICAL); + pill.setPadding(px(12), px(8), px(14), px(8)); pill.setClickable(true); pill.setFocusable(true); + ImageView radio = new ImageView(requireContext()); + LinearLayout.LayoutParams radLp = new LinearLayout.LayoutParams(px(18), px(18)); + radLp.rightMargin = px(8); + pill.addView(radio, radLp); + + LinearLayout col = new LinearLayout(requireContext()); + col.setOrientation(LinearLayout.VERTICAL); + TextView plabel = new TextView(requireContext()); plabel.setText(getString(g.opts[oi].label)); - plabel.setGravity(Gravity.CENTER); plabel.setTextAppearance(com.google.android.material.R.style.TextAppearance_Material3_BodyMedium); - pill.addView(plabel); + col.addView(plabel); TextView psize = new TextView(requireContext()); psize.setText(g.opts[oi].mb > 0 ? fmt(g.opts[oi].mb) : "—"); - psize.setGravity(Gravity.CENTER); psize.setTextAppearance(com.google.android.material.R.style.TextAppearance_Material3_BodySmall); - pill.addView(psize); + col.addView(psize); + + pill.addView(col); pill.setOnClickListener(v -> selectOpt(gg, oo)); pill.setMinimumWidth(px(64)); @@ -240,11 +251,19 @@ private void applyGroupSelection(int gi, int selOi) { for (int oi = 0; oi < pillViews[gi].length; oi++) { LinearLayout pill = pillViews[gi][oi]; boolean sel = oi == selOi; - pill.setBackgroundResource(sel ? R.drawable.k2go_chip_bg : R.drawable.k2go_pill_bg); - int labelColor = sel ? android.R.color.white : R.color.k2go_ink; - int sizeColor = sel ? android.R.color.white : R.color.k2go_muted; - ((TextView) pill.getChildAt(0)).setTextColor(ContextCompat.getColor(requireContext(), labelColor)); - ((TextView) pill.getChildAt(1)).setTextColor(ContextCompat.getColor(requireContext(), sizeColor)); + // Selected = tonal fill + a filled radio; unselected = outline + an empty radio. No check + // (single-select). Text stays readable on the tonal fill -- teal, not white on solid teal. + pill.setBackgroundResource(sel ? R.drawable.k2go_pill_tonal : R.drawable.k2go_pill_bg); + ImageView radio = (ImageView) pill.getChildAt(0); + radio.setImageResource(sel ? R.drawable.ic_radio_on : R.drawable.ic_radio_off); + // The radio drawables carry fixed teal/gray, unreadable on the night surface; tint with the + // day/night tokens so the ring reads in both themes. + radio.setColorFilter(ContextCompat.getColor(requireContext(), sel ? R.color.k2go_teal : R.color.k2go_muted)); + LinearLayout col = (LinearLayout) pill.getChildAt(1); + int labelColor = sel ? R.color.k2go_teal : R.color.k2go_ink; + int sizeColor = sel ? R.color.k2go_teal : R.color.k2go_muted; + ((TextView) col.getChildAt(0)).setTextColor(ContextCompat.getColor(requireContext(), labelColor)); + ((TextView) col.getChildAt(1)).setTextColor(ContextCompat.getColor(requireContext(), sizeColor)); } groupSizeViews[gi].setText(selectedMb[gi] > 0 ? fmt(selectedMb[gi]) : "—"); } diff --git a/controller/app/src/main/java/org/appdevforall/k2go/ui/dialog/BrandDialog.java b/controller/app/src/main/java/org/appdevforall/k2go/ui/dialog/BrandDialog.java index d7ab50177..ac8c585a3 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/ui/dialog/BrandDialog.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/ui/dialog/BrandDialog.java @@ -7,9 +7,12 @@ import android.view.View; import android.widget.Button; import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.ColorRes; +import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; @@ -78,7 +81,11 @@ public void setContent(@NonNull View view) { private CharSequence neutralText; private OnClick neutralClick; private boolean cancelable = true; + private OnClick cancelClick; private boolean dismissOnPositive = true; + private boolean dismissOnNeutral = true; + private int iconRes; // 0 = no leading title icon + private int iconTintRes; // 0 = no tint private OnConfirm positiveConfirm; private CharSequence checkboxLabel; private boolean checkboxChecked; @@ -215,11 +222,33 @@ public BrandDialog setCancelable(boolean cancelable) { return this; } + /** Called when the dialog is canceled (back button or tap-outside), not when a button dismisses it. + * Lets a caller react to a bail-out without reaching into the underlying dialog. */ + public BrandDialog setOnCancel(@Nullable OnClick cancelClick) { + this.cancelClick = cancelClick; + return this; + } + public BrandDialog setDismissOnPositive(boolean dismissOnPositive) { this.dismissOnPositive = dismissOnPositive; return this; } + /** Keep the dialog open when the neutral (tertiary) button is tapped -- e.g. "Report the problem", + * which sends feedback but must leave the two real choices (recover / close) on screen. */ + public BrandDialog setDismissOnNeutral(boolean dismissOnNeutral) { + this.dismissOnNeutral = dismissOnNeutral; + return this; + } + + /** Optional leading state icon beside the title (e.g. a clay error icon). tintRes 0 leaves the + * drawable's own colour. */ + public BrandDialog setIcon(@DrawableRes int iconRes, @ColorRes int tintRes) { + this.iconRes = iconRes; + this.iconTintRes = tintRes; + return this; + } + public Handle create() { View root = LayoutInflater.from(context).inflate(R.layout.dialog_brand, null, false); TextView titleView = root.findViewById(R.id.brand_dialog_title); @@ -229,6 +258,14 @@ public Handle create() { Button neutral = root.findViewById(R.id.brand_dialog_neutral); Button negative = root.findViewById(R.id.brand_dialog_negative); + ImageView iconView = root.findViewById(R.id.brand_dialog_icon); + if (iconRes != 0) { + iconView.setImageResource(iconRes); + if (iconTintRes != 0) { + iconView.setColorFilter(ContextCompat.getColor(context, iconTintRes)); + } + iconView.setVisibility(View.VISIBLE); + } if (title != null) { titleView.setText(title); titleView.setVisibility(View.VISIBLE); @@ -285,6 +322,9 @@ public Handle create() { .setView(root) .setCancelable(cancelable) .create(); + if (cancelClick != null) { + dialog.setOnCancelListener(d -> cancelClick.onClick()); + } if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); } @@ -331,10 +371,12 @@ public Handle create() { neutral.setText(neutralText); neutral.setVisibility(View.VISIBLE); neutral.setOnClickListener(v -> { - dialog.dismiss(); if (neutralClick != null) { neutralClick.onClick(); } + if (dismissOnNeutral) { + dialog.dismiss(); + } }); } if (negativeText != null) { diff --git a/controller/app/src/main/res/drawable/ic_error_outline_24.xml b/controller/app/src/main/res/drawable/ic_error_outline_24.xml new file mode 100644 index 000000000..c90c04847 --- /dev/null +++ b/controller/app/src/main/res/drawable/ic_error_outline_24.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/controller/app/src/main/res/drawable/k2go_chip_bg.xml b/controller/app/src/main/res/drawable/k2go_chip_bg.xml deleted file mode 100644 index 71a3cf304..000000000 --- a/controller/app/src/main/res/drawable/k2go_chip_bg.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/controller/app/src/main/res/drawable/k2go_pill_tonal.xml b/controller/app/src/main/res/drawable/k2go_pill_tonal.xml new file mode 100644 index 000000000..b592f5069 --- /dev/null +++ b/controller/app/src/main/res/drawable/k2go_pill_tonal.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/controller/app/src/main/res/layout/activity_library.xml b/controller/app/src/main/res/layout/activity_library.xml index a165bc0b7..d068d6525 100644 --- a/controller/app/src/main/res/layout/activity_library.xml +++ b/controller/app/src/main/res/layout/activity_library.xml @@ -89,12 +89,16 @@ android:textAppearance="?attr/textAppearanceBodyMedium" android:textColor="@color/k2go_boot_ink" /> + @@ -201,13 +205,13 @@ android:visibility="gone"> @@ -15,14 +15,32 @@ android:orientation="vertical" android:padding="20dp"> - + + android:orientation="horizontal" + android:gravity="center_vertical"> + + + + + + + android:textColor="@color/k2go_muted" /> + android:textColor="@color/k2go_muted" /> + android:textColor="@color/k2go_amber" /> @@ -359,10 +359,10 @@ android:paddingRight="12dp" android:paddingTop="5dp" android:paddingBottom="5dp" - android:background="@drawable/k2go_pill_amber" + android:background="@drawable/k2go_pill_bg" android:text="@string/k2go_maps_rebuild_pill_heavy" android:textAppearance="?attr/textAppearanceBodySmall" - android:textColor="@color/k2go_amber" /> + android:textColor="@color/k2go_muted" /> + android:textColor="@color/k2go_leaf" /> diff --git a/controller/app/src/main/res/values-night/colors_k2go.xml b/controller/app/src/main/res/values-night/colors_k2go.xml index 99f16a0ac..a27978e92 100644 --- a/controller/app/src/main/res/values-night/colors_k2go.xml +++ b/controller/app/src/main/res/values-night/colors_k2go.xml @@ -4,6 +4,8 @@ #0F1A19 #17302E #4FB3BA + + #1E3A33 #2E9E5B #F2A23C #F2A23C diff --git a/controller/app/src/main/res/values/colors_k2go.xml b/controller/app/src/main/res/values/colors_k2go.xml index 63f5cdf0a..0f25e3def 100644 --- a/controller/app/src/main/res/values/colors_k2go.xml +++ b/controller/app/src/main/res/values/colors_k2go.xml @@ -23,6 +23,9 @@ #D9D4C8 #EFEBE2 #0E5C63 + + #DCE9E5 #2E9E5B #F2A23C #B0740F diff --git a/controller/app/src/main/res/values/themes_k2go.xml b/controller/app/src/main/res/values/themes_k2go.xml index 537e81bb0..3c862f291 100644 --- a/controller/app/src/main/res/values/themes_k2go.xml +++ b/controller/app/src/main/res/values/themes_k2go.xml @@ -89,6 +89,19 @@ @color/k2go_teal + + + + + + + + + +