mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-27 19:38:22 +01:00
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:
parent
79cc6ddf1e
commit
c64b6ef229
@ -6,8 +6,8 @@ android {
|
||||
applicationId "ml.docilealligator.infinityforreddit"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 92
|
||||
versionName "5.1.7"
|
||||
versionCode 93
|
||||
versionName "5.1.8"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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_summary">Level %1$d</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>
|
||||
|
||||
@ -1264,4 +1265,9 @@
|
||||
<string name="reddit_gallery_item_caption_hint">Caption (max 180 characters)</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>
|
||||
|
@ -46,10 +46,6 @@
|
||||
app:title="@string/settings_share_title"
|
||||
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
|
||||
android:key="version"
|
||||
app:title="@string/settings_version_title"
|
||||
|
@ -87,4 +87,12 @@
|
||||
app:title="@string/settings_about_master_title"
|
||||
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>
|
Loading…
Reference in New Issue
Block a user