aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2022-02-11 15:08:16 +0000
committerAlex <docilealligator.app@gmail.com>2022-02-12 14:05:22 +0000
commitc64b6ef2293754b337d7b0a91358a819cd77ffd9 (patch)
treeb2302a2183731e3e4c521ddfdcc6b6852268d92e /app/src/main/java/ml/docilealligator/infinityforreddit
parent79cc6ddf1ee979d9a5c3cac2d426bf94813cef1f (diff)
downloadinfinity-for-reddit-c64b6ef2293754b337d7b0a91358a819cd77ffd9.tar
infinity-for-reddit-c64b6ef2293754b337d7b0a91358a819cd77ffd9.tar.gz
infinity-for-reddit-c64b6ef2293754b337d7b0a91358a819cd77ffd9.tar.bz2
infinity-for-reddit-c64b6ef2293754b337d7b0a91358a819cd77ffd9.tar.lz
infinity-for-reddit-c64b6ef2293754b337d7b0a91358a819cd77ffd9.tar.xz
infinity-for-reddit-c64b6ef2293754b337d7b0a91358a819cd77ffd9.tar.zst
infinity-for-reddit-c64b6ef2293754b337d7b0a91358a819cd77ffd9.zip
Version 5.1.8. Add Reddit User Agreement to settings. Move Privacy Policy option from About to main settings page.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java33
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/AboutPreferenceFragment.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
4 files changed, 59 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
index 8e143136..552dbca9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
@@ -8,6 +8,8 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
+import android.text.SpannableString;
+import android.text.util.Linkify;
import android.util.Log;
import android.view.InflateException;
import android.view.MenuItem;
@@ -40,6 +42,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.FetchMyInfo;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
@@ -58,6 +61,7 @@ import retrofit2.Retrofit;
public class LoginActivity extends BaseActivity {
private static final String ENABLE_DOM_STATE = "EDS";
+ private static final String IS_AGREE_TO_USER_AGGREMENT_STATE = "IATUAS";
@BindView(R.id.coordinator_layout_login_activity)
CoordinatorLayout coordinatorLayout;
@@ -91,6 +95,7 @@ public class LoginActivity extends BaseActivity {
Executor mExecutor;
private String authCode;
private boolean enableDom = false;
+ private boolean isAgreeToUserAgreement = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -123,6 +128,7 @@ public class LoginActivity extends BaseActivity {
if (savedInstanceState != null) {
enableDom = savedInstanceState.getBoolean(ENABLE_DOM_STATE);
+ isAgreeToUserAgreement = savedInstanceState.getBoolean(IS_AGREE_TO_USER_AGGREMENT_STATE);
}
fab.setOnClickListener(view -> {
@@ -260,12 +266,39 @@ public class LoginActivity extends BaseActivity {
super.onPageFinished(view, url);
}
});
+
+ if (!isAgreeToUserAgreement) {
+ TextView messageTextView = new TextView(this);
+ int padding = (int) Utils.convertDpToPixel(24, this);
+ messageTextView.setPaddingRelative(padding, padding, padding, padding);
+ SpannableString message = new SpannableString(getString(R.string.user_agreement_message, "https://www.redditinc.com/policies/user-agreement-september-12-2021", "https://docile-alligator.github.io"));
+ Linkify.addLinks(message, Linkify.WEB_URLS);
+ messageTextView.setMovementMethod(BetterLinkMovementMethod.newInstance().setOnLinkClickListener(new BetterLinkMovementMethod.OnLinkClickListener() {
+ @Override
+ public boolean onClick(TextView textView, String url) {
+ Intent intent = new Intent(LoginActivity.this, LinkResolverActivity.class);
+ intent.setData(Uri.parse(url));
+ startActivity(intent);
+ return true;
+ }
+ }));
+ messageTextView.setLinkTextColor(getResources().getColor(R.color.colorAccent));
+ messageTextView.setText(message);
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(getString(R.string.user_agreement_dialog_title))
+ .setView(messageTextView)
+ .setPositiveButton(R.string.agree, (dialogInterface, i) -> isAgreeToUserAgreement = true)
+ .setNegativeButton(R.string.do_not_agree, (dialogInterface, i) -> finish())
+ .setCancelable(false)
+ .show();
+ }
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(ENABLE_DOM_STATE, enableDom);
+ outState.putBoolean(IS_AGREE_TO_USER_AGGREMENT_STATE, isAgreeToUserAgreement);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AboutPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AboutPreferenceFragment.java
index abcdb0d3..f746cf48 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AboutPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AboutPreferenceFragment.java
@@ -35,7 +35,6 @@ public class AboutPreferenceFragment extends CustomFontPreferenceFragmentCompat
Preference redditAccountPreference = findPreference(SharedPreferencesUtils.REDDIT_ACCOUNT_KEY);
Preference subredditPreference = findPreference(SharedPreferencesUtils.SUBREDDIT_KEY);
Preference sharePreference = findPreference(SharedPreferencesUtils.SHARE_KEY);
- Preference privacyPolicyPreference = findPreference(SharedPreferencesUtils.PRIVACY_POLICY_KEY);
Preference versionPreference = findPreference(SharedPreferencesUtils.VERSION_KEY);
if (openSourcePreference != null) {
@@ -107,18 +106,6 @@ public class AboutPreferenceFragment extends CustomFontPreferenceFragmentCompat
});
}
- if (privacyPolicyPreference != null) {
- privacyPolicyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- Intent intent = new Intent(activity, LinkResolverActivity.class);
- intent.setData(Uri.parse("https://docile-alligator.github.io/"));
- activity.startActivity(intent);
- return true;
- }
- });
- }
-
if (versionPreference != null) {
versionPreference.setSummary(getString(R.string.settings_version_summary, BuildConfig.VERSION_NAME));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java
index 272af42f..80ff74ab 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java
@@ -6,6 +6,7 @@ import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTI
import android.content.Intent;
import android.content.SharedPreferences;
+import android.net.Uri;
import android.os.Bundle;
import androidx.biometric.BiometricManager;
@@ -16,6 +17,7 @@ import javax.inject.Named;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity;
import ml.docilealligator.infinityforreddit.customviews.CustomFontPreferenceFragmentCompat;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
@@ -37,6 +39,8 @@ public class MainPreferenceFragment extends CustomFontPreferenceFragmentCompat {
Preference securityPreference = findPreference(SharedPreferencesUtils.SECURITY);
Preference postFilterPreference = findPreference(SharedPreferencesUtils.POST_FILTER);
+ Preference privacyPolicyPreference = findPreference(SharedPreferencesUtils.PRIVACY_POLICY_KEY);
+ Preference redditUserAgreementPreference = findPreference(SharedPreferencesUtils.REDDIT_USER_AGREEMENT_KEY);
BiometricManager biometricManager = BiometricManager.from(activity);
if (biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) != BiometricManager.BIOMETRIC_SUCCESS) {
@@ -52,5 +56,26 @@ public class MainPreferenceFragment extends CustomFontPreferenceFragmentCompat {
return true;
});
}
+
+ if (privacyPolicyPreference != null) {
+ privacyPolicyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ Intent intent = new Intent(activity, LinkResolverActivity.class);
+ intent.setData(Uri.parse("https://docile-alligator.github.io/"));
+ activity.startActivity(intent);
+ return true;
+ }
+ });
+ }
+
+ if (redditUserAgreementPreference != null) {
+ redditUserAgreementPreference.setOnPreferenceClickListener(preference -> {
+ Intent intent = new Intent(activity, LinkResolverActivity.class);
+ intent.setData(Uri.parse("https://www.redditinc.com/policies/user-agreement-september-12-2021"));
+ activity.startActivity(intent);
+ return true;
+ });
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
index 9c20f2f6..803ca8ef 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -43,6 +43,7 @@ public class SharedPreferencesUtils {
public static final String CUSTOM_FONT_FAMILY_KEY = "custom_font_family";
public static final String CUSTOM_TITLE_FONT_FAMILY_KEY = "custom_title_font_family";
public static final String CUSTOM_CONTENT_FONT_FAMILY_KEY = "custom_content_font_family";
+ public static final String REDDIT_USER_AGREEMENT_KEY = "reddit_user_agreement";
public static final String SORT_TYPE_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.sort_type";
public static final String SORT_TYPE_BEST_POST = "sort_type_best_post";