添加 UrlBuilder,release 时不显示 Log
No files matched your search
@@ -20,7 +20,7 @@
|
||||
<folderInfo id="com.android.toolchain.gcc.1322280913.1369823253" name="/" resourcePath="">
|
||||
<toolChain id="com.android.toolchain.gcc.803500692" name="Android GCC" superClass="com.android.toolchain.gcc">
|
||||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="com.android.targetPlatform.1260474165" isAbstract="false" superClass="com.android.targetPlatform"/>
|
||||
<builder arguments="NDK_DEBUG=0" command="ndk-build" id="com.android.builder.2127875218" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Android Builder" superClass="com.android.builder">
|
||||
<builder arguments="NDK_DEBUG=0" command="ndk-build" enableCleanBuild="false" id="com.android.builder.2127875218" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Android Builder" superClass="com.android.builder">
|
||||
<outputEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="obj"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="libs"/>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
|
||||
|
After Width: | Height: | Size: 861 B |
|
After Width: | Height: | Size: 986 B |
|
After Width: | Height: | Size: 549 B |
|
After Width: | Height: | Size: 656 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
@@ -205,6 +205,9 @@
|
||||
<string name="gallery_show_clock_title">显示时间</string>
|
||||
<string name="gallery_show_battery_title">显示电量</string>
|
||||
|
||||
<string name="advanced_settings_title">高级</string>
|
||||
<string name="http_advanced_settings_title">HTTP</string>
|
||||
|
||||
<string name="about_settings_title">关于</string>
|
||||
<string name="author_title">作者</string>
|
||||
<string name="changelog_title">日志</string>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2014 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.
|
||||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/http_advanced_settings_title">
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -40,6 +40,12 @@
|
||||
android:title="@string/read_settings_title"
|
||||
android:icon="@drawable/ic_setting_read_dark" />
|
||||
|
||||
<header
|
||||
android:id="@+id/advanced_settings"
|
||||
android:fragment="com.hippo.ehviewer.ui.SettingsActivity$AdvancedFragment"
|
||||
android:title="@string/advanced_settings_title"
|
||||
android:icon="@drawable/ic_setting_advanced_dark" />
|
||||
|
||||
<header
|
||||
android:id="@+id/about_settings"
|
||||
android:fragment="com.hippo.ehviewer.ui.SettingsActivity$AboutFragment"
|
||||
|
||||
@@ -42,6 +42,8 @@ public class AppContext extends Application implements UncaughtExceptionHandler
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = "AppContext";
|
||||
|
||||
public static final boolean DEBUG = true;
|
||||
|
||||
private Thread.UncaughtExceptionHandler mDefaultHandler;
|
||||
|
||||
private static AppContext sInstance;
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import com.hippo.ehviewer.ehclient.EhClient;
|
||||
import com.hippo.ehviewer.network.UrlBuilder;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Utils;
|
||||
|
||||
@@ -214,98 +215,104 @@ public class ListUrls {
|
||||
}
|
||||
|
||||
public String getUrl(int mode) {
|
||||
StringBuilder url = new StringBuilder(EhClient.getUrlHeader(mode));
|
||||
|
||||
switch (mMode) {
|
||||
case MODE_POPULAR:
|
||||
return null;
|
||||
|
||||
case MODE_IMAGE_SEARCH:
|
||||
if (mResultUrl == null) {
|
||||
if (mResultUrl == null)
|
||||
return null;
|
||||
} else {
|
||||
else
|
||||
return mResultUrl + "&page=" + page;
|
||||
}
|
||||
|
||||
case MODE_TAG:
|
||||
// Add tag
|
||||
url.append("tag/");
|
||||
StringBuilder sb = new StringBuilder(EhClient.getUrlHeader(mode));
|
||||
sb.append("tag/");
|
||||
if (mTag != null) {
|
||||
String[] tag = mTag.split("\\s+");
|
||||
try {
|
||||
for (int i = 0; i < tag.length; i++)
|
||||
tag[i] = URLEncoder.encode(tag[i], "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {}
|
||||
url.append(Utils.join(tag, '+'));
|
||||
sb.append(Utils.join(tag, '+'));
|
||||
|
||||
// Add page
|
||||
url.append("/").append(page);
|
||||
sb.append("/").append(page);
|
||||
} else {
|
||||
url.append(page);
|
||||
sb.append(page);
|
||||
}
|
||||
break;
|
||||
return sb.toString();
|
||||
|
||||
case MODE_NORMAL:
|
||||
case MODE_UPLOADER:
|
||||
default:
|
||||
String header = EhClient.getUrlHeader(mode);
|
||||
boolean isNeedFooter = false;
|
||||
UrlBuilder ub;
|
||||
// Add category
|
||||
if (category != NONE) {
|
||||
isNeedFooter = true;
|
||||
if (NUM_CATEGORY) {
|
||||
url.append(category).append('?');
|
||||
ub = new UrlBuilder(header + category);
|
||||
} else {
|
||||
url.append("?");
|
||||
if ((category & DOUJINSHI) == 0) url.append("f_doujinshi=0&"); else url.append("f_doujinshi=1&");
|
||||
if ((category & MANGA) == 0) url.append("f_manga=0&"); else url.append("f_manga=1&");
|
||||
if ((category & ARTIST_CG) == 0) url.append("f_artistcg=0&"); else url.append("f_artistcg=1&");
|
||||
if ((category & GAME_CG) == 0) url.append("f_gamecg=0&"); else url.append("f_gamecg=1&");
|
||||
if ((category & WESTERN) == 0) url.append("f_western=0&"); else url.append("f_western=1&");
|
||||
if ((category & NON_H) == 0) url.append("f_non-h=0&"); else url.append("f_non-h=1&");
|
||||
if ((category & IMAGE_SET) == 0) url.append("f_imageset=0&"); else url.append("f_imageset=1&");
|
||||
if ((category & COSPLAY) == 0) url.append("f_cosplay=0&"); else url.append("f_cosplay=1&");
|
||||
if ((category & ASIAN_PORN) == 0) url.append("f_asianporn=0&"); else url.append("f_asianporn=1&");
|
||||
if ((category & MISC) == 0) url.append("f_misc=0&"); else url.append("f_misc=1&");
|
||||
ub = new UrlBuilder(header);
|
||||
ub.addQuery("f_doujinshi", ((category & DOUJINSHI) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_manga", ((category & MANGA) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_artistcg", ((category & ARTIST_CG) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_gamecg", ((category & GAME_CG) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_western", ((category & WESTERN) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_non-h", ((category & NON_H) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_imageset", ((category & IMAGE_SET) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_cosplay", ((category & COSPLAY) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_asianporn", ((category & ASIAN_PORN) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_misc", ((category & MISC) == 0) ? "0" : "1");
|
||||
}
|
||||
} else {
|
||||
url.append('?');
|
||||
ub = new UrlBuilder(header);
|
||||
}
|
||||
|
||||
// Add search item
|
||||
if (search != null) {
|
||||
isNeedFooter = true;
|
||||
url.append("f_search=");
|
||||
|
||||
String[] tag = search.split("\\s+");
|
||||
try {
|
||||
for (int i = 0; i < tag.length; i++)
|
||||
tag[i] = URLEncoder.encode(tag[i], "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {}
|
||||
url.append(Utils.join(tag, '+')).append("&");
|
||||
|
||||
ub.addQuery("f_search", Utils.join(tag, '+'));
|
||||
}
|
||||
|
||||
// Add page
|
||||
url.append("page=").append(page).append("&");
|
||||
if (page != 0) {
|
||||
ub.addQuery("page", page);
|
||||
}
|
||||
|
||||
// Add foot
|
||||
if (isNeedFooter) url.append("f_apply=Apply+Filter");
|
||||
if (isNeedFooter) ub.addQuery("f_apply", "Apply+Filter");
|
||||
|
||||
// Add advance search
|
||||
if (isAdvance()) {
|
||||
url.append("&advsearch=1");
|
||||
if((advsearchType & SNAME) != 0) url.append("&f_sname=on");
|
||||
if((advsearchType & STAGS) != 0) url.append("&f_stags=on");
|
||||
if((advsearchType & SDESC) != 0) url.append("&f_sdesc=on");
|
||||
if((advsearchType & STORR) != 0) url.append("&f_storr=on");
|
||||
if((advsearchType & STO) != 0) url.append("&f_sto=on");
|
||||
if((advsearchType & STD1) != 0) url.append("&f_sdt1=on");
|
||||
if((advsearchType & STD2) != 0) url.append("&f_sdt2=on");
|
||||
if((advsearchType & SH) != 0) url.append("&f_sh=on");
|
||||
ub.addQuery("advsearch", "1");
|
||||
if((advsearchType & SNAME) != 0) ub.addQuery("f_sname", "on");
|
||||
if((advsearchType & STAGS) != 0) ub.addQuery("f_stags", "on");
|
||||
if((advsearchType & SDESC) != 0) ub.addQuery("f_sdesc", "on");
|
||||
if((advsearchType & STORR) != 0) ub.addQuery("f_storr", "on");
|
||||
if((advsearchType & STO) != 0) ub.addQuery("f_sto", "on");
|
||||
if((advsearchType & STD1) != 0) ub.addQuery("f_sdt1", "on");
|
||||
if((advsearchType & STD2) != 0) ub.addQuery("f_sdt2", "on");
|
||||
if((advsearchType & SH) != 0) ub.addQuery("f_sh", "on");
|
||||
|
||||
// Set min star
|
||||
if (isMinRating()) url.append("&f_sr=on&f_srdd=").append(minRating);
|
||||
if (isMinRating()) {
|
||||
ub.addQuery("f_sr", "on");
|
||||
ub.addQuery("f_srdd", minRating);
|
||||
}
|
||||
}
|
||||
return ub.build();
|
||||
}
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ import com.hippo.ehviewer.util.Utils;
|
||||
public class HttpHelper {
|
||||
private static final String TAG = HttpHelper.class.getSimpleName();
|
||||
|
||||
private static final int HTTP_RETRY_TIMES = 5;
|
||||
private static final int HTTP_RETRY_TIMES = 3;
|
||||
|
||||
public static final String SAD_PANDA_ERROR = "Sad Panda";
|
||||
public static final String HAPPY_PANDA_BODY = "Happy Panda";
|
||||
@@ -197,12 +197,12 @@ public class HttpHelper {
|
||||
}
|
||||
|
||||
private Object requst(RequestHelper rh) {
|
||||
mException = null;
|
||||
int redirectionCount = 0;
|
||||
URL url = null;
|
||||
HttpURLConnection conn = null;
|
||||
|
||||
for (int times = 0; times < HTTP_RETRY_TIMES; times++) {
|
||||
mException = null;
|
||||
int redirectionCount = 0;
|
||||
boolean firstTime = true;
|
||||
try {
|
||||
url = rh.getUrl();
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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.network;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class UrlBuilder {
|
||||
|
||||
public String mRootUrl;
|
||||
public Map<String, Object> mQueryMap = new HashMap<String, Object>();
|
||||
|
||||
public UrlBuilder(String rootUrl) {
|
||||
mRootUrl = rootUrl;
|
||||
}
|
||||
|
||||
public void addQuery(String key, Object value) {
|
||||
mQueryMap.put(key, value);
|
||||
}
|
||||
|
||||
public String build() {
|
||||
if (mQueryMap.size() == 0) {
|
||||
return mRootUrl;
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder(mRootUrl);
|
||||
sb.append("?");
|
||||
|
||||
Iterator<String> iter = mQueryMap.keySet().iterator();
|
||||
if (iter.hasNext()) {
|
||||
String key = iter.next();
|
||||
Object value = mQueryMap.get(key);
|
||||
sb.append(key).append("=").append(value);
|
||||
}
|
||||
while (iter.hasNext()) {
|
||||
String key = iter.next();
|
||||
Object value = mQueryMap.get(key);
|
||||
sb.append("&").append(key).append("=").append(value);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,6 +137,7 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
EhFragment.class.getName(),
|
||||
DataFragment.class.getName(),
|
||||
ReadFragment.class.getName(),
|
||||
AdvancedFragment.class.getName(),
|
||||
AboutFragment.class.getName()
|
||||
};
|
||||
|
||||
@@ -145,6 +146,7 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
R.drawable.ic_action_panda,
|
||||
R.drawable.ic_setting_data,
|
||||
R.drawable.ic_setting_read,
|
||||
R.drawable.ic_setting_advanced,
|
||||
R.drawable.ic_setting_about
|
||||
};
|
||||
|
||||
@@ -609,6 +611,14 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public static class AdvancedFragment extends TranslucentPreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.advanced_settings);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AboutFragment extends TranslucentPreferenceFragment
|
||||
implements Preference.OnPreferenceClickListener,
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
||||
@@ -22,7 +22,9 @@ import java.io.IOException;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class Log {
|
||||
import com.hippo.ehviewer.AppContext;
|
||||
|
||||
public final class Log {
|
||||
private static final String NULL = "null";
|
||||
private static final String LOG_FILENAME = "log.log";
|
||||
|
||||
@@ -72,51 +74,59 @@ public class Log {
|
||||
}
|
||||
|
||||
public static int v(String tag, String msg) {
|
||||
if (msg == null)
|
||||
msg = NULL;
|
||||
return android.util.Log.v(tag, msg);
|
||||
if (AppContext.DEBUG)
|
||||
return android.util.Log.v(tag, msg == null ? NULL : msg);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int v(String tag, String msg, Throwable tr) {
|
||||
if (msg == null)
|
||||
msg = NULL;
|
||||
return android.util.Log.v(tag, msg, tr);
|
||||
if (AppContext.DEBUG)
|
||||
return android.util.Log.v(tag, msg == null ? NULL : msg, tr);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int d(String tag, String msg) {
|
||||
if (msg == null)
|
||||
msg = NULL;
|
||||
return android.util.Log.d(tag, msg);
|
||||
if (AppContext.DEBUG)
|
||||
return android.util.Log.d(tag, msg == null ? NULL : msg);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int d(String tag, String msg, Throwable tr) {
|
||||
if (msg == null)
|
||||
msg = NULL;
|
||||
return android.util.Log.d(tag, msg, tr);
|
||||
if (AppContext.DEBUG)
|
||||
return android.util.Log.d(tag, msg == null ? NULL : msg, tr);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int i(String tag, String msg) {
|
||||
if (msg == null)
|
||||
msg = NULL;
|
||||
return android.util.Log.i(tag, msg);
|
||||
if (AppContext.DEBUG)
|
||||
return android.util.Log.i(tag, msg == null ? NULL : msg);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int i(String tag, String msg, Throwable tr) {
|
||||
if (msg == null)
|
||||
msg = NULL;
|
||||
return android.util.Log.i(tag, msg, tr);
|
||||
if (AppContext.DEBUG)
|
||||
return android.util.Log.i(tag, msg == null ? NULL : msg, tr);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int w(String tag, String msg) {
|
||||
if (msg == null)
|
||||
msg = NULL;
|
||||
return android.util.Log.w(tag, msg);
|
||||
if (AppContext.DEBUG)
|
||||
return android.util.Log.w(tag, msg == null ? NULL : msg);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int w(String tag, String msg, Throwable tr) {
|
||||
if (msg == null)
|
||||
msg = NULL;
|
||||
return android.util.Log.w(tag, msg, tr);
|
||||
if (AppContext.DEBUG)
|
||||
return android.util.Log.w(tag, msg == null ? NULL : msg, tr);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int w(String tag, Throwable tr) {
|
||||
@@ -124,14 +134,16 @@ public class Log {
|
||||
}
|
||||
|
||||
public static int e(String tag, String msg) {
|
||||
if (msg == null)
|
||||
msg = NULL;
|
||||
return android.util.Log.e(tag, msg);
|
||||
if (AppContext.DEBUG)
|
||||
return android.util.Log.e(tag, msg == null ? NULL : msg);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int e(String tag, String msg, Throwable tr) {
|
||||
if (msg == null)
|
||||
msg = NULL;
|
||||
return android.util.Log.e(tag, msg, tr);
|
||||
if (AppContext.DEBUG)
|
||||
return android.util.Log.e(tag, msg == null ? NULL : msg, tr);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||