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..056431ab 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, confirmReplace, confirmFresh; + private TextView confirmSys, confirmContent, confirmTotal; private enum RStage { JOIN, START } private RStage rStage = RStage.JOIN; private boolean pasteExpanded = false; @@ -166,8 +166,12 @@ 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); + confirmReplace = v.findViewById(R.id.k2go_rcv_confirm_replace); + confirmFresh = v.findViewById(R.id.k2go_rcv_confirm_fresh); 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,11 +555,25 @@ 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: 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(); + 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); + } + // ADFA-4790: on an empty phone there's nothing to replace — show the benign notice + // instead of the "replaces your library / no undo" warning. + boolean fresh = !rootfsPresent(); + confirmFresh.setVisibility(fresh ? View.VISIBLE : View.GONE); + confirmReplace.setVisibility(fresh ? View.GONE : View.VISIBLE); confirmPanel.setVisibility(View.VISIBLE); return; } diff --git a/controller/app/src/main/res/drawable/k2go_ok_bg.xml b/controller/app/src/main/res/drawable/k2go_ok_bg.xml new file mode 100644 index 00000000..9c043ff5 --- /dev/null +++ b/controller/app/src/main/res/drawable/k2go_ok_bg.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + 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..b6b6018f 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,66 @@ android:textAppearance="?attr/textAppearanceTitleLarge" android:clickable="true" android:focusable="true" /> - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +