summaryrefslogtreecommitdiff
path: root/ui/preferences/src/main/java
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2024-03-29 13:39:45 +0100
committerGitHub <noreply@github.com>2024-03-29 13:39:45 +0100
commit0c8c9a89a371d6515c34d1c4f7417c26059ee969 (patch)
treebe7b961ba1cbf0e3e688a0e9f1e8f2ce7808bcd1 /ui/preferences/src/main/java
parentf9dd837362921df3fbcea424f9e064ecc696f367 (diff)
downloadAntennaPod-0c8c9a89a371d6515c34d1c4f7417c26059ee969.zip
Move about screen to :ui:preferences (#7039)
Diffstat (limited to 'ui/preferences/src/main/java')
-rw-r--r--ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/about/AboutFragment.java70
1 files changed, 70 insertions, 0 deletions
diff --git a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/about/AboutFragment.java b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/about/AboutFragment.java
new file mode 100644
index 000000000..ad956ed71
--- /dev/null
+++ b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/about/AboutFragment.java
@@ -0,0 +1,70 @@
+package de.danoeh.antennapod.ui.preferences.screen.about;
+
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Bundle;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.preference.PreferenceFragmentCompat;
+import com.google.android.material.snackbar.Snackbar;
+import de.danoeh.antennapod.core.util.IntentUtils;
+import de.danoeh.antennapod.ui.preferences.BuildConfig;
+import de.danoeh.antennapod.ui.preferences.R;
+
+public class AboutFragment extends PreferenceFragmentCompat {
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ addPreferencesFromResource(R.xml.preferences_about);
+
+ String versionName = "?";
+ try {
+ PackageInfo packageInfo = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0);
+ versionName = packageInfo.versionName;
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ //noinspection ConstantValue
+ if ("free".equals(BuildConfig.FLAVOR)) {
+ versionName += "f";
+ }
+
+ findPreference("about_version").setSummary(String.format(
+ "%s (%s)", versionName, BuildConfig.COMMIT_HASH));
+ findPreference("about_version").setOnPreferenceClickListener((preference) -> {
+ ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipData clip = ClipData.newPlainText(getString(R.string.bug_report_title),
+ findPreference("about_version").getSummary());
+ clipboard.setPrimaryClip(clip);
+ if (Build.VERSION.SDK_INT <= 32) {
+ Snackbar.make(getView(), R.string.copied_to_clipboard, Snackbar.LENGTH_SHORT).show();
+ }
+ return true;
+ });
+ findPreference("about_contributors").setOnPreferenceClickListener((preference) -> {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.settingsContainer, new ContributorsPagerFragment())
+ .addToBackStack(getString(R.string.contributors)).commit();
+ return true;
+ });
+ findPreference("about_privacy_policy").setOnPreferenceClickListener((preference) -> {
+ IntentUtils.openInBrowser(getContext(), "https://antennapod.org/privacy/");
+ return true;
+ });
+ findPreference("about_licenses").setOnPreferenceClickListener((preference) -> {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.settingsContainer, new LicensesFragment())
+ .addToBackStack(getString(R.string.translators)).commit();
+ return true;
+ });
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.about_pref);
+ }
+}