fix build timestamp
This commit is contained in:
parent
ab20010954
commit
4582e6afef
@ -6,6 +6,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.fox.ttrss"
|
applicationId "org.fox.ttrss"
|
||||||
|
buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 23 // we're not targeting SDK 25 because of this: https://issuetracker.google.com/issues/37103380#makechanges
|
targetSdkVersion 23 // we're not targeting SDK 25 because of this: https://issuetracker.google.com/issues/37103380#makechanges
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import android.preference.PreferenceFragment;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
@ -27,11 +28,11 @@ public class PreferencesFragment extends PreferenceFragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
String version = "?";
|
|
||||||
int versionCode = -1;
|
|
||||||
String buildTimestamp = "N/A";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
String version;
|
||||||
|
int versionCode;
|
||||||
|
String buildTimestamp;
|
||||||
|
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
|
|
||||||
PackageInfo packageInfo = activity.getPackageManager().
|
PackageInfo packageInfo = activity.getPackageManager().
|
||||||
@ -40,24 +41,14 @@ public class PreferencesFragment extends PreferenceFragment {
|
|||||||
version = packageInfo.versionName;
|
version = packageInfo.versionName;
|
||||||
versionCode = packageInfo.versionCode;
|
versionCode = packageInfo.versionCode;
|
||||||
|
|
||||||
ApplicationInfo appInfo = activity.getPackageManager().
|
|
||||||
getApplicationInfo(activity.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);
|
|
||||||
|
|
||||||
|
|
||||||
findPreference("version").setSummary(getString(R.string.prefs_version, version, versionCode));
|
findPreference("version").setSummary(getString(R.string.prefs_version, version, versionCode));
|
||||||
|
|
||||||
|
buildTimestamp = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss").format(new Date(BuildConfig.TIMESTAMP));
|
||||||
|
|
||||||
findPreference("build_timestamp").setSummary(getString(R.string.prefs_build_timestamp, buildTimestamp));
|
findPreference("build_timestamp").setSummary(getString(R.string.prefs_build_timestamp, buildTimestamp));
|
||||||
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user