diff --git a/app/src/main/java/com/hippo/ehviewer/AppConfig.java b/app/src/main/java/com/hippo/ehviewer/AppConfig.java
index 45ecbd25f..7235e1b37 100644
--- a/app/src/main/java/com/hippo/ehviewer/AppConfig.java
+++ b/app/src/main/java/com/hippo/ehviewer/AppConfig.java
@@ -32,6 +32,7 @@ public class AppConfig {
private static final String TEMP = "temp";
private static final String IMAGE = "image";
private static final String CRASH = "crash";
+ private static final String PARSE_ERROR = "parse_error";
private static Context sContext;
@@ -91,6 +92,11 @@ public class AppConfig {
return getDirInExternalAppDir(CRASH);
}
+ @Nullable
+ public static File getExternalParseErrorDir() {
+ return getDirInExternalAppDir(PARSE_ERROR);
+ }
+
@Nullable
public static File createExternalTempFile() {
return FileUtils.createTempFile(getExternalTempDir(), null);
diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.java b/app/src/main/java/com/hippo/ehviewer/EhApplication.java
index 59c955e32..fb0e4ab92 100644
--- a/app/src/main/java/com/hippo/ehviewer/EhApplication.java
+++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.java
@@ -99,10 +99,6 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
Analytics.start(this);
}
- if (BETA) {
- Settings.putBetaUpdateChannel(true);
- }
-
// Update version code
try {
PackageInfo pi= getPackageManager().getPackageInfo(getPackageName(), 0);
diff --git a/app/src/main/java/com/hippo/ehviewer/Settings.java b/app/src/main/java/com/hippo/ehviewer/Settings.java
index b9be7c950..48eb5bfff 100644
--- a/app/src/main/java/com/hippo/ehviewer/Settings.java
+++ b/app/src/main/java/com/hippo/ehviewer/Settings.java
@@ -539,14 +539,28 @@ public class Settings {
****** Crash
********************/
private static final String KEY_CRASH_FILENAME = "crash_filename";
- private static final String VALUE_CRASH_FILENAME = null;
+ private static final String DEFAULT_CRASH_FILENAME = null;
public static String getCrashFilename() {
- return getString(KEY_CRASH_FILENAME, VALUE_CRASH_FILENAME);
+ return getString(KEY_CRASH_FILENAME, DEFAULT_CRASH_FILENAME);
}
@SuppressLint("CommitPrefEdits")
public static void putCrashFilename(String value) {
sSettingsPre.edit().putString(KEY_CRASH_FILENAME, value).commit();
}
+
+ /********************
+ ****** Advanced
+ ********************/
+ public static final String KEY_SAVE_PARSE_ERROR_BODY = "save_parse_error_body";
+ private static final boolean DEFAULT_SAVE_PARSE_ERROR_BODY = EhApplication.BETA;
+
+ public static boolean getSaveParseErrorBody() {
+ return getBoolean(KEY_SAVE_PARSE_ERROR_BODY, DEFAULT_SAVE_PARSE_ERROR_BODY);
+ }
+
+ public static void putSaveParseErrorBody(boolean value) {
+ putBoolean(KEY_SAVE_PARSE_ERROR_BODY, value);
+ }
}
diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java b/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java
index e53f35fc7..dcdccbba4 100644
--- a/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java
+++ b/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java
@@ -20,8 +20,10 @@ import android.support.annotation.Nullable;
import android.util.Log;
import android.util.Pair;
+import com.hippo.ehviewer.AppConfig;
import com.hippo.ehviewer.GetText;
import com.hippo.ehviewer.R;
+import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.client.data.GalleryComment;
import com.hippo.ehviewer.client.data.GalleryDetail;
import com.hippo.ehviewer.client.data.GalleryInfo;
@@ -41,11 +43,17 @@ import com.hippo.ehviewer.client.parser.SignInParser;
import com.hippo.ehviewer.client.parser.TorrentParser;
import com.hippo.ehviewer.client.parser.WhatsHotParser;
import com.hippo.network.StatusCodeException;
+import com.hippo.util.ReadableTime;
import com.hippo.yorozuya.AssertUtils;
+import com.hippo.yorozuya.IOUtils;
import org.json.JSONArray;
import org.json.JSONObject;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -71,6 +79,33 @@ public class EhEngine {
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
+ private static void saveParseErrorBody(ParseException e) {
+ File dir = AppConfig.getExternalParseErrorDir();
+ if (null == dir) {
+ return;
+ }
+
+ File file = new File(dir, ReadableTime.getFilenamableTime(System.currentTimeMillis()) + ".txt");
+ OutputStream os = null;
+ try {
+ os = new FileOutputStream(file);
+ String message = e.getMessage();
+ String body = e.getBody();
+ if (null != message) {
+ os.write(message.getBytes("utf-8"));
+ os.write('\n');
+ }
+ if (null != body) {
+ os.write(body.getBytes("utf-8"));
+ }
+ os.flush();
+ } catch (IOException e1) {
+ // Ignore
+ } finally {
+ IOUtils.closeQuietly(os);
+ }
+ }
+
private static void throwException(Call call, int code, @Nullable Headers headers,
@Nullable String body, Exception e) throws Exception {
if (call.isCanceled()) {
@@ -88,6 +123,9 @@ public class EhEngine {
if (body != null && !body.contains("<")){
throw new EhException(body);
} else {
+ if (Settings.getSaveParseErrorBody()) {
+ saveParseErrorBody((ParseException) e);
+ }
throw new EhException(GetText.getString(R.string.error_parse_error));
}
}
diff --git a/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.java
index c8ec38946..c46a86b03 100644
--- a/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.java
+++ b/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.java
@@ -34,6 +34,7 @@ import android.widget.ListAdapter;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.ui.fragment.AboutFragment;
+import com.hippo.ehviewer.ui.fragment.AdvancedFragment;
import com.hippo.ehviewer.ui.fragment.DownloadFragment;
import com.hippo.ehviewer.ui.fragment.EhFragment;
import com.hippo.ehviewer.ui.fragment.ReadFragment;
@@ -50,6 +51,7 @@ public final class SettingsActivity extends TrackedPreferenceActivity {
EhFragment.class.getName(),
ReadFragment.class.getName(),
DownloadFragment.class.getName(),
+ AdvancedFragment.class.getName(),
AboutFragment.class.getName(),
};
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 a11adfe5d..39c6370ac 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
@@ -43,7 +43,6 @@ public class AboutFragment extends PreferenceFragment
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";
- private static final String KEY_BETA_UPDATE_CHANNEL = "beta_update_channel";
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -59,10 +58,8 @@ public class AboutFragment extends PreferenceFragment
Preference license = findPreference(KEY_LICENSE);
Preference donate = findPreference(KEY_DONATE);
Preference checkForUpdate = findPreference(KEY_CHECK_FOR_UPDATES);
- Preference betaUpdateChannel = findPreference(KEY_BETA_UPDATE_CHANNEL);
author.setSummary(getString(R.string.settings_about_author_summary).replace('$', '@'));
- betaUpdateChannel.setDefaultValue(EhApplication.BETA);
author.setOnPreferenceClickListener(this);
googlePlus.setOnPreferenceClickListener(this);
diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/AdvancedFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/AdvancedFragment.java
new file mode 100644
index 000000000..3d85ab34a
--- /dev/null
+++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/AdvancedFragment.java
@@ -0,0 +1,31 @@
+/*
+ * 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.ui.fragment;
+
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+import com.hippo.ehviewer.R;
+
+public class AdvancedFragment extends PreferenceFragment {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.advanced_settings);
+ }
+}
diff --git a/app/src/main/res/drawable/v_adb_primary_x24.xml b/app/src/main/res/drawable/v_adb_primary_x24.xml
new file mode 100644
index 000000000..b155c431c
--- /dev/null
+++ b/app/src/main/res/drawable/v_adb_primary_x24.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index d131d658e..f63e46761 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -321,6 +321,10 @@
恢复失败
成功恢复 %s 项
+ 高级
+ 解析失败时保存页面内容
+ 页面内容可能含有隐私敏感信息
+
关于
作者
Google+ 社群
diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml
index 6768f78be..b9471535a 100644
--- a/app/src/main/res/values-zh-rHK/strings.xml
+++ b/app/src/main/res/values-zh-rHK/strings.xml
@@ -321,6 +321,10 @@
恢復失敗
成功恢復 %s 項
+ 高級
+ 解析失敗時保存頁面內容
+ 頁面內容可能含有隱私敏感信息
+
關於
作者
Google+ 社羣
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 8bab7ecb0..f4985ecf6 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -321,6 +321,10 @@
恢復失敗
成功恢復 %s 項
+ 高階
+ 解析失敗時儲存頁面內容
+ 頁面內容可能含有隱私敏感資訊
+
關於
作者
Google+ 社群
diff --git a/app/src/main/res/values/bools.xml b/app/src/main/res/values/bools.xml
index 313be884e..f723a9d7a 100644
--- a/app/src/main/res/values/bools.xml
+++ b/app/src/main/res/values/bools.xml
@@ -17,6 +17,7 @@
+ true
true
diff --git a/app/src/main/res/values/pathdata.xml b/app/src/main/res/values/pathdata.xml
index 70a24211a..3691671f0 100644
--- a/app/src/main/res/values/pathdata.xml
+++ b/app/src/main/res/values/pathdata.xml
@@ -54,6 +54,7 @@
M16,11.78L20.24,4.45L21.97,5.45L16.74,14.5L10.23,10.75L5.46,19H22V21H2V3H4V17.54L9.5,8L16,11.78Z
M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A9,9 0 0,0 21,12C21,11.5 20.96,11 20.87,10.5C20.6,10 20,10 20,10H18V9C18,8 17,8 17,8H15V7C15,6 14,6 14,6H13V4C13,3 12,3 12,3M9.5,6A1.5,1.5 0 0,1 11,7.5A1.5,1.5 0 0,1 9.5,9A1.5,1.5 0 0,1 8,7.5A1.5,1.5 0 0,1 9.5,6M6.5,10A1.5,1.5 0 0,1 8,11.5A1.5,1.5 0 0,1 6.5,13A1.5,1.5 0 0,1 5,11.5A1.5,1.5 0 0,1 6.5,10M11.5,11A1.5,1.5 0 0,1 13,12.5A1.5,1.5 0 0,1 11.5,14A1.5,1.5 0 0,1 10,12.5A1.5,1.5 0 0,1 11.5,11M16.5,13A1.5,1.5 0 0,1 18,14.5A1.5,1.5 0 0,1 16.5,16H16.5A1.5,1.5 0 0,1 15,14.5H15A1.5,1.5 0 0,1 16.5,13M11,16A1.5,1.5 0 0,1 12.5,17.5A1.5,1.5 0 0,1 11,19A1.5,1.5 0 0,1 9.5,17.5A1.5,1.5 0 0,1 11,16Z
M14,12H10V10H14M14,16H10V14H14M20,8H17.19C16.74,7.22 16.12,6.55 15.37,6.04L17,4.41L15.59,3L13.42,5.17C12.96,5.06 12.5,5 12,5C11.5,5 11.04,5.06 10.59,5.17L8.41,3L7,4.41L8.62,6.04C7.88,6.55 7.26,7.22 6.81,8H4V10H6.09C6.04,10.33 6,10.66 6,11V12H4V14H6V15C6,15.34 6.04,15.67 6.09,16H4V18H6.81C7.85,19.79 9.78,21 12,21C14.22,21 16.15,19.79 17.19,18H20V16H17.91C17.96,15.67 18,15.34 18,15V14H20V12H18V11C18,10.66 17.96,10.33 17.91,10H20V8Z
+ M15,9A1,1 0 0,1 14,8A1,1 0 0,1 15,7A1,1 0 0,1 16,8A1,1 0 0,1 15,9M9,9A1,1 0 0,1 8,8A1,1 0 0,1 9,7A1,1 0 0,1 10,8A1,1 0 0,1 9,9M16.12,4.37L18.22,2.27L17.4,1.44L15.09,3.75C14.16,3.28 13.11,3 12,3C10.88,3 9.84,3.28 8.91,3.75L6.6,1.44L5.78,2.27L7.88,4.37C6.14,5.64 5,7.68 5,10V11H19V10C19,7.68 17.86,5.64 16.12,4.37M5,16C5,19.86 8.13,23 12,23A7,7 0 0,0 19,16V12H5V16Z
M12.88,2H4V11L14.97,22.14L24,13.1L12.88,2ZM7.26,5.26C7.96,4.58,9.06,4.58,9.74,5.26C10.42,5.96,10.42,7.06,9.74,7.74S7.94,8.42,7.26,7.74S6.58,5.94,7.26,5.26ZM14.98,19.3L8.76,12.95L14.88,6.83L21.18,13.11L14.98,19.31ZM11.6,21.56L10.23,23L0,12.74V5H2V11.9L11.6,21.56Z
M20.46,14.65C21.86,16.15,20.31,18.6,18.32,17.87C19.78,17.57,20.79,16.37,20.46,14.65ZM4.32,17.87C6.32,18.6,7.86,16.17,6.46,14.65C6.79,16.38,5.78,17.55,4.32,17.87ZM16.87,4.3C16.6,3.56,15.87,3,15,3C13.7,3,12.7,4.24,13.1,5.58C14.2,5.18,15.44,4.48,16.87,4.31ZM24,16C24,18.76,21.76,21,19,21C14.96,21,14.84,16.88,12,16.88S9.04,21,5,21C2.24,21,0,18.76,0,16C0,13.87,1.53,11.43,3.94,7.18C5.84,3.81,8.69,5.92,10.76,6.58C11.54,6.85,12.41,6.88,13.24,6.58C15.3,5.92,18.14,3.81,20.06,7.18C22.46,11.43,24,13.88,24,16ZM8,16C8,14.35,6.65,13,5,13S2,14.35,2,16S3.35,19,5,19S8,17.65,8,16ZM13,14C13,13.45,12.55,13,12,13S11,13.45,11,14S11.45,15,12,15S13,14.55,13,14ZM22,16C22,14.35,20.65,13,19,13S16,14.35,16,16S17.35,19,19,19S22,17.65,22,16ZM9,3C8.14,3,7.4,3.55,7.13,4.3C8.56,4.48,9.79,5.2,10.9,5.58C11.3,4.24,10.3,3,9,3Z
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 29b1b6855..7b6c15592 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -360,6 +360,10 @@
Restore failed
Restore %d items successfully
+ Advanced
+ Save html content when parsing error
+ Html content may be privacy-sensitive
+
About
Author
Hippo <ehviewersu$gmail.com>
diff --git a/app/src/main/res/xml/about_settings.xml b/app/src/main/res/xml/about_settings.xml
index b91df5773..fa433cbcc 100644
--- a/app/src/main/res/xml/about_settings.xml
+++ b/app/src/main/res/xml/about_settings.xml
@@ -69,6 +69,6 @@
android:widgetLayout="@layout/preference_widget_fixed_switch"
android:key="beta_update_channel"
android:title="@string/settings_about_beta_update_channel"
- android:defaultValue="false"/>
+ android:defaultValue="@bool/beta"/>
diff --git a/app/src/main/res/xml/advanced_settings.xml b/app/src/main/res/xml/advanced_settings.xml
new file mode 100644
index 000000000..3b71b3709
--- /dev/null
+++ b/app/src/main/res/xml/advanced_settings.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/xml/settings_headers.xml b/app/src/main/res/xml/settings_headers.xml
index 5f20f6551..a1c82f418 100644
--- a/app/src/main/res/xml/settings_headers.xml
+++ b/app/src/main/res/xml/settings_headers.xml
@@ -33,6 +33,11 @@
android:title="@string/settings_download"
android:icon="@drawable/v_download_primary_x24"/>
+
+