Dbrant has uploaded a new change for review.
https://gerrit.wikimedia.org/r/250008
Change subject: Fix possible unnecessary tab creation.
......................................................................
Fix possible unnecessary tab creation.
When the app is launched via a VIEW intent (e.g. from an external
Browser), and it didn't have any tabs open from previous sessions, the app
unconditionally creates a new tab for the Main Page *and* a new tab for
the page requested in the VIEW intent, resulting in a puzzling appearance
of a new tab on top of a "blank" tab.
This patch makes it so that the app creates a new tab only if the topmost
tab's backstack is nonempty. This successfully handles the case described
above.
Bug: T116502
Change-Id: I6557678d11e965fd28f63c76e835aa85317c5075
---
M app/src/main/java/org/wikipedia/page/PageFragment.java
1 file changed, 21 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia
refs/changes/08/250008/1
diff --git a/app/src/main/java/org/wikipedia/page/PageFragment.java
b/app/src/main/java/org/wikipedia/page/PageFragment.java
index 1218fcd..1160f30 100755
--- a/app/src/main/java/org/wikipedia/page/PageFragment.java
+++ b/app/src/main/java/org/wikipedia/page/PageFragment.java
@@ -930,20 +930,32 @@
}
private void openInNewTab(PageTitle title, HistoryEntry entry, int
position) {
- // create a new tab
- Tab tab = new Tab();
- // if the requested position is at the top, then make its backstack
current
- if (position == getForegroundTabPosition()) {
- pageLoadStrategy.setBackStack(tab.getBackStack());
+ if (shouldCreateNewTab()) {
+ // create a new tab
+ Tab tab = new Tab();
+ // if the requested position is at the top, then make its
backstack current
+ if (position == getForegroundTabPosition()) {
+ pageLoadStrategy.setBackStack(tab.getBackStack());
+ }
+ // put this tab in the requested position
+ tabList.add(position, tab);
+ // add the requested page to its backstack
+ tab.getBackStack().add(new PageBackStackItem(title, entry));
+ } else {
+ getTopMostTab().getBackStack().add(new PageBackStackItem(title,
entry));
}
- // put this tab in the requested position
- tabList.add(position, tab);
- // add the requested page to its backstack
- tab.getBackStack().add(new PageBackStackItem(title, entry));
// and... that should be it.
tabsProvider.showAndHideTabs();
}
+ private Tab getTopMostTab() {
+ return tabList.get(tabList.size() - 1);
+ }
+
+ private boolean shouldCreateNewTab() {
+ return !getTopMostTab().getBackStack().isEmpty();
+ }
+
private int getBackgroundTabPosition() {
return Math.max(0, getForegroundTabPosition() - 1);
}
--
To view, visit https://gerrit.wikimedia.org/r/250008
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6557678d11e965fd28f63c76e835aa85317c5075
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits