show build timestamp in preferences
This commit is contained in:
parent
265af1356c
commit
61ead264fb
@ -1,11 +1,17 @@
|
||||
package org.fox.ttrss;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class PreferencesActivity extends PreferenceActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -13,29 +19,39 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
boolean compatMode = android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB;
|
||||
|
||||
if (compatMode) {
|
||||
findPreference("webview_hardware_accel").setEnabled(false);
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
|
||||
findPreference("enable_condensed_fonts").setEnabled(false);
|
||||
}
|
||||
|
||||
Preference versionPref = (Preference)findPreference("version");
|
||||
String version = null;
|
||||
String version = "?";
|
||||
int versionCode = -1;
|
||||
String buildTimestamp = "N/A";
|
||||
|
||||
try {
|
||||
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
PackageInfo packageInfo = getPackageManager().
|
||||
getPackageInfo(getPackageName(), 0);
|
||||
|
||||
version = packageInfo.versionName;
|
||||
versionCode = packageInfo.versionCode;
|
||||
|
||||
ApplicationInfo appInfo = getPackageManager().
|
||||
getApplicationInfo(getPackageName(), 0);
|
||||
|
||||
ZipFile zf = new ZipFile(appInfo.sourceDir);
|
||||
ZipEntry ze = zf.getEntry("classes.dex");
|
||||
long time = ze.getTime();
|
||||
|
||||
buildTimestamp = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss",
|
||||
Locale.getDefault()).format(time);
|
||||
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
versionPref.setTitle(getString(R.string.version, version, versionCode));
|
||||
|
||||
findPreference("version").setTitle(getString(R.string.prefs_version, version, versionCode));
|
||||
findPreference("build_timestamp").setTitle(getString(R.string.prefs_build_timestamp, buildTimestamp));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -263,6 +263,7 @@
|
||||
<string name="headline_display_mode_default">Default</string>
|
||||
<string name="headline_display_mode_no_images">No images</string>
|
||||
<string name="headline_display_mode_compact">Compact</string>
|
||||
<string name="version">Version: %1$s (%2$d)</string>
|
||||
<string name="prefs_version">Version: %1$s (%2$d)</string>
|
||||
<string name="prefs_build_timestamp">Build timestamp: %1$s</string>
|
||||
<string name="crash_dialog_text">Unfortunately, Tiny Tiny RSS has stopped. Submit crash report to tt-rss.org?</string>
|
||||
</resources>
|
||||
|
@ -192,6 +192,10 @@
|
||||
<Preference
|
||||
android:key="version"
|
||||
android:enabled="false"
|
||||
android:title="@string/version" />
|
||||
android:title="@string/prefs_version" />
|
||||
|
||||
<Preference
|
||||
android:key="build_timestamp"
|
||||
android:enabled="false"
|
||||
android:title="@string/prefs_build_timestamp" />
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user