aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/Settings/AboutPreferenceFragment.java62
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SettingsActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java4
-rw-r--r--app/src/main/res/values/strings.xml10
-rw-r--r--app/src/main/res/xml/about_preferences.xml20
5 files changed, 103 insertions, 4 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;
+ });
+ }
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SettingsActivity.java
index 41c82e41..f963b0a4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SettingsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SettingsActivity.java
@@ -19,6 +19,7 @@ import androidx.preference.PreferenceFragmentCompat;
import javax.inject.Inject;
+import Settings.AboutPreferenceFragment;
import Settings.MainPreferenceFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -84,10 +85,12 @@ public class SettingsActivity extends AppCompatActivity implements
setTitle(savedInstanceState.getCharSequence(TITLE_STATE));
}
getSupportFragmentManager().addOnBackStackChangedListener(() -> {
- if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
- setTitle(R.string.settings_activity_label);
- }
- });
+ if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
+ setTitle(R.string.settings_activity_label);
+ } else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof AboutPreferenceFragment) {
+ setTitle(R.string.settings_about_master_title);
+ }
+ });
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
index fd7dc27f..6c4ca027 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
@@ -17,4 +17,8 @@ public class SharedPreferencesUtils {
public static final String CROSSPOST_ICON_KEY = "crosspost_icon";
public static final String THUMBTACK_ICON_KEY = "thumbtack_icon";
public static final String MATERIAL_ICONS_KEY = "material_icons";
+ public static final String OPEN_SOURCE_KEY = "open_source";
+ public static final String RATE_KEY = "rate";
+ public static final String EMAIL_KEY = "email";
+ public static final String REDDIT_ACCOUNT_KEY = "reddit_account";
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 340e90f9..afd0cc44 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -288,6 +288,14 @@
<string name="settings_credits_thumbtack_icon_title">Thumbtack Icon</string>
<string name="settings_credits_thumbtack_icon_summary">Icon made by Freepik from www.flaticon.com</string>
<string name="settings_credits_material_icons_title">Material Icons</string>
+ <string name="settings_open_source_title">Open Source</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_summary">Give me a 5-star rating and I will be really happy</string>
+ <string name="settings_email_title">Email</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_summary">u/Hostilenemy</string>
<string name="no_link_available">Cannot get the link</string>
@@ -304,4 +312,6 @@
<string name="cannot_handle_intent">Could not handle the share request</string>
<string name="share">Share</string>
+
+ <string name="no_email_client">No Email client found</string>
</resources>
diff --git a/app/src/main/res/xml/about_preferences.xml b/app/src/main/res/xml/about_preferences.xml
index a16237e4..e27844fc 100644
--- a/app/src/main/res/xml/about_preferences.xml
+++ b/app/src/main/res/xml/about_preferences.xml
@@ -10,4 +10,24 @@
app:title="@string/settings_credits_master_title"
app:fragment="Settings.CreditsPreferenceFragment" />
+ <Preference
+ android:key="open_source"
+ app:title="@string/settings_open_source_title"
+ app:summary="@string/settings_open_source_summary" />
+
+ <Preference
+ android:key="rate"
+ app:title="@string/settings_rate_title"
+ app:summary="@string/settings_rate_summary" />
+
+ <Preference
+ android:key="email"
+ app:title="@string/settings_email_title"
+ app:summary="@string/settings_email_summary" />
+
+ <Preference
+ android:key="reddit_account"
+ app:title="@string/settings_reddit_account_title"
+ app:summary="@string/settings_reddit_account_summary" />
+
</PreferenceScreen> \ No newline at end of file