Making the tab object tag more specific for its use case
This commit is contained in:
parent
368d71df7d
commit
66b4ea16f4
@ -105,12 +105,12 @@ public class BrowserPresenter {
|
||||
// TODO: Restore this when Google fixes the bug where the WebView is
|
||||
// blank after calling onPause followed by onResume.
|
||||
// mCurrentTab.onPause();
|
||||
mCurrentTab.setForegroundTab(false);
|
||||
mCurrentTab.setIsForegroundTab(false);
|
||||
}
|
||||
|
||||
newTab.resumeTimers();
|
||||
newTab.onResume();
|
||||
newTab.setForegroundTab(true);
|
||||
newTab.setIsForegroundTab(true);
|
||||
|
||||
mView.updateProgress(newTab.getProgress());
|
||||
mView.setBackButtonEnabled(newTab.canGoBack());
|
||||
@ -161,7 +161,7 @@ public class BrowserPresenter {
|
||||
}
|
||||
|
||||
final boolean isShown = tabToDelete.isShown();
|
||||
boolean shouldClose = mShouldClose && isShown && Boolean.TRUE.equals(tabToDelete.getTag());
|
||||
boolean shouldClose = mShouldClose && isShown && tabToDelete.isNewTab();
|
||||
final LightningView currentTab = mTabsModel.getCurrentTab();
|
||||
if (mTabsModel.size() == 1 && currentTab != null &&
|
||||
(UrlUtils.isSpecialUrl(currentTab.getUrl()) ||
|
||||
@ -239,7 +239,7 @@ public class BrowserPresenter {
|
||||
mShouldClose = true;
|
||||
LightningView tab = mTabsModel.lastTab();
|
||||
if (tab != null) {
|
||||
tab.setTag(true);
|
||||
tab.setIsNewTab(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -248,7 +248,7 @@ public class BrowserPresenter {
|
||||
mShouldClose = true;
|
||||
LightningView tab = mTabsModel.lastTab();
|
||||
if (tab != null) {
|
||||
tab.setTag(true);
|
||||
tab.setIsNewTab(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,9 +99,9 @@ public class LightningView {
|
||||
@NonNull private final GestureDetector mGestureDetector;
|
||||
@NonNull private final Activity mActivity;
|
||||
@NonNull private final Paint mPaint = new Paint();
|
||||
@Nullable private Object mTag;
|
||||
private boolean mIsNewTab;
|
||||
private final boolean mIsIncognitoTab;
|
||||
private boolean isForegroundTab;
|
||||
private boolean mIsForegroundTab;
|
||||
private boolean mInvertPage = false;
|
||||
private boolean mToggleDesktop = false;
|
||||
@NonNull private final WebViewHandler mWebViewHandler = new WebViewHandler(this);
|
||||
@ -162,25 +162,27 @@ public class LightningView {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tag on the object,
|
||||
* a reference to this object is held
|
||||
* indefinitely.
|
||||
* Sets whether this tab was the
|
||||
* result of a new intent sent
|
||||
* to the browser.
|
||||
*
|
||||
* @param tag the tag to set, may be null.
|
||||
* @param isNewTab true if it's from
|
||||
* a new intent,
|
||||
* false otherwise.
|
||||
*/
|
||||
public void setTag(@Nullable Object tag) {
|
||||
mTag = tag;
|
||||
public void setIsNewTab(boolean isNewTab) {
|
||||
mIsNewTab = isNewTab;
|
||||
}
|
||||
|
||||
/**
|
||||
* The tag set on the object.
|
||||
* Returns whether this tab was created
|
||||
* as a result of a new intent.
|
||||
*
|
||||
* @return the tag set on the object,
|
||||
* may be null.
|
||||
* @return true if it was a new intent,
|
||||
* false otherwise.
|
||||
*/
|
||||
@Nullable
|
||||
public Object getTag() {
|
||||
return mTag;
|
||||
public boolean isNewTab() {
|
||||
return mIsNewTab;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -617,8 +619,8 @@ public class LightningView {
|
||||
* @param isForeground true if the tab should be set as
|
||||
* foreground, false otherwise.
|
||||
*/
|
||||
public void setForegroundTab(boolean isForeground) {
|
||||
isForegroundTab = isForeground;
|
||||
public void setIsForegroundTab(boolean isForeground) {
|
||||
mIsForegroundTab = isForeground;
|
||||
mUIController.tabChanged(this);
|
||||
}
|
||||
|
||||
@ -629,7 +631,7 @@ public class LightningView {
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean isForegroundTab() {
|
||||
return isForegroundTab;
|
||||
return mIsForegroundTab;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user