Show version name in about

This commit is contained in:
seven332 committed 2016-06-10 20:37:27 +08:00
1 parent cacfd58330
commit 148588e53a
6 files changed
+64

No files matched your search

@@ -0,0 +1,57 @@
/*
* Copyright 2016 Hippo Seven
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hippo.ehviewer.preference;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.preference.Preference;
import android.util.AttributeSet;
import com.hippo.ehviewer.R;
public class VersionPreference extends Preference {
public VersionPreference(Context context) {
super(context);
init(context);
}
public VersionPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public VersionPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
setTitle(R.string.settings_about_version);
String version;
try {
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
version = pInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
version = context.getString(R.string.error_unknown);
}
setSummary(version);
}
}
@@ -489,6 +489,7 @@
<string name="settings_about_donate_toast">邮箱地址已复制到剪切板</string>
<string name="settings_about_enable_analytics">启用数据统计</string>
<string name="settings_about_about_analytics">关于数据统计</string>
<string name="settings_about_version">版本号</string>
<string name="settings_about_check_for_updates">检查更新</string>
<string name="settings_about_beta_update_channel">更新测试版</string>
<string name="settings_about_beta_update_channel_summary">测试版可能在你的设备上出现不可预知的错误</string>
@@ -489,6 +489,7 @@
<string name="settings_about_donate_toast">郵箱地址已複製到剪切板</string>
<string name="settings_about_enable_analytics">啟用數據統計</string>
<string name="settings_about_about_analytics">關於數據統計</string>
<string name="settings_about_version">版本號</string>
<string name="settings_about_check_for_updates">檢查更新</string>
<string name="settings_about_beta_update_channel">更新測試版</string>
<string name="settings_about_beta_update_channel_summary">測試版可能在你的設備上出現不可預知的錯誤</string>
@@ -489,6 +489,7 @@
<string name="settings_about_donate_toast">郵箱地址已複製到剪下板</string>
<string name="settings_about_enable_analytics">啟用資料統計</string>
<string name="settings_about_about_analytics">關於資料統計</string>
<string name="settings_about_version">版本號</string>
<string name="settings_about_check_for_updates">檢查更新</string>
<string name="settings_about_beta_update_channel">更新測試版</string>
<string name="settings_about_beta_update_channel_summary">測試版可能在你的裝置上出現不可預知的錯誤</string>
+1
View File
@@ -533,6 +533,7 @@
<string name="settings_about_donate_toast">Email address copied to clipboard</string>
<string name="settings_about_enable_analytics">Enable analytics</string>
<string name="settings_about_about_analytics">About analytics</string>
<string name="settings_about_version">Build version</string>
<string name="settings_about_check_for_updates">Check for updates</string>
<string name="settings_about_beta_update_channel">Beta update channel</string>
<string name="settings_about_beta_update_channel_summary">Beta release might be broken on your devices</string>
+3
View File
@@ -54,6 +54,9 @@
android:summary="@string/settings_about_license_summary"
app:activity="com.hippo.ehviewer.ui.LicenseActivity"/>
<com.hippo.ehviewer.preference.VersionPreference
android:key="version"/>
<Preference
android:key="check_for_updates"
android:title="@string/settings_about_check_for_updates"/>