Skip to content

Commit 543b8f4

Browse files
Merge pull request #327 from appdevforall/feat/ADFA-4988-getmore-unified-routing
ADFA-4988: Books confirm lands on the downloads screen, not back on Get More
2 parents 286e514 + 3c33f0f commit 543b8f4

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

‎controller/app/src/main/java/org/iiab/controller/redesign/SetupLibraryActivity.java‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,14 @@ public void startBooksDownload() {
329329
titles.add(v != null && v.length > 0 ? v[0] : "");
330330
urls.add(v != null && v.length > 2 ? v[2] : "");
331331
}
332-
int count = ids.size();
333332
booksCart.clear();
334333
BooksDownloadService.start(getApplicationContext(),
335334
ids.toArray(new String[0]), titles.toArray(new String[0]), urls.toArray(new String[0]));
336-
// ADFA-4910: mirror the wizard's confirm — hand the picks to the background service and
337-
// return to the Get More home (drop landing + confirm off the stack), instead of stranding
338-
// the user on the downloads screen. The download keeps running; the landing's "View
339-
// downloads" link (and the notification) let them check progress later.
340-
getSupportFragmentManager().popBackStack("getmore_books",
341-
androidx.fragment.app.FragmentManager.POP_BACK_STACK_INCLUSIVE);
342-
android.widget.Toast.makeText(this,
343-
getString(R.string.k2go_books_dl_started_fmt, count), android.widget.Toast.LENGTH_SHORT).show();
335+
// ADFA-4988: go to the downloads screen (its per-item list with download -> done checks),
336+
// matching ZIM/maps/modules — instead of returning to Get More and downloading invisibly.
337+
// Hint "books": the index opens the books detail when books is the only stream, else the cards.
338+
startActivity(new Intent(this, SetupProgressActivity.class)
339+
.putExtra(SetupProgressActivity.EXTRA_HINT_STREAM, "books"));
344340
}
345341

346342
/** ADFA-4850: Books landing -> the download manager screen (per-book checklist + retry). */

‎controller/app/src/main/java/org/iiab/controller/redesign/SetupProgressActivity.java‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public class SetupProgressActivity extends AppCompatActivity implements org.iiab
4545
* ("books" -> BooksDownloadsFragment, "zim" -> ZimPreparingFragment). */
4646
public static final String EXTRA_OPEN_STREAM = "openStream";
4747

48+
/** ADFA-4988: hint from a content confirm — open this stream's detail iff it is the only active one. */
49+
public static final String EXTRA_HINT_STREAM = "hintStream";
50+
4851
private static final long READY_POLL_MS = 2000L;
4952
private static final long REDIRECT_MS = 3000L;
5053
// ADFA-4900: if the maps module queue never reports RUNNING/DONE this long after hand-off, treat
@@ -134,13 +137,28 @@ protected void onCreate(@Nullable Bundle s) {
134137
// so a proot-only install could finish without the index ever updating to Finish/redirect.
135138
ModuleQueueRepository.get().state().observe(this, st -> render());
136139

137-
// ADFA-4987: a download notification tapped -> land on that stream's detail (not the legacy UI).
140+
// ADFA-4987: a download notification tapped -> force that stream's detail (not the legacy UI).
141+
// ADFA-4988: a content confirm hints its stream -> open its detail only when it is the sole
142+
// active stream, otherwise show the index.
138143
if (s == null) {
139144
String openStream = getIntent().getStringExtra(EXTRA_OPEN_STREAM);
145+
String hintStream = getIntent().getStringExtra(EXTRA_HINT_STREAM);
140146
if (openStream != null && !openStream.isEmpty()) openDetail(openStream);
147+
else if (hintStream != null && !hintStream.isEmpty()) openHintedStream(hintStream);
141148
}
142149
}
143150

151+
/** ADFA-4988: open the just-confirmed REST stream's detail directly when it is the ONLY active work;
152+
* otherwise keep the index. The hinted stream may not have registered its session yet (it just
153+
* started), so trust the hint and inspect only the OTHER streams, which started earlier. */
154+
private void openHintedStream(String hint) {
155+
boolean otherProot = mapsInSession() || moduleInSession();
156+
boolean otherZim = !"zim".equals(hint) && (ZimDownloadService.hasSession() || ZimWishlist.size(this) > 0);
157+
boolean otherBooks = !"books".equals(hint) && (BooksDownloadService.hasSession() || BooksWishlist.size(this) > 0);
158+
if (otherProot || otherZim || otherBooks) return; // several streams -> keep the index
159+
openDetail(hint);
160+
}
161+
144162
@Override
145163
protected void onResume() {
146164
super.onResume();

0 commit comments

Comments
 (0)