diff options
author | Ben Murdoch <benm@google.com> | 2010-11-16 11:58:21 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-11-23 12:14:30 +0000 |
commit | 8029a777106fa6fb911ee1d58402b0de768a583a (patch) | |
tree | 9bad7ba26817f4fa97271ad544f8f7fa09fc0e90 /src | |
parent | 1514bb7ed5656316a8dac966cee21653f3c59aff (diff) | |
download | packages_apps_Browser-8029a777106fa6fb911ee1d58402b0de768a583a.zip packages_apps_Browser-8029a777106fa6fb911ee1d58402b0de768a583a.tar.gz packages_apps_Browser-8029a777106fa6fb911ee1d58402b0de768a583a.tar.bz2 |
Invite the user to set up AutoFill
If the user has not set up an AutoFill profile but has the
feature enabled and they start to fill out a form that we
have determined as "autofillable" then offer to take them
to the profile editor to set up their profile.
Change-Id: Ia44c7036ef616d4ea826e541471dd916262488f2
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/BrowserSettings.java | 7 | ||||
-rw-r--r-- | src/com/android/browser/Controller.java | 24 | ||||
-rw-r--r-- | src/com/android/browser/Tab.java | 30 | ||||
-rw-r--r-- | src/com/android/browser/WebViewController.java | 3 |
4 files changed, 64 insertions, 0 deletions
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index 069f886..ab2ddb2 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -567,6 +567,13 @@ public class BrowserSettings extends Observable { ed.apply(); } + /* package */ void disableAutoFill(Context ctx) { + autoFillEnabled = false; + Editor ed = PreferenceManager.getDefaultSharedPreferences(ctx).edit(); + ed.putBoolean(PREF_AUTOFILL_ENABLED, false); + ed.apply(); + } + /** * Add a WebSettings object to the list of observers that will be updated * when update() is called. diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index e0b15b4..41e7356 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -47,6 +47,7 @@ import android.os.Handler; import android.os.Message; import android.os.PowerManager; import android.os.PowerManager.WakeLock; +import android.preference.PreferenceActivity; import android.provider.Browser; import android.provider.BrowserContract; import android.provider.BrowserContract.History; @@ -114,6 +115,8 @@ public class Controller // activity requestCode final static int PREFERENCES_PAGE = 3; final static int FILE_SELECTED = 4; + final static int AUTOFILL_SETUP = 5; + private final static int WAKELOCK_TIMEOUT = 5 * 60 * 1000; // 5 minutes // As the ids are dynamically created, we can't guarantee that they will @@ -143,6 +146,8 @@ public class Controller private PageDialogsHandler mPageDialogsHandler; private NetworkStateHandler mNetworkHandler; + private Message mAutoFillSetupMessage; + private boolean mShouldShowErrorConsole; private SystemAllowGeolocationOrigins mSystemAllowGeolocationOrigins; @@ -1050,6 +1055,15 @@ public class Controller mUploadHandler.onResult(resultCode, intent); mUploadHandler = null; break; + case AUTOFILL_SETUP: + // Determine whether a profile was actually set up or not + // and if so, send the message back to the WebTextView to + // fill the form with the new profile. + if (getSettings().getAutoFillProfile() != null) { + mAutoFillSetupMessage.sendToTarget(); + mAutoFillSetupMessage = null; + } + break; default: break; } @@ -2409,4 +2423,14 @@ public class Controller return mMenuIsDown; } + public void setupAutoFill(Message message) { + // Open the settings activity at the AutoFill profile fragment so that + // the user can create a new profile. When they return, we will dispatch + // the message so that we can autofill the form using their new profile. + Intent intent = new Intent(mActivity, BrowserPreferencesPage.class); + intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, + AutoFillSettingsFragment.class.getName()); + mAutoFillSetupMessage = message; + mActivity.startActivityForResult(intent, AUTOFILL_SETUP); + } } diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index b12b317..0f8ce6b 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -54,6 +54,7 @@ import android.webkit.WebViewClient; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TextView; +import android.widget.Toast; import java.util.ArrayList; import java.util.HashMap; @@ -1061,6 +1062,35 @@ class Tab { public void getVisitedHistory(final ValueCallback<String[]> callback) { mWebViewController.getVisitedHistory(callback); } + + @Override + public void setupAutoFill(Message message) { + // 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(); + } }; // ------------------------------------------------------------------------- diff --git a/src/com/android/browser/WebViewController.java b/src/com/android/browser/WebViewController.java index 8c99c58..eeeee18 100644 --- a/src/com/android/browser/WebViewController.java +++ b/src/com/android/browser/WebViewController.java @@ -22,6 +22,7 @@ import android.app.Activity; import android.graphics.Bitmap; import android.net.Uri; import android.net.http.SslError; +import android.os.Message; import android.view.KeyEvent; import android.view.View; import android.webkit.HttpAuthHandler; @@ -102,4 +103,6 @@ public interface WebViewController { void closeTab(Tab tab); + void setupAutoFill(Message message); + } |