Version 5.1.8. Add Reddit User Agreement to settings. Move Privacy Policy option from About to main settings page.

This commit is contained in:
Alex Ning 2022-02-11 23:08:16 +08:00 committed by Alex
parent 79cc6ddf1e
commit c64b6ef229
8 changed files with 75 additions and 19 deletions

View File

@ -6,8 +6,8 @@ android {
applicationId "ml.docilealligator.infinityforreddit" applicationId "ml.docilealligator.infinityforreddit"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 30 targetSdkVersion 30
versionCode 92 versionCode 93
versionName "5.1.7" versionName "5.1.8"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions { javaCompileOptions {
annotationProcessorOptions { annotationProcessorOptions {

View File

@ -8,6 +8,8 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.SpannableString;
import android.text.util.Linkify;
import android.util.Log; import android.util.Log;
import android.view.InflateException; import android.view.InflateException;
import android.view.MenuItem; import android.view.MenuItem;
@ -40,6 +42,7 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.FetchMyInfo; import ml.docilealligator.infinityforreddit.FetchMyInfo;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
@ -58,6 +61,7 @@ import retrofit2.Retrofit;
public class LoginActivity extends BaseActivity { public class LoginActivity extends BaseActivity {
private static final String ENABLE_DOM_STATE = "EDS"; 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) @BindView(R.id.coordinator_layout_login_activity)
CoordinatorLayout coordinatorLayout; CoordinatorLayout coordinatorLayout;
@ -91,6 +95,7 @@ public class LoginActivity extends BaseActivity {
Executor mExecutor; Executor mExecutor;
private String authCode; private String authCode;
private boolean enableDom = false; private boolean enableDom = false;
private boolean isAgreeToUserAgreement = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -123,6 +128,7 @@ public class LoginActivity extends BaseActivity {
if (savedInstanceState != null) { if (savedInstanceState != null) {
enableDom = savedInstanceState.getBoolean(ENABLE_DOM_STATE); enableDom = savedInstanceState.getBoolean(ENABLE_DOM_STATE);
isAgreeToUserAgreement = savedInstanceState.getBoolean(IS_AGREE_TO_USER_AGGREMENT_STATE);
} }
fab.setOnClickListener(view -> { fab.setOnClickListener(view -> {
@ -260,12 +266,39 @@ public class LoginActivity extends BaseActivity {
super.onPageFinished(view, url); 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 @Override
protected void onSaveInstanceState(@NonNull Bundle outState) { protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putBoolean(ENABLE_DOM_STATE, enableDom); outState.putBoolean(ENABLE_DOM_STATE, enableDom);
outState.putBoolean(IS_AGREE_TO_USER_AGGREMENT_STATE, isAgreeToUserAgreement);
} }
@Override @Override

View File

@ -35,7 +35,6 @@ public class AboutPreferenceFragment extends CustomFontPreferenceFragmentCompat
Preference redditAccountPreference = findPreference(SharedPreferencesUtils.REDDIT_ACCOUNT_KEY); Preference redditAccountPreference = findPreference(SharedPreferencesUtils.REDDIT_ACCOUNT_KEY);
Preference subredditPreference = findPreference(SharedPreferencesUtils.SUBREDDIT_KEY); Preference subredditPreference = findPreference(SharedPreferencesUtils.SUBREDDIT_KEY);
Preference sharePreference = findPreference(SharedPreferencesUtils.SHARE_KEY); Preference sharePreference = findPreference(SharedPreferencesUtils.SHARE_KEY);
Preference privacyPolicyPreference = findPreference(SharedPreferencesUtils.PRIVACY_POLICY_KEY);
Preference versionPreference = findPreference(SharedPreferencesUtils.VERSION_KEY); Preference versionPreference = findPreference(SharedPreferencesUtils.VERSION_KEY);
if (openSourcePreference != null) { 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) { if (versionPreference != null) {
versionPreference.setSummary(getString(R.string.settings_version_summary, BuildConfig.VERSION_NAME)); versionPreference.setSummary(getString(R.string.settings_version_summary, BuildConfig.VERSION_NAME));

View File

@ -6,6 +6,7 @@ import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTI
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import androidx.biometric.BiometricManager; import androidx.biometric.BiometricManager;
@ -16,6 +17,7 @@ import javax.inject.Named;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity; import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity;
import ml.docilealligator.infinityforreddit.customviews.CustomFontPreferenceFragmentCompat; import ml.docilealligator.infinityforreddit.customviews.CustomFontPreferenceFragmentCompat;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
@ -37,6 +39,8 @@ public class MainPreferenceFragment extends CustomFontPreferenceFragmentCompat {
Preference securityPreference = findPreference(SharedPreferencesUtils.SECURITY); Preference securityPreference = findPreference(SharedPreferencesUtils.SECURITY);
Preference postFilterPreference = findPreference(SharedPreferencesUtils.POST_FILTER); 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); BiometricManager biometricManager = BiometricManager.from(activity);
if (biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) != BiometricManager.BIOMETRIC_SUCCESS) { if (biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) != BiometricManager.BIOMETRIC_SUCCESS) {
@ -52,5 +56,26 @@ public class MainPreferenceFragment extends CustomFontPreferenceFragmentCompat {
return true; 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;
});
}
} }
} }

View File

@ -43,6 +43,7 @@ public class SharedPreferencesUtils {
public static final String CUSTOM_FONT_FAMILY_KEY = "custom_font_family"; 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_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 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_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.sort_type";
public static final String SORT_TYPE_BEST_POST = "sort_type_best_post"; public static final String SORT_TYPE_BEST_POST = "sort_type_best_post";

View File

@ -630,6 +630,7 @@
<string name="settings_show_fewer_toolbar_options_threshold_title">Show Fewer Toolbar Options Starting From</string> <string name="settings_show_fewer_toolbar_options_threshold_title">Show Fewer Toolbar Options Starting From</string>
<string name="settings_show_fewer_toolbar_options_threshold_summary">Level %1$d</string> <string name="settings_show_fewer_toolbar_options_threshold_summary">Level %1$d</string>
<string name="settings_show_author_avatar_title">Hide Author Avatar</string> <string name="settings_show_author_avatar_title">Hide Author Avatar</string>
<string name="settings_reddit_user_agreement_title">Reddit User Agreement</string>
<string name="no_link_available">Cannot get the link</string> <string name="no_link_available">Cannot get the link</string>
@ -1264,4 +1265,9 @@
<string name="reddit_gallery_item_caption_hint">Caption (max 180 characters)</string> <string name="reddit_gallery_item_caption_hint">Caption (max 180 characters)</string>
<string name="reddit_gallery_item_url_hint">Url</string> <string name="reddit_gallery_item_url_hint">Url</string>
<string name="user_agreement_dialog_title">User Agreement</string>
<string name="user_agreement_message">You need to agree to Reddit User Agreement (%1$s) and Infinity for Reddit\'s Privacy Policy (%2$s) before logging in.</string>
<string name="agree">Agree</string>
<string name="do_not_agree">Don\'t Agree</string>
</resources> </resources>

View File

@ -46,10 +46,6 @@
app:title="@string/settings_share_title" app:title="@string/settings_share_title"
app:summary="@string/settings_share_summary" /> app:summary="@string/settings_share_summary" />
<ml.docilealligator.infinityforreddit.customviews.CustomFontPreference
android:key="privacy_policy"
app:title="@string/settings_privacy_policy_title" />
<ml.docilealligator.infinityforreddit.customviews.CustomFontPreference <ml.docilealligator.infinityforreddit.customviews.CustomFontPreference
android:key="version" android:key="version"
app:title="@string/settings_version_title" app:title="@string/settings_version_title"

View File

@ -87,4 +87,12 @@
app:title="@string/settings_about_master_title" app:title="@string/settings_about_master_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.AboutPreferenceFragment" /> app:fragment="ml.docilealligator.infinityforreddit.settings.AboutPreferenceFragment" />
<ml.docilealligator.infinityforreddit.customviews.CustomFontPreference
android:key="privacy_policy"
app:title="@string/settings_privacy_policy_title" />
<ml.docilealligator.infinityforreddit.customviews.CustomFontPreference
android:key="reddit_user_agreement"
app:title="@string/settings_reddit_user_agreement_title" />
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>