summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-08-19 13:26:43 -0700
committerJohn Reck <jreck@google.com>2011-08-19 13:26:43 -0700
commit42229bcdea8a1623d9ac3fce099793a3767fb14d (patch)
tree3069825c505174e5b67d4be65bd5714db75f27f3 /src/com
parent0d7c69e9621a860f467a3e3171ee4962ad793df9 (diff)
downloadpackages_apps_Browser-42229bcdea8a1623d9ac3fce099793a3767fb14d.zip
packages_apps_Browser-42229bcdea8a1623d9ac3fce099793a3767fb14d.tar.gz
packages_apps_Browser-42229bcdea8a1623d9ac3fce099793a3767fb14d.tar.bz2
YAMR - Yet Another Menu Reorg
Bug: 5186166 Change-Id: Icd459c8f9cd557659a5402431a843a856fb1b134
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/browser/Controller.java10
-rw-r--r--src/com/android/browser/NavigationBarBase.java77
-rw-r--r--src/com/android/browser/NavigationBarPhone.java10
-rw-r--r--src/com/android/browser/NavigationBarTablet.java1
4 files changed, 21 insertions, 77 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 19ad9a9..84d7e36 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1466,10 +1466,12 @@ public class Controller
boolean canGoBack = false;
boolean canGoForward = false;
boolean isHome = false;
+ boolean isDesktopUa = false;
if (tab != null) {
canGoBack = tab.canGoBack();
canGoForward = tab.canGoForward();
isHome = mSettings.getHomePage().equals(tab.getUrl());
+ isDesktopUa = mSettings.hasDesktopUseragent(tab.getWebView());
}
final MenuItem back = menu.findItem(R.id.back_menu_id);
back.setEnabled(canGoBack);
@@ -1504,6 +1506,8 @@ public class Controller
final MenuItem counter = menu.findItem(R.id.dump_counters_menu_id);
counter.setVisible(showDebugSettings);
counter.setEnabled(showDebugSettings);
+ final MenuItem uaSwitcher = menu.findItem(R.id.ua_desktop_menu_id);
+ uaSwitcher.setChecked(isDesktopUa);
mUi.updateMenuState(tab, menu);
}
@@ -1650,6 +1654,12 @@ public class Controller
viewDownloads();
break;
+ case R.id.ua_desktop_menu_id:
+ WebView web = getCurrentWebView();
+ mSettings.toggleDesktopUseragent(web);
+ web.loadUrl(web.getOriginalUrl());
+ break;
+
case R.id.window_one_menu_id:
case R.id.window_two_menu_id:
case R.id.window_three_menu_id:
diff --git a/src/com/android/browser/NavigationBarBase.java b/src/com/android/browser/NavigationBarBase.java
index ab79b37..bfdd9a0 100644
--- a/src/com/android/browser/NavigationBarBase.java
+++ b/src/com/android/browser/NavigationBarBase.java
@@ -24,17 +24,11 @@ import android.os.Bundle;
import android.speech.RecognizerResultsIntent;
import android.util.AttributeSet;
import android.view.KeyEvent;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
-import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.PopupMenu;
-import android.widget.PopupMenu.OnDismissListener;
-import android.widget.PopupMenu.OnMenuItemClickListener;
import com.android.browser.UI.DropdownChangeListener;
import com.android.browser.UrlInputView.UrlInputListener;
@@ -42,9 +36,9 @@ import com.android.browser.autocomplete.SuggestedTextController.TextChangeWatche
import java.util.List;
-public class NavigationBarBase extends LinearLayout implements OnClickListener,
- OnMenuItemClickListener, UrlInputListener, OnFocusChangeListener,
- TextChangeWatcher, OnDismissListener {
+public class NavigationBarBase extends LinearLayout implements
+ OnClickListener, UrlInputListener, OnFocusChangeListener,
+ TextChangeWatcher {
protected BaseUi mBaseUi;
protected TitleBar mTitleBar;
@@ -54,9 +48,6 @@ public class NavigationBarBase extends LinearLayout implements OnClickListener,
private ImageView mFavicon;
private ImageView mLockIcon;
- private View mUaSwitcher;
- private boolean mUaSwitcherShowing;
- private PopupMenu mUaSwitcherMenu;
public NavigationBarBase(Context context) {
super(context);
@@ -104,59 +95,8 @@ public class NavigationBarBase extends LinearLayout implements OnClickListener,
mFavicon.setImageDrawable(mBaseUi.getFaviconDrawable(icon));
}
- public void setUaSwitcher(View v) {
- if (mUaSwitcher != null) {
- mUaSwitcher.setOnClickListener(null);
- }
- mUaSwitcher = v;
- mUaSwitcher.setOnClickListener(this);
- }
-
@Override
public void onClick(View v) {
- if (mUaSwitcher == v) {
- BrowserSettings settings = BrowserSettings.getInstance();
- WebView web = mTitleBar.getCurrentWebView();
- if (web == null) return;
- boolean desktop = settings.hasDesktopUseragent(web);
- mUaSwitcherMenu = new PopupMenu(mContext, mUaSwitcher);
- Menu menu = mUaSwitcherMenu.getMenu();
- mUaSwitcherMenu.getMenuInflater().inflate(R.menu.ua_switcher, menu);
- menu.findItem(R.id.ua_mobile_menu_id).setChecked(!desktop);
- menu.findItem(R.id.ua_desktop_menu_id).setChecked(desktop);
- Tab tab = mUiController.getCurrentTab();
- MenuItem saveSnapshot = menu.findItem(R.id.save_snapshot_menu_id);
- saveSnapshot.setVisible(tab != null && !tab.isSnapshot());
- MenuItem find = menu.findItem(R.id.find_menu_id);
- find.setVisible(tab != null && !tab.isSnapshot());
- mUaSwitcherMenu.setOnMenuItemClickListener(this);
- mUaSwitcherMenu.setOnDismissListener(this);
- mUaSwitcherShowing = true;
- mUaSwitcherMenu.show();
- }
- }
-
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- BrowserSettings settings = BrowserSettings.getInstance();
- WebView web = mTitleBar.getCurrentWebView();
- if (web == null) return false;
- boolean desktop = settings.hasDesktopUseragent(web);
- switch (item.getItemId()) {
- case R.id.ua_mobile_menu_id:
- if (desktop) {
- settings.toggleDesktopUseragent(web);
- web.loadUrl(web.getOriginalUrl());
- }
- return true;
- case R.id.ua_desktop_menu_id:
- if (!desktop) {
- settings.toggleDesktopUseragent(web);
- web.loadUrl(web.getOriginalUrl());
- }
- return true;
- }
- return mUiController.onOptionsItemSelected(item);
}
@Override
@@ -340,17 +280,8 @@ public class NavigationBarBase extends LinearLayout implements OnClickListener,
public void onProgressStopped() {
}
- @Override
- public void onDismiss(PopupMenu menu) {
- if (mUaSwitcherMenu == menu) {
- mUaSwitcherShowing = false;
- mUaSwitcherMenu = null;
- mBaseUi.showTitleBarForDuration();
- }
- }
-
public boolean isMenuShowing() {
- return mUaSwitcherShowing;
+ return false;
}
public void onTabDataChanged(Tab tab) {
diff --git a/src/com/android/browser/NavigationBarPhone.java b/src/com/android/browser/NavigationBarPhone.java
index d2d3797..5cabe31 100644
--- a/src/com/android/browser/NavigationBarPhone.java
+++ b/src/com/android/browser/NavigationBarPhone.java
@@ -27,11 +27,12 @@ import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnDismissListener;
+import android.widget.PopupMenu.OnMenuItemClickListener;
import com.android.browser.UrlInputView.StateListener;
public class NavigationBarPhone extends NavigationBarBase implements
- StateListener {
+ StateListener, OnMenuItemClickListener, OnDismissListener {
private ImageView mStopButton;
private ImageView mVoiceButton;
@@ -81,7 +82,6 @@ public class NavigationBarPhone extends NavigationBarBase implements
mStopDescription = res.getString(R.string.accessibility_button_stop);
mRefreshDescription = res.getString(R.string.accessibility_button_refresh);
mTextfieldBgDrawable = res.getDrawable(R.drawable.textfield_active_holo_dark);
- setUaSwitcher(mComboIcon);
mUrlInput.setContainer(this);
mUrlInput.setStateListener(this);
mNeedsMenu = !ViewConfiguration.get(getContext()).hasPermanentMenuKey();
@@ -182,7 +182,6 @@ public class NavigationBarPhone extends NavigationBarBase implements
if (menu == mPopupMenu) {
onMenuHidden();
}
- super.onDismiss(menu);
}
private void onMenuHidden() {
@@ -240,4 +239,9 @@ public class NavigationBarPhone extends NavigationBarBase implements
? View.VISIBLE : View.GONE);
}
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ return mUiController.onOptionsItemSelected(item);
+ }
+
}
diff --git a/src/com/android/browser/NavigationBarTablet.java b/src/com/android/browser/NavigationBarTablet.java
index 7f6992a..8c08dcf 100644
--- a/src/com/android/browser/NavigationBarTablet.java
+++ b/src/com/android/browser/NavigationBarTablet.java
@@ -110,7 +110,6 @@ public class NavigationBarTablet extends NavigationBarBase {
mGoButton.setOnClickListener(this);
mClearButton.setOnClickListener(this);
mVoiceSearch.setOnClickListener(this);
- setUaSwitcher(mUrlIcon);
mUrlInput.setContainer(mUrlContainer);
}