diff options
author | Docile-Alligator <chineseperson5@gmail.com> | 2022-06-01 08:46:04 +0000 |
---|---|---|
committer | Docile-Alligator <chineseperson5@gmail.com> | 2022-06-01 08:46:04 +0000 |
commit | 12ba414ea1912cf25888ad552031b56c9828c743 (patch) | |
tree | 3976db3c617d0274054438849a48a1d11542518b /app/src/main | |
parent | f0747c65cb62c7866119da033c2bc70726053100 (diff) | |
download | infinity-for-reddit-12ba414ea1912cf25888ad552031b56c9828c743.tar infinity-for-reddit-12ba414ea1912cf25888ad552031b56c9828c743.tar.gz infinity-for-reddit-12ba414ea1912cf25888ad552031b56c9828c743.tar.bz2 infinity-for-reddit-12ba414ea1912cf25888ad552031b56c9828c743.tar.lz infinity-for-reddit-12ba414ea1912cf25888ad552031b56c9828c743.tar.xz infinity-for-reddit-12ba414ea1912cf25888ad552031b56c9828c743.tar.zst infinity-for-reddit-12ba414ea1912cf25888ad552031b56c9828c743.zip |
Request incognito keyboard in anonymous mode on Android 8+.
Diffstat (limited to '')
8 files changed, 55 insertions, 1 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java index 6be1059a..ff62df44 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java @@ -17,6 +17,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.view.inputmethod.EditorInfoCompat; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; @@ -117,6 +118,10 @@ public class CreateMultiRedditActivity extends BaseActivity { if (mAccessToken == null) { visibilityLinearLayout.setVisibility(View.GONE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + nameEditText.setImeOptions(nameEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); + descriptionEditText.setImeOptions(descriptionEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); + } } if (savedInstanceState != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java index 7388c7c9..0a7cfb4f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java @@ -19,6 +19,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.view.inputmethod.EditorInfoCompat; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; @@ -126,6 +127,10 @@ public class EditMultiRedditActivity extends BaseActivity { if (mAccessToken == null) { visibilityLinearLayout.setVisibility(View.GONE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + nameEditText.setImeOptions(nameEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); + descriptionEditText.setImeOptions(descriptionEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); + } } if (savedInstanceState != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java index 60a2c6e2..996b8ef4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Build; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; @@ -20,6 +21,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.view.inputmethod.EditorInfoCompat; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.RecyclerView; @@ -182,6 +184,10 @@ public class SearchActivity extends BaseActivity { finish(); }); + if (mAccessToken == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + searchEditText.setImeOptions(searchEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); + } + searchEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java index ad5d1746..e9e2bd04 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java @@ -21,6 +21,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.view.inputmethod.EditorInfoCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; @@ -176,6 +177,10 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti showMultiReddits = getIntent().getBooleanExtra(EXTRA_SHOW_MULTIREDDITS, false); } + if (mAccessToken == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + searchEditText.setImeOptions(searchEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); + } + searchEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java index 96d48c08..d40bc570 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java @@ -21,6 +21,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.view.inputmethod.EditorInfoCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; @@ -248,6 +249,10 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele return false; }); + if (mAccessToken == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + searchTextInputEditText.setImeOptions(searchTextInputEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); + } + checkNewAccountAndBindView(savedInstanceState); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java index dd9e07e2..9922ca59 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java @@ -9,6 +9,7 @@ import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.util.Log; import android.view.InflateException; @@ -34,6 +35,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.LollipopBugFixedWebView; +import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; public class WebViewActivity extends BaseActivity { @@ -50,6 +52,9 @@ public class WebViewActivity extends BaseActivity { @Named("default") SharedPreferences mSharedPreferences; @Inject + @Named("current_account") + SharedPreferences mCurrentAccountSharedPreferences; + @Inject CustomThemeWrapper mCustomThemeWrapper; private String url; @@ -76,6 +81,10 @@ public class WebViewActivity extends BaseActivity { setSupportActionBar(toolbar); + if (mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null) == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + webView.setAnonymous(true); + } + webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setDomStorageEnabled(true); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/LollipopBugFixedWebView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/LollipopBugFixedWebView.java index 71387a2f..f598f35f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/LollipopBugFixedWebView.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/LollipopBugFixedWebView.java @@ -4,9 +4,13 @@ import android.content.Context; import android.content.res.Configuration; import android.os.Build; import android.util.AttributeSet; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputConnection; import android.webkit.WebView; -public class LollipopBugFixedWebView extends WebView{ +public class LollipopBugFixedWebView extends WebView { + private boolean isAnonymous; + public LollipopBugFixedWebView(Context context) { super(getFixedContext(context)); } @@ -26,4 +30,17 @@ public class LollipopBugFixedWebView extends WebView{ return context.createConfigurationContext(new Configuration()); return context; } + + public void setAnonymous(boolean isAnonymous) { + this.isAnonymous = isAnonymous; + } + + @Override + public InputConnection onCreateInputConnection(EditorInfo outAttrs) { + InputConnection inputConnection = super.onCreateInputConnection(outAttrs); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && isAnonymous) { + outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING; + } + return inputConnection; + } } diff --git a/app/src/main/res/layout/activity_subscribed_thing_listing.xml b/app/src/main/res/layout/activity_subscribed_thing_listing.xml index 15e8fd7b..1d7c4fdd 100644 --- a/app/src/main/res/layout/activity_subscribed_thing_listing.xml +++ b/app/src/main/res/layout/activity_subscribed_thing_listing.xml @@ -41,6 +41,8 @@ android:maxLines="1" android:textSize="?attr/font_20" android:fontFamily="?attr/font_family" + android:inputType="textNoSuggestions" + android:imeOptions="actionSearch" android:visibility="gone" /> </androidx.appcompat.widget.Toolbar> |