Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
17 changes: 17 additions & 0 deletions controller/app/src/main/res/drawable/k2go_ok_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ADFA-4790: benign "first copy, nothing to replace" notice. Fixed colors in both themes
(like k2go_notice_bg / k2go_warn_bg); body text uses k2go_notice_ink so it reads on the fill. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#2E7D32" />
<corners android:radius="16dp" />
</shape>
</item>
<item android:left="5dp">
<shape android:shape="rectangle">
<solid android:color="#E4F0E3" />
<corners android:radius="16dp" />
</shape>
</item>
</layer-list>
71 changes: 59 additions & 12 deletions controller/app/src/main/res/layout/fragment_k2go_clone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,66 @@
android:textAppearance="?attr/textAppearanceTitleLarge" android:clickable="true" android:focusable="true" />
</LinearLayout>

<LinearLayout android:id="@+id/k2go_rcv_confirm" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_marginTop="12dp" android:padding="16dp" android:background="@drawable/k2go_card_bg" android:visibility="gone">
<TextView android:id="@+id/k2go_rcv_confirm_title" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/k2go_ink" android:textStyle="bold" android:textAppearance="?attr/textAppearanceTitleMedium" />
<TextView android:id="@+id/k2go_rcv_confirm_msg" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="6dp" android:textColor="@color/k2go_ink" android:textAppearance="?attr/textAppearanceBodyMedium" />
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"
android:layout_marginTop="14dp" android:gravity="end">
<TextView android:id="@+id/k2go_rcv_confirm_cancel" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:padding="10dp" android:text="Cancel" android:textColor="@color/k2go_muted" android:textAppearance="?attr/textAppearanceTitleMedium" android:clickable="true" android:focusable="true" />
<TextView android:id="@+id/k2go_rcv_confirm_go" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:padding="10dp" android:text="Continue" android:textStyle="bold" android:textColor="@color/k2go_teal" android:textAppearance="?attr/textAppearanceTitleMedium" android:clickable="true" android:focusable="true" />
<!-- ADFA-4790: confirm as a System/Content/Total table + replace notice, per the design mockup. -->
<LinearLayout android:id="@+id/k2go_rcv_confirm" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_marginTop="12dp" android:visibility="gone">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="You'll receive a full copy" android:textColor="@color/k2go_ink" android:textStyle="bold" android:textAppearance="?attr/textAppearanceTitleLarge" />
<LinearLayout android:id="@+id/k2go_rcv_confirm_sizes" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_marginTop="12dp" android:padding="16dp" android:background="@drawable/k2go_card_bg">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="FROM THE OTHER PHONE" android:textColor="@color/k2go_teal" android:letterSpacing="0.08" android:textStyle="bold" android:textAppearance="?attr/textAppearanceLabelSmall" />
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginTop="10dp">
<TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"
android:text="System" android:textColor="@color/k2go_muted" android:textAppearance="?attr/textAppearanceBodyMedium" />
<TextView android:id="@+id/k2go_rcv_confirm_sys" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/k2go_ink" android:textAppearance="?attr/textAppearanceBodyMedium" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginTop="4dp">
<TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"
android:text="Content" android:textColor="@color/k2go_muted" android:textAppearance="?attr/textAppearanceBodyMedium" />
<TextView android:id="@+id/k2go_rcv_confirm_content" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/k2go_ink" android:textAppearance="?attr/textAppearanceBodyMedium" />
</LinearLayout>
<View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp"
android:background="@color/k2go_muted" android:alpha="0.25" />
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginTop="8dp">
<TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"
android:text="Total" android:textStyle="bold" android:textColor="@color/k2go_ink" android:textAppearance="?attr/textAppearanceTitleMedium" />
<TextView android:id="@+id/k2go_rcv_confirm_total" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textStyle="bold" android:textColor="@color/k2go_teal" android:textAppearance="?attr/textAppearanceTitleMedium" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/k2go_rcv_confirm_replace" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_marginTop="14dp" android:padding="14dp" android:background="@drawable/k2go_notice_bg">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingEnd="12dp"
android:text="!" android:textStyle="bold" android:textColor="@color/k2go_clay" android:textAppearance="?attr/textAppearanceTitleLarge" />
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="This replaces your K2Go library" android:textStyle="bold" android:textColor="@color/k2go_clay" android:textAppearance="?attr/textAppearanceTitleMedium" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp"
android:text="Your current library (system + content) is replaced with theirs. No undo." android:textColor="@color/k2go_notice_ink" android:textAppearance="?attr/textAppearanceBodySmall" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/k2go_rcv_confirm_fresh" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_marginTop="14dp" android:padding="14dp" android:background="@drawable/k2go_ok_bg" android:visibility="gone">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingEnd="12dp"
android:text="✓" android:textStyle="bold" android:textColor="#1E6B2E" android:textAppearance="?attr/textAppearanceTitleLarge" />
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Nothing to replace" android:textStyle="bold" android:textColor="#1E6B2E" android:textAppearance="?attr/textAppearanceTitleMedium" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp"
android:text="This phone has no library yet — you'll simply receive the sender's copy." android:textColor="@color/k2go_notice_ink" android:textAppearance="?attr/textAppearanceBodySmall" />
</LinearLayout>
</LinearLayout>
<TextView android:id="@+id/k2go_rcv_confirm_go" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:padding="16dp" android:gravity="center" android:text="Continue — start copying"
android:background="@drawable/k2go_primary_bg" android:textColor="@color/k2go_on_teal"
android:textAppearance="?attr/textAppearanceTitleLarge" android:clickable="true" android:focusable="true" />
<TextView android:id="@+id/k2go_rcv_confirm_cancel" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:padding="14dp" android:gravity="center" android:text="Cancel"
android:background="@drawable/k2go_getmore_bg" android:textColor="@color/k2go_muted"
android:textAppearance="?attr/textAppearanceTitleMedium" android:clickable="true" android:focusable="true" />
</LinearLayout>

<!-- ADFA-4784: "these phones aren't compatible" hard-block state (no arch jargon; raw
Expand Down