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