mirror of
https://github.com/seven332/EhViewer
synced 2026-12-02 12:08:02 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f340279e57 | ||
|
|
ddb1edb7d1 | ||
|
|
a7f29a3cd5 | ||
|
|
d09e4a9215 | ||
|
|
07335ba49c | ||
|
|
b55d5a1538 | ||
|
|
97fc40a69c | ||
|
|
cc73666475 | ||
|
|
0ed34f2eca | ||
|
|
a7a3d56c91 | ||
|
|
748c5cb812 |
No files matched your search
+2
-2
@@ -16,8 +16,8 @@
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hippo.ehviewer"
|
||||
android:versionCode="26"
|
||||
android:versionName="0.6.5" >
|
||||
android:versionCode="27"
|
||||
android:versionName="0.6.6" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
Version 0.6.6 (2014-10-13)
|
||||
* 下载目录命名方式恢复为 gid-title,以前的目录名称可在 设置->高级->其他->修正下载文件夹名 处修改
|
||||
* 避免大量通知
|
||||
* 添加 Twitter 信息
|
||||
* 修正阅读边界提示过于敏感
|
||||
* 修正一处可能的崩溃
|
||||
|
||||
Version 0.6.5 (2014-10-07)
|
||||
* 调整界面
|
||||
* 调整阅读滑动效果
|
||||
|
||||
@@ -77,6 +77,8 @@
|
||||
<string name="no_avatar">无头像</string>
|
||||
<string name="get_avatar_error">获取头像失败</string>
|
||||
<string name="image_search">图像搜索</string>
|
||||
<string name="image_not_exist">图像不存在</string>
|
||||
<string name="image_not_readable">图像不可读</string>
|
||||
|
||||
<!-- Update -->
|
||||
<string name="update_message" formatted="false">发现新版本:%s\n大小:%s\n%s\n\n是否更新?</string>
|
||||
@@ -101,6 +103,12 @@
|
||||
<string name="legacy_pages">%d 页未下载</string>
|
||||
<string name="download_over">下载结束</string>
|
||||
<string name="start_download">开始下载</string>
|
||||
<string name="download_1">下载成功 %d</string>
|
||||
<string name="download_2">下载成功 %d 项</string>
|
||||
<string name="download_3">下载失败 %d</string>
|
||||
<string name="download_4">下载失败 %d 项</string>
|
||||
<string name="download_5" formatted="false">下载成功 %d, 下载失败 %d</string>
|
||||
<string name="download_6" formatted="false">下载成功 %d 项, 下载失败 %d 项</string>
|
||||
|
||||
<!-- ErrorMessage -->
|
||||
<string name="em_network_error">网络错误</string>
|
||||
@@ -133,6 +141,9 @@
|
||||
<string name="em_index_error">索引错误</string>
|
||||
<string name="em_requst_null">请求内容为空</string>
|
||||
|
||||
<!-- GalleryActivity -->
|
||||
<string name="ga_data_error">数据错误!</string>
|
||||
|
||||
<!-- Gallery -->
|
||||
<string name="gallery_tip">长按屏幕,可使下载从当前页面开始。若该项正在下载,则仅优先加载当前页面。</string>
|
||||
<string name="read_image_error">读取图片错误</string>
|
||||
@@ -231,9 +242,14 @@
|
||||
<string name="http_read_timeout_title">读取超时 (ms)</string>
|
||||
<string name="eh_advanced_settings_title">EH</string>
|
||||
<string name="eh_min_interval_title">EH 站点最小连接间隔 (ms)</string>
|
||||
<string name="eh_others_settings_title">其他</string>
|
||||
<string name="fix_dirname_title">修正下载文件夹名</string>
|
||||
<string name="fix_dirname_title_summary">将下载文件夹名由 gid 改为 gid-title,不进行修正不会影响使用</string>
|
||||
|
||||
<string name="about_settings_title">关于</string>
|
||||
<string name="author_title">作者</string>
|
||||
<string name="twitter_title">Twitter</string>
|
||||
<string name="twitter_summary">目前由 @jkjvinn 管理更新</string>
|
||||
<string name="changelog_title">日志</string>
|
||||
<string name="thanks_title">感谢</string>
|
||||
<string name="website_title">网站</string>
|
||||
@@ -325,6 +341,7 @@
|
||||
<string name="rating0">…</string>
|
||||
|
||||
<!-- Utils -->
|
||||
<string name="close">关闭</string>
|
||||
<string name="select">选择</string>
|
||||
<string name="click_more">点击查看更多</string>
|
||||
<string name="similar_content">相似内容</string>
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
<string name="no_avatar">無頭像</string>
|
||||
<string name="get_avatar_error">獲取頭像失敗</string>
|
||||
<string name="image_search">圖像搜索</string>
|
||||
<string name="image_not_exist">圖像不存在</string>
|
||||
<string name="image_not_readable">圖像不可讀</string>
|
||||
|
||||
<!-- Update -->
|
||||
<string name="update_message" formatted="false">發現新版本:%s\n大小:%s\n%s\n\n是否更新?</string>
|
||||
@@ -89,6 +91,12 @@
|
||||
<string name="legacy_pages">%d 頁未下載</string>
|
||||
<string name="download_over">下載結束</string>
|
||||
<string name="start_download">開始下載</string>
|
||||
<string name="download_1">下載成功 %d</string>
|
||||
<string name="download_2">下載成功 %d 項</string>
|
||||
<string name="download_3">下載失敗 %d</string>
|
||||
<string name="download_4">下載失敗 %d 項</string>
|
||||
<string name="download_5" formatted="false">下載成功 %d, 下載失敗 %d</string>
|
||||
<string name="download_6" formatted="false">下載成功 %d 項, 下載失敗 %d 項</string>
|
||||
|
||||
<!-- ErrorMessage -->
|
||||
<string name="em_network_error">網絡錯誤</string>
|
||||
@@ -121,6 +129,9 @@
|
||||
<string name="em_index_error">索引錯誤</string>
|
||||
<string name="em_requst_null">請求內容爲空</string>
|
||||
|
||||
<!-- GalleryActivity -->
|
||||
<string name="ga_data_error">數據錯誤!</string>
|
||||
|
||||
<!-- Gallery -->
|
||||
<string name="gallery_tip">長按屏幕,可使下載從當前頁面開始。若該項正在下載,則僅優先加載當前頁面。</string>
|
||||
<string name="read_image_error">讀取圖片錯誤</string>
|
||||
@@ -194,6 +205,15 @@
|
||||
<string name="custom_codec_title">自定義解碼</string>
|
||||
<string name="custom_codec_summary">自定義解碼可能會更使用更少內存,解碼更快</string>
|
||||
<string name="custom_codec_summary_not">自定義解碼暫不支持 x86, mips</string>
|
||||
<string name="clean_redundancy_title">清理閱讀冗餘</string>
|
||||
<string name="no_redundancy">未發現冗餘</string>
|
||||
<string name="clean_redundancy">完成冗餘清理,共清理 %d 項</string>
|
||||
<string name="decode_format_title">解碼格式</string>
|
||||
<string name="decode_format_auto">自動</string>
|
||||
<string name="decode_format_gray">黑白</string>
|
||||
<string name="decode_format_gray_alpha">黑白(透明)</string>
|
||||
<string name="decode_format_rgb">彩色</string>
|
||||
<string name="decode_format_rgba">彩色(透明)</string>
|
||||
|
||||
<string name="download_settings_title">下載</string>
|
||||
<string name="download_path_title">下載路徑</string>
|
||||
@@ -210,9 +230,14 @@
|
||||
<string name="http_read_timeout_title">讀取超時 (ms)</string>
|
||||
<string name="eh_advanced_settings_title">EH</string>
|
||||
<string name="eh_min_interval_title">EH 站點最小連接間隔 (ms)</string>
|
||||
<string name="eh_others_settings_title">其他</string>
|
||||
<string name="fix_dirname_title">修正下載文件夾名</string>
|
||||
<string name="fix_dirname_title_summary">將下載文件夾名由 gid 改爲 gid-title,不進行修正不會影響使用</string>
|
||||
|
||||
<string name="about_settings_title">關於</string>
|
||||
<string name="author_title">作者</string>
|
||||
<string name="twitter_title">Twitter</string>
|
||||
<string name="twitter_summary">目前由 @jkjvinn 管理更新</string>
|
||||
<string name="changelog_title">日誌</string>
|
||||
<string name="thanks_title">感謝</string>
|
||||
<string name="website_title">網站</string>
|
||||
@@ -304,6 +329,7 @@
|
||||
<string name="rating0">…</string>
|
||||
|
||||
<!-- Utils -->
|
||||
<string name="close">關閉</string>
|
||||
<string name="select">選擇</string>
|
||||
<string name="click_more">點擊查看更多</string>
|
||||
<string name="similar_content">相似內容</string>
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
<string name="no_avatar">無頭像</string>
|
||||
<string name="get_avatar_error">獲取頭像失敗</string>
|
||||
<string name="image_search">影象搜索</string>
|
||||
<string name="image_not_exist">影象不存在</string>
|
||||
<string name="image_not_readable">影象不可讀</string>
|
||||
|
||||
<!-- Update -->
|
||||
<string name="update_message" formatted="false">發現新版本:%s\n大小:%s\n%s\n\n是否更新?</string>
|
||||
@@ -89,6 +91,12 @@
|
||||
<string name="legacy_pages">%d 頁未下載</string>
|
||||
<string name="download_over">下載結束</string>
|
||||
<string name="start_download">開始下載</string>
|
||||
<string name="download_1">下載成功 %d</string>
|
||||
<string name="download_2">下載成功 %d 項</string>
|
||||
<string name="download_3">下載失敗 %d</string>
|
||||
<string name="download_4">下載失敗 %d 項</string>
|
||||
<string name="download_5" formatted="false">下載成功 %d, 下載失敗 %d</string>
|
||||
<string name="download_6" formatted="false">下載成功 %d 項, 下載失敗 %d 項</string>
|
||||
|
||||
<!-- ErrorMessage -->
|
||||
<string name="em_network_error">網路錯誤</string>
|
||||
@@ -121,6 +129,9 @@
|
||||
<string name="em_index_error">索引錯誤</string>
|
||||
<string name="em_requst_null">請求內容為空</string>
|
||||
|
||||
<!-- GalleryActivity -->
|
||||
<string name="ga_data_error">資料錯誤!</string>
|
||||
|
||||
<!-- Gallery -->
|
||||
<string name="gallery_tip">長按螢幕,可使下載從當前頁面開始。若該項正在下載,則僅優先載入當前頁面。</string>
|
||||
<string name="read_image_error">讀取圖片錯誤</string>
|
||||
@@ -194,6 +205,15 @@
|
||||
<string name="custom_codec_title">自定義解碼</string>
|
||||
<string name="custom_codec_summary">自定義解碼可能會更使用更少內存,解碼更快</string>
|
||||
<string name="custom_codec_summary_not">自定義解碼暫不支援 x86, mips</string>
|
||||
<string name="clean_redundancy_title">清理閱讀冗餘</string>
|
||||
<string name="no_redundancy">未發現冗餘</string>
|
||||
<string name="clean_redundancy">完成冗餘清理,共清理 %d 項</string>
|
||||
<string name="decode_format_title">解碼格式</string>
|
||||
<string name="decode_format_auto">自動</string>
|
||||
<string name="decode_format_gray">黑白</string>
|
||||
<string name="decode_format_gray_alpha">黑白(透明)</string>
|
||||
<string name="decode_format_rgb">彩色</string>
|
||||
<string name="decode_format_rgba">彩色(透明)</string>
|
||||
|
||||
<string name="download_settings_title">下載</string>
|
||||
<string name="download_path_title">下載路徑</string>
|
||||
@@ -210,9 +230,14 @@
|
||||
<string name="http_read_timeout_title">讀取超時 (ms)</string>
|
||||
<string name="eh_advanced_settings_title">EH</string>
|
||||
<string name="eh_min_interval_title">EH 站點最小連線間隔 (ms)</string>
|
||||
<string name="eh_others_settings_title">其他</string>
|
||||
<string name="fix_dirname_title">修正下載資料夾名</string>
|
||||
<string name="fix_dirname_title_summary">將下載資料夾名由 gid 改為 gid-title,不進行修正不會影響使用</string>
|
||||
|
||||
<string name="about_settings_title">關於</string>
|
||||
<string name="author_title">作者</string>
|
||||
<string name="twitter_title">Twitter</string>
|
||||
<string name="twitter_summary">目前由 @jkjvinn 管理更新</string>
|
||||
<string name="changelog_title">日誌</string>
|
||||
<string name="thanks_title">感謝</string>
|
||||
<string name="website_title">網站</string>
|
||||
@@ -304,6 +329,7 @@
|
||||
<string name="rating0">…</string>
|
||||
|
||||
<!-- Utils -->
|
||||
<string name="close">關閉</string>
|
||||
<string name="select">選擇</string>
|
||||
<string name="click_more">點選檢視更多</string>
|
||||
<string name="similar_content">相似內容</string>
|
||||
|
||||
@@ -80,6 +80,8 @@
|
||||
<string name="no_avatar">No avatar</string>
|
||||
<string name="get_avatar_error">Get avatar error</string>
|
||||
<string name="image_search">Image search</string>
|
||||
<string name="image_not_exist">Image does not exist</string>
|
||||
<string name="image_not_readable">Image is not readable</string>
|
||||
|
||||
<!-- Update -->
|
||||
<string name="update_message" formatted="false">Found new version : %s\nSize : %s\n%s\n\nUpdate ?</string>
|
||||
@@ -104,6 +106,12 @@
|
||||
<string name="legacy_pages">%d pages leaved</string>
|
||||
<string name="download_over">Download over</string>
|
||||
<string name="start_download">Start downloading</string>
|
||||
<string name="download_1">Download OK %d</string>
|
||||
<string name="download_2">Download OK %d items</string>
|
||||
<string name="download_3">Download failed %d</string>
|
||||
<string name="download_4">Download failed %d items</string>
|
||||
<string name="download_5" formatted="false">Download OK %d, Download failed %d</string>
|
||||
<string name="download_6" formatted="false">Download OK %d items, Download failed %d items</string>
|
||||
|
||||
<!-- ErrorMessage -->
|
||||
<string name="em_network_error">Network Error</string>
|
||||
@@ -136,6 +144,9 @@
|
||||
<string name="em_index_error">Index error</string>
|
||||
<string name="em_requst_null">Requst content is null</string>
|
||||
|
||||
<!-- GalleryActivity -->
|
||||
<string name="ga_data_error">Data Error !</string>
|
||||
|
||||
<!-- Gallery -->
|
||||
<string name="gallery_tip">Long press the screen to download from the current page. If the item is being downloaded, just load current page first.</string>
|
||||
<string name="read_image_error">Read image error</string>
|
||||
@@ -209,6 +220,15 @@
|
||||
<string name="custom_codec_title">Custom codec</string>
|
||||
<string name="custom_codec_summary">Custom codec may cost less memory, decode faster</string>
|
||||
<string name="custom_codec_summary_not">Custom codec do not support x86, mips</string>
|
||||
<string name="clean_redundancy_title">Clean redundancy</string>
|
||||
<string name="no_redundancy">No redundancy</string>
|
||||
<string name="clean_redundancy">Redundancy cleaning completed, clean-up %d items totally</string>
|
||||
<string name="decode_format_title">Decode format</string>
|
||||
<string name="decode_format_auto">Auto</string>
|
||||
<string name="decode_format_gray">Gray</string>
|
||||
<string name="decode_format_gray_alpha">Gray (alpha)</string>
|
||||
<string name="decode_format_rgb">RGB</string>
|
||||
<string name="decode_format_rgba">RGB (alpha)</string>
|
||||
|
||||
<string name="download_settings_title">Download</string>
|
||||
<string name="download_path_title">Download path</string>
|
||||
@@ -225,10 +245,15 @@
|
||||
<string name="http_read_timeout_title">Read timeout (ms)</string>
|
||||
<string name="eh_advanced_settings_title">EH</string>
|
||||
<string name="eh_min_interval_title">The minimum connection interval of EH site (ms)</string>
|
||||
<string name="eh_others_settings_title">Others</string>
|
||||
<string name="fix_dirname_title">Fix download folder name</string>
|
||||
<string name="fix_dirname_title_summary">Download folder name will be human readable. It is OK to leave me alone.</string>
|
||||
|
||||
<string name="about_settings_title">About</string>
|
||||
<string name="author_title">Author</string>
|
||||
<string name="author_summary" translatable="false">Hippo <ehviewersu@gmail.com></string>
|
||||
<string name="twitter_title">Twitter</string>
|
||||
<string name="twitter_summary">\@jkjvinn is in charge</string>
|
||||
<string name="changelog_title">Changelog</string>
|
||||
<string name="thanks_title">Thanks</string>
|
||||
<string name="website_title">Website</string>
|
||||
@@ -338,6 +363,7 @@
|
||||
<string name="rating0">DISASTER</string>
|
||||
|
||||
<!-- Util -->
|
||||
<string name="close">Close</string>
|
||||
<string name="select">Select</string>
|
||||
<string name="click_more">Click for more</string>
|
||||
<string name="similar_content">Similar content</string>
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
android:title="@string/author_title"
|
||||
android:summary="@string/author_summary" />
|
||||
|
||||
<Preference
|
||||
android:key="twitter"
|
||||
android:title="@string/twitter_title"
|
||||
android:summary="@string/twitter_summary" />
|
||||
|
||||
<Preference
|
||||
android:key="changelog"
|
||||
android:title="@string/changelog_title" />
|
||||
|
||||
@@ -59,5 +59,14 @@
|
||||
android:defaultValue="0" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/eh_others_settings_title">
|
||||
|
||||
<Preference
|
||||
android:key="fix_dirname"
|
||||
android:title="@string/fix_dirname_title"
|
||||
android:summary="@string/fix_dirname_title_summary" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
@@ -107,23 +107,14 @@ public class AppContext extends Application implements UncaughtExceptionHandler
|
||||
String[] list = downloadDir.list();
|
||||
if (list != null && list.length != 0) {
|
||||
for (String str : list) {
|
||||
// Change download dir name from gid-title to gid
|
||||
File oldDir = new File(downloadDir, str);
|
||||
if (!new File(oldDir, EhUtils.EH_DOWNLOAD_FILENAME).exists())
|
||||
continue;
|
||||
int index = str.indexOf('-');
|
||||
if (index == -1)
|
||||
continue;
|
||||
String gid = str.substring(0, index);
|
||||
File newDir = new File(downloadDir, gid);
|
||||
if (!oldDir.renameTo(newDir)) {
|
||||
// if delete error, might same gid and different title
|
||||
Utils.deleteDirInThread(oldDir);
|
||||
continue;
|
||||
}
|
||||
File gDir = new File(downloadDir, str);
|
||||
// Move download info file
|
||||
File oldInfoFile = new File(oldEdInfoDir, gid);
|
||||
File newInfoFile = new File(newDir, EhUtils.EH_DOWNLOAD_FILENAME);
|
||||
File newInfoFile = new File(gDir, EhUtils.EH_DOWNLOAD_FILENAME);
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(newInfoFile);
|
||||
// Add last page
|
||||
@@ -139,7 +130,6 @@ public class AppContext extends Application implements UncaughtExceptionHandler
|
||||
Utils.deleteDirInThread(oldEdInfoDir);
|
||||
}
|
||||
|
||||
|
||||
// Update version code
|
||||
try {
|
||||
PackageInfo pi= getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.hippo.ehviewer.data.Comment;
|
||||
import com.hippo.ehviewer.data.LargePreviewList;
|
||||
import com.hippo.ehviewer.data.NormalPreviewList;
|
||||
import com.hippo.ehviewer.data.PreviewList;
|
||||
import com.hippo.ehviewer.util.EhUtils;
|
||||
import com.hippo.ehviewer.util.Utils;
|
||||
|
||||
public class DetailParser {
|
||||
@@ -153,7 +154,7 @@ public class DetailParser {
|
||||
thumb = Utils.unescapeXml(m.group(1));
|
||||
title = Utils.unescapeXml(m.group(2));
|
||||
title_jpn = Utils.unescapeXml(m.group(3));
|
||||
category = EhClient.getType(m.group(4));
|
||||
category = EhUtils.getCategory(m.group(4));
|
||||
uploader = m.group(5);
|
||||
posted = m.group(6);
|
||||
pages = Integer.parseInt(m.group(7));
|
||||
|
||||
@@ -36,15 +36,17 @@ import android.os.Process;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.AppHandler;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.data.ApiGalleryInfo;
|
||||
import com.hippo.ehviewer.data.Comment;
|
||||
import com.hippo.ehviewer.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.data.GalleryPopular;
|
||||
import com.hippo.ehviewer.data.ListUrls;
|
||||
import com.hippo.ehviewer.data.LofiGalleryDetail;
|
||||
import com.hippo.ehviewer.data.PreviewList;
|
||||
import com.hippo.ehviewer.network.HttpHelper;
|
||||
import com.hippo.ehviewer.util.BgThread;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.EhUtils;
|
||||
import com.hippo.ehviewer.util.Utils;
|
||||
|
||||
public class EhClient {
|
||||
@@ -885,7 +887,7 @@ public class EhClient {
|
||||
|
||||
public void comment(final String detailUrl, final String comment,
|
||||
final OnCommentListener listener) {
|
||||
new Thread(new Runnable() {
|
||||
new BgThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HttpHelper hp = new HttpHelper(mContext);
|
||||
@@ -1090,56 +1092,6 @@ public class EhClient {
|
||||
}).start();
|
||||
}
|
||||
|
||||
private static final int[] CATEGORY_VALUES = {
|
||||
ListUrls.MISC,
|
||||
ListUrls.DOUJINSHI,
|
||||
ListUrls.MANGA,
|
||||
ListUrls.ARTIST_CG,
|
||||
ListUrls.GAME_CG,
|
||||
ListUrls.IMAGE_SET,
|
||||
ListUrls.COSPLAY,
|
||||
ListUrls.ASIAN_PORN,
|
||||
ListUrls.NON_H,
|
||||
ListUrls.WESTERN,
|
||||
ListUrls.UNKNOWN
|
||||
};
|
||||
|
||||
// TODO How about "Private"
|
||||
private static final String[][] CATEGORY_STRINGS = {
|
||||
new String[]{"misc"},
|
||||
new String[]{"doujinshi"},
|
||||
new String[]{"manga"},
|
||||
new String[]{"artistcg", "Artist CG Sets"},
|
||||
new String[]{"gamecg", "Game CG Sets"},
|
||||
new String[]{"imageset", "Image Sets"},
|
||||
new String[]{"cosplay"},
|
||||
new String[]{"asianporn", "Asian Porn"},
|
||||
new String[]{"non-h"},
|
||||
new String[]{"western"},
|
||||
new String[]{"unknown"}
|
||||
};
|
||||
|
||||
public static int getType(String type) {
|
||||
int i;
|
||||
for (i = 0; i < CATEGORY_STRINGS.length - 1; i++) {
|
||||
for (String str : CATEGORY_STRINGS[i])
|
||||
if (str.equalsIgnoreCase(type))
|
||||
return CATEGORY_VALUES[i];
|
||||
}
|
||||
|
||||
return CATEGORY_VALUES[i];
|
||||
}
|
||||
|
||||
public static String getType(int type) {
|
||||
int i;
|
||||
for (i = 0; i < CATEGORY_VALUES.length - 1; i++) {
|
||||
if (CATEGORY_VALUES[i] == type)
|
||||
break;
|
||||
}
|
||||
return CATEGORY_STRINGS[i][0];
|
||||
}
|
||||
|
||||
|
||||
// modifyFavorite
|
||||
public interface OnModifyFavoriteListener {
|
||||
void onSuccess(List<GalleryInfo> gis, int pageNum);
|
||||
@@ -1173,7 +1125,7 @@ public class EhClient {
|
||||
*/
|
||||
public void modifyFavorite(final int[] gids, final int dstCat, final int srcCat,
|
||||
final OnModifyFavoriteListener listener) {
|
||||
new Thread(new Runnable() {
|
||||
new BgThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int i;
|
||||
@@ -1231,7 +1183,7 @@ public class EhClient {
|
||||
listener.onFailure(e.getMessage());
|
||||
return;
|
||||
}
|
||||
new Thread(new Runnable() {
|
||||
new BgThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HttpHelper hp = new HttpHelper(mContext);
|
||||
@@ -1262,7 +1214,7 @@ public class EhClient {
|
||||
gi.title = Utils.unescapeXml(j.getString("title"));
|
||||
gi.posted = Utils.sDate.format(Long.parseLong(j.getString("posted")) * 1000);
|
||||
gi.thumb = j.getString("thumb");
|
||||
gi.category = getType(j.getString("category"));
|
||||
gi.category = EhUtils.getCategory(j.getString("category"));
|
||||
gi.uploader = j.getString("uploader");
|
||||
gi.rating = Float.parseFloat(j.getString("rating"));
|
||||
gi.generateSLang();
|
||||
@@ -1290,183 +1242,163 @@ public class EhClient {
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
private static class GetGalleryMetadataPackage {
|
||||
public Map<String, ListMangaDetail> lmds;
|
||||
public OnGetGalleryMetadataListener listener;
|
||||
|
||||
public GetGalleryMetadataPackage(Map<String, ListMangaDetail> lmds,
|
||||
OnGetGalleryMetadataListener listener) {
|
||||
this.lmds = lmds;
|
||||
this.listener = listener;
|
||||
}
|
||||
public interface OnGetApiGalleryInfoListener {
|
||||
public void onSuccess(Object checkFlag, ApiGalleryInfo[] agiArray);
|
||||
public void onFailure(Object checkFlag, String eMsg);
|
||||
}
|
||||
|
||||
private static Handler getGalleryMetadataHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
OnGetGalleryMetadataListener listener =
|
||||
((GetGalleryMetadataPackage) msg.obj).listener;
|
||||
Map<String, ListMangaDetail> lmds =
|
||||
((GetGalleryMetadataPackage) msg.obj).lmds;
|
||||
if (lmds == null || lmds.size() == 0)
|
||||
listener.onFailure(msg.what);
|
||||
else
|
||||
listener.onSuccess(lmds);
|
||||
};
|
||||
};
|
||||
private class GetApiGalleryInfoResponder implements Runnable {
|
||||
private final boolean isOk;
|
||||
private final OnGetApiGalleryInfoListener listener;
|
||||
private final Object checkFlag;
|
||||
private final ApiGalleryInfo[] agiArray;
|
||||
private final String eMesg;
|
||||
|
||||
private static class GetGalleryMetadataRunnable implements Runnable {
|
||||
private String[][] gidTokens;
|
||||
private OnGetGalleryMetadataListener listener;
|
||||
|
||||
public GetGalleryMetadataRunnable(String[][] gidTokens,
|
||||
OnGetGalleryMetadataListener listener) {
|
||||
this.gidTokens = gidTokens;
|
||||
public GetApiGalleryInfoResponder(OnGetApiGalleryInfoListener listener,
|
||||
Object checkFlag, ApiGalleryInfo[] agiArray) {
|
||||
this.isOk = true;
|
||||
this.listener = listener;
|
||||
this.checkFlag = checkFlag;
|
||||
this.agiArray = agiArray;
|
||||
this.eMesg = null;
|
||||
}
|
||||
|
||||
public GetApiGalleryInfoResponder(OnGetApiGalleryInfoListener listener,
|
||||
Object checkFlag, String eMsg) {
|
||||
this.isOk = false;
|
||||
this.listener = listener;
|
||||
this.checkFlag = checkFlag;
|
||||
this.agiArray = null;
|
||||
this.eMesg = eMsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int errorMessageId = R.string.em_unknown_error;
|
||||
Map<String, ListMangaDetail> lmds = new HashMap<String, ListMangaDetail>();
|
||||
if (isOk)
|
||||
listener.onSuccess(checkFlag, agiArray);
|
||||
else
|
||||
listener.onFailure(checkFlag, eMesg);
|
||||
}
|
||||
}
|
||||
|
||||
// Create post string
|
||||
StringBuffer strBuf = new StringBuffer();
|
||||
strBuf.append("{\"method\": \"gdata\",\"gidlist\": [");
|
||||
for (String[] item: gidTokens)
|
||||
strBuf.append("[" + item[0] + ",\"" + item[1] + "\"],");
|
||||
strBuf.delete(strBuf.length()-1, strBuf.length());
|
||||
strBuf.append("]}");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
errorMessageId = postJson(API_URL, strBuf.toString(),sb);
|
||||
if (sb.length() != 0) {
|
||||
String pageContent = sb.toString();
|
||||
private ApiGalleryInfo Json2Agi(JSONObject js) throws JSONException {
|
||||
ApiGalleryInfo agi = new ApiGalleryInfo();
|
||||
agi.gid = js.getInt("gid");
|
||||
agi.token = js.getString("token");
|
||||
agi.archiver_key = js.getString("archiver_key");
|
||||
agi.title = js.getString("title");
|
||||
agi.title_jpn = js.getString("title_jpn");
|
||||
agi.category = EhUtils.getCategory(js.getString("category"));
|
||||
agi.thumb = js.getString("thumb");
|
||||
agi.uploader = js.getString("uploader");
|
||||
agi.posted = Utils.sDate.format(Long.parseLong(js.getString("posted")) * 1000);
|
||||
agi.filecount = js.getString("filecount");
|
||||
agi.filesize = js.getLong("filesize");
|
||||
agi.expunged = js.getBoolean("expunged");
|
||||
agi.rating = Float.parseFloat(js.getString("rating"));
|
||||
agi.torrentcount = js.getString("torrentcount");
|
||||
JSONArray tags = js.getJSONArray("tags");
|
||||
agi.apiTags = new String[tags.length()];
|
||||
for (int j = 0; j < tags.length(); j++)
|
||||
agi.apiTags[j] = tags.getString(j);
|
||||
return agi;
|
||||
}
|
||||
|
||||
public void getApiGalleryInfo(final Object checkFlag, final int[] gids, final String[] tokens, final OnGetApiGalleryInfoListener l) {
|
||||
new BgThread() {
|
||||
@Override
|
||||
public void run() {
|
||||
GetApiGalleryInfoResponder responder;
|
||||
ApiGalleryInfo[] agiArray;
|
||||
int requstLen;
|
||||
// Create json
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd hh:mm");
|
||||
JSONObject jsonObject = new JSONObject(pageContent);
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("gmetadata");
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jo = jsonArray.getJSONObject(i);
|
||||
if (jo.getString("error") != null)
|
||||
continue;
|
||||
ListMangaDetail lmd = new ListMangaDetail();
|
||||
lmd.gid = Long.toString(jo.getLong("gid"));
|
||||
lmd.token = jo.getString("token");
|
||||
lmd.archiver_key = jo.getString("archiver_key");
|
||||
lmd.title = jo.getString("title");
|
||||
lmd.title_jpn = jo.getString("title_jpn");
|
||||
lmd.category = getType(jo.getString("category"));
|
||||
lmd.thumb = jo.getString("thumb");
|
||||
lmd.uploader = jo.getString("uploader");
|
||||
lmd.posted = fm.format(Long.parseLong(jo.getString("posted")) * 1000);
|
||||
lmd.filecount = jo.getString("filecount");
|
||||
lmd.filesize = jo.getLong("filesize");
|
||||
lmd.expunged = jo.getBoolean("expunged");
|
||||
lmd.rating = jo.getString("rating");
|
||||
lmd.torrentcount = jo.getString("torrentcount");
|
||||
JSONArray ja = jo.getJSONArray("tags");
|
||||
int length = ja.length();
|
||||
lmd.tags = new String[1][length+1];
|
||||
lmd.tags[0][0] = "all";
|
||||
for (int j = 1; j < length+1; j++)
|
||||
lmd.tags[0][j] = ja.getString(j);
|
||||
|
||||
lmds.put(lmd.gid, lmd);
|
||||
json.put("method", "gdata");
|
||||
JSONArray jsonA = new JSONArray();
|
||||
requstLen = Math.min(gids.length, tokens.length);
|
||||
agiArray = new ApiGalleryInfo[requstLen];
|
||||
for (int i = 0; i < requstLen; i++) {
|
||||
JSONArray ja = new JSONArray();
|
||||
ja.put(gids[i]);
|
||||
ja.put(tokens[i]);
|
||||
jsonA.put(ja);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
errorMessageId = R.string.em_parser_error;
|
||||
json.put("gidlist", jsonA);
|
||||
} catch (Throwable e) {
|
||||
responder = new GetApiGalleryInfoResponder(l, null, "Create json error");
|
||||
mHandler.post(responder);
|
||||
return;
|
||||
}
|
||||
// Post
|
||||
HttpHelper hh = new HttpHelper(mContext);
|
||||
String body = hh.postJson(getApiUrl(), json);
|
||||
if (body != null) {
|
||||
try {
|
||||
json = new JSONObject(body);
|
||||
JSONArray jsonA = (JSONArray) json.get("gmetadata");
|
||||
for (int i = 0; i < jsonA.length(); i++) {
|
||||
ApiGalleryInfo agi = Json2Agi(jsonA.getJSONObject(i));
|
||||
// Add to agiArray
|
||||
for (int j = 0; j < requstLen; j++) {
|
||||
if (agi.gid == gids[j])
|
||||
agiArray[j] = agi;
|
||||
}
|
||||
}
|
||||
responder = new GetApiGalleryInfoResponder(l, checkFlag, agiArray);
|
||||
} catch (Throwable e) {
|
||||
responder = new GetApiGalleryInfoResponder(l, checkFlag, "Json error");
|
||||
}
|
||||
} else {
|
||||
responder = new GetApiGalleryInfoResponder(l, checkFlag, hh.getEMsg());
|
||||
}
|
||||
mHandler.post(responder);
|
||||
}
|
||||
Message msg = new Message();
|
||||
msg.what = errorMessageId;
|
||||
msg.obj = new GetGalleryMetadataPackage(lmds, listener);
|
||||
getGalleryMetadataHandler.sendMessage(msg);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
public static void getGalleryMetadata(String[][] gidTokens,
|
||||
OnGetGalleryMetadataListener listener) {
|
||||
new Thread(new GetGalleryMetadataRunnable(gidTokens,
|
||||
listener)).start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class GetGalleryTokensPackage {
|
||||
public Map<String, String> tokens;
|
||||
public OnGetGalleryTokensListener listener;
|
||||
|
||||
public GetGalleryTokensPackage(Map<String, String> tokens,
|
||||
OnGetGalleryTokensListener listener) {
|
||||
this.tokens = tokens;
|
||||
this.listener = listener;
|
||||
public ApiGalleryInfo[] getApiGalleryInfo(int[] gids, String[] tokens) {
|
||||
ApiGalleryInfo[] agiArray;
|
||||
int requstLen;
|
||||
// Create json
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
json.put("method", "gdata");
|
||||
JSONArray jsonA = new JSONArray();
|
||||
requstLen = Math.min(gids.length, tokens.length);
|
||||
agiArray = new ApiGalleryInfo[requstLen];
|
||||
for (int i = 0; i < requstLen; i++) {
|
||||
JSONArray ja = new JSONArray();
|
||||
ja.put(gids[i]);
|
||||
ja.put(tokens[i]);
|
||||
jsonA.put(ja);
|
||||
}
|
||||
json.put("gidlist", jsonA);
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Handler getGalleryTokensHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
OnGetGalleryTokensListener listener =
|
||||
((GetGalleryTokensPackage) msg.obj).listener;
|
||||
Map<String, String> tokens =
|
||||
((GetGalleryTokensPackage) msg.obj).tokens;
|
||||
if (tokens == null || tokens.size() == 0)
|
||||
listener.onFailure(msg.what);
|
||||
else
|
||||
listener.onSuccess(tokens);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
private static class GetGalleryTokensRunnable implements Runnable {
|
||||
private String gid;
|
||||
private String token;
|
||||
private String[] pages;
|
||||
private OnGetGalleryMetadataListener listener;
|
||||
|
||||
public GetGalleryTokensRunnable(String gid, String token, String[] pages,
|
||||
OnGetGalleryMetadataListener listener) {
|
||||
this.gid = gid;
|
||||
this.token = token;
|
||||
this.pages = pages;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int errorMessageId = R.string.em_unknown_error;
|
||||
Map<String, String> tokens = new HashMap<String, String>();
|
||||
|
||||
// Create post string
|
||||
StringBuffer strBuf = new StringBuffer();
|
||||
strBuf.append("{\"method\": \"gtoken\",\"pagelist\": [");
|
||||
for (String item: pages)
|
||||
strBuf.append("[" + gid + ",\"" + token + "\"," + item + "],");
|
||||
strBuf.delete(strBuf.length()-1, strBuf.length());
|
||||
strBuf.append("]}");
|
||||
|
||||
Log.i(TAG, strBuf.toString());
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
errorMessageId = postJson(API_URL, strBuf.toString(),sb);
|
||||
if (sb.length() != 0) {
|
||||
String pageContent = sb.toString();
|
||||
Log.d(TAG, pageContent);
|
||||
// Post api
|
||||
HttpHelper hh = new HttpHelper(mContext);
|
||||
String body = hh.postJson(getApiUrl(), json);
|
||||
if (body == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
json = new JSONObject(body);
|
||||
JSONArray jsonA = (JSONArray) json.get("gmetadata");
|
||||
for (int i = 0; i < jsonA.length(); i++) {
|
||||
ApiGalleryInfo agi = Json2Agi(jsonA.getJSONObject(i));
|
||||
// Add to agiArray
|
||||
for (int j = 0; j < requstLen; j++) {
|
||||
if (agi.gid == gids[j])
|
||||
agiArray[j] = agi;
|
||||
}
|
||||
}
|
||||
return agiArray;
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
private static void getGalleryTokens(String gid, String token, String[] pages,
|
||||
OnGetGalleryMetadataListener listener) {
|
||||
new Thread(new GetGalleryTokensRunnable(gid, token, pages,
|
||||
listener)).start();
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class ExDownloader implements Runnable {
|
||||
mControlorArray = new HttpHelper.DownloadControlor[mWorkerNum];
|
||||
|
||||
// Make sure dir
|
||||
mDir = EhUtils.getGalleryDir(mGid);
|
||||
mDir = EhUtils.getGalleryDir(mGid, mTitle);
|
||||
Utils.ensureDir(mDir, true);
|
||||
}
|
||||
|
||||
@@ -427,9 +427,9 @@ public class ExDownloader implements Runnable {
|
||||
} catch (Throwable e) {}
|
||||
}
|
||||
|
||||
public static int readCurReadIndex(int gid) {
|
||||
public static int readCurReadIndex(int gid, String title) {
|
||||
try {
|
||||
RandomAccessFile raf = new RandomAccessFile(new File(EhUtils.getGalleryDir(gid),
|
||||
RandomAccessFile raf = new RandomAccessFile(new File(EhUtils.getGalleryDir(gid, title),
|
||||
EhUtils.EH_DOWNLOAD_FILENAME), "r");
|
||||
int index = Integer.parseInt(raf.readLine(), 16);
|
||||
raf.close();
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import com.hippo.ehviewer.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.data.LofiGalleryInfo;
|
||||
import com.hippo.ehviewer.util.EhUtils;
|
||||
import com.hippo.ehviewer.util.Utils;
|
||||
|
||||
public class ListParser {
|
||||
@@ -84,7 +85,7 @@ public class ListParser {
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
lgi.category = EhClient.getType(m.group(5));
|
||||
lgi.category = EhUtils.getCategory(m.group(5));
|
||||
String tags = m.group(6);
|
||||
if (tags.equals("-"))
|
||||
lgi.lofiTags = null;
|
||||
@@ -147,7 +148,7 @@ public class ListParser {
|
||||
while (m.find()) {
|
||||
GalleryInfo gi = new GalleryInfo();
|
||||
|
||||
gi.category = EhClient.getType(m.group(1));
|
||||
gi.category = EhUtils.getCategory(m.group(1));
|
||||
gi.posted = m.group(2);
|
||||
if (m.group(3) == null) {
|
||||
gi.thumb = Utils.unescapeXml("http://"
|
||||
|
||||
@@ -94,6 +94,7 @@ public class GalleryView extends GLView
|
||||
private static final float MILLSEC_PER_DIX = 0.2f;
|
||||
private static final float CHANGE_PAGE_PROPORTION = 0.1f;
|
||||
private static final float SLIDE_SENSITIVITY = 0;
|
||||
private static final float BORDER_TIP_SENSITIVITY = Ui.dp2pix(48);
|
||||
|
||||
private static final int ANIMATE_MIN = 200;
|
||||
|
||||
@@ -1157,38 +1158,40 @@ public class GalleryView extends GLView
|
||||
case SCROLL_ANIME_RIGHT:
|
||||
return false;
|
||||
case SCROLL_NONE:
|
||||
boolean changePage = false;
|
||||
// If it is true, page will move
|
||||
boolean movePage = false;
|
||||
Rect rect = curShowItem.mRect;
|
||||
|
||||
// Check change page or not
|
||||
if (curShowItem == null || !(curShowItem instanceof BasicItem))
|
||||
changePage = true;
|
||||
else{
|
||||
if ( Math.abs(totalX/totalY) > 1 && ((totalX > SLIDE_SENSITIVITY && dx < 0 && rect.left >= 0)
|
||||
|| (totalX < -SLIDE_SENSITIVITY && dx > 0 && rect.right <= mScreenWidth)))
|
||||
changePage = true;
|
||||
// If show item is null or TextItem, just move
|
||||
// Check finger move left or right
|
||||
// Check min sensitivity
|
||||
if (curShowItem == null || !(curShowItem instanceof BasicItem) ||
|
||||
(Math.abs(totalX/totalY) > 1 && ((totalX > SLIDE_SENSITIVITY && dx < 0 && rect.left >= 0)
|
||||
|| (totalX < -SLIDE_SENSITIVITY && dx > 0 && rect.right <= mScreenWidth)))) {
|
||||
movePage = true;
|
||||
}
|
||||
if (changePage) { // If change page
|
||||
if (movePage) { // If change page
|
||||
if (dx < 0) { // Go to left
|
||||
if (!isFirstPage()) { // Not first page
|
||||
scrollXOffset = 0;
|
||||
mScrollState = SCROLL_LEFT;
|
||||
// Prepare previous show item
|
||||
resetSizePosition(PRE_TARGET_INDEX);
|
||||
} else {
|
||||
changePage = false;
|
||||
movePage = false;
|
||||
}
|
||||
}
|
||||
else { // Go to righ
|
||||
} else { // Go to righ
|
||||
if (!isLastPage()) { // Not last page
|
||||
scrollXOffset = 0;
|
||||
mScrollState = SCROLL_RIGHT;
|
||||
// Prepare next show item
|
||||
resetSizePosition(NEXT_TARGET_INDEX);
|
||||
} else {
|
||||
changePage = false;
|
||||
movePage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!changePage){ // Move cur image
|
||||
if (!movePage) { // Move cur image
|
||||
int actDx = -(int)dx;
|
||||
int actDy = -(int)dy;
|
||||
if (rect.width() <= mScreenWidth)
|
||||
@@ -1224,7 +1227,7 @@ public class GalleryView extends GLView
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrollEnd() {
|
||||
public boolean onScrollEnd(float totalX, float totalY) {
|
||||
|
||||
if (isScale)
|
||||
return false;
|
||||
@@ -1264,7 +1267,7 @@ public class GalleryView extends GLView
|
||||
break;
|
||||
case SCROLL_NONE:
|
||||
ShowItem showItem = showItems[CUR_TARGET_INDEX];
|
||||
if (showItem != null) {
|
||||
if (showItem != null && Math.abs(totalX) - BORDER_TIP_SENSITIVITY > 0) {
|
||||
if (isFirstPage() && showItem.mRect.left >= 0)
|
||||
MaterialToast.showToast(mContext.getString(R.string.first_page));
|
||||
else if (isLastPage() && showItem.mRect.right <= mScreenWidth)
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ImageSet implements ExDownloader.ListenerForImageSet {
|
||||
|
||||
public ImageSet(int gid, String token, String title, int startIndex) {
|
||||
|
||||
mDir = EhUtils.getGalleryDir(gid);
|
||||
mDir = EhUtils.getGalleryDir(gid, title);
|
||||
Utils.ensureDir(mDir, true);
|
||||
|
||||
// Init ExDownloader
|
||||
|
||||
@@ -35,7 +35,7 @@ public class GestureRecognizer {
|
||||
void onLongPress(MotionEvent e);
|
||||
boolean onScrollBegin(float dx, float dy, float totalX, float totalY);
|
||||
boolean onScroll(float dx, float dy, float totalX, float totalY);
|
||||
boolean onScrollEnd();
|
||||
boolean onScrollEnd(float totalX, float totalY);
|
||||
boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY);
|
||||
boolean onScaleBegin(float focusX, float focusY);
|
||||
boolean onScale(float focusX, float focusY, float scale);
|
||||
@@ -149,9 +149,13 @@ public class GestureRecognizer {
|
||||
}
|
||||
|
||||
private class MyDownUpListener implements DownUpDetector.DownUpListener {
|
||||
|
||||
private float mFirstX;
|
||||
private float mFirstY;
|
||||
|
||||
@Override
|
||||
public void onDown(MotionEvent e) {
|
||||
mListener.onDown(e.getX(), e.getY());
|
||||
mListener.onDown(mFirstX = e.getX(), mFirstY = e.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,7 +163,7 @@ public class GestureRecognizer {
|
||||
mListener.onUp();
|
||||
if (mStillScroll) {
|
||||
mStillScroll = false;
|
||||
mListener.onScrollEnd();
|
||||
mListener.onScrollEnd(e.getX() - mFirstX, e.getY() - mFirstY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,10 @@ public class EditTextPreference extends DialogPreference {
|
||||
public boolean onClick(MaterialAlertDialog dialog, int which) {
|
||||
super.onClick(dialog, which);
|
||||
if (which == MaterialAlertDialog.POSITIVE) {
|
||||
String value = ((EditText) dialog.findViewById(R.id.edittextpreference_edittext)).getText().toString();
|
||||
EditText et = (EditText) dialog.findViewById(R.id.edittextpreference_edittext);
|
||||
if (et == null)
|
||||
return true;
|
||||
String value = et.getText().toString();
|
||||
if (callChangeListener(value)) {
|
||||
persistString(value);
|
||||
setSummary(value);
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.hippo.ehviewer.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
@@ -39,11 +42,14 @@ public class DownloadService extends Service
|
||||
implements ExDownloader.ListenerForDownload {
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = DownloadService.class.getSimpleName();
|
||||
private static final int DOWNLOAD_NOTIFY_ID = -1;
|
||||
private static final int DOWNLOADING_NOTIFY_ID = -1;
|
||||
private static final int DOWNLOAD_NOTIFY_ID = -2;
|
||||
//private static final int DOWNLOAD_FAILED_NOTIFY_ID = -3;
|
||||
|
||||
public static final String ACTION_UPDATE = "com.hippo.ehviewer.service.DownloadService.UPDATE";
|
||||
public static final String ACTION_STOP = "com.hippo.ehviewer.service.DownloadService.STOP";
|
||||
public static final String ACTION_STOP_ALL = "com.hippo.ehviewer.service.DownloadService.STOP_ALL";
|
||||
public static final String ACTION_CLEAR = "com.hippo.ehviewer.service.DownloadService.ACTION_CLEAR";
|
||||
|
||||
private Context mContext;
|
||||
private Data mData;
|
||||
@@ -55,6 +61,9 @@ public class DownloadService extends Service
|
||||
private NotificationCompat.Builder mBuilder;
|
||||
private String mSpeedStr = null;
|
||||
|
||||
private final List<Integer> mDownloadOk = new ArrayList<Integer>();
|
||||
private final List<Integer> mDownloadFailed = new ArrayList<Integer>();
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
@@ -68,16 +77,20 @@ public class DownloadService extends Service
|
||||
getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
private void handleIntent(Intent intent) {
|
||||
private synchronized void handleIntent(Intent intent) {
|
||||
if (intent == null)
|
||||
return;
|
||||
|
||||
if (ACTION_STOP.equals(intent.getAction())) {
|
||||
String action = intent.getAction();
|
||||
if (ACTION_STOP.equals(action)) {
|
||||
stopCurrentTask();
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
} else if (ACTION_STOP_ALL.equals(intent.getAction())) {
|
||||
mNotifyManager.cancel(DOWNLOADING_NOTIFY_ID);
|
||||
} else if (ACTION_STOP_ALL.equals(action)) {
|
||||
stopAll();
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
mNotifyManager.cancel(DOWNLOADING_NOTIFY_ID);
|
||||
} else if (ACTION_CLEAR.equals(action)) {
|
||||
mDownloadOk.clear();
|
||||
mDownloadFailed.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +111,7 @@ public class DownloadService extends Service
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
mNotifyManager.cancel(DOWNLOADING_NOTIFY_ID);
|
||||
|
||||
mBinder = null;
|
||||
mNotifyManager = null;
|
||||
@@ -154,7 +167,7 @@ public class DownloadService extends Service
|
||||
public synchronized void stop(DownloadInfo di) {
|
||||
if (mCurDownloadInfo == di) {
|
||||
// Cancel download notification
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
mNotifyManager.cancel(DOWNLOADING_NOTIFY_ID);
|
||||
|
||||
// Target downloadinfo is downloading
|
||||
mCurDownloadInfo.state = DownloadInfo.STATE_NONE;
|
||||
@@ -195,7 +208,7 @@ public class DownloadService extends Service
|
||||
di.state == DownloadInfo.STATE_DOWNLOAD) {
|
||||
if (mCurDownloadInfo == di) {
|
||||
// Cancel download notification
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
mNotifyManager.cancel(DOWNLOADING_NOTIFY_ID);
|
||||
|
||||
// Target downloadinfo is downloading
|
||||
mCurDownloadInfo.state = DownloadInfo.STATE_NONE;
|
||||
@@ -269,7 +282,7 @@ public class DownloadService extends Service
|
||||
mBuilder.setContentTitle(getString(R.string.start_download) + " " + gid)
|
||||
.setContentText(null)
|
||||
.setProgress(0, 0, true);
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, mBuilder.build());
|
||||
mNotifyManager.notify(DOWNLOADING_NOTIFY_ID, mBuilder.build());
|
||||
mNotifyManager.cancel(gid);
|
||||
|
||||
notifyUpdate();
|
||||
@@ -288,7 +301,7 @@ public class DownloadService extends Service
|
||||
mBuilder.setContentTitle(getString(R.string.downloading) + " " + gid)
|
||||
.setContentText(mSpeedStr)
|
||||
.setProgress(totalSize, downloadSize, false);
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, mBuilder.build());
|
||||
mNotifyManager.notify(DOWNLOADING_NOTIFY_ID, mBuilder.build());
|
||||
|
||||
notifyUpdate();
|
||||
}
|
||||
@@ -307,28 +320,66 @@ public class DownloadService extends Service
|
||||
.setContentText(mSpeedStr)
|
||||
.setProgress(mCurDownloadInfo.total, mCurDownloadInfo.download,
|
||||
mCurDownloadInfo.total == -1 ? true :false);
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, mBuilder.build());
|
||||
mNotifyManager.notify(DOWNLOADING_NOTIFY_ID, mBuilder.build());
|
||||
|
||||
notifyUpdate();
|
||||
}
|
||||
|
||||
private synchronized String getDownloadNotificationText() {
|
||||
|
||||
int ok = mDownloadOk.size();
|
||||
int failed = mDownloadFailed.size();
|
||||
|
||||
if (ok == 0 && failed == 0) {
|
||||
return "null";
|
||||
} else if (ok == 1 && failed == 0) {
|
||||
return String.format(getString(R.string.download_1), mDownloadOk.get(0));
|
||||
} else if (failed == 0) {
|
||||
return String.format(getString(R.string.download_2), mDownloadOk.size());
|
||||
} else if (ok == 0 && failed == 1) {
|
||||
return String.format(getString(R.string.download_3), mDownloadFailed.get(0));
|
||||
} else if (ok == 0) {
|
||||
return String.format(getString(R.string.download_4), mDownloadFailed.size());
|
||||
} else if (ok == 1 && failed == 1){
|
||||
return String.format(getString(R.string.download_5), mDownloadOk.get(0), mDownloadFailed.get(0));
|
||||
} else {
|
||||
return String.format(getString(R.string.download_6), mDownloadOk.size(), mDownloadFailed.size());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onDownloadOver(int gid, int legacy) {
|
||||
if (mCurDownloadInfo == null)
|
||||
return;
|
||||
|
||||
mCurDownloadInfo.legacy = legacy;
|
||||
if (mCurDownloadInfo.legacy == 0) {
|
||||
// Download ok
|
||||
if (!mDownloadOk.contains(gid))
|
||||
mDownloadOk.add(gid);
|
||||
mDownloadFailed.remove((Integer) gid);
|
||||
} else {
|
||||
// Download failed
|
||||
if (!mDownloadFailed.contains(gid))
|
||||
mDownloadFailed.add(gid);
|
||||
mDownloadOk.remove((Integer) gid);
|
||||
}
|
||||
|
||||
Intent clearIntent = new Intent(this, DownloadService.class);
|
||||
clearIntent.setAction(ACTION_CLEAR);
|
||||
PendingIntent piClear = PendingIntent.getService(this, 0, clearIntent, 0);
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
|
||||
builder.setSmallIcon(android.R.drawable.stat_sys_download_done);
|
||||
Intent intent = new Intent(DownloadService.this,DownloadActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(DownloadService.this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
builder.setContentTitle(getString(R.string.download_over) + " " + gid)
|
||||
.setContentText(legacy == 0 ? getString(R.string.done) :
|
||||
String.format(getString(R.string.legacy_pages), legacy))
|
||||
builder.setContentTitle(getString(R.string.download_over))
|
||||
.setContentText(getDownloadNotificationText())
|
||||
.setDeleteIntent(piClear)
|
||||
.setOngoing(false).setAutoCancel(true);
|
||||
mNotifyManager.notify(gid, builder.build());
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, builder.build());
|
||||
mNotifyManager.cancel(DOWNLOADING_NOTIFY_ID);
|
||||
|
||||
mCurDownloadInfo.legacy = legacy;
|
||||
mCurDownloadInfo.state = DownloadInfo.STATE_FINISH;
|
||||
|
||||
@@ -360,7 +360,7 @@ public class DownloadActivity extends AbsActivity {
|
||||
mServiceConn.getService().delete(mDownloadInfo);
|
||||
// Delete dir
|
||||
GalleryInfo gi = mDownloadInfo.galleryInfo;
|
||||
Utils.deleteDirInThread(EhUtils.getGalleryDir(gi.gid));
|
||||
Utils.deleteDirInThread(EhUtils.getGalleryDir(gi.gid, gi.title));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -201,12 +201,12 @@ public class GalleryActivity extends AbsActivity
|
||||
mTitle = intent.getStringExtra(KEY_TITLE);
|
||||
int startIndex = intent.getIntExtra(KEY_START_INDEX, 0);
|
||||
if (startIndex == -1)
|
||||
startIndex = ExDownloader.readCurReadIndex(mGid);
|
||||
startIndex = ExDownloader.readCurReadIndex(mGid, mTitle);
|
||||
|
||||
if (mGid == -1 || token == null || mTitle == null) {
|
||||
new MaterialAlertDialog.Builder(this).setTitle(R.string.error)
|
||||
.setMessage("数据错误!") // TODO
|
||||
.setPositiveButton("关闭")
|
||||
.setMessage(R.string.ga_data_error)
|
||||
.setPositiveButton(R.string.close)
|
||||
.setButtonListener(new MaterialAlertDialog.OnClickListener() {
|
||||
@Override
|
||||
public boolean onClick(MaterialAlertDialog dialog, int which) {
|
||||
|
||||
@@ -537,10 +537,10 @@ public class GalleryListActivity extends AbsGalleryActivity
|
||||
String filePath = (String)mSearchImageText.getText();
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
MaterialToast.showToast("图片不存在"); // TODO
|
||||
MaterialToast.showToast(R.string.image_not_exist);
|
||||
} else {
|
||||
if (!file.canRead()) {
|
||||
MaterialToast.showToast("图片不可读");
|
||||
MaterialToast.showToast(R.string.image_not_readable);
|
||||
} else {
|
||||
|
||||
CheckBox similar = (CheckBox)view.findViewById(R.id.checkboxSimilar);
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -56,8 +58,10 @@ import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.SimpleSuggestionProvider;
|
||||
import com.hippo.ehviewer.UpdateHelper;
|
||||
import com.hippo.ehviewer.app.MaterialAlertDialog;
|
||||
import com.hippo.ehviewer.data.ApiGalleryInfo;
|
||||
import com.hippo.ehviewer.data.Data;
|
||||
import com.hippo.ehviewer.data.DownloadInfo;
|
||||
import com.hippo.ehviewer.ehclient.EhClient;
|
||||
import com.hippo.ehviewer.ehclient.EhInfo;
|
||||
import com.hippo.ehviewer.network.HttpHelper;
|
||||
import com.hippo.ehviewer.preference.ListPreference;
|
||||
@@ -772,17 +776,20 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
}
|
||||
|
||||
public static class AdvancedFragment extends TranslucentPreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
implements Preference.OnPreferenceChangeListener,
|
||||
Preference.OnPreferenceClickListener {
|
||||
|
||||
private static final String KEY_HTTP_RETRY = "http_retry";
|
||||
private static final String KEY_HTTP_CONNECT_TIMEOUT = "http_connect_timeout";
|
||||
private static final String KEY_HTTP_READ_TIMEOUT = "http_read_timeout";
|
||||
private static final String KEY_EH_MIN_INTERVAL = "eh_min_interval";
|
||||
private static final String KEY_FIX_DIRNAME = "fix_dirname";
|
||||
|
||||
private Preference mHttpRetry;
|
||||
private Preference mHttpConnectTimeout;
|
||||
private Preference mHttpReadTimeout;
|
||||
private Preference mEhMinInterval;
|
||||
private Preference mFixDirname;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -797,6 +804,8 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
mHttpReadTimeout.setOnPreferenceChangeListener(this);
|
||||
mEhMinInterval = findPreference(KEY_EH_MIN_INTERVAL);
|
||||
mEhMinInterval.setOnPreferenceChangeListener(this);
|
||||
mFixDirname = findPreference(KEY_FIX_DIRNAME);
|
||||
mFixDirname.setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -846,6 +855,106 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
final String key = preference.getKey();
|
||||
if (KEY_FIX_DIRNAME.equals(key)) {
|
||||
mFixDirname.setEnabled(false);
|
||||
new BgThread() {
|
||||
@Override
|
||||
public void run() {
|
||||
File downloadDir = new File(Config.getDownloadPath());
|
||||
List<File> targetDirList = new ArrayList<File>();
|
||||
|
||||
String[] list = downloadDir.list();
|
||||
if (list != null) {
|
||||
for (String str: list) {
|
||||
if (str.contains("-")) continue;
|
||||
File dir = new File(downloadDir, str);
|
||||
if (new File(dir, EhUtils.EH_DOWNLOAD_FILENAME).exists())
|
||||
targetDirList.add(dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (targetDirList.size() == 0) {
|
||||
AppHandler.getInstance().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mFixDirname.setEnabled(true);
|
||||
MaterialToast.showToast("未发现可修正项"); // TODO
|
||||
}
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
AppHandler.getInstance().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MaterialToast.showToast("开始修正"); // TODO
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int handleNum = 0;
|
||||
List<File> dirs = new ArrayList<File>();
|
||||
List<Integer> gids = new ArrayList<Integer>();
|
||||
List<String> tokens = new ArrayList<String>();
|
||||
// Do get title from api
|
||||
for (int i = 0; i < targetDirList.size(); i++) {
|
||||
File dir = targetDirList.get(i);
|
||||
File info = new File(dir, EhUtils.EH_DOWNLOAD_FILENAME);
|
||||
InputStream is = null;
|
||||
int gid;
|
||||
String token;
|
||||
try {
|
||||
is = new BufferedInputStream(new FileInputStream(info),
|
||||
128);
|
||||
// skip read index
|
||||
Utils.readAsciiLine(is);
|
||||
gid = Integer.parseInt(Utils.readAsciiLine(is));
|
||||
token = Utils.readAsciiLine(is);
|
||||
Utils.closeQuietly(is);
|
||||
dirs.add(dir);
|
||||
gids.add(gid);
|
||||
tokens.add(token);
|
||||
// Post api when to 25 or the end
|
||||
if (gids.size() == 25 || i == targetDirList.size() - 1) {
|
||||
ApiGalleryInfo[] agiArray = EhClient.getInstance().getApiGalleryInfo(
|
||||
Utils.toIntArray(gids), tokens.toArray(new String[tokens.size()]));
|
||||
// Change dirname
|
||||
if (agiArray != null) {
|
||||
for (int j = 0; j < agiArray.length; j++) {
|
||||
ApiGalleryInfo agi = agiArray[j];
|
||||
if (agi != null) {
|
||||
handleNum++;
|
||||
dirs.get(j).renameTo(EhUtils.generateGalleryDir(agi.gid, agi.title));
|
||||
}
|
||||
}
|
||||
}
|
||||
dirs.clear();
|
||||
gids.clear();
|
||||
tokens.clear();
|
||||
// Wait for CD, if not last
|
||||
if (i != targetDirList.size() - 1)
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
final int _handleNum = handleNum;
|
||||
AppHandler.getInstance().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mFixDirname.setEnabled(true);
|
||||
MaterialToast.showToast("共修正 " + _handleNum + " 项"); // TODO
|
||||
}
|
||||
});
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class AboutFragment extends TranslucentPreferenceFragment
|
||||
@@ -853,6 +962,7 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY_AUTHOR = "author";
|
||||
private static final String KEY_TWITTER = "twitter";
|
||||
private static final String KEY_CHANGELOG = "changelog";
|
||||
private static final String KEY_THANKS = "thanks";
|
||||
private static final String KEY_WEBSITE = "website";
|
||||
@@ -863,6 +973,7 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
private static final String KEY_ABOUT_ANALYICS = "about_analyics";
|
||||
|
||||
private Preference mAuthor;
|
||||
private Preference mTwitter;
|
||||
private Preference mChangelog;
|
||||
private Preference mThanks;
|
||||
private Preference mWebsite;
|
||||
@@ -879,6 +990,8 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
|
||||
mAuthor = findPreference(KEY_AUTHOR);
|
||||
mAuthor.setOnPreferenceClickListener(this);
|
||||
mTwitter = findPreference(KEY_TWITTER);
|
||||
mTwitter.setOnPreferenceClickListener(this);
|
||||
mChangelog = findPreference(KEY_CHANGELOG);
|
||||
mChangelog.setOnPreferenceClickListener(this);
|
||||
mThanks = findPreference(KEY_THANKS);
|
||||
@@ -906,6 +1019,28 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
i.putExtra(Intent.EXTRA_SUBJECT, "About EhViewer");
|
||||
startActivity(i);
|
||||
|
||||
} else if (KEY_TWITTER.equals(key)) {
|
||||
new MaterialAlertDialog.Builder(mActivity).setTitle(R.string.twitter_title)
|
||||
.setItems(new CharSequence[]{"@EhViewer", "@jkjvinn"}, new MaterialAlertDialog.OnClickListener() {
|
||||
@Override
|
||||
public boolean onClick(MaterialAlertDialog dialog, int which) {
|
||||
Uri uri = null;
|
||||
switch (which) {
|
||||
case 0:
|
||||
uri = Uri.parse("https://twitter.com/EhViewer");
|
||||
break;
|
||||
case 1:
|
||||
uri = Uri.parse("https://twitter.com/jkjvinn");
|
||||
break;
|
||||
}
|
||||
if (uri != null) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(intent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).setNegativeButton(android.R.string.cancel).show();
|
||||
|
||||
} else if (KEY_CHANGELOG.equals(key)) {
|
||||
InputStream is = mActivity.getResources()
|
||||
.openRawResource(R.raw.change_log);
|
||||
|
||||
@@ -111,6 +111,14 @@ public class Config {
|
||||
mConfigPre.edit().putInt(key, value).apply();
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String key, boolean defValue) {
|
||||
return mConfigPre.getBoolean(key, defValue);
|
||||
}
|
||||
|
||||
public static void setBoolean(String key, boolean value) {
|
||||
mConfigPre.edit().putBoolean(key, value).apply();
|
||||
}
|
||||
|
||||
|
||||
/****** For Normal Config ******/
|
||||
private static final String KEY_ALLOWED = "allowed";
|
||||
|
||||
@@ -18,19 +18,93 @@ package com.hippo.ehviewer.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.hippo.ehviewer.data.ListUrls;
|
||||
|
||||
public final class EhUtils {
|
||||
|
||||
public static final String EH_DOWNLOAD_FILENAME = ".ehviewer";
|
||||
|
||||
private static final int[] CATEGORY_VALUES = {
|
||||
ListUrls.MISC,
|
||||
ListUrls.DOUJINSHI,
|
||||
ListUrls.MANGA,
|
||||
ListUrls.ARTIST_CG,
|
||||
ListUrls.GAME_CG,
|
||||
ListUrls.IMAGE_SET,
|
||||
ListUrls.COSPLAY,
|
||||
ListUrls.ASIAN_PORN,
|
||||
ListUrls.NON_H,
|
||||
ListUrls.WESTERN,
|
||||
ListUrls.UNKNOWN
|
||||
};
|
||||
|
||||
// TODO How about "Private"
|
||||
private static final String[][] CATEGORY_STRINGS = {
|
||||
new String[]{"misc"},
|
||||
new String[]{"doujinshi"},
|
||||
new String[]{"manga"},
|
||||
new String[]{"artistcg", "Artist CG Sets"},
|
||||
new String[]{"gamecg", "Game CG Sets"},
|
||||
new String[]{"imageset", "Image Sets"},
|
||||
new String[]{"cosplay"},
|
||||
new String[]{"asianporn", "Asian Porn"},
|
||||
new String[]{"non-h"},
|
||||
new String[]{"western"},
|
||||
new String[]{"unknown"}
|
||||
};
|
||||
|
||||
public static int getCategory(String type) {
|
||||
int i;
|
||||
for (i = 0; i < CATEGORY_STRINGS.length - 1; i++) {
|
||||
for (String str : CATEGORY_STRINGS[i])
|
||||
if (str.equalsIgnoreCase(type))
|
||||
return CATEGORY_VALUES[i];
|
||||
}
|
||||
|
||||
return CATEGORY_VALUES[i];
|
||||
}
|
||||
|
||||
public static String getCategory(int type) {
|
||||
int i;
|
||||
for (i = 0; i < CATEGORY_VALUES.length - 1; i++) {
|
||||
if (CATEGORY_VALUES[i] == type)
|
||||
break;
|
||||
}
|
||||
return CATEGORY_STRINGS[i][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gallery for read and download
|
||||
* Gid is constant, but title may be changed
|
||||
* 非要标题,记一下 gid 不行么
|
||||
*
|
||||
* @param gid
|
||||
* @param title
|
||||
* @return
|
||||
*/
|
||||
public static File getGalleryDir(int gid) {
|
||||
return new File(Config.getDownloadPath(),
|
||||
public static File getGalleryDir(int gid, String title) {
|
||||
|
||||
File downloadDir = new File(Config.getDownloadPath());
|
||||
File gDir = new File(downloadDir,
|
||||
Utils.standardizeFilename(Integer.toString(gid)));
|
||||
File defaultDir = generateGalleryDir(gid, title);
|
||||
|
||||
if (gDir.exists()) {
|
||||
if (gDir.renameTo(defaultDir))
|
||||
return defaultDir;
|
||||
else
|
||||
return gDir;
|
||||
} else {
|
||||
return defaultDir;
|
||||
}
|
||||
|
||||
// TODO check a dir start with the gid, but it may take a long time
|
||||
// Create a map to record all ?
|
||||
}
|
||||
|
||||
public static File generateGalleryDir(int gid, String title) {
|
||||
return new File(Config.getDownloadPath(),
|
||||
Utils.standardizeFilename(gid + "-" + title));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -634,4 +635,15 @@ public final class Utils {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static int[] toIntArray(Collection<? extends Number> collection) {
|
||||
Object[] boxedArray = collection.toArray();
|
||||
int len = boxedArray.length;
|
||||
int[] array = new int[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
// checkNotNull for GWT (do not optimize)
|
||||
array[i] = ((Number) (boxedArray[i])).intValue();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.text.Layout;
|
||||
import android.text.Spannable;
|
||||
@@ -27,43 +28,44 @@ import android.view.MotionEvent;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class LinkifyTextView extends TextView {
|
||||
|
||||
|
||||
private String mUrl;
|
||||
|
||||
|
||||
public LinkifyTextView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
public LinkifyTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
public LinkifyTextView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
public void init() {
|
||||
// Just make urls striking
|
||||
// LinkifyTextView itself should not handle touch url event
|
||||
setAutoLinkMask(Linkify.WEB_URLS);
|
||||
setLinksClickable(false);
|
||||
}
|
||||
|
||||
|
||||
public String getTouchedUrl() {
|
||||
return mUrl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call it when you do not need the url any more
|
||||
*/
|
||||
public void clearTouchedUrl() {
|
||||
mUrl = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (getText() instanceof Spannable) {
|
||||
// Get this code from android.text.method.LinkMovementMethod.
|
||||
@@ -71,19 +73,19 @@ public class LinkifyTextView extends TextView {
|
||||
int x = (int) event.getX();
|
||||
int y = (int) event.getY();
|
||||
boolean isGetUrl = false;
|
||||
|
||||
|
||||
x -= getTotalPaddingLeft();
|
||||
y -= getTotalPaddingTop();
|
||||
|
||||
|
||||
x += getScrollX();
|
||||
y += getScrollY();
|
||||
|
||||
|
||||
Layout layout = getLayout();
|
||||
int line = layout.getLineForVertical(y);
|
||||
int off = layout.getOffsetForHorizontal(line, x);
|
||||
|
||||
|
||||
ClickableSpan[] links = ((Spannable)getText()).getSpans(off, off, ClickableSpan.class);
|
||||
|
||||
|
||||
for (ClickableSpan link : links) {
|
||||
if (link instanceof URLSpan) {
|
||||
mUrl = ((URLSpan)link).getURL();
|
||||
@@ -96,7 +98,7 @@ public class LinkifyTextView extends TextView {
|
||||
} else {
|
||||
mUrl = null;
|
||||
}
|
||||
|
||||
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user