diff options
| author | Menny Even Danan <menny@evendanan.net> | 2020-06-21 03:11:45 +0000 |
|---|---|---|
| committer | Menny Even Danan <menny@evendanan.net> | 2020-06-21 03:11:45 +0000 |
| commit | 3e0f5e98103b53b553fecec65c2f4db458f17d5f (patch) | |
| tree | 116cb7a51fcf9dca7842464a221a711aab9b90bd | |
| parent | 492e2b632416bc64a867132b070d65ae5bcdb6b3 (diff) | |
| download | AnySoftKeyboard-3e0f5e98103b53b553fecec65c2f4db458f17d5f.tar.gz AnySoftKeyboard-3e0f5e98103b53b553fecec65c2f4db458f17d5f.tar.bz2 | |
Fix issue with password field detection
This was in clipboard suggestion action.
3 files changed, 55 insertions, 22 deletions
diff --git a/ime/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardClipboard.java b/ime/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardClipboard.java index cba90db8b..a9cac24c0 100644 --- a/ime/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardClipboard.java +++ b/ime/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardClipboard.java @@ -7,7 +7,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.support.annotation.VisibleForTesting; -import android.text.InputType; import android.text.TextUtils; import android.view.KeyCharacterMap; import android.view.KeyEvent; @@ -139,17 +138,21 @@ public abstract class AnySoftKeyboardClipboard extends AnySoftKeyboardSwipeListe && !TextUtils.isEmpty(mLastSyncedClipboardEntry)) { getInputViewContainer().addStripAction(mSuggestionClipboardEntry); getInputViewContainer().setActionsStripVisibility(true); - final int variation = (info.inputType & InputType.TYPE_MASK_VARIATION); mSuggestionClipboardEntry.setClipboardText( - mLastSyncedClipboardEntry, - (variation & InputType.TYPE_TEXT_VARIATION_PASSWORD) - == InputType.TYPE_TEXT_VARIATION_PASSWORD - || (variation & InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) - == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD - || - // InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD - (variation & 0x000000e0) == 0x000000e0); + mLastSyncedClipboardEntry, isTextPassword(info)); + } + } + + protected static boolean isTextPassword(EditorInfo info) { + if ((info.inputType & EditorInfo.TYPE_CLASS_TEXT) == 0) return false; + switch (info.inputType & EditorInfo.TYPE_MASK_VARIATION) { + case EditorInfo.TYPE_TEXT_VARIATION_PASSWORD: + case EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD: + case EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD: + return true; + default: + return false; } } diff --git a/ime/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardIncognito.java b/ime/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardIncognito.java index 0715fb709..bd4b28690 100644 --- a/ime/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardIncognito.java +++ b/ime/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardIncognito.java @@ -22,18 +22,6 @@ public abstract class AnySoftKeyboardIncognito extends AnySoftKeyboardWithGestur } } - private static boolean isTextPassword(EditorInfo info) { - if ((info.inputType & EditorInfo.TYPE_CLASS_TEXT) == 0) return false; - switch (info.inputType & EditorInfo.TYPE_MASK_VARIATION) { - case EditorInfo.TYPE_TEXT_VARIATION_PASSWORD: - case EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD: - case EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD: - return true; - default: - return false; - } - } - private static boolean isNumberPassword(EditorInfo info) { return (info.inputType & NUMBER_INCOGNITO_TYPE) == NUMBER_INCOGNITO_TYPE; } diff --git a/ime/app/src/test/java/com/anysoftkeyboard/ime/AnySoftKeyboardClipboardTest.java b/ime/app/src/test/java/com/anysoftkeyboard/ime/AnySoftKeyboardClipboardTest.java index 0efbcc2ad..6bee4d484 100644 --- a/ime/app/src/test/java/com/anysoftkeyboard/ime/AnySoftKeyboardClipboardTest.java +++ b/ime/app/src/test/java/com/anysoftkeyboard/ime/AnySoftKeyboardClipboardTest.java @@ -543,6 +543,48 @@ public class AnySoftKeyboardClipboardTest extends AnySoftKeyboardBaseTest { } @Test + public void testShowStripActionAsNonPasswordIfClipboardIsNotEmptyInNonPasswordField() { + simulateFinishInputFlow(); + ClipboardManager clipboardManager = + (ClipboardManager) + getApplicationContext().getSystemService(Context.CLIPBOARD_SERVICE); + clipboardManager.setPrimaryClip( + new ClipData("text 1", new String[0], new ClipData.Item("text 1"))); + + int[] variations = + new int[] { + InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT, + InputType.TYPE_TEXT_VARIATION_FILTER, + InputType.TYPE_TEXT_VARIATION_PHONETIC, + InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS, + InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS, + InputType.TYPE_TEXT_VARIATION_PERSON_NAME, + InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE, + InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE, + InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT, + InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS, + InputType.TYPE_TEXT_VARIATION_URI, + InputType.TYPE_TEXT_VARIATION_NORMAL, + }; + + for (int variation : variations) { + simulateOnStartInputFlow( + false, + createEditorInfo( + EditorInfo.IME_ACTION_NONE, InputType.TYPE_CLASS_TEXT | variation)); + + final TextView clipboardView = + mAnySoftKeyboardUnderTest + .getInputViewContainer() + .findViewById(R.id.clipboard_suggestion_text); + Assert.assertNotNull("for " + variation, clipboardView); + Assert.assertEquals("for " + variation, "text 1", clipboardView.getText().toString()); + + simulateFinishInputFlow(); + } + } + + @Test public void testDoesNotShowStripActionIfClipboardEntryIsOld() { simulateFinishInputFlow(); ClipboardManager clipboardManager = |
