diff --git a/app/src/main/java/com/hippo/ehviewer/Settings.java b/app/src/main/java/com/hippo/ehviewer/Settings.java
index 93590ad71..f3c8ecb3f 100644
--- a/app/src/main/java/com/hippo/ehviewer/Settings.java
+++ b/app/src/main/java/com/hippo/ehviewer/Settings.java
@@ -392,7 +392,7 @@ public class Settings {
putBoolean(KEY_ASK_ANALYTICS, value);
}
- private static final String KEY_ENABLE_ANALYTICS = "enable_analytics";
+ public static final String KEY_ENABLE_ANALYTICS = "enable_analytics";
private static final boolean DEFAULT_ENABLE_ANALYTICS = false;
public static boolean getEnableAnalytics() {
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 da48e6d5a..bee2ad4e6 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
@@ -17,15 +17,32 @@
package com.hippo.ehviewer.ui.fragment;
import android.os.Bundle;
+import android.preference.Preference;
import android.preference.PreferenceFragment;
+import com.hippo.ehviewer.Analytics;
import com.hippo.ehviewer.R;
+import com.hippo.ehviewer.Settings;
-public class AboutFragment extends PreferenceFragment {
+public class AboutFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.about_settings);
+
+ Preference enableAnalytics = findPreference(Settings.KEY_ENABLE_ANALYTICS);
+ enableAnalytics.setOnPreferenceChangeListener(this);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ String key = preference.getKey();
+ if (Settings.KEY_ENABLE_ANALYTICS.equals(key)) {
+ if (newValue instanceof Boolean && (Boolean) newValue) {
+ Analytics.start(getActivity());
+ }
+ }
+ return true;
}
}
diff --git a/app/src/main/java/com/hippo/preference/SimpleDialogPreference.java b/app/src/main/java/com/hippo/preference/SimpleDialogPreference.java
new file mode 100644
index 000000000..9e0cecc03
--- /dev/null
+++ b/app/src/main/java/com/hippo/preference/SimpleDialogPreference.java
@@ -0,0 +1,75 @@
+/*
+ * 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.annotation.TargetApi;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.os.Build;
+import android.preference.DialogPreference;
+import android.util.AttributeSet;
+
+import com.hippo.ehviewer.R;
+import com.hippo.text.Html;
+
+// TODO Add html attr
+// TODO Add url clickable
+public class SimpleDialogPreference extends DialogPreference {
+
+ private CharSequence mMessage;
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public SimpleDialogPreference(Context context) {
+ super(context);
+ init(context, null, 0, 0);
+ }
+
+ public SimpleDialogPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(context, attrs, 0, 0);
+ }
+
+ public SimpleDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(context, attrs, defStyleAttr, 0);
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public SimpleDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ init(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ public void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SimpleDialogPreference, defStyleAttr, defStyleRes);
+ setMessage(a.getString(R.styleable.SimpleDialogPreference_message));
+ a.recycle();
+ }
+
+ public void setMessage(String message) {
+ mMessage = Html.fromHtml(message);
+ }
+
+ @Override
+ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
+ super.onPrepareDialogBuilder(builder);
+ builder.setMessage(mMessage);
+ builder.setPositiveButton(android.R.string.ok, null);
+ builder.setNegativeButton(null, null);
+ }
+}
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index cc70aca72..2f0569731 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -277,6 +277,8 @@
文档
关于
+ 启用数据统计
+ 关于数据统计
选择文件夹
diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml
index 775d45074..0c3adc24c 100644
--- a/app/src/main/res/values-zh-rHK/strings.xml
+++ b/app/src/main/res/values-zh-rHK/strings.xml
@@ -65,6 +65,7 @@
點擊重試
EhViewer 將申請設備存儲空間訪問權限以便下載畫廊。你願意授權嗎?
好痛
+ 你同意讓開發者收集你的設備信息與使用情況嗎?這將對開發有很大幫助。<br><br>數據統計服務由 Google Analytics 提供,其隱私政策可在 <a href="https://www.google.com/policies/privacy/">https://www.google.com/policies/privacy/</a> 查看。<br><br>若您同意參與數據統計,您的設備信息與應用使用情況將會被記錄,其包括但不限於:Android API 版本、設備型號、語言所在地、本應用版本號、會話時長、應用功能使用次數。開發者承諾以下信息並不會被記錄:電話號碼、電子郵件地址、IMEI。<br><br>在您同意參與數據統計之前,您的信息不會被記錄。<br><br>被記錄的數據會由 Google Analytics 進行分析,分析報表僅可被本應用開發者訪問。
搜索 ExHentai
@@ -276,6 +277,8 @@
文檔
關於
+ 啟用數據統計
+ 關於數據統計
選擇文件夾
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 42d3f7ff0..76ad68fdb 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -65,6 +65,7 @@
點選重試
EhViewer 將申請裝置儲存空間訪問許可權以便下載畫廊。你願意授權嗎?
好痛
+ 你同意讓開發者收集你的裝置資訊與使用情況嗎?這將對開發有很大幫助。<br><br>資料統計服務由 Google Analytics 提供,其隱私政策可在 <a href="https://www.google.com/policies/privacy/">https://www.google.com/policies/privacy/</a> 檢視。<br><br>若您同意參與資料統計,您的裝置資訊與應用使用情況將會被記錄,其包括但不限於:Android API 版本、裝置型號、語言所在地、本應用版本號、會話時長、應用功能使用次數。開發者承諾以下資訊並不會被記錄:電話號碼、電子郵件地址、IMEI。<br><br>在您同意參與資料統計之前,您的資訊不會被記錄。<br><br>被記錄的資料會由 Google Analytics 進行分析,分析報表僅可被本應用開發者訪問。
搜尋 ExHentai
@@ -276,6 +277,8 @@
文件
關於
+ 啟用資料統計
+ 關於資料統計
選擇資料夾
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index dbdfb8ae9..a91dda631 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -108,6 +108,10 @@
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e5fc2da00..2e03d3f1a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -316,6 +316,8 @@
Document
About
+ Enable analytics
+ About analytics
Dir picker
diff --git a/app/src/main/res/xml/about_settings.xml b/app/src/main/res/xml/about_settings.xml
index 87b4e1ab6..087ee1b6c 100644
--- a/app/src/main/res/xml/about_settings.xml
+++ b/app/src/main/res/xml/about_settings.xml
@@ -18,9 +18,18 @@
+
-
-
-
+