Bug 943915 - Encapsulate SiteIdentityPopup into BrowserToolbar (r=wesj)

This commit is contained in:
Lucas Rocha 2013-12-12 00:28:14 +00:00
Родитель f8bbdb0c3c
Коммит 1e4c7a02f2
2 изменённых файлов: 30 добавлений и 24 удалений

Просмотреть файл

@ -27,7 +27,6 @@ import org.mozilla.gecko.preferences.GeckoPreferences;
import org.mozilla.gecko.prompts.Prompt;
import org.mozilla.gecko.toolbar.AutocompleteHandler;
import org.mozilla.gecko.toolbar.BrowserToolbar;
import org.mozilla.gecko.toolbar.SiteIdentityPopup;
import org.mozilla.gecko.util.Clipboard;
import org.mozilla.gecko.util.GamepadUtils;
import org.mozilla.gecko.util.HardwareUtils;
@ -188,15 +187,6 @@ abstract public class BrowserApp extends GeckoApp
// race by determining if the web content should be hidden at the animation's end.
private boolean mHideWebContentOnAnimationEnd = false;
private SiteIdentityPopup mSiteIdentityPopup;
public SiteIdentityPopup getSiteIdentityPopup() {
if (mSiteIdentityPopup == null)
mSiteIdentityPopup = new SiteIdentityPopup(this);
return mSiteIdentityPopup;
}
@Override
public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
if (tab == null) {
@ -219,9 +209,6 @@ abstract public class BrowserApp extends GeckoApp
if (Tabs.getInstance().isSelectedTab(tab)) {
updateHomePagerForTab(tab);
if (mSiteIdentityPopup != null)
mSiteIdentityPopup.dismiss();
final TabsPanel.Panel panel = tab.isPrivate()
? TabsPanel.Panel.PRIVATE_TABS
: TabsPanel.Panel.NORMAL_TABS;
@ -618,8 +605,7 @@ abstract public class BrowserApp extends GeckoApp
return;
}
if (mSiteIdentityPopup != null && mSiteIdentityPopup.isShowing()) {
mSiteIdentityPopup.dismiss();
if (mBrowserToolbar.onBackPressed()) {
return;
}
@ -1048,9 +1034,7 @@ abstract public class BrowserApp extends GeckoApp
invalidateOptionsMenu();
updateSideBarState();
mTabsPanel.refresh();
if (mSiteIdentityPopup != null) {
mSiteIdentityPopup.dismiss();
}
mBrowserToolbar.refresh();
}
@Override

Просмотреть файл

@ -141,6 +141,8 @@ public class BrowserToolbar extends GeckoRelativeLayout
private OnStartEditingListener mStartEditingListener;
private OnStopEditingListener mStopEditingListener;
private SiteIdentityPopup mSiteIdentityPopup;
final private BrowserApp mActivity;
private boolean mHasSoftMenuButton;
@ -295,7 +297,9 @@ public class BrowserToolbar extends GeckoRelativeLayout
mSiteSecurity = (ImageButton) findViewById(R.id.site_security);
mSiteSecurityVisible = (mSiteSecurity.getVisibility() == View.VISIBLE);
mActivity.getSiteIdentityPopup().setAnchor(mSiteSecurity);
mSiteIdentityPopup = new SiteIdentityPopup(mActivity);
mSiteIdentityPopup.setAnchor(mSiteSecurity);
mProgressSpinner = AnimationUtils.loadAnimation(mActivity, R.anim.progress_spinner);
@ -429,9 +433,9 @@ public class BrowserToolbar extends GeckoRelativeLayout
Log.e(LOGTAG, "Selected tab has no identity data");
return;
}
SiteIdentityPopup siteIdentityPopup = mActivity.getSiteIdentityPopup();
siteIdentityPopup.updateIdentity(identityData);
siteIdentityPopup.show();
mSiteIdentityPopup.updateIdentity(identityData);
mSiteIdentityPopup.show();
}
};
@ -481,6 +485,14 @@ public class BrowserToolbar extends GeckoRelativeLayout
}
}
public void refresh() {
dismissSiteIdentityPopup();
}
public boolean onBackPressed() {
return dismissSiteIdentityPopup();
}
public boolean onKey(int keyCode, KeyEvent event) {
if (event.getAction() != KeyEvent.ACTION_DOWN) {
return false;
@ -557,6 +569,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
case RESTORED:
// TabCount fixup after OOM
case SELECTED:
dismissSiteIdentityPopup();
updateTabCount(tabs.getDisplayCount());
mSwitchingTabs = true;
// Fall through.
@ -593,7 +606,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
case LOCATION_CHANGE:
// A successful location change will cause Tab to notify
// us of a title change, so we don't update the title here.
refresh();
refreshState();
break;
case CLOSED:
@ -668,6 +681,15 @@ public class BrowserToolbar extends GeckoRelativeLayout
}
}
private boolean dismissSiteIdentityPopup() {
if (mSiteIdentityPopup != null && mSiteIdentityPopup.isShowing()) {
mSiteIdentityPopup.dismiss();
return true;
}
return false;
}
private int getUrlBarEntryTranslation() {
return getWidth() - mUrlBarEntry.getRight();
}
@ -1533,7 +1555,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
setVisibility(View.GONE);
}
private void refresh() {
private void refreshState() {
Tab tab = Tabs.getInstance().getSelectedTab();
if (tab != null) {
setFavicon(tab.getFavicon());