mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Request incognito keyboard in anonymous mode on Android 8+.
This commit is contained in:
parent
f0747c65cb
commit
12ba414ea1
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user