summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/FindDialog.java
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2010-04-19 13:21:13 -0400
committerLeon Scroggins III <scroggo@google.com>2010-05-06 11:42:12 -0400
commit211ba54a3052f7e68bf8af035ea1ef4e9445130c (patch)
tree08deedf1efe1dca7626ffec910191a435f968e79 /src/com/android/browser/FindDialog.java
parent875dfa2ba28db2d243e44722c69009377377e5b2 (diff)
downloadpackages_apps_Browser-211ba54a3052f7e68bf8af035ea1ef4e9445130c.tar.gz
packages_apps_Browser-211ba54a3052f7e68bf8af035ea1ef4e9445130c.tar.bz2
packages_apps_Browser-211ba54a3052f7e68bf8af035ea1ef4e9445130c.zip
Allow interaction with page while Find is up.
In order to do this, I have changed the FindDialog from an actual Dialog, which steals all touch events, to a Linearlayout, which rests below the WebView. Also dismiss Find when the user opens/closes a subwindow, or navigates to a new page. res/layout/browser_subwindow.xml: Add an id to the holder for the subwindow, so it can be used to add the FindDialog. res/values/styles.xml: Remove the style for FindDialog, as the animations are now added in code (since FindDialog is now a LinearLayout, which has no theme). res/values/themes.xml: Deleted, as the only theme there was FindDialog, which has been removed. src/com/android/browser/BrowserActivity.java: closeFind is now the starting point for removing the FindDialog, so that it can be called from Tab. Close the FindDialog when a new page starts loading. Call showFind on the current Tab. src/com/android/browser/FindDialog.java Change from a Dialog to a LinearLayout, so it can be inserted into the layout. Call closeFind directly, which now calls dismiss. Perform the animations which were previously part of the theme. Remove the call to set the height of the find dialog, which is no longer necessary. Open and close the IME when opening and closing Find. src/com/android/browser/Tab.java Change pointer to mContainer to a LinearLayout, which is used to add the FindDialog. Add a pointer to BrowserActivity to SubWindowClient, which is then used to close the FindDialog in onPageStarted. Close find when adding/removing a Tab or its subwindow. Add showFind, which attaches it to the layout for the tab, and closeFind, which removes it from the layout. Requires a change to frameworks/base Change-Id: If6745fb65c5628da827781a7b98061e87b279844
Diffstat (limited to 'src/com/android/browser/FindDialog.java')
-rw-r--r--src/com/android/browser/FindDialog.java71
1 files changed, 38 insertions, 33 deletions
diff --git a/src/com/android/browser/FindDialog.java b/src/com/android/browser/FindDialog.java
index 45c801694..caff852a6 100644
--- a/src/com/android/browser/FindDialog.java
+++ b/src/com/android/browser/FindDialog.java
@@ -16,24 +16,23 @@
package com.android.browser;
-import android.app.Dialog;
import android.content.Context;
-import android.os.Bundle;
import android.text.Editable;
import android.text.Spannable;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.KeyEvent;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.Window;
-import android.view.WindowManager;
+import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebView;
import android.widget.EditText;
+import android.widget.LinearLayout;
import android.widget.TextView;
-/* package */ class FindDialog extends Dialog implements TextWatcher {
+/* package */ class FindDialog extends LinearLayout implements TextWatcher {
private WebView mWebView;
private TextView mMatches;
private BrowserActivity mBrowserActivity;
@@ -53,7 +52,7 @@ import android.widget.TextView;
private View.OnClickListener mFindCancelListener =
new View.OnClickListener() {
public void onClick(View v) {
- dismiss();
+ mBrowserActivity.closeFind();
}
};
@@ -89,22 +88,11 @@ import android.widget.TextView;
}
/* package */ FindDialog(BrowserActivity context) {
- super(context, R.style.FindDialogTheme);
+ super(context);
mBrowserActivity = context;
- setCanceledOnTouchOutside(true);
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Window theWindow = getWindow();
- theWindow.setGravity(Gravity.BOTTOM|Gravity.FILL_HORIZONTAL);
- setContentView(R.layout.browser_find);
-
- theWindow.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT);
+ LayoutInflater factory = LayoutInflater.from(context);
+ factory.inflate(R.layout.browser_find, this);
mEditText = (EditText) findViewById(R.id.edit);
@@ -122,23 +110,38 @@ import android.widget.TextView;
mMatches = (TextView) findViewById(R.id.matches);
mMatchesView = findViewById(R.id.matches_view);
disableButtons();
- theWindow.setSoftInputMode(
- WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
+
}
-
+
+ /**
+ * Called by BrowserActivity.closeFind. Start the animation to hide
+ * the dialog, inform the WebView that the dialog is being dismissed,
+ * and hide the soft keyboard.
+ */
public void dismiss() {
- super.dismiss();
- mBrowserActivity.closeFind();
mWebView.notifyFindDialogDismissed();
+ startAnimation(AnimationUtils.loadAnimation(mBrowserActivity,
+ R.anim.find_dialog_exit));
+ InputMethodManager imm = (InputMethodManager)
+ getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+
+ imm.hideSoftInputFromWindow(this.getWindowToken(), 0);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
- if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER
- && event.getAction() == KeyEvent.ACTION_UP
- && mEditText.hasFocus()) {
- findNext();
- return true;
+ int keyCode = event.getKeyCode();
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ if (event.getAction() == KeyEvent.ACTION_UP) {
+ mBrowserActivity.closeFind();
+ return true;
+ }
+ } else if (event.getAction() == KeyEvent.ACTION_UP) {
+ if (keyCode == KeyEvent.KEYCODE_ENTER
+ && mEditText.hasFocus()) {
+ findNext();
+ return true;
+ }
}
return super.dispatchKeyEvent(event);
}
@@ -152,7 +155,6 @@ import android.widget.TextView;
}
public void show() {
- super.show();
mEditText.requestFocus();
mEditText.setText("");
Spannable span = (Spannable) mEditText.getText();
@@ -160,6 +162,11 @@ import android.widget.TextView;
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
setMatchesFound(0);
disableButtons();
+ startAnimation(AnimationUtils.loadAnimation(mBrowserActivity,
+ R.anim.find_dialog_enter));
+ InputMethodManager imm = (InputMethodManager)
+ mBrowserActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.showSoftInput(mEditText, 0);
}
// TextWatcher methods
@@ -184,8 +191,6 @@ import android.widget.TextView;
mMatchesView.setVisibility(View.INVISIBLE);
} else {
mMatchesView.setVisibility(View.VISIBLE);
- mWebView.setFindDialogHeight(
- getWindow().getDecorView().getHeight());
int found = mWebView.findAll(find.toString());
setMatchesFound(found);
if (found < 2) {