Move about screen to :ui:preferences (#7039)

This commit is contained in:
ByteHamster 2024-03-29 13:39:45 +01:00 committed by GitHub
parent f9dd837362
commit 0c8c9a89a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 40 additions and 23 deletions

View File

@ -15,18 +15,6 @@ android {
versionCode 3030095
versionName "3.3.0"
def commit = ""
try {
def hashStdOut = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-parse", "--short", "HEAD"
standardOutput = hashStdOut
}
commit = hashStdOut.toString().trim()
} catch (Exception ignore) {
}
buildConfigField "String", "COMMIT_HASH", ('"' + (commit.isEmpty() ? "Unknown commit" : commit) + '"')
javaCompileOptions {
annotationProcessorOptions {
arguments = [eventBusIndex: 'de.danoeh.antennapod.ApEventBusIndex']

View File

@ -21,7 +21,7 @@ import com.bytehamster.lib.preferencesearch.SearchPreferenceResultListener;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.ui.common.ThemeSwitcher;
import de.danoeh.antennapod.databinding.SettingsActivityBinding;
import de.danoeh.antennapod.event.MessageEvent;
import de.danoeh.antennapod.fragment.preferences.ImportExportPreferencesFragment;
import de.danoeh.antennapod.fragment.preferences.MainPreferencesFragment;
@ -32,6 +32,7 @@ import de.danoeh.antennapod.fragment.preferences.UserInterfacePreferencesFragmen
import de.danoeh.antennapod.ui.preferences.screen.AutoDownloadPreferencesFragment;
import de.danoeh.antennapod.ui.preferences.screen.NotificationPreferencesFragment;
import de.danoeh.antennapod.ui.preferences.screen.synchronization.SynchronizationPreferencesFragment;
import de.danoeh.antennapod.ui.preferences.databinding.SettingsActivityBinding;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

View File

@ -16,7 +16,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.BugReportActivity;
import de.danoeh.antennapod.activity.PreferenceActivity;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.fragment.preferences.about.AboutFragment;
import de.danoeh.antennapod.ui.preferences.screen.about.AboutFragment;
public class MainPreferencesFragment extends PreferenceFragmentCompat {

View File

@ -6,6 +6,20 @@ apply from: "../../playFlavor.gradle"
android {
namespace "de.danoeh.antennapod.ui.preferences"
defaultConfig {
def commit = ""
try {
def hashStdOut = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-parse", "--short", "HEAD"
standardOutput = hashStdOut
}
commit = hashStdOut.toString().trim()
} catch (Exception ignore) {
}
buildConfigField "String", "COMMIT_HASH", ('"' + (commit.isEmpty() ? "Unknown commit" : commit) + '"')
}
}
dependencies {
@ -23,6 +37,7 @@ dependencies {
annotationProcessor "androidx.annotation:annotation:$annotationVersion"
implementation "androidx.appcompat:appcompat:$appcompatVersion"
implementation "androidx.fragment:fragment:$fragmentVersion"
implementation "com.google.android.material:material:$googleMaterialVersion"
implementation "androidx.preference:preference:$preferenceVersion"
implementation "androidx.work:work-runtime:$workManagerVersion"

View File

@ -1,18 +1,18 @@
package de.danoeh.antennapod.fragment.preferences.about;
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.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.PreferenceActivity;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.ui.preferences.screen.about.ContributorsPagerFragment;
import de.danoeh.antennapod.ui.preferences.screen.about.LicensesFragment;
import de.danoeh.antennapod.ui.preferences.BuildConfig;
import de.danoeh.antennapod.ui.preferences.R;
public class AboutFragment extends PreferenceFragmentCompat {
@ -20,8 +20,20 @@ public class AboutFragment extends PreferenceFragmentCompat {
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)", BuildConfig.VERSION_NAME, BuildConfig.COMMIT_HASH));
"%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),
@ -53,6 +65,6 @@ public class AboutFragment extends PreferenceFragmentCompat {
@Override
public void onStart() {
super.onStart();
((PreferenceActivity) getActivity()).getSupportActionBar().setTitle(R.string.about_pref);
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.about_pref);
}
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.fragment.app.FragmentContainerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/settingsContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />