summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2010-12-12 12:44:27 -0800
committerMichael Kolb <kolby@google.com>2010-12-13 09:30:22 -0800
commit81b6f83b7032f22fdaaa514afda2448f801b73da (patch)
treef2cda854982c2ebc4847bebc65868de717b94a6f
parentd7d26819d01abc200dd569589579660435def146 (diff)
downloadpackages_apps_Browser-81b6f83b7032f22fdaaa514afda2448f801b73da.zip
packages_apps_Browser-81b6f83b7032f22fdaaa514afda2448f801b73da.tar.gz
packages_apps_Browser-81b6f83b7032f22fdaaa514afda2448f801b73da.tar.bz2
fix urlbar focus handling
Bug: http://b/issue?id=3275805 Entering url edit mode is controlled by the UI class Only the overlay title bar is used for editing Url selection action mode does not hide overlay title bar Change-Id: Ib528c641ba6cebb3a62de498ef3974a6117369df
-rw-r--r--src/com/android/browser/BaseUi.java16
-rw-r--r--src/com/android/browser/TitleBarXLarge.java50
2 files changed, 51 insertions, 15 deletions
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 4fca79d..70813e5 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -132,9 +132,9 @@ public class BaseUi implements UI, WebViewFactory {
frameLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);
if (mXLargeScreenSize) {
- mTitleBar = new TitleBarXLarge(mActivity, mUiController);
+ mTitleBar = new TitleBarXLarge(mActivity, mUiController, this);
mTitleBar.setProgress(100);
- mFakeTitleBar = new TitleBarXLarge(mActivity, mUiController);
+ mFakeTitleBar = new TitleBarXLarge(mActivity, mUiController, this);
ActionBar actionBar = mActivity.getActionBar();
mTabBar = new TabBar(mActivity, mUiController, this);
actionBar.setCustomNavigationMode(mTabBar);
@@ -515,6 +515,11 @@ public class BaseUi implements UI, WebViewFactory {
return 0;
}
+ void editUrl(boolean clearInput) {
+ showFakeTitleBar();
+ ((TitleBarXLarge) mFakeTitleBar).onEditUrl(clearInput);
+ }
+
void showFakeTitleBar() {
if (!isFakeTitleBarShowing() && mActiveTabsPage == null &&
!mActivityPaused) {
@@ -781,8 +786,11 @@ public class BaseUi implements UI, WebViewFactory {
@Override
public void onActionModeStarted(ActionMode mode) {
- // hide the fake title bar when CAB is shown
- hideFakeTitleBar();
+ if (!mXLargeScreenSize
+ || !((TitleBarXLarge) mFakeTitleBar).isEditingUrl()) {
+ // hide the fake title bar when CAB is shown
+ hideFakeTitleBar();
+ }
}
@Override
diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java
index 99e86c4..b7497ec 100644
--- a/src/com/android/browser/TitleBarXLarge.java
+++ b/src/com/android/browser/TitleBarXLarge.java
@@ -46,6 +46,7 @@ public class TitleBarXLarge extends TitleBarBase
private static final int PROGRESS_MAX = 100;
private UiController mUiController;
+ private BaseUi mUi;
private Drawable mStopDrawable;
private Drawable mReloadDrawable;
@@ -63,11 +64,14 @@ public class TitleBarXLarge extends TitleBarBase
private View mVoiceSearch;
private PageProgressView mProgressView;
private UrlInputView mUrlInput;
+
private boolean mInLoad;
- public TitleBarXLarge(Activity activity, UiController controller) {
+ public TitleBarXLarge(Activity activity, UiController controller,
+ BaseUi ui) {
super(activity);
mUiController = controller;
+ mUi = ui;
Resources resources = activity.getResources();
mStopDrawable = resources.getDrawable(R.drawable.ic_stop_normal);
mReloadDrawable = resources.getDrawable(R.drawable.ic_refresh_normal);
@@ -94,6 +98,7 @@ public class TitleBarXLarge extends TitleBarBase
mVoiceSearch = findViewById(R.id.voicesearch);
mProgressView = (PageProgressView) findViewById(R.id.progress);
mUrlContainer = findViewById(R.id.urlbar_focused);
+
mBackButton.setOnClickListener(this);
mForwardButton.setOnClickListener(this);
mStar.setOnClickListener(this);
@@ -121,9 +126,30 @@ public class TitleBarXLarge extends TitleBarBase
mStar.setActivated(isBookmark);
}
+ /**
+ * called from the Ui when the user wants to edit
+ * Note: only the fake titlebar will get this callback
+ * independent of which input field started the edit mode
+ * @param clearInput clear the input field
+ */
+ void onEditUrl(boolean clearInput) {
+ mUrlInput.requestFocusFromTouch();
+ if (clearInput) {
+ mUrlInput.setText("");
+ }
+ }
+
+ boolean isEditingUrl() {
+ return mUrlInput.hasFocus();
+ }
+
@Override
public void onClick(View v) {
- if (mBackButton == v) {
+ if (mUrlInput == v) {
+ if (!mUrlInput.hasFocus()) {
+ mUi.editUrl(false);
+ }
+ } else if (mBackButton == v) {
mUiController.getCurrentTopWebView().goBack();
} else if (mForwardButton == v) {
mUiController.getCurrentTopWebView().goForward();
@@ -133,7 +159,7 @@ public class TitleBarXLarge extends TitleBarBase
} else if (mAllButton == v) {
mUiController.bookmarksOrHistoryPicker(false);
} else if (mSearchButton == v) {
- search();
+ mUi.editUrl(true);
} else if (mStopButton == v) {
stopOrRefresh();
} else if (mGoButton == v) {
@@ -165,6 +191,10 @@ public class TitleBarXLarge extends TitleBarBase
// UrlInputListener implementation
+ /**
+ * callback from suggestion dropdown
+ * user selected a suggestion
+ */
@Override
public void onAction(String text, String extra, String source) {
mUiController.getCurrentTopWebView().requestFocus();
@@ -199,6 +229,10 @@ public class TitleBarXLarge extends TitleBarBase
}
}
+ /**
+ * callback from the suggestion dropdown
+ * copy text to input field and stay in edit mode
+ */
@Override
public void onEdit(String text) {
setDisplayTitle(text, true);
@@ -207,7 +241,7 @@ public class TitleBarXLarge extends TitleBarBase
}
}
- private void setUrlMode(boolean focused) {
+ void setUrlMode(boolean focused) {
if (focused) {
mUrlInput.setDropDownWidth(mUrlContainer.getWidth());
mUrlInput.setDropDownHorizontalOffset(-mUrlInput.getLeft());
@@ -225,12 +259,6 @@ public class TitleBarXLarge extends TitleBarBase
}
}
- private void search() {
- mUrlInput.requestFocus();
- setDisplayTitle("");
- setUrlMode(true);
- }
-
private void stopOrRefresh() {
if (mInLoad) {
mUiController.stopLoading();
@@ -285,7 +313,7 @@ public class TitleBarXLarge extends TitleBarBase
@Override
public void afterTextChanged(Editable s) {
if (mUrlInput.hasFocus()) {
- // check if url input is empty and adjust voice search state
+ // check if input field is empty and adjust voice search state
updateSearchMode();
}
}