diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-09-12 10:13:59 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-09-12 10:13:59 +0000 |
commit | 4ac9784ab109bed94c1808e6af83d85d9dab35c5 (patch) | |
tree | d128262d249651441a542232e515b38b66ad186b /app/src/main/java/Settings/AboutPreferenceFragment.java | |
parent | 64390d4a5b2c118155d245721567a91181706e3f (diff) | |
download | infinity-for-reddit-4ac9784ab109bed94c1808e6af83d85d9dab35c5.tar infinity-for-reddit-4ac9784ab109bed94c1808e6af83d85d9dab35c5.tar.gz infinity-for-reddit-4ac9784ab109bed94c1808e6af83d85d9dab35c5.tar.bz2 infinity-for-reddit-4ac9784ab109bed94c1808e6af83d85d9dab35c5.tar.lz infinity-for-reddit-4ac9784ab109bed94c1808e6af83d85d9dab35c5.tar.xz infinity-for-reddit-4ac9784ab109bed94c1808e6af83d85d9dab35c5.tar.zst infinity-for-reddit-4ac9784ab109bed94c1808e6af83d85d9dab35c5.zip |
Add more info in settings->about. Fix title mismatch in settings.
Diffstat (limited to 'app/src/main/java/Settings/AboutPreferenceFragment.java')
-rw-r--r-- | app/src/main/java/Settings/AboutPreferenceFragment.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/app/src/main/java/Settings/AboutPreferenceFragment.java b/app/src/main/java/Settings/AboutPreferenceFragment.java index 40873284..8d93bd6c 100644 --- a/app/src/main/java/Settings/AboutPreferenceFragment.java +++ b/app/src/main/java/Settings/AboutPreferenceFragment.java @@ -1,11 +1,18 @@ package Settings; +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; import android.os.Bundle; +import android.widget.Toast; +import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; +import ml.docilealligator.infinityforreddit.LinkResolverActivity; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; /** * A simple {@link PreferenceFragmentCompat} subclass. @@ -15,5 +22,60 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.about_preferences, rootKey); + + Preference openSourcePreference = findPreference(SharedPreferencesUtils.OPEN_SOURCE_KEY); + Preference reviewPreference = findPreference(SharedPreferencesUtils.RATE_KEY); + Preference emailPreference = findPreference(SharedPreferencesUtils.EMAIL_KEY); + Preference redditAccountPreference = findPreference(SharedPreferencesUtils.REDDIT_ACCOUNT_KEY); + + Activity activity = getActivity(); + + if(activity != null) { + 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); + return true; + }); + } + + if(reviewPreference != null) { + reviewPreference.setOnPreferenceClickListener(preference -> { + Intent playStoreIntent = new Intent(Intent.ACTION_VIEW); + playStoreIntent.setData(Uri.parse("market://details?id=ml.docilealligator.infinityforreddit")); + if(playStoreIntent.resolveActivity(activity.getPackageManager()) != null) { + activity.startActivity(playStoreIntent); + } 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); + } + return true; + }); + } + + if(emailPreference != null) { + emailPreference.setOnPreferenceClickListener(preference -> { + Intent intent = new Intent(Intent.ACTION_SENDTO); + intent.setData(Uri.parse("mailto:docilealligator.app@gmail.com")); + if(intent.resolveActivity(activity.getPackageManager()) != null) { + startActivity(intent); + } else { + Toast.makeText(activity, R.string.no_email_client, Toast.LENGTH_SHORT).show(); + } + return true; + }); + } + + if(redditAccountPreference != null) { + redditAccountPreference.setOnPreferenceClickListener(preference -> { + Intent intent = new Intent(activity, LinkResolverActivity.class); + intent.setData(Uri.parse("https://www.reddit.com/user/Hostilenemy")); + startActivity(intent); + return true; + }); + } + } } } |