From 71cbf9d23486e6016852c584f5000c69b8a7bbe6 Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Tue, 21 Jul 2026 12:50:09 -0600 Subject: [PATCH 1/3] ADFA-4790: Receive confirm size breakdown + compact QR keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Receive CONFIRM keeps the backend's localized title/message and appends a System/Content split (sizes travel in the QR) plus the replace warning, both via string resources in strings_k2go.xml (translatable=false, picked up by the redesign l10n pass) — no hardcoded English, so it follows the device language like the rest of the redesign UI. - Payload size keys shortened to sb / cb (lighter QR). Cross-version: an older QR (long keys) parses with sizes = 0 (split hidden); the transfer itself is unaffected. --- .../iiab/controller/SyncHandshakeHelper.java | 8 +++---- .../controller/redesign/CloneFragment.java | 21 ++++++++++++++----- .../app/src/main/res/values/strings_k2go.xml | 2 ++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/controller/app/src/main/java/org/iiab/controller/SyncHandshakeHelper.java b/controller/app/src/main/java/org/iiab/controller/SyncHandshakeHelper.java index 49e96811..29093ebf 100644 --- a/controller/app/src/main/java/org/iiab/controller/SyncHandshakeHelper.java +++ b/controller/app/src/main/java/org/iiab/controller/SyncHandshakeHelper.java @@ -69,8 +69,8 @@ public static String createPayload(String ip, int port, String user, String pass json.put("has_rootfs", hasRootfs); json.put("a", archBits); json.put("app", "iiab_sync"); - if (sysBytes > 0) json.put("sys_bytes", sysBytes); - if (contentBytes > 0) json.put("content_bytes", contentBytes); + if (sysBytes > 0) json.put("sb", sysBytes); // ADFA-4790: compact keys keep the QR light + if (contentBytes > 0) json.put("cb", contentBytes); return json.toString(); } catch (Exception e) { Log.e(TAG, "Error creating JSON payload", e); @@ -108,8 +108,8 @@ public static SyncCredentials parsePayload(String scannedJson) { json.optBoolean("has_rootfs", true), // Default to true if missing for legacy compatibility json.optInt("a", 0) ); - creds.sysBytes = json.optLong("sys_bytes", 0L); // ADFA-4780 (optional) - creds.contentBytes = json.optLong("content_bytes", 0L); + creds.sysBytes = json.optLong("sb", 0L); // ADFA-4790: compact payload keys + creds.contentBytes = json.optLong("cb", 0L); return creds; } catch (Exception e) { Log.e(TAG, "Error parsing scanned QR code", e); diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java index ad8c951f..ea1e5e5d 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java @@ -551,11 +551,22 @@ private void renderReceive() { SyncTransferState.Phase ph = st.phase; if (ph == SyncTransferState.Phase.CONFIRM) { progressBox.setVisibility(View.GONE); - confirmTitle.setText((st.title != null && !st.title.isEmpty()) ? st.title : "Copy the library?"); - String m = (st.message != null) ? st.message : ""; - if (!m.isEmpty()) m += "\n\n"; - m += "This replaces the library on this phone with the sender's copy."; - confirmMsg.setText(m); + // ADFA-4790: keep the backend's localized title + message, then append a localized + // System/Content split (sizes travel in the QR) and a localized replace warning — all + // via string resources, so the confirm follows the device language (no hardcoded English). + confirmTitle.setText((st.title != null && !st.title.isEmpty()) + ? st.title : getString(R.string.sync_title_install)); + StringBuilder m = new StringBuilder(); + if (st.message != null && !st.message.isEmpty()) m.append(st.message); + SyncHandshakeHelper.SyncCredentials pc = syncVm.getPendingCreds(); + if (pc != null && (pc.sysBytes > 0 || pc.contentBytes > 0)) { + if (m.length() > 0) m.append('\n'); + m.append(getString(R.string.k2go_clone_confirm_split, + LibrarySize.human(pc.sysBytes), LibrarySize.human(pc.contentBytes))); + } + if (m.length() > 0) m.append("\n\n"); + m.append(getString(R.string.k2go_clone_confirm_replace)); + confirmMsg.setText(m.toString()); confirmPanel.setVisibility(View.VISIBLE); return; } diff --git a/controller/app/src/main/res/values/strings_k2go.xml b/controller/app/src/main/res/values/strings_k2go.xml index 72509441..04821815 100644 --- a/controller/app/src/main/res/values/strings_k2go.xml +++ b/controller/app/src/main/res/values/strings_k2go.xml @@ -54,6 +54,8 @@ They\'re connected — show next › Total copy WHAT THEY\'LL RECEIVE + System %1$s · Content %2$s + This replaces the library on this phone with the sender\'s copy. No undo. Wi-Fi Wikipedia (via Kiwix) With pictures From d913cf84d995574093d48f132500ecb242767aff Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Tue, 21 Jul 2026 13:10:47 -0600 Subject: [PATCH 2/3] ADFA-4790: render the Receive confirm as a System/Content/Total table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Match the design mockup: the confirm now shows a 'FROM THE OTHER PHONE' card with System / Content / (divider) / Total rows, the pink replace notice, and full-width Continue / Cancel — instead of a single run-on text line. Sizes come from the QR (getPendingCreds); the table hides if the sender didn't send sizes. Mirrors the Send 'SHARING NOW' card styling. --- .../controller/redesign/CloneFragment.java | 36 +++++------ .../main/res/layout/fragment_k2go_clone.xml | 60 +++++++++++++++---- .../app/src/main/res/values/strings_k2go.xml | 2 - 3 files changed, 66 insertions(+), 32 deletions(-) diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java index ea1e5e5d..ea70e19c 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java @@ -84,8 +84,8 @@ private enum Stage { JOIN, START } private TextView receiveStart, pStatus, pFile, pStats, cancel; private ProgressBar pbar; private long lastSeq = -1L; - private LinearLayout confirmPanel; - private TextView confirmTitle, confirmMsg; + private LinearLayout confirmPanel, confirmSizes; + private TextView confirmSys, confirmContent, confirmTotal; private enum RStage { JOIN, START } private RStage rStage = RStage.JOIN; private boolean pasteExpanded = false; @@ -166,8 +166,10 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c pStats = v.findViewById(R.id.k2go_clone_pstats); cancel = v.findViewById(R.id.k2go_clone_cancel); confirmPanel = v.findViewById(R.id.k2go_rcv_confirm); - confirmTitle = v.findViewById(R.id.k2go_rcv_confirm_title); - confirmMsg = v.findViewById(R.id.k2go_rcv_confirm_msg); + confirmSizes = v.findViewById(R.id.k2go_rcv_confirm_sizes); + confirmSys = v.findViewById(R.id.k2go_rcv_confirm_sys); + confirmContent = v.findViewById(R.id.k2go_rcv_confirm_content); + confirmTotal = v.findViewById(R.id.k2go_rcv_confirm_total); v.findViewById(R.id.k2go_rcv_confirm_go).setOnClickListener(x -> startReceiveTransfer()); v.findViewById(R.id.k2go_rcv_confirm_cancel).setOnClickListener(x -> { syncVm.cancelProbe(); renderReceive(); }); showcode = v.findViewById(R.id.k2go_clone_showcode); @@ -551,22 +553,20 @@ private void renderReceive() { SyncTransferState.Phase ph = st.phase; if (ph == SyncTransferState.Phase.CONFIRM) { progressBox.setVisibility(View.GONE); - // ADFA-4790: keep the backend's localized title + message, then append a localized - // System/Content split (sizes travel in the QR) and a localized replace warning — all - // via string resources, so the confirm follows the device language (no hardcoded English). - confirmTitle.setText((st.title != null && !st.title.isEmpty()) - ? st.title : getString(R.string.sync_title_install)); - StringBuilder m = new StringBuilder(); - if (st.message != null && !st.message.isEmpty()) m.append(st.message); + // ADFA-4790: confirm as a System/Content/Total table (sizes travel in the QR) per the + // design mockup; the replace notice is static in the layout. If the sender didn't send + // sizes (older build), hide the table and just show the notice. SyncHandshakeHelper.SyncCredentials pc = syncVm.getPendingCreds(); - if (pc != null && (pc.sysBytes > 0 || pc.contentBytes > 0)) { - if (m.length() > 0) m.append('\n'); - m.append(getString(R.string.k2go_clone_confirm_split, - LibrarySize.human(pc.sysBytes), LibrarySize.human(pc.contentBytes))); + long sysB = (pc != null) ? pc.sysBytes : 0L; + long contentB = (pc != null) ? pc.contentBytes : 0L; + if (sysB > 0 || contentB > 0) { + confirmSys.setText(LibrarySize.human(sysB)); + confirmContent.setText(LibrarySize.human(contentB)); + confirmTotal.setText(LibrarySize.human(sysB + contentB)); + confirmSizes.setVisibility(View.VISIBLE); + } else { + confirmSizes.setVisibility(View.GONE); } - if (m.length() > 0) m.append("\n\n"); - m.append(getString(R.string.k2go_clone_confirm_replace)); - confirmMsg.setText(m.toString()); confirmPanel.setVisibility(View.VISIBLE); return; } diff --git a/controller/app/src/main/res/layout/fragment_k2go_clone.xml b/controller/app/src/main/res/layout/fragment_k2go_clone.xml index f839e157..462d2606 100644 --- a/controller/app/src/main/res/layout/fragment_k2go_clone.xml +++ b/controller/app/src/main/res/layout/fragment_k2go_clone.xml @@ -181,19 +181,55 @@ android:textAppearance="?attr/textAppearanceTitleLarge" android:clickable="true" android:focusable="true" /> - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/controller/app/src/main/res/layout/fragment_k2go_clone.xml b/controller/app/src/main/res/layout/fragment_k2go_clone.xml index 462d2606..b6b6018f 100644 --- a/controller/app/src/main/res/layout/fragment_k2go_clone.xml +++ b/controller/app/src/main/res/layout/fragment_k2go_clone.xml @@ -211,7 +211,7 @@ android:textStyle="bold" android:textColor="@color/k2go_teal" android:textAppearance="?attr/textAppearanceTitleMedium" /> - @@ -222,6 +222,17 @@ android:text="Your current library (system + content) is replaced with theirs. No undo." android:textColor="@color/k2go_notice_ink" android:textAppearance="?attr/textAppearanceBodySmall" /> + + + + + + +