diff options
| author | 2019-11-27 13:15:48 +0000 | |
|---|---|---|
| committer | 2019-11-27 13:15:48 +0000 | |
| commit | db0b8bfd098721b0ac38ce7840c50cd2f8bf2ed5 (patch) | |
| tree | 773616bbb0cc50edc6e29b242266d90856870378 | |
| parent | 0715e47f92a8c3bb398a06dda127d11733b141fa (diff) | |
| parent | 67428261d2802812b04865d8668866a991c1d231 (diff) | |
Merge "Improves text of the negative button on the save UI"
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/service/autofill/SaveInfo.java | 20 | ||||
| -rw-r--r-- | core/res/res/values/strings.xml | 5 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 2 | ||||
| -rw-r--r-- | services/autofill/java/com/android/server/autofill/ui/FillUi.java | 2 | ||||
| -rw-r--r-- | services/autofill/java/com/android/server/autofill/ui/SaveUi.java | 15 |
6 files changed, 33 insertions, 12 deletions
diff --git a/api/current.txt b/api/current.txt index f1c03a4e576d..f74c765574cd 100644 --- a/api/current.txt +++ b/api/current.txt @@ -41525,6 +41525,7 @@ package android.service.autofill { field public static final int FLAG_DONT_SAVE_ON_FINISH = 2; // 0x2 field public static final int FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE = 1; // 0x1 field public static final int NEGATIVE_BUTTON_STYLE_CANCEL = 0; // 0x0 + field public static final int NEGATIVE_BUTTON_STYLE_NEVER = 2; // 0x2 field public static final int NEGATIVE_BUTTON_STYLE_REJECT = 1; // 0x1 field public static final int POSITIVE_BUTTON_STYLE_CONTINUE = 1; // 0x1 field public static final int POSITIVE_BUTTON_STYLE_SAVE = 0; // 0x0 diff --git a/core/java/android/service/autofill/SaveInfo.java b/core/java/android/service/autofill/SaveInfo.java index 48ba4295f3c8..4df43628b5d3 100644 --- a/core/java/android/service/autofill/SaveInfo.java +++ b/core/java/android/service/autofill/SaveInfo.java @@ -216,10 +216,21 @@ public final class SaveInfo implements Parcelable { */ public static final int NEGATIVE_BUTTON_STYLE_REJECT = 1; + /** + * Style for the negative button of the save UI to never do the + * save operation. This means that the user does not need to save + * any data on this activity or application. Once the user tapping + * the negative button, the service should never trigger the save + * UI again. In addition to this, must consider providing restore + * options for the user. + */ + public static final int NEGATIVE_BUTTON_STYLE_NEVER = 2; + /** @hide */ @IntDef(prefix = { "NEGATIVE_BUTTON_STYLE_" }, value = { NEGATIVE_BUTTON_STYLE_CANCEL, - NEGATIVE_BUTTON_STYLE_REJECT + NEGATIVE_BUTTON_STYLE_REJECT, + NEGATIVE_BUTTON_STYLE_NEVER }) @Retention(RetentionPolicy.SOURCE) @interface NegativeButtonStyle{} @@ -571,6 +582,7 @@ public final class SaveInfo implements Parcelable { * * @see #NEGATIVE_BUTTON_STYLE_CANCEL * @see #NEGATIVE_BUTTON_STYLE_REJECT + * @see #NEGATIVE_BUTTON_STYLE_NEVER * * @throws IllegalArgumentException If the style is invalid */ @@ -578,11 +590,7 @@ public final class SaveInfo implements Parcelable { @Nullable IntentSender listener) { throwIfDestroyed(); Preconditions.checkArgumentInRange(style, NEGATIVE_BUTTON_STYLE_CANCEL, - NEGATIVE_BUTTON_STYLE_REJECT, "style"); - if (style != NEGATIVE_BUTTON_STYLE_CANCEL - && style != NEGATIVE_BUTTON_STYLE_REJECT) { - throw new IllegalArgumentException("Invalid style: " + style); - } + NEGATIVE_BUTTON_STYLE_NEVER, "style"); mNegativeButtonStyle = style; mNegativeActionListener = listener; return this; diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index a0aa18690b51..2d31f4910335 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -5083,11 +5083,14 @@ data (for example, username, password and credit card info) [CHAR LIMIT=NONE] --> <string name="autofill_update_title_with_3types">Update these items in <b><xliff:g id="label" example="MyPass">%4$s</xliff:g></b>: <xliff:g id="type" example="Username">%1$s</xliff:g>, <xliff:g id="type" example="Password">%2$s</xliff:g>, and <xliff:g id="type" example="Credit Card">%3$s</xliff:g> ?</string> - <!-- Label for the autofill save button [CHAR LIMIT=NONE] --> <string name="autofill_save_yes">Save</string> <!-- Label for the autofill cancel button [CHAR LIMIT=NONE] --> <string name="autofill_save_no">No thanks</string> + <!-- Label for the autofill cancel button, saying not to save the filled data at this moment. [CHAR LIMIT=NONE] --> + <string name="autofill_save_notnow">Not now</string> + <!-- Label for the autofill reject button, saying never to save the filled data. [CHAR LIMIT=NONE] --> + <string name="autofill_save_never">Never</string> <!-- Label for the autofill update button [CHAR LIMIT=NONE] --> <string name="autofill_update_yes">Update</string> <!-- Label for the autofill continue button [CHAR LIMIT=NONE] --> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index e93c9bd458a5..130b31f092e0 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3248,6 +3248,8 @@ <java-symbol type="string" name="autofill_save_title_with_3types" /> <java-symbol type="string" name="autofill_save_yes" /> <java-symbol type="string" name="autofill_save_no" /> + <java-symbol type="string" name="autofill_save_notnow" /> + <java-symbol type="string" name="autofill_save_never" /> <java-symbol type="string" name="autofill_save_type_password" /> <java-symbol type="string" name="autofill_save_type_address" /> <java-symbol type="string" name="autofill_save_type_credit_card" /> diff --git a/services/autofill/java/com/android/server/autofill/ui/FillUi.java b/services/autofill/java/com/android/server/autofill/ui/FillUi.java index 70fb535bed57..57961423061f 100644 --- a/services/autofill/java/com/android/server/autofill/ui/FillUi.java +++ b/services/autofill/java/com/android/server/autofill/ui/FillUi.java @@ -383,7 +383,7 @@ final class FillUi { } child.setOnClickListener((v) -> { if (sVerbose) { - Slog.v(TAG, "Applying " + id + " after " + v + " was clicked"); + Slog.v(TAG, " Cancelling session after " + v + " clicked"); } mCallback.cancelSession(); }); diff --git a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java index d7114a0b9a62..8eea04759cdb 100644 --- a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java +++ b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java @@ -291,10 +291,17 @@ final class SaveUi { } final TextView noButton = view.findViewById(R.id.autofill_save_no); - if (info.getNegativeActionStyle() == SaveInfo.NEGATIVE_BUTTON_STYLE_REJECT) { - noButton.setText(R.string.save_password_notnow); - } else { - noButton.setText(R.string.autofill_save_no); + final int negativeActionStyle = info.getNegativeActionStyle(); + switch (negativeActionStyle) { + case SaveInfo.NEGATIVE_BUTTON_STYLE_REJECT: + noButton.setText(R.string.autofill_save_notnow); + break; + case SaveInfo.NEGATIVE_BUTTON_STYLE_NEVER: + noButton.setText(R.string.autofill_save_never); + break; + case SaveInfo.NEGATIVE_BUTTON_STYLE_CANCEL: + default: + noButton.setText(R.string.autofill_save_no); } noButton.setOnClickListener((v) -> mListener.onCancel(info.getNegativeActionListener())); |