diff --git a/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java index 0531a40379..684df211c7 100644 --- a/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java @@ -4,11 +4,14 @@ import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.Preference; import android.provider.ContactsContract; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.preference.PreferenceFragment; import android.util.Log; import android.widget.Toast; @@ -51,8 +54,9 @@ public class AdvancedPreferenceFragment extends PreferenceFragment { initializePushMessagingToggle(); initializeIdentitySelection(); - this.findPreference(SUBMIT_DEBUG_LOG_PREF) - .setOnPreferenceClickListener(new SubmitDebugLogListener()); + Preference submitDebugLog = this.findPreference(SUBMIT_DEBUG_LOG_PREF); + submitDebugLog.setOnPreferenceClickListener(new SubmitDebugLogListener()); + submitDebugLog.setSummary(getVersion(getActivity())); } @Override @@ -97,6 +101,20 @@ public class AdvancedPreferenceFragment extends PreferenceFragment { } } + private @NonNull String getVersion(@Nullable Context context) { + try { + if (context == null) return ""; + + String app = context.getString(R.string.app_name); + String version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; + + return String.format("%s %s", app, version); + } catch (PackageManager.NameNotFoundException e) { + Log.w(TAG, e); + return context.getString(R.string.app_name); + } + } + private class IdentityPreferenceClickListener implements Preference.OnPreferenceClickListener { @Override public boolean onPreferenceClick(Preference preference) {