summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-09-02 16:42:26 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-02 16:42:26 -0700
commit54e1fb3806e27c88226802d48adeb5c1a1963b2e (patch)
tree8784f6d811b8726086a14564c6160d7b3406f4d6
parentd91493249d3cbf795b3dd4813966624f08bd6e2e (diff)
parent94ec527ac5b4d4ca245c878de4eb559658a55d4d (diff)
downloadpackages_apps_Browser-54e1fb3806e27c88226802d48adeb5c1a1963b2e.zip
packages_apps_Browser-54e1fb3806e27c88226802d48adeb5c1a1963b2e.tar.gz
packages_apps_Browser-54e1fb3806e27c88226802d48adeb5c1a1963b2e.tar.bz2
Merge "Fix focus highlight bug"
-rw-r--r--res/layout/title_bar_nav.xml16
-rw-r--r--src/com/android/browser/NavigationBarPhone.java13
-rw-r--r--src/com/android/browser/UrlInputView.java20
3 files changed, 45 insertions, 4 deletions
diff --git a/res/layout/title_bar_nav.xml b/res/layout/title_bar_nav.xml
index eeba9d7..8ed6331 100644
--- a/res/layout/title_bar_nav.xml
+++ b/res/layout/title_bar_nav.xml
@@ -26,6 +26,14 @@
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
+ android:id="@+id/magnify"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="8dip"
+ android:paddingRight="8dip"
+ android:visibility="gone"
+ android:src="@drawable/ic_search_category_suggest" />
+ <ImageView
android:id="@+id/incognito_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -83,6 +91,14 @@
android:src="@drawable/ic_voice_search_holo_dark"
style="@style/HoloButton"
android:visibility="gone" />
+ <ImageView
+ android:id="@+id/clear"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:contentDescription="@string/accessibility_button_clear"
+ android:src="@drawable/ic_close_window_holo_dark"
+ style="@style/HoloButton"
+ android:visibility="gone" />
</LinearLayout>
<ImageButton
android:id="@+id/tab_switcher"
diff --git a/src/com/android/browser/NavigationBarPhone.java b/src/com/android/browser/NavigationBarPhone.java
index fee9604..7e8695b 100644
--- a/src/com/android/browser/NavigationBarPhone.java
+++ b/src/com/android/browser/NavigationBarPhone.java
@@ -36,6 +36,8 @@ public class NavigationBarPhone extends NavigationBarBase implements
private ImageView mStopButton;
private ImageView mVoiceButton;
+ private ImageView mMagnify;
+ private ImageView mClearButton;
private Drawable mStopDrawable;
private Drawable mRefreshDrawable;
private String mStopDescription;
@@ -69,6 +71,9 @@ public class NavigationBarPhone extends NavigationBarBase implements
mStopButton.setOnClickListener(this);
mVoiceButton = (ImageView) findViewById(R.id.voice);
mVoiceButton.setOnClickListener(this);
+ mClearButton = (ImageView) findViewById(R.id.clear);
+ mClearButton.setOnClickListener(this);
+ mMagnify = (ImageView) findViewById(R.id.magnify);
mTabSwitcher = findViewById(R.id.tab_switcher);
mTabSwitcher.setOnClickListener(this);
mMore = findViewById(R.id.more);
@@ -156,6 +161,8 @@ public class NavigationBarPhone extends NavigationBarBase implements
((PhoneUi) mBaseUi).toggleNavScreen();
} else if (mMore == v) {
showMenu(mMore);
+ } else if (mClearButton == v) {
+ mUrlInput.setText("");
} else {
super.onClick(v);
}
@@ -209,6 +216,8 @@ public class NavigationBarPhone extends NavigationBarBase implements
case StateListener.STATE_NORMAL:
mComboIcon.setVisibility(View.VISIBLE);
mStopButton.setVisibility(View.GONE);
+ mClearButton.setVisibility(View.GONE);
+ mMagnify.setVisibility(View.GONE);
setSearchMode(mInVoiceMode);
mTabSwitcher.setVisibility(View.VISIBLE);
mTitleContainer.setBackgroundDrawable(null);
@@ -217,6 +226,8 @@ public class NavigationBarPhone extends NavigationBarBase implements
case StateListener.STATE_HIGHLIGHTED:
mComboIcon.setVisibility(View.GONE);
mStopButton.setVisibility(View.VISIBLE);
+ mClearButton.setVisibility(View.GONE);
+ mMagnify.setVisibility(View.GONE);
setSearchMode(true);
mTabSwitcher.setVisibility(View.GONE);
mMore.setVisibility(View.GONE);
@@ -225,6 +236,8 @@ public class NavigationBarPhone extends NavigationBarBase implements
case StateListener.STATE_EDITED:
mComboIcon.setVisibility(View.GONE);
mStopButton.setVisibility(View.GONE);
+ mClearButton.setVisibility(View.VISIBLE);
+ mMagnify.setVisibility(View.VISIBLE);
setSearchMode(false);
mTabSwitcher.setVisibility(View.GONE);
mMore.setVisibility(View.GONE);
diff --git a/src/com/android/browser/UrlInputView.java b/src/com/android/browser/UrlInputView.java
index 2acc69b..fbdf400 100644
--- a/src/com/android/browser/UrlInputView.java
+++ b/src/com/android/browser/UrlInputView.java
@@ -56,6 +56,8 @@ public class UrlInputView extends SuggestiveAutoCompleteTextView
static final String SUGGESTED = "browser-suggest";
static final String VOICE = "voice-search";
+ static final int POST_DELAY = 100;
+
static interface StateListener {
static final int STATE_NORMAL = 0;
static final int STATE_HIGHLIGHTED = 1;
@@ -123,16 +125,23 @@ public class UrlInputView extends SuggestiveAutoCompleteTextView
protected void onFocusChanged(boolean focused, int direction, Rect prevRect) {
super.onFocusChanged(focused, direction, prevRect);
+ int state = -1;
if (focused) {
if (hasSelection()) {
- changeState(StateListener.STATE_HIGHLIGHTED);
+ state = StateListener.STATE_HIGHLIGHTED;
} else {
- changeState(StateListener.STATE_EDITED);
+ state = StateListener.STATE_EDITED;
}
} else {
// reset the selection state
- changeState(StateListener.STATE_NORMAL);
+ state = StateListener.STATE_NORMAL;
}
+ final int s = state;
+ post(new Runnable() {
+ public void run() {
+ changeState(s);
+ }
+ });
}
@Override
@@ -141,7 +150,10 @@ public class UrlInputView extends SuggestiveAutoCompleteTextView
boolean res = super.onTouchEvent(evt);
if ((MotionEvent.ACTION_DOWN == evt.getActionMasked())
&& hasSelection) {
- changeState(StateListener.STATE_EDITED);
+ postDelayed(new Runnable() {
+ public void run() {
+ changeState(StateListener.STATE_EDITED);
+ }}, POST_DELAY);
}
return res;
}