From 8cec7aff119459f9478d296906a9167c808be89f Mon Sep 17 00:00:00 2001 From: Hermes Junior Date: Sat, 20 Jun 2020 00:51:13 +0200 Subject: Add version info to about section. --- .../Settings/AboutPreferenceFragment.java | 20 ++++++++++++++++++++ .../Utils/SharedPreferencesUtils.java | 1 + app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/about_preferences.xml | 7 ++++++- 4 files changed, 30 insertions(+), 1 deletion(-) (limited to 'app/src/main') 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 3d81bb30..71e9dbc6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AboutPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AboutPreferenceFragment.java @@ -13,6 +13,7 @@ import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity; +import ml.docilealligator.infinityforreddit.BuildConfig; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; @@ -34,6 +35,7 @@ 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 versionPreference = findPreference(SharedPreferencesUtils.VERSION_KEY); if (openSourcePreference != null) { openSourcePreference.setOnPreferenceClickListener(preference -> { @@ -112,6 +114,24 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { return true; }); } + + if (versionPreference != null) { + versionPreference.setSummary(getString(R.string.settings_version_summary, BuildConfig.VERSION_NAME)); + + versionPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + int clickedTimes = 0; + + @Override + public boolean onPreferenceClick(Preference preference) { + clickedTimes++; + if (clickedTimes > 6) { + Toast.makeText(activity, R.string.no_developer_easter_egg, Toast.LENGTH_SHORT).show(); + clickedTimes = 0; + } + return true; + } + }); + } } @Override 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 a26571a9..7058c4b9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -26,6 +26,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 VERSION_KEY = "version"; public static final String FONT_SIZE_KEY = "font_size"; public static final String TITLE_FONT_SIZE_KEY = "title_font_size"; public static final String CONTENT_FONT_SIZE_KEY = "content_font_size"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 53f28bc9..dff92e8d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -402,6 +402,8 @@ r/Infinity_For_Reddit Share Share this app to other people if you enjoy it + Infinity For Reddit + Version %s Customization Light Theme Dark Theme @@ -425,6 +427,7 @@ Subreddit Name (Without r/ prefix) MultiReddit Name (/user/yourusername/m/yourmultiredditname) Username (Without u/ prefix) + There\'s no developer options here Cannot get the link diff --git a/app/src/main/res/xml/about_preferences.xml b/app/src/main/res/xml/about_preferences.xml index 2772f2ed..a73f9aaa 100644 --- a/app/src/main/res/xml/about_preferences.xml +++ b/app/src/main/res/xml/about_preferences.xml @@ -45,4 +45,9 @@ app:title="@string/settings_share_title" app:summary="@string/settings_share_summary" /> - \ No newline at end of file + + + -- cgit v1.2.3