From 148588e53ae2e96301687c60c2d95a1305ea1bf8 Mon Sep 17 00:00:00 2001 From: seven332 Date: Fri, 10 Jun 2016 20:37:27 +0800 Subject: [PATCH] Show version name in about --- .../preference/VersionPreference.java | 57 +++++++++++++++++++ app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/about_settings.xml | 3 + 6 files changed, 64 insertions(+) create mode 100644 app/src/main/java/com/hippo/ehviewer/preference/VersionPreference.java diff --git a/app/src/main/java/com/hippo/ehviewer/preference/VersionPreference.java b/app/src/main/java/com/hippo/ehviewer/preference/VersionPreference.java new file mode 100644 index 000000000..1d5ad0e0b --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/preference/VersionPreference.java @@ -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); + } +} diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 760790c78..2bc76f617 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -489,6 +489,7 @@ 邮箱地址已复制到剪切板 启用数据统计 关于数据统计 + 版本号 检查更新 更新测试版 测试版可能在你的设备上出现不可预知的错误 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 5524fe337..9ecf1ea64 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -489,6 +489,7 @@ 郵箱地址已複製到剪切板 啟用數據統計 關於數據統計 + 版本號 檢查更新 更新測試版 測試版可能在你的設備上出現不可預知的錯誤 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 130f0ecc3..f1ca541cb 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -489,6 +489,7 @@ 郵箱地址已複製到剪下板 啟用資料統計 關於資料統計 + 版本號 檢查更新 更新測試版 測試版可能在你的裝置上出現不可預知的錯誤 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 05fa9e9a4..1dce614d3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -533,6 +533,7 @@ Email address copied to clipboard Enable analytics About analytics + Build version Check for updates Beta update channel Beta release might be broken on your devices diff --git a/app/src/main/res/xml/about_settings.xml b/app/src/main/res/xml/about_settings.xml index a57251016..7b36eac8a 100644 --- a/app/src/main/res/xml/about_settings.xml +++ b/app/src/main/res/xml/about_settings.xml @@ -54,6 +54,9 @@ android:summary="@string/settings_about_license_summary" app:activity="com.hippo.ehviewer.ui.LicenseActivity"/> + +