From ba75ae1f5374228562707beae6305bde675ef983 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 11 Jan 2021 19:42:39 +0800 Subject: [PATCH] Add Privacy Policy. --- .../settings/AboutPreferenceFragment.java | 25 ++++++++++++++----- .../utils/SharedPreferencesUtils.java | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/about_preferences.xml | 4 +++ 4 files changed, 25 insertions(+), 6 deletions(-) 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 4e930fba..c132b339 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AboutPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AboutPreferenceFragment.java @@ -35,13 +35,14 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { 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) { openSourcePreference.setOnPreferenceClickListener(preference -> { Intent intent = new Intent(activity, LinkResolverActivity.class); intent.setData(Uri.parse("https://github.com/Docile-Alligator/Infinity-For-Reddit")); - startActivity(intent); + activity.startActivity(intent); return true; }); } @@ -55,7 +56,7 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { } else { Intent intent = new Intent(activity, LinkResolverActivity.class); intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=ml.docilealligator.infinityforreddit")); - startActivity(intent); + activity.startActivity(intent); } return true; }); @@ -66,7 +67,7 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:docilealligator.app@gmail.com")); try { - startActivity(intent); + activity.startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(activity, R.string.no_email_client, Toast.LENGTH_SHORT).show(); } @@ -78,7 +79,7 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { redditAccountPreference.setOnPreferenceClickListener(preference -> { Intent intent = new Intent(activity, LinkResolverActivity.class); intent.setData(Uri.parse("https://www.reddit.com/user/Hostilenemy")); - startActivity(intent); + activity.startActivity(intent); return true; }); } @@ -87,7 +88,7 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { subredditPreference.setOnPreferenceClickListener(preference -> { Intent intent = new Intent(activity, LinkResolverActivity.class); intent.setData(Uri.parse("https://www.reddit.com/r/Infinity_For_Reddit")); - startActivity(intent); + activity.startActivity(intent); return true; }); } @@ -98,7 +99,7 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_this_app)); if (intent.resolveActivity(activity.getPackageManager()) != null) { - startActivity(intent); + activity.startActivity(intent); } else { Toast.makeText(activity, R.string.no_app, Toast.LENGTH_SHORT).show(); } @@ -106,6 +107,18 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { }); } + 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/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java index ece6d14a..45878da5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -23,6 +23,7 @@ public class SharedPreferencesUtils { public static final String REDDIT_ACCOUNT_KEY = "reddit_account"; public static final String SUBREDDIT_KEY = "subreddit"; public static final String SHARE_KEY = "share"; + public static final String PRIVACY_POLICY_KEY = "privacy_policy"; public static final String VERSION_KEY = "version"; public static final String FONT_SIZE_KEY = "font_size"; public static final String TITLE_FONT_SIZE_KEY = "title_font_size"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cb020396..e096984a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -441,6 +441,7 @@ r/Infinity_For_Reddit Share Share this app to other people if you enjoy it + Privacy Policy Infinity For Reddit Version %s Customization diff --git a/app/src/main/res/xml/about_preferences.xml b/app/src/main/res/xml/about_preferences.xml index ded0ccee..d451d84b 100644 --- a/app/src/main/res/xml/about_preferences.xml +++ b/app/src/main/res/xml/about_preferences.xml @@ -46,6 +46,10 @@ app:title="@string/settings_share_title" app:summary="@string/settings_share_summary" /> + +