Add analytics settings
This commit is contained in:
1 parent
5b6b6f63b2
commit
1851ce0ab7
9 files changed
+120
-5
No files matched your search
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -277,6 +277,8 @@
|
||||
<string name="settings_download_document">文档</string>
|
||||
|
||||
<string name="settings_about_title">关于</string>
|
||||
<string name="settings_about_enable_analytics">启用数据统计</string>
|
||||
<string name="settings_about_about_analytics">关于数据统计</string>
|
||||
|
||||
<!-- Dir Picker-->
|
||||
<string name="dir_picker">选择文件夹</string>
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
<string name="content_layout_restore_tip">點擊重試</string>
|
||||
<string name="write_rationale">EhViewer 將申請設備存儲空間訪問權限以便下載畫廊。你願意授權嗎?</string>
|
||||
<string name="you_rejected_me">好痛</string>
|
||||
<string name="analytics_explain">你同意讓開發者收集你的設備信息與使用情況嗎?這將對開發有很大幫助。<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 進行分析,分析報表僅可被本應用開發者訪問。</string>
|
||||
|
||||
<!-- Gallery List -->
|
||||
<string name="gallery_list_search_bar_hint">搜索 ExHentai</string>
|
||||
@@ -276,6 +277,8 @@
|
||||
<string name="settings_download_document">文檔</string>
|
||||
|
||||
<string name="settings_about_title">關於</string>
|
||||
<string name="settings_about_enable_analytics">啟用數據統計</string>
|
||||
<string name="settings_about_about_analytics">關於數據統計</string>
|
||||
|
||||
<!-- Dir Picker-->
|
||||
<string name="dir_picker">選擇文件夾</string>
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
<string name="content_layout_restore_tip">點選重試</string>
|
||||
<string name="write_rationale">EhViewer 將申請裝置儲存空間訪問許可權以便下載畫廊。你願意授權嗎?</string>
|
||||
<string name="you_rejected_me">好痛</string>
|
||||
<string name="analytics_explain">你同意讓開發者收集你的裝置資訊與使用情況嗎?這將對開發有很大幫助。<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 進行分析,分析報表僅可被本應用開發者訪問。</string>
|
||||
|
||||
<!-- Gallery List -->
|
||||
<string name="gallery_list_search_bar_hint">搜尋 ExHentai</string>
|
||||
@@ -276,6 +277,8 @@
|
||||
<string name="settings_download_document">文件</string>
|
||||
|
||||
<string name="settings_about_title">關於</string>
|
||||
<string name="settings_about_enable_analytics">啟用資料統計</string>
|
||||
<string name="settings_about_about_analytics">關於資料統計</string>
|
||||
|
||||
<!-- Dir Picker-->
|
||||
<string name="dir_picker">選擇資料夾</string>
|
||||
|
||||
@@ -108,6 +108,10 @@
|
||||
<attr name="disableDependentsState" format="boolean"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="SimpleDialogPreference">
|
||||
<attr name="message" format="string"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="BatteryView">
|
||||
<attr name="color"/>
|
||||
<attr name="warningColor" format="color"/>
|
||||
|
||||
@@ -316,6 +316,8 @@
|
||||
<string name="settings_download_document">Document</string>
|
||||
|
||||
<string name="settings_about_title">About</string>
|
||||
<string name="settings_about_enable_analytics">Enable analytics</string>
|
||||
<string name="settings_about_about_analytics">About analytics</string>
|
||||
|
||||
<!-- Dir Picker-->
|
||||
<string name="dir_picker">Dir picker</string>
|
||||
|
||||
@@ -18,9 +18,18 @@
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<com.hippo.preference.FixedSwitchPreference
|
||||
style="?android:attr/preferenceStyle"
|
||||
android:widgetLayout="@layout/preference_widget_fixed_switch"
|
||||
android:key="enable_analytics"
|
||||
android:title="@string/settings_about_enable_analytics"
|
||||
android:defaultValue="true"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<com.hippo.preference.SimpleDialogPreference
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="?android:attr/preferenceStyle"
|
||||
android:key="about_analytics"
|
||||
android:title="@string/settings_about_about_analytics"
|
||||
app:message="@string/analytics_explain"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
Reference in new issue
Block a user