Add a "disable autofill" checkbox to the setup prompt
Make the intent of the buttons in the setup autofill dialog
clearer by adding an option to disable the feature. The cancel
button now simply dismisses the dialog and we only disable the
feature if the user checks the new box and clicks OK. Clicking OK
without checking the box takes the user to the prdoile editor as
before.
Bug:3348828
Change-Id: Ib54b879b6953d0c8865d50374188059a43a8e6ba
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index d70b0ef..0347ef5 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -53,6 +53,7 @@
import android.webkit.WebStorage;
import android.webkit.WebView;
import android.webkit.WebViewClient;
+import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -1124,28 +1125,36 @@
// Prompt the user to set up their profile.
final Message msg = message;
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
- builder.setMessage(R.string.autofill_setup_dialog_message)
- .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- // Take user to the AutoFill profile editor. When they return,
- // we will send the message that we pass here which will trigger
- // the form to get filled out with their new profile.
- mWebViewController.setupAutoFill(msg);
- }
- })
- .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- // Disable autofill and show a toast with how to turn it on again.
- BrowserSettings s = BrowserSettings.getInstance();
- s.addObserver(mMainView.getSettings());
- s.disableAutoFill(mActivity);
- s.update();
- Toast.makeText(mActivity, R.string.autofill_setup_dialog_negative_toast,
- Toast.LENGTH_LONG).show();
- }
- }).show();
+ LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ final View layout = inflater.inflate(R.layout.setup_autofill_dialog, null);
+
+ builder.setView(layout)
+ .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ CheckBox disableAutoFill = (CheckBox) layout.findViewById(
+ R.id.setup_autofill_dialog_disable_autofill);
+
+ if (disableAutoFill.isChecked()) {
+ // Disable autofill and show a toast with how to turn it on again.
+ BrowserSettings s = BrowserSettings.getInstance();
+ s.addObserver(mMainView.getSettings());
+ s.disableAutoFill(mActivity);
+ s.update();
+ Toast.makeText(mActivity,
+ R.string.autofill_setup_dialog_negative_toast,
+ Toast.LENGTH_LONG).show();
+ } else {
+ // Take user to the AutoFill profile editor. When they return,
+ // we will send the message that we pass here which will trigger
+ // the form to get filled out with their new profile.
+ mWebViewController.setupAutoFill(msg);
+ }
+ }
+ })
+ .setNegativeButton(R.string.cancel, null)
+ .show();
}
};