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 @@ -78,7 +78,8 @@ private enum Stage { JOIN, START }
private TextView receiveStart, pStatus, pFile, pStats, cancel;
private ProgressBar pbar;
private long lastSeq = -1L;
private AlertDialog confirmDialog;
private LinearLayout confirmPanel;
private TextView confirmTitle, confirmMsg;
private enum RStage { JOIN, START }
private RStage rStage = RStage.JOIN;
private boolean pasteExpanded = false;
Expand Down Expand Up @@ -139,6 +140,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
pFile = v.findViewById(R.id.k2go_clone_pfile);
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);
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);
codeblock = v.findViewById(R.id.k2go_clone_codeblock);
codetext = v.findViewById(R.id.k2go_clone_codetext);
Expand Down Expand Up @@ -382,8 +388,7 @@ private void onTransferState(SyncTransferState st) {
if (!isAdded() || st == null) return;
Log.i("IIAB-Clone", "recv state=" + st.phase + " title=" + st.title + " msg=" + st.message);
if (st.seq > lastSeq) {
if (st.phase == SyncTransferState.Phase.CONFIRM) { lastSeq = st.seq; showReceiveConfirm(st); }
else if (st.phase == SyncTransferState.Phase.SUCCESS) { lastSeq = st.seq; showReceiveTerminal(true, st.message); }
if (st.phase == SyncTransferState.Phase.SUCCESS) { lastSeq = st.seq; showReceiveTerminal(true, st.message); }
else if (st.phase == SyncTransferState.Phase.FAILED || st.phase == SyncTransferState.Phase.ABORTED) { lastSeq = st.seq; showReceiveTerminal(false, st.message); }
}
if (side == Side.RECEIVE) renderReceive();
Expand All @@ -393,14 +398,24 @@ private void renderReceive() {
SyncTransferState st = SyncProgressRepository.get().current();
boolean busy = (st != null && st.isActive());
progressBox.setVisibility(busy ? View.VISIBLE : View.GONE);
confirmPanel.setVisibility(View.GONE);
if (busy) {
rcvSteps.setVisibility(View.GONE); rcvCaption.setVisibility(View.GONE);
rcvIntro.setVisibility(View.GONE); rcvNotice.setVisibility(View.GONE);
rcvScan.setVisibility(View.GONE); rcvSub.setVisibility(View.GONE);
rcvSkip.setVisibility(View.GONE); rcvSkipHint.setVisibility(View.GONE);
rcvCamNote.setVisibility(View.GONE); rcvShowPaste.setVisibility(View.GONE); pasteBlock.setVisibility(View.GONE);
SyncTransferState.Phase ph = st.phase;
if (ph == SyncTransferState.Phase.CONFIRM) { showReceiveConfirm(st); return; }
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);
confirmPanel.setVisibility(View.VISIBLE);
return;
}
if (ph == SyncTransferState.Phase.TRANSFERRING) {
pbar.setIndeterminate(false);
pbar.setProgress(st.percent);
Expand Down Expand Up @@ -430,9 +445,9 @@ private void renderReceive() {
rcvSkipHint.setText("K2Go can't join that network for you \u2014 connect in Settings, then Continue.");
rcvSkip.setVisibility(atJoin ? View.VISIBLE : View.GONE);
rcvSkipHint.setVisibility(atJoin ? View.VISIBLE : View.GONE);
rcvCamNote.setVisibility(atJoin ? View.GONE : View.VISIBLE);
rcvCamNote.setVisibility(View.GONE);
rcvShowPaste.setVisibility(atJoin ? View.GONE : View.VISIBLE);
rcvShowPaste.setText(pasteExpanded ? "Input QR code as text \u25B4" : "Input QR code as text \u25BE");
rcvShowPaste.setText(pasteExpanded ? "Scan didn't work? Enter code as text \u25B4" : "Scan didn't work? Enter code as text \u25BE");
pasteBlock.setVisibility((!atJoin && pasteExpanded) ? View.VISIBLE : View.GONE);
}

Expand Down Expand Up @@ -475,21 +490,6 @@ private void openWifiSettings() {
}
}

private void showReceiveConfirm(SyncTransferState st) {
if (confirmDialog != null && confirmDialog.isShowing()) return;
String title = (st.title != null && !st.title.isEmpty()) ? st.title : "Copy the library?";
String msg = (st.message != null) ? st.message : "";
if (!msg.isEmpty()) msg += "\n\n";
msg += "This replaces the library on this phone with the sender's copy.";
confirmDialog = new AlertDialog.Builder(requireContext())
.setTitle(title)
.setMessage(msg)
.setNegativeButton("Cancel", (d, w) -> { syncVm.cancelProbe(); renderReceive(); })
.setPositiveButton("Copy", (d, w) -> startReceiveTransfer())
.setCancelable(false)
.show();
}

private void startReceiveTransfer() {
final Context app = requireContext().getApplicationContext();
SyncHandshakeHelper.SyncCredentials creds = syncVm.getPendingCreds();
Expand Down
25 changes: 20 additions & 5 deletions controller/app/src/main/res/layout/fragment_k2go_clone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<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 library (system + content) is replaced with the other phone's. No undo." android:textColor="@color/k2go_ink" android:textAppearance="?attr/textAppearanceBodySmall" />
android:text="Your library (system + content) is replaced with the other phone's. No undo." android:textColor="@color/k2go_notice_ink" android:textAppearance="?attr/textAppearanceBodySmall" />
</LinearLayout>
</LinearLayout>

Expand All @@ -132,9 +132,9 @@
android:textColor="@color/k2go_muted" android:textAppearance="?attr/textAppearanceBodySmall" android:visibility="gone" />

<TextView android:id="@+id/k2go_rcv_showpaste" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="6dp" android:padding="14dp" android:gravity="center" android:text="Input QR code as text ▾"
android:background="@drawable/k2go_getmore_bg" android:textColor="@color/k2go_teal"
android:textAppearance="?attr/textAppearanceBodyLarge" android:clickable="true" android:focusable="true" android:visibility="gone" />
android:layout_marginTop="12dp" android:padding="8dp" android:gravity="center" android:text="Scan didn\'t work? Enter code as text ▾"
android:textColor="@color/k2go_teal"
android:textAppearance="?attr/textAppearanceBodyMedium" android:clickable="true" android:focusable="true" android:visibility="gone" />

<LinearLayout android:id="@+id/k2go_rcv_pasteblock" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_marginTop="6dp" android:visibility="gone">
Expand All @@ -149,7 +149,22 @@
android:textAppearance="?attr/textAppearanceTitleLarge" android:clickable="true" android:focusable="true" />
</LinearLayout>

<LinearLayout android:id="@+id/k2go_clone_progress" android:layout_width="match_parent" android:layout_height="wrap_content"
<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" />
</LinearLayout>
</LinearLayout>

<LinearLayout android:id="@+id/k2go_clone_progress" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_marginTop="8dp" android:padding="14dp"
android:background="@drawable/k2go_card_bg" android:visibility="gone">
<TextView android:id="@+id/k2go_clone_pstatus" android:layout_width="wrap_content" android:layout_height="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions controller/app/src/main/res/values/colors_k2go.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<color name="k2go_amber">#F2A23C</color>
<color name="k2go_amber_text">#B0740F</color>
<color name="k2go_clay">#C4462F</color>
<color name="k2go_notice_ink">#3A2320</color> <!-- fixed dark; notice bg is always light pink -->
<color name="k2go_muted">#5C6360</color>
<color name="k2go_hairline">#D9D4C8</color>
<color name="k2go_on_teal">#FBF8F3</color>
Expand Down