Add a F-Droid option in settings.

This commit is contained in:
Alex Ning 2020-02-20 15:43:53 +08:00
parent d9b9a7c3c1
commit b06c24402b
4 changed files with 21 additions and 3 deletions

View File

@ -28,7 +28,8 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat {
setPreferencesFromResource(R.xml.about_preferences, rootKey); setPreferencesFromResource(R.xml.about_preferences, rootKey);
Preference openSourcePreference = findPreference(SharedPreferencesUtils.OPEN_SOURCE_KEY); Preference openSourcePreference = findPreference(SharedPreferencesUtils.OPEN_SOURCE_KEY);
Preference reviewPreference = findPreference(SharedPreferencesUtils.RATE_KEY); Preference ratePreference = findPreference(SharedPreferencesUtils.RATE_KEY);
Preference fDroidPreference = findPreference(SharedPreferencesUtils.F_DROID_KEY);
Preference emailPreference = findPreference(SharedPreferencesUtils.EMAIL_KEY); Preference emailPreference = findPreference(SharedPreferencesUtils.EMAIL_KEY);
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);
@ -43,8 +44,8 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
if (reviewPreference != null) { if (ratePreference != null) {
reviewPreference.setOnPreferenceClickListener(preference -> { ratePreference.setOnPreferenceClickListener(preference -> {
Intent playStoreIntent = new Intent(Intent.ACTION_VIEW); Intent playStoreIntent = new Intent(Intent.ACTION_VIEW);
playStoreIntent.setData(Uri.parse("market://details?id=ml.docilealligator.infinityforreddit")); playStoreIntent.setData(Uri.parse("market://details?id=ml.docilealligator.infinityforreddit"));
if (playStoreIntent.resolveActivity(activity.getPackageManager()) != null) { if (playStoreIntent.resolveActivity(activity.getPackageManager()) != null) {
@ -58,6 +59,15 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
if (fDroidPreference != null) {
fDroidPreference.setOnPreferenceClickListener(preference -> {
Intent intent = new Intent(activity, LinkResolverActivity.class);
intent.setData(Uri.parse("https://www.reddit.com/r/Infinity_For_Reddit/comments/f23o0y/for_anyone_who_wants_to_use_fdroid/"));
startActivity(intent);
return true;
});
}
if (emailPreference != null) { if (emailPreference != null) {
emailPreference.setOnPreferenceClickListener(preference -> { emailPreference.setOnPreferenceClickListener(preference -> {
Intent intent = new Intent(Intent.ACTION_SENDTO); Intent intent = new Intent(Intent.ACTION_SENDTO);

View File

@ -21,6 +21,7 @@ public class SharedPreferencesUtils {
public static final String MATERIAL_ICONS_KEY = "material_icons"; public static final String MATERIAL_ICONS_KEY = "material_icons";
public static final String OPEN_SOURCE_KEY = "open_source"; public static final String OPEN_SOURCE_KEY = "open_source";
public static final String RATE_KEY = "rate"; public static final String RATE_KEY = "rate";
public static final String F_DROID_KEY = "f-droid";
public static final String EMAIL_KEY = "email"; public static final String EMAIL_KEY = "email";
public static final String REDDIT_ACCOUNT_KEY = "reddit_account"; public static final String REDDIT_ACCOUNT_KEY = "reddit_account";
public static final String SUBREDDIT_KEY = "subreddit"; public static final String SUBREDDIT_KEY = "subreddit";

View File

@ -344,6 +344,8 @@
<string name="settings_open_source_summary">Star it on Github if you like this app</string> <string name="settings_open_source_summary">Star it on Github if you like this app</string>
<string name="settings_rate_title">Rate in Google Play</string> <string name="settings_rate_title">Rate in Google Play</string>
<string name="settings_rate_summary">Give me a 5-star rating and I will be really happy</string> <string name="settings_rate_summary">Give me a 5-star rating and I will be really happy</string>
<string name="settings_f_droid_title">F-Droid</string>
<string name="settings_f_droid_summary">It\'s available in IzzyOnDroid, an F-Droid Repository</string>
<string name="settings_email_title">Email</string> <string name="settings_email_title">Email</string>
<string name="settings_email_summary">docilealligator.app@gmail.com</string> <string name="settings_email_summary">docilealligator.app@gmail.com</string>
<string name="settings_reddit_account_title">Reddit Account</string> <string name="settings_reddit_account_title">Reddit Account</string>

View File

@ -20,6 +20,11 @@
app:title="@string/settings_rate_title" app:title="@string/settings_rate_title"
app:summary="@string/settings_rate_summary" /> app:summary="@string/settings_rate_summary" />
<Preference
android:key="f-droid"
app:title="@string/settings_f_droid_title"
app:summary="@string/settings_f_droid_summary" />
<Preference <Preference
android:key="email" android:key="email"
app:title="@string/settings_email_title" app:title="@string/settings_email_title"