Bug 771525 - Back button should dismiss the Find In Page bar [r=bnicholson]

This commit is contained in:
Matt Brubeck 2012-07-11 16:04:49 -07:00
Родитель 6d1fc8c035
Коммит ab4793bfd8
7 изменённых файлов: 57 добавлений и 33 удалений

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

@ -65,7 +65,7 @@ public class AwesomeBar extends GeckoActivity {
private String mTarget;
private AwesomeBarTabs mAwesomeTabs;
private AwesomeBarEditText mText;
private CustomEditText mText;
private ImageButton mGoButton;
private ContentResolver mResolver;
private ContextMenuSubject mContextMenuSubject;
@ -82,7 +82,7 @@ public class AwesomeBar extends GeckoActivity {
setContentView(R.layout.awesomebar);
mGoButton = (ImageButton) findViewById(R.id.awesomebar_button);
mText = (AwesomeBarEditText) findViewById(R.id.awesomebar_text);
mText = (CustomEditText) findViewById(R.id.awesomebar_text);
TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
tabWidget.setDividerDrawable(null);
@ -124,7 +124,7 @@ public class AwesomeBar extends GeckoActivity {
mText.selectAll();
}
mText.setOnKeyPreImeListener(new AwesomeBarEditText.OnKeyPreImeListener() {
mText.setOnKeyPreImeListener(new CustomEditText.OnKeyPreImeListener() {
public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) {
// We only want to process one event per tap
if (event.getAction() != KeyEvent.ACTION_DOWN)
@ -591,28 +591,4 @@ public class AwesomeBar extends GeckoActivity {
return false;
}
public static class AwesomeBarEditText extends EditText {
OnKeyPreImeListener mOnKeyPreImeListener;
public interface OnKeyPreImeListener {
public boolean onKeyPreIme(View v, int keyCode, KeyEvent event);
}
public AwesomeBarEditText(Context context, AttributeSet attrs) {
super(context, attrs);
mOnKeyPreImeListener = null;
}
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (mOnKeyPreImeListener != null)
return mOnKeyPreImeListener.onKeyPreIme(this, keyCode, event);
return false;
}
public void setOnKeyPreImeListener(OnKeyPreImeListener listener) {
mOnKeyPreImeListener = listener;
}
}
}

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

@ -0,0 +1,37 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko;
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
public class CustomEditText extends EditText {
OnKeyPreImeListener mOnKeyPreImeListener;
public interface OnKeyPreImeListener {
public boolean onKeyPreIme(View v, int keyCode, KeyEvent event);
}
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
mOnKeyPreImeListener = null;
}
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (mOnKeyPreImeListener != null)
return mOnKeyPreImeListener.onKeyPreIme(this, keyCode, event);
return false;
}
public void setOnKeyPreImeListener(OnKeyPreImeListener listener) {
mOnKeyPreImeListener = listener;
}
}

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

@ -9,10 +9,10 @@ import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
@ -20,7 +20,7 @@ public class FindInPageBar extends RelativeLayout implements TextWatcher, View.O
private static final String LOGTAG = "GeckoFindInPagePopup";
private final Context mContext;
private EditText mFindText;
private CustomEditText mFindText;
private boolean mInflated = false;
public FindInPageBar(Context context, AttributeSet attrs) {
@ -37,8 +37,17 @@ public class FindInPageBar extends RelativeLayout implements TextWatcher, View.O
content.findViewById(R.id.find_next).setOnClickListener(this);
content.findViewById(R.id.find_close).setOnClickListener(this);
mFindText = (EditText) content.findViewById(R.id.find_text);
mFindText = (CustomEditText) content.findViewById(R.id.find_text);
mFindText.addTextChangedListener(this);
mFindText.setOnKeyPreImeListener(new CustomEditText.OnKeyPreImeListener() {
public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
hide();
return true;
}
return false;
}
});
mInflated = true;
}

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

@ -76,6 +76,7 @@ FENNEC_JAVA_FILES = \
MenuItemDefault.java \
MultiChoicePreference.java \
NSSBridge.java \
CustomEditText.java \
PrivateDataPreference.java \
PropertyAnimator.java \
ProfileMigrator.java \

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

@ -14,7 +14,7 @@
android:background="@drawable/tabs_normal"
android:gravity="center_vertical"/>
<view class="org.mozilla.gecko.AwesomeBar$AwesomeBarEditText"
<view class="org.mozilla.gecko.CustomEditText"
android:id="@+id/awesomebar_text"
style="@style/AddressBar.Button"
android:background="@drawable/address_bar_url"

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

@ -7,7 +7,7 @@
style="@style/AwesomeBar"
android:background="@drawable/address_bar_bg">
<view class="org.mozilla.gecko.AwesomeBar$AwesomeBarEditText"
<view class="org.mozilla.gecko.CustomEditText"
android:id="@+id/awesomebar_text"
style="@style/AddressBar.Button"
android:background="@drawable/address_bar_url"

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

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<EditText android:id="@+id/find_text"
<view class="org.mozilla.gecko.CustomEditText"
android:id="@+id/find_text"
android:contentDescription="@string/find_text"
android:background="@drawable/address_bar_url"
android:singleLine="true"