mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-25 10:37:51 +02:00
Show version (commit count) and build time in the 'about' section
This commit is contained in:
@ -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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
SettingsCacheFragment.newInstance(
|
||||
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
|
||||
|
Reference in New Issue
Block a user