mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 10:41:50 +01:00
Show version (commit count) and build time in the 'about' section
This commit is contained in:
parent
a571bb5637
commit
9c0abdeb81
@ -1,3 +1,5 @@
|
|||||||
|
import java.text.SimpleDateFormat
|
||||||
|
|
||||||
apply plugin: 'android-sdk-manager'
|
apply plugin: 'android-sdk-manager'
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'com.neenbedankt.android-apt'
|
apply plugin: 'com.neenbedankt.android-apt'
|
||||||
@ -7,6 +9,26 @@ retrolambda {
|
|||||||
jvmArgs '-noverify'
|
jvmArgs '-noverify'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
// Git is needed in your system PATH for these commands to work.
|
||||||
|
// If it's not installed, you can return a random value as a workaround
|
||||||
|
getCommitCount = {
|
||||||
|
return "git rev-list --count master".execute().text.trim()
|
||||||
|
// return "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
getGitSha = {
|
||||||
|
return 'git rev-parse --short HEAD'.execute().text.trim()
|
||||||
|
// return "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
getBuildTime = {
|
||||||
|
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
|
||||||
|
df.setTimeZone(TimeZone.getTimeZone("UTC"))
|
||||||
|
return df.format(new Date())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 23
|
compileSdkVersion 23
|
||||||
buildToolsVersion "23.0.2"
|
buildToolsVersion "23.0.2"
|
||||||
@ -19,6 +41,10 @@ android {
|
|||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
|
buildConfigField "String", "COMMIT_COUNT", "\"${getCommitCount()}\""
|
||||||
|
buildConfigField "String", "COMMIT_SHA", "\"${getGitSha()}\""
|
||||||
|
buildConfigField "String", "BUILD_TIME", "\"${getBuildTime()}\""
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package eu.kanade.mangafeed.ui.setting;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import eu.kanade.mangafeed.BuildConfig;
|
||||||
|
import eu.kanade.mangafeed.R;
|
||||||
|
|
||||||
|
public class SettingsAboutFragment extends SettingsNestedFragment {
|
||||||
|
|
||||||
|
public static SettingsNestedFragment newInstance(int resourcePreference, int resourceTitle) {
|
||||||
|
SettingsNestedFragment fragment = new SettingsAboutFragment();
|
||||||
|
fragment.setArgs(resourcePreference, resourceTitle);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
||||||
|
|
||||||
|
Preference version = findPreference(getString(R.string.pref_version));
|
||||||
|
Preference buildTime = findPreference(getString(R.string.pref_build_time));
|
||||||
|
|
||||||
|
version.setSummary(BuildConfig.DEBUG ? "r" + BuildConfig.COMMIT_COUNT :
|
||||||
|
BuildConfig.VERSION_NAME);
|
||||||
|
|
||||||
|
buildTime.setSummary(getFormattedBuildTime());
|
||||||
|
|
||||||
|
return super.onCreateView(inflater, container, savedState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getFormattedBuildTime() {
|
||||||
|
try {
|
||||||
|
DateFormat inputDf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
|
||||||
|
inputDf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
Date date = inputDf.parse(BuildConfig.BUILD_TIME);
|
||||||
|
|
||||||
|
DateFormat outputDf = DateFormat.getDateTimeInstance(
|
||||||
|
DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault());
|
||||||
|
outputDf.setTimeZone(TimeZone.getDefault());
|
||||||
|
|
||||||
|
return outputDf.format(date);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
@ -50,19 +50,23 @@ public class SettingsActivity extends BaseActivity {
|
|||||||
|
|
||||||
registerSubpreference(R.string.pref_category_reader_key,
|
registerSubpreference(R.string.pref_category_reader_key,
|
||||||
SettingsNestedFragment.newInstance(
|
SettingsNestedFragment.newInstance(
|
||||||
R.xml.pref_reader, R.string.pref_category_reader));
|
R.xml.pref_reader, R.string.pref_category_reader));
|
||||||
|
|
||||||
registerSubpreference(R.string.pref_category_downloads_key,
|
registerSubpreference(R.string.pref_category_downloads_key,
|
||||||
SettingsDownloadsFragment.newInstance(
|
SettingsDownloadsFragment.newInstance(
|
||||||
R.xml.pref_downloads, R.string.pref_category_downloads));
|
R.xml.pref_downloads, R.string.pref_category_downloads));
|
||||||
|
|
||||||
registerSubpreference(R.string.pref_category_accounts_key,
|
registerSubpreference(R.string.pref_category_accounts_key,
|
||||||
SettingsAccountsFragment.newInstance(
|
SettingsAccountsFragment.newInstance(
|
||||||
R.xml.pref_accounts, R.string.pref_category_accounts));
|
R.xml.pref_accounts, R.string.pref_category_accounts));
|
||||||
|
|
||||||
registerSubpreference(R.string.pref_category_cache_key,
|
registerSubpreference(R.string.pref_category_cache_key,
|
||||||
SettingsCacheFragment.newInstance(
|
SettingsCacheFragment.newInstance(
|
||||||
R.xml.pref_cache, R.string.pref_category_cache));
|
R.xml.pref_cache, R.string.pref_category_cache));
|
||||||
|
|
||||||
|
registerSubpreference(R.string.pref_category_about_key,
|
||||||
|
SettingsAboutFragment.newInstance(
|
||||||
|
R.xml.pref_about, R.string.pref_category_about));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<string name="pref_category_accounts_key">pref_category_accounts_key</string>
|
<string name="pref_category_accounts_key">pref_category_accounts_key</string>
|
||||||
<string name="pref_category_downloads_key">pref_category_downloads_key</string>
|
<string name="pref_category_downloads_key">pref_category_downloads_key</string>
|
||||||
<string name="pref_category_cache_key">pref_category_cache_key</string>
|
<string name="pref_category_cache_key">pref_category_cache_key</string>
|
||||||
|
<string name="pref_category_about_key">pref_category_about_key</string>
|
||||||
|
|
||||||
<string name="pref_default_viewer_key">pref_default_viewer_key</string>
|
<string name="pref_default_viewer_key">pref_default_viewer_key</string>
|
||||||
<string name="pref_hide_status_bar_key">pref_hide_status_bar_key</string>
|
<string name="pref_hide_status_bar_key">pref_hide_status_bar_key</string>
|
||||||
@ -19,4 +20,7 @@
|
|||||||
|
|
||||||
<string name="pref_chapter_cache_size_key">pref_chapter_cache_size_key</string>
|
<string name="pref_chapter_cache_size_key">pref_chapter_cache_size_key</string>
|
||||||
<string name="pref_clear_chapter_cache_key">pref_clear_chapter_cache_key</string>
|
<string name="pref_clear_chapter_cache_key">pref_clear_chapter_cache_key</string>
|
||||||
|
|
||||||
|
<string name="pref_version">pref_version</string>
|
||||||
|
<string name="pref_build_time">pref_build_time</string>
|
||||||
</resources>
|
</resources>
|
@ -39,6 +39,7 @@
|
|||||||
<string name="pref_category_accounts">Accounts</string>
|
<string name="pref_category_accounts">Accounts</string>
|
||||||
<string name="pref_category_downloads">Downloads</string>
|
<string name="pref_category_downloads">Downloads</string>
|
||||||
<string name="pref_category_cache">Cache</string>
|
<string name="pref_category_cache">Cache</string>
|
||||||
|
<string name="pref_category_about">About</string>
|
||||||
|
|
||||||
<!-- Reader section -->
|
<!-- Reader section -->
|
||||||
<string name="pref_hide_status_bar">Hide status bar</string>
|
<string name="pref_hide_status_bar">Hide status bar</string>
|
||||||
@ -64,6 +65,10 @@
|
|||||||
<string name="cache_deleted">Cache cleared. %1$d files have been deleted</string>
|
<string name="cache_deleted">Cache cleared. %1$d files have been deleted</string>
|
||||||
<string name="cache_delete_error">An error occurred clearing cache</string>
|
<string name="cache_delete_error">An error occurred clearing cache</string>
|
||||||
|
|
||||||
|
<!-- About section -->
|
||||||
|
<string name="version">Version</string>
|
||||||
|
<string name="build_time">Build time</string>
|
||||||
|
|
||||||
<!-- ACRA -->
|
<!-- ACRA -->
|
||||||
<string name="pref_enable_acra">Send crash reports</string>
|
<string name="pref_enable_acra">Send crash reports</string>
|
||||||
<string name="pref_acra_summary">Help fixing bugs. Sensitive data is not sent</string>
|
<string name="pref_acra_summary">Help fixing bugs. Sensitive data is not sent</string>
|
||||||
|
20
app/src/main/res/xml/pref_about.xml
Normal file
20
app/src/main/res/xml/pref_about.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="acra.enable"
|
||||||
|
android:title="@string/pref_enable_acra"
|
||||||
|
android:summary="@string/pref_acra_summary"
|
||||||
|
android:defaultValue="false"/>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="@string/pref_version"
|
||||||
|
android:title="@string/version"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="@string/pref_build_time"
|
||||||
|
android:title="@string/build_time"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
@ -21,10 +21,9 @@
|
|||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/pref_category_cache" />
|
android:title="@string/pref_category_cache" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<Preference
|
||||||
android:key="acra.enable"
|
android:key="@string/pref_category_about_key"
|
||||||
android:title="@string/pref_enable_acra"
|
android:persistent="false"
|
||||||
android:summary="@string/pref_acra_summary"
|
android:title="@string/pref_category_about" />
|
||||||
android:defaultValue="false"/>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user