diff --git a/app/build.gradle b/app/build.gradle
index 0a90c48..3890e99 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -7,7 +7,7 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
- versionCode 13200
+ versionCode 13300
}
buildTypes {
release {
@@ -17,7 +17,7 @@ android {
}
productFlavors {
- def String name = "1.3.2"
+ def String name = "1.3.3"
COOLAPK {
applicationId "rikka.searchbyimage"
diff --git a/app/src/main/java/rikka/searchbyimage/SearchByImageApplication.java b/app/src/main/java/rikka/searchbyimage/SearchByImageApplication.java
index 7c9c409..7e85fa9 100644
--- a/app/src/main/java/rikka/searchbyimage/SearchByImageApplication.java
+++ b/app/src/main/java/rikka/searchbyimage/SearchByImageApplication.java
@@ -10,6 +10,7 @@
* Created by Rikka on 2015/12/31.
*/
public class SearchByImageApplication extends Application {
+ // TODO: change this to save to file
private InputStream imageInputStream;
public InputStream getImageInputStream() {
diff --git a/app/src/main/java/rikka/searchbyimage/ui/UploadActivity.java b/app/src/main/java/rikka/searchbyimage/ui/UploadActivity.java
index 401f547..dc5f0e4 100644
--- a/app/src/main/java/rikka/searchbyimage/ui/UploadActivity.java
+++ b/app/src/main/java/rikka/searchbyimage/ui/UploadActivity.java
@@ -17,6 +17,7 @@
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.JsonReader;
+import android.widget.PopupWindow;
import java.io.File;
import java.io.FileInputStream;
@@ -43,6 +44,7 @@ public class UploadActivity extends AppCompatActivity {
public final static int SITE_IQDB = 2;
public final static int SITE_TINEYE = 3;
public final static int SITE_SAUCENAO = 4;
+ public final static int SITE_ASCII2D = 5;
private class Error {
public String title;
@@ -116,6 +118,10 @@ protected HttpUpload doInBackground(Uri... imageUrl) {
uploadUri = "http://saucenao.com/search.php";
name = "file";
break;
+ case SITE_ASCII2D:
+ uploadUri = "http://www.ascii2d.net/search/file";
+ name = "file";
+ break;
}
HttpRequestUtils httpRequest = new HttpRequestUtils(uploadUri, "POST");
@@ -220,20 +226,25 @@ public void onCancel(DialogInterface dialog) {
switch (result.siteId) {
case SITE_BAIDU:
- int errno = 0;
+ int err_no = 0;
String contsign = "";
String obj_url = "";
String simid = "";
+ String error_msg = "";
JsonReader reader = null;
try {
reader = new JsonReader(new InputStreamReader(new FileInputStream(new File(result.html))));
reader.beginObject();
+
while (reader.hasNext()) {
String keyName = reader.nextName();
switch (keyName) {
case "errno":
- errno = reader.nextInt();
+ err_no = reader.nextInt();
+ break;
+ case "msg":
+ error_msg = reader.nextString();
break;
case "json_data":
reader.beginObject();
@@ -253,7 +264,7 @@ public void onCancel(DialogInterface dialog) {
}
}
reader.endObject();
- } catch (IOException e) {
+ } catch (IllegalStateException | IOException e) {
e.printStackTrace();
} finally {
try {
@@ -265,6 +276,29 @@ public void onCancel(DialogInterface dialog) {
}
}
+ if (err_no != 0) {
+ new AlertDialog.Builder(mActivity)
+ .setTitle("baidu.com")
+ .setMessage(error_msg)
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
+ })
+ .setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ finish();
+ }
+ })
+ .show();
+
+ mProgressDialog.dismiss();
+
+ return;
+ }
+
StringBuilder sb = new StringBuilder();
sb.append("http://image.baidu.com/n/mo_search?guess=1&rn=30&appid=0&tag=1&isMobile=0");
sb.append("&queryImageUrl=");
@@ -276,6 +310,7 @@ public void onCancel(DialogInterface dialog) {
result.url = sb.toString();
case SITE_GOOGLE:
case SITE_TINEYE:
+ case SITE_ASCII2D:
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mActivity);
switch (sharedPref.getString("show_result_in", URLUtils.SHOW_IN_WEBVIEW)) {
case URLUtils.SHOW_IN_WEBVIEW:
diff --git a/app/src/main/java/rikka/searchbyimage/ui/WebViewActivity.java b/app/src/main/java/rikka/searchbyimage/ui/WebViewActivity.java
index 4c4d17d..0d9f024 100644
--- a/app/src/main/java/rikka/searchbyimage/ui/WebViewActivity.java
+++ b/app/src/main/java/rikka/searchbyimage/ui/WebViewActivity.java
@@ -69,7 +69,8 @@ public class WebViewActivity extends AppCompatActivity {
"", // baidu
"", // iqdb
"", // tineye
- "http://saucenao.com/" //saucenao
+ "http://saucenao.com/", //saucenao
+ ""
};
private WebView mWebView;
diff --git a/app/src/main/java/rikka/searchbyimage/ui/fragment/SettingsFragment.java b/app/src/main/java/rikka/searchbyimage/ui/fragment/SettingsFragment.java
index 45f0091..0cc7a67 100644
--- a/app/src/main/java/rikka/searchbyimage/ui/fragment/SettingsFragment.java
+++ b/app/src/main/java/rikka/searchbyimage/ui/fragment/SettingsFragment.java
@@ -43,6 +43,9 @@ public class SettingsFragment extends PreferenceFragment implements
EditTextPreference mCustomGoogleUri;
PreferenceCategory mCategorySauceNAO;
+ PreferenceCategory mCategoryNotice;
+ Preference mNotice;
+
private int click = 0;
private Runnable clearClickCount = new Runnable() {
@Override
@@ -83,10 +86,12 @@ public void onCreatePreferences(Bundle bundle, String s) {
mCategoryGoogle = (PreferenceCategory) findPreference("category_google");
mCategoryIqdb = (PreferenceCategory) findPreference("category_iqdb");
mCategorySauceNAO = (PreferenceCategory) findPreference("category_saucenao");
+ mCategoryNotice = (PreferenceCategory) findPreference("category_notice");
mSafeSearch = (SwitchPreference) findPreference("safe_search_preference");
mScreen = (PreferenceScreen) findPreference("screen");
mCustomGoogleUri = (EditTextPreference) findPreference("google_region");
+ mNotice = (Preference) findPreference("preference_notice");
setCustomGoogleUriHide();
setSearchEngineHide();
@@ -185,6 +190,7 @@ private void setSearchEngineHide() {
mScreen.removePreference(mCategoryIqdb);
mScreen.addPreference(mCategorySauceNAO);
break;
+ case UploadActivity.SITE_ASCII2D:
case UploadActivity.SITE_BAIDU:
case UploadActivity.SITE_TINEYE:
mScreen.removePreference(mCategoryGoogle);
@@ -193,6 +199,20 @@ private void setSearchEngineHide() {
break;
}
+
+ switch (siteId) {
+ case UploadActivity.SITE_BAIDU:
+ mScreen.addPreference(mCategoryNotice);
+ mNotice.setSummary(R.string.notice_baidu);
+ break;
+ case UploadActivity.SITE_GOOGLE:
+ case UploadActivity.SITE_IQDB:
+ case UploadActivity.SITE_SAUCENAO:
+ case UploadActivity.SITE_ASCII2D:
+ case UploadActivity.SITE_TINEYE:
+ mScreen.removePreference(mCategoryNotice);
+ break;
+ }
}
@Override
diff --git a/app/src/main/java/rikka/searchbyimage/utils/HttpRequestUtils.java b/app/src/main/java/rikka/searchbyimage/utils/HttpRequestUtils.java
index 20d1b1a..5ef8c3a 100644
--- a/app/src/main/java/rikka/searchbyimage/utils/HttpRequestUtils.java
+++ b/app/src/main/java/rikka/searchbyimage/utils/HttpRequestUtils.java
@@ -182,7 +182,6 @@ public Request initRequest(RequestBody requestBody) throws IOException {
.addHeader("accept-encoding", "deflate")
.addHeader("cache-control", "no-cache")
.addHeader("connection", "Keep-Alive")
- .addHeader("transfer-rncoding", "chunked")
.addHeader("user-agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36")
.post(requestBody)
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index 97954d5..8494072 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -11,6 +11,7 @@
- iqdb
- TinEye
- SauceNAO
+ - ascii2d
使い方
@@ -56,6 +57,7 @@
設定
アップロード前に設定を開く
アップロード画像を圧縮
+ Try this if upload error
アップロード
アクセスが必要
@@ -82,6 +84,9 @@
接続タイムアウト
ドメイン解決エラー
+ Notice
+ WEBP image or large size image is not supported.
+
検索結果を表示
アプリ内ブラウザ
Chrome custom tabs
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 7190ce4..ef7d82e 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -11,7 +11,7 @@
- iqdb
- TinEye
- SauceNAO
-
+ - ascii2d
使用方法
@@ -56,6 +56,7 @@
设置
上传前打开设置
压缩上传图片
+ 当图片不能正常上传时可尝试此选项
开始上传
需要权限
@@ -82,6 +83,9 @@
域名解析错误
网络错误
+ 注意
+ 不支持WebP格式和较大图片
+
结果打开方式
内置浏览器
Chrome custom tabs
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 000dcca..5fdce8e 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -11,6 +11,7 @@
- iqdb
- TinEye
- SauceNAO
+ - ascii2d
使用方法
@@ -54,6 +55,7 @@
設定
上載前打開設置
压缩上載圖片
+ 当图片不能正常上传时可尝试此选项
開始上載
需要权限
@@ -79,6 +81,9 @@
网络错误
域名解析错误
+ 注意
+ 不支持webp格式和较大图片
+
结果打开方式
內建瀏覽器
Chrome custom tabs
diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml
index 03c6657..fc874b4 100644
--- a/app/src/main/res/values/array.xml
+++ b/app/src/main/res/values/array.xml
@@ -5,6 +5,7 @@
- 2
- 3
- 4
+ - 5
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 563bec5..1dea6dc 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -11,6 +11,7 @@
- iqdb
- TinEye
- SauceNAO
+ - ascii2d
Usage
@@ -56,6 +57,7 @@
Settings
Open settings before upload
Compress upload image
+ Try this if upload error
Start upload
Permission require
@@ -82,6 +84,9 @@
Domain resolution error
Network error
+ Notice
+ WEBP image or large size image is not supported.
+
Show result in
Build-in browser
Chrome custom tabs
diff --git a/app/src/main/res/xml/preferences_general.xml b/app/src/main/res/xml/preferences_general.xml
index 66636b4..90e3aa3 100644
--- a/app/src/main/res/xml/preferences_general.xml
+++ b/app/src/main/res/xml/preferences_general.xml
@@ -25,9 +25,10 @@
android:layout="@layout/preference_material"/>