diff options
Diffstat (limited to 'src/com/android/browser/BrowserActivity.java')
-rw-r--r-- | src/com/android/browser/BrowserActivity.java | 90 |
1 files changed, 80 insertions, 10 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 5e55789..8db4436 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -834,6 +834,13 @@ public class BrowserActivity extends Activity if (mainView == null) { return; } + // Do not need to check for null, since the current tab will have + // at least a main WebView, or we would have returned above. + if (dialogIsUp()) { + // Do not show the fake title bar, which would cover up the + // find or select dialog. + return; + } WindowManager manager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); @@ -1271,6 +1278,22 @@ public class BrowserActivity extends Activity getTopWindow().requestFocus(); } + private WebView showDialog(WebDialog dialog) { + // Need to do something special for Tablet + Tab tab = mTabControl.getCurrentTab(); + if (tab.getSubWebView() == null) { + // If the find or select is being performed on the main webview, + // remove the embedded title bar. + WebView mainView = tab.getWebView(); + if (mainView != null) { + mainView.setEmbeddedTitleBar(null); + } + } + hideFakeTitleBar(); + mMenuState = EMPTY_MENU; + return tab.showDialog(dialog); + } + @Override public boolean onOptionsItemSelected(MenuItem item) { if (!mCanChord) { @@ -1364,18 +1387,13 @@ public class BrowserActivity extends Activity break; case R.id.find_menu_id: - if (null == mFindDialog) { - mFindDialog = new FindDialog(this); - } - mFindDialog.setWebView(getTopWindow()); - mFindDialog.show(); - getTopWindow().setFindIsUp(true); - mMenuState = EMPTY_MENU; + showFindDialog(); break; case R.id.select_text_id: - getTopWindow().emulateShiftHeld(); + showSelectDialog(); break; + case R.id.page_info_menu_id: showPageInfo(mTabControl.getCurrentTab(), false); break; @@ -1450,8 +1468,59 @@ public class BrowserActivity extends Activity return true; } - public void closeFind() { + private boolean dialogIsUp() { + return null != mFindDialog && mFindDialog.isVisible() || + null != mSelectDialog && mSelectDialog.isVisible(); + } + + private boolean closeDialog(WebDialog dialog) { + if (null == dialog || !dialog.isVisible()) return false; + Tab currentTab = mTabControl.getCurrentTab(); + currentTab.closeDialog(dialog); + dialog.dismiss(); + return true; + } + + /* + * Remove the find dialog or select dialog. + */ + public void closeDialogs() { + if (!(closeDialog(mFindDialog) || closeDialog(mSelectDialog))) return; + // If the Find was being performed in the main WebView, replace the + // embedded title bar. + Tab currentTab = mTabControl.getCurrentTab(); + if (currentTab.getSubWebView() == null) { + WebView mainView = currentTab.getWebView(); + if (mainView != null) { + mainView.setEmbeddedTitleBar(mTitleBar); + } + } mMenuState = R.id.MAIN_MENU; + if (mInLoad) { + // The title bar was hidden, because otherwise it would cover up the + // find or select dialog. Now that the dialog has been removed, + // show the fake title bar once again. + showFakeTitleBar(); + } + } + + public void showFindDialog() { + if (null == mFindDialog) { + mFindDialog = new FindDialog(this); + } + showDialog(mFindDialog).setFindIsUp(true); + } + + public void setFindDialogText(String text) { + mFindDialog.setText(text); + } + + public void showSelectDialog() { + if (null == mSelectDialog) { + mSelectDialog = new SelectDialog(this); + } + showDialog(mSelectDialog).setUpSelect(); + mSelectDialog.hideSoftInput(); } @Override @@ -2462,7 +2531,7 @@ public class BrowserActivity extends Activity onProgressChanged(view, INITIAL_PROGRESS); mDidStopLoad = false; if (!mIsNetworkUp) createAndShowNetworkDialog(); - + closeDialogs(); if (mSettings.isTracing()) { String host; try { @@ -3770,6 +3839,7 @@ public class BrowserActivity extends Activity private Menu mMenu; private FindDialog mFindDialog; + private SelectDialog mSelectDialog; // Used to prevent chording to result in firing two shortcuts immediately // one after another. Fixes bug 1211714. boolean mCanChord; |