Browser: add to support exit prompt feature
Add for carrier feature.When user click exit menu or press back key
to exit browser,it will show a dialog to let user choose quit or
minimize browser.
CRs-Fixed: 507959
Change-Id: Ic4c2bcf94b0054e24591ebbc87c7a1a786d14995
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index e84358f..8e118a1 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -17,6 +17,7 @@
package com.android.browser;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DownloadManager;
import android.app.ProgressDialog;
@@ -1652,8 +1653,8 @@
String ret = SystemProperties.get("persist.debug.browsermonkeytest");
if (ret != null && ret.equals("enable"))
break;
- onPause();
- return false;
+ showExitDialog(mActivity);
+ return true;
case R.id.homepage_menu_id:
Tab current = mTabControl.getCurrentTab();
@@ -1835,6 +1836,35 @@
t.loadUrl(t.getUrl(), null);
}
+ private void showExitDialog(final Activity activity) {
+ new AlertDialog.Builder(activity)
+ .setTitle(R.string.exit_browser_title)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setMessage(R.string.exit_browser_msg)
+ .setNegativeButton(R.string.exit_minimize, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ activity.moveTaskToBack(true);
+ dialog.dismiss();
+ }
+ })
+ .setPositiveButton(R.string.exit_quit, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ activity.finish();
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+ mCrashRecoveryHandler.clearState(true);
+ int pid = android.os.Process.myPid();
+ android.os.Process.killProcess(pid);
+ }
+ }, 300);
+ dialog.dismiss();
+ }
+ })
+ .show();
+ }
+
@Override
public void showPageInfo() {
mPageDialogsHandler.showPageInfo(mTabControl.getCurrentTab(), false, null);
@@ -2638,7 +2668,7 @@
* root of the task. So we can use either true or false for
* moveTaskToBack().
*/
- mActivity.moveTaskToBack(true);
+ showExitDialog(mActivity);
return;
}
if (current.canGoBack()) {
@@ -2652,9 +2682,6 @@
// Now we close the other tab
closeTab(current);
} else {
- if ((current.getAppId() != null) || current.closeOnBack()) {
- closeCurrentTab(true);
- }
/*
* Instead of finishing the activity, simply push this to the back
* of the stack and let ActivityManager to choose the foreground
@@ -2662,7 +2689,7 @@
* root of the task. So we can use either true or false for
* moveTaskToBack().
*/
- mActivity.moveTaskToBack(true);
+ showExitDialog(mActivity);
}
}
}