diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java index 2b4abc409..af61185f1 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java @@ -25,7 +25,6 @@ import com.hippo.ehviewer.Analytics; import com.hippo.ehviewer.EhApplication; import com.hippo.ehviewer.R; import com.hippo.ehviewer.Settings; -import com.hippo.ehviewer.UrlOpener; import com.hippo.ehviewer.ui.CommonOperations; import com.hippo.util.ActivityHelper; @@ -34,11 +33,6 @@ public class AboutFragment extends PreferenceFragment Preference.OnPreferenceClickListener { private static final String KEY_AUTHOR = "author"; - private static final String KEY_GOOGLE_PLUS = "google_plus"; - private static final String KEY_WEBSITE = "website"; - private static final String KEY_SOURCE = "source"; - private static final String KEY_CHANGELOG = "changelog"; - private static final String KEY_LICENSE = "license"; private static final String KEY_DONATE = "donate"; private static final String KEY_CHECK_FOR_UPDATES = "check_for_updates"; @@ -48,11 +42,7 @@ public class AboutFragment extends PreferenceFragment addPreferencesFromResource(R.xml.about_settings); Preference author = findPreference(KEY_AUTHOR); - Preference googlePlus = findPreference(KEY_GOOGLE_PLUS); Preference enableAnalytics = findPreference(Settings.KEY_ENABLE_ANALYTICS); - Preference website = findPreference(KEY_WEBSITE); - Preference source = findPreference(KEY_SOURCE); - Preference changelog = findPreference(KEY_CHANGELOG); Preference donate = findPreference(KEY_DONATE); Preference checkForUpdate = findPreference(KEY_CHECK_FOR_UPDATES); @@ -60,10 +50,6 @@ public class AboutFragment extends PreferenceFragment donate.setSummary(getString(R.string.settings_about_donate_summary).replace('$', '@')); author.setOnPreferenceClickListener(this); - googlePlus.setOnPreferenceClickListener(this); - website.setOnPreferenceClickListener(this); - source.setOnPreferenceClickListener(this); - changelog.setOnPreferenceClickListener(this); donate.setOnPreferenceClickListener(this); checkForUpdate.setOnPreferenceClickListener(this); @@ -88,18 +74,6 @@ public class AboutFragment extends PreferenceFragment if (KEY_AUTHOR.equals(key)) { ActivityHelper.sendEmail(getActivity(), EhApplication.getDeveloperEmail(), "About EhViewer", null); - } else if (KEY_GOOGLE_PLUS.equals(key)) { - UrlOpener.openUrl(getActivity(), "https://plus.google.com/communities/103823982034655188459", - false, true); - } else if (KEY_WEBSITE.equals(key)) { - UrlOpener.openUrl(getActivity(), "http://www.ehviewer.com", - false, true); - } else if (KEY_SOURCE.equals(key)) { - UrlOpener.openUrl(getActivity(), "https://github.com/seven332/EhViewer", - false, true); - } else if (KEY_CHANGELOG.equals(key)) { - UrlOpener.openUrl(getActivity(), "http://www.ehviewer.com/changelog", - false, true); } else if (KEY_DONATE.equals(key)) { new AlertDialog.Builder(getActivity()) .setTitle(R.string.settings_about_donate) diff --git a/app/src/main/java/com/hippo/preference/UrlPreference.java b/app/src/main/java/com/hippo/preference/UrlPreference.java new file mode 100644 index 000000000..c1e033b42 --- /dev/null +++ b/app/src/main/java/com/hippo/preference/UrlPreference.java @@ -0,0 +1,65 @@ +/* + * 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.preference; + +import android.content.Context; +import android.content.res.TypedArray; +import android.preference.Preference; +import android.util.AttributeSet; + +import com.hippo.ehviewer.R; +import com.hippo.ehviewer.UrlOpener; + +public class UrlPreference extends Preference { + + private String mUrl; + + public UrlPreference(Context context) { + super(context); + init(context, null, 0, 0); + } + + public UrlPreference(Context context, AttributeSet attrs) { + super(context, attrs); + init(context, attrs, 0, 0); + } + + public UrlPreference(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(context, attrs, defStyleAttr, 0); + } + + private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UrlPreference, defStyleAttr, defStyleRes); + mUrl = a.getString(R.styleable.UrlPreference_url); + a.recycle(); + } + + @Override + public CharSequence getSummary() { + if (null != mUrl) { + return mUrl; + } else { + return super.getSummary(); + } + } + + @Override + protected void onClick() { + UrlOpener.openUrl(getContext(), mUrl, true, true); + } +} diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 4a4e1ac11..621c0b23a 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -423,6 +423,7 @@ 网站 源码 更新日志 + 帮助 开源许可 EhViewer 的诞生离不开许多开源项目 捐赠 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index fd141382e..ef9c8fb85 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -423,6 +423,7 @@ 網站 源碼 更新日誌 + 幫助 開源許可 EhViewer 的誕生離不開許多開源項目 捐贈 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 5b9cf6e86..1e80050da 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -423,6 +423,7 @@ 網站 原始碼 更新日誌 + 幫助 開源許可 EhViewer 的誕生離不開許多開源專案 捐贈 diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index c62ba25c2..ee6d9df20 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -133,4 +133,8 @@ + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4c5f83f7d..2d59b1abb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -463,13 +463,10 @@ Author Hippo <ehviewersu$gmail.com> Google+ Community - https://plus.google.com/communities/103823982034655188459 Website - http://www.ehviewer.com Source - https://github.com/seven332/EhViewer Changelog - http://www.ehviewer.com/changlog + Help License EhViewer is made possible by many open source projects Donate diff --git a/app/src/main/res/xml/about_settings.xml b/app/src/main/res/xml/about_settings.xml index be232607f..a57251016 100644 --- a/app/src/main/res/xml/about_settings.xml +++ b/app/src/main/res/xml/about_settings.xml @@ -23,25 +23,30 @@ android:key="author" android:title="@string/settings_about_author"/> - + app:url="https://plus.google.com/communities/103823982034655188459"/> - + app:url="http://www.ehviewer.com"/> - + app:url="https://github.com/seven332/EhViewer"/> - + app:url="http://www.ehviewer.com/changelog"/> + +