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

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

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