Added commit to new about screen

This commit is contained in:
ByteHamster 2019-11-09 00:06:32 +01:00
parent ace46235c6
commit b401c5b64b
2 changed files with 11 additions and 1 deletions

View File

@ -24,6 +24,12 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
generatedDensities = []
def commit = "Unknown commit"
try {
commit = "git rev-parse --short HEAD".execute().text.trim()
} catch (Exception ignore) { }
buildConfigField "String", "COMMIT_HASH", ('"' + commit + '"')
javaCompileOptions {
annotationProcessorOptions {
arguments = [ eventBusIndex : 'de.danoeh.antennapod.ApEventBusIndex' ]

View File

@ -6,6 +6,7 @@ import android.content.Context;
import android.os.Bundle;
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;
@ -15,9 +16,12 @@ public class AboutFragment extends PreferenceFragmentCompat {
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.preferences_about);
findPreference("about_version").setSummary(String.format(
"%s (%s)", BuildConfig.VERSION_NAME, 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), "todo");
ClipData clip = ClipData.newPlainText(getString(R.string.bug_report_title),
findPreference("about_version").getSummary());
clipboard.setPrimaryClip(clip);
Snackbar.make(getView(), R.string.copied_to_clipboard, Snackbar.LENGTH_SHORT).show();
return true;