Compare commits

...
13 Commits
Author SHA1 Message Date
seven332 baeba9251d update 2014-08-11 15:35:35 +08:00
seven332 e06db7e16e 修正下载错误 2014-08-11 15:33:21 +08:00
seven332 ecd695f4f4 更新信息 2014-08-09 23:26:09 +08:00
seven332 10665dfeef 针对网站变化的临时修补 2014-08-09 23:19:01 +08:00
seven332 937fc619dd 移除不必要的资源 2014-06-15 03:51:17 +08:00
seven332 30c46bd0a2 调整类别识别 2014-06-15 02:46:08 +08:00
seven332 ae90c1b2b1 changlog 2014-06-15 02:28:18 +08:00
seven332 e6e85dc8d4 添加收藏统计 2014-06-15 02:24:43 +08:00
seven332 1a1242cc47 修正翻译 2014-06-15 02:03:34 +08:00
seven332 9b34b561d8 修正时间显示 2014-06-15 02:01:20 +08:00
seven332 ee5cc24a4d 添加 popular 提示 2014-06-15 01:59:04 +08:00
seven332 6ebc172783 Add popular 2014-06-14 23:43:16 +08:00
seven332 a6237f0dc5 规范统计 2014-06-14 20:20:10 +08:00
97 changed files with 794 additions and 474 deletions

No files matched your search

+2 -2
View File
@@ -15,8 +15,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hippo.ehviewer"
android:versionCode="17"
android:versionName="0.5.2" >
android:versionCode="20"
android:versionName="0.5.3.2" >
<uses-sdk
android:minSdkVersion="14"
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 921 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 914 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 794 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 797 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 855 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

+41
View File
@@ -0,0 +1,41 @@
<?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.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<TextView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="24dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="24dp"
android:textSize="18sp"
android:text="@string/popular_warning_message" >
</TextView>
<CheckBox
android:id="@+id/set_default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12.0dp"
android:layout_marginTop="8.0dp"
android:layout_marginBottom="8.0dp"
android:checked="false"
android:text="@string/never_show" />
</merge>
+9
View File
@@ -1,3 +1,12 @@
Version 0.5.3.2 (2014-08-11)
* 修正下载错误
Version 0.5.3.1 (2014-08-09)
* 修正由于网站变化而导致分析错误
Version 0.5.3 (2014-06-15)
* 添加热门
Version 0.5.2 (2014-06-14)
* 添加账户收藏管理
* 添加主题颜色设定
+5
View File
@@ -165,6 +165,9 @@
<string name="failed_to_delete">删除失败</string>
<string name="set_default_favorite">设为默认收藏夹</string>
<!-- Popular -->
<string name="popular_warning_message">该页面中的内容基于数据统计,您尚未开启数据统计。若开启数据统计,您的行为将对该页面产生影响。是否现在开启数据统计?</string>
<!-- Settings -->
<string name="display_settings_title">显示</string>
<string name="theme_display_settings_title">主题</string>
@@ -327,6 +330,7 @@
<string name="rating0">感觉快要窒息了</string>
<!-- Util -->
<string name="never_show">不再显示</string>
<string name="retry">重试</string>
<string name="local">本地</string>
<string name="tag">标签</string>
@@ -362,6 +366,7 @@
<string name="homepage">首页</string>
<string name="mode">模式</string>
<string name="favourite">收藏</string>
<string name="popular">热门</string>
<string name="download">下载</string>
<string name="star_2">2 星</string>
+5
View File
@@ -166,6 +166,9 @@
<string name="failed_to_delete">Failed to delete</string>
<string name="set_default_favorite">Set it as default favorite</string>
<!-- Popular -->
<string name="popular_warning_message">该页面中的内容基于数据统计,您尚未开启数据统计。若开启了数据统计,您的行为将对该页面产生影响。是否现在开启数据统计?</string>
<!-- Settings -->
<string name="display_settings_title">Display</string>
<string name="theme_display_settings_title">Theme</string>
@@ -334,6 +337,7 @@
<string name="rating0">DISASTER</string>
<!-- Util -->
<string name="never_show">Never show me this dialog</string>
<string name="retry">Retry</string>
<string name="local">Local</string>
<string name="tag">Tag</string>
@@ -370,6 +374,7 @@
<string name="homepage">Homepage</string>
<string name="mode">Mode</string>
<string name="favourite">Favourite</string>
<string name="popular">Popular</string>
<string name="download">Download</string>
<string name="star_2">2 stars</string>
+63
View File
@@ -0,0 +1,63 @@
/*
* 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;
import org.json.JSONObject;
import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.MapBuilder;
import com.hippo.ehviewer.data.GalleryInfo;
import com.hippo.ehviewer.util.Config;
import android.content.Context;
public class Analytics {
private static final String KEY_GALLERY = "gallery";
private static final String KEY_OPEN = "open";
private static final String KEY_READ = "read";
private static final String KEY_DOWNLOAD = "download";
private static final String KEY_ADD_TO_FAVORITE = "add_to_favorite";
private static void doGallery(Context context, GalleryInfo galleryInfo, String method) {
if (!Config.getAllowAnalyics())
return;
try {
JSONObject js = new JSONObject();
js.put("gid", galleryInfo.gid).put("token", galleryInfo.token);
EasyTracker easyTracker = EasyTracker.getInstance(context);
easyTracker.send(MapBuilder.createEvent(KEY_GALLERY, method, js.toString(), null).build());
} catch (Exception e) {}
}
public static void openGallery(Context context, GalleryInfo galleryInfo) {
doGallery(context, galleryInfo, KEY_OPEN);
}
public static void readGallery(Context context, GalleryInfo galleryInfo) {
doGallery(context, galleryInfo, KEY_READ);
}
public static void downloadGallery(Context context, GalleryInfo galleryInfo) {
doGallery(context, galleryInfo, KEY_DOWNLOAD);
}
public static void addToFavoriteGallery(Context context, GalleryInfo galleryInfo) {
doGallery(context, galleryInfo, KEY_ADD_TO_FAVORITE);
}
}
+7
View File
@@ -19,6 +19,8 @@ package com.hippo.ehviewer;
import java.io.File;
import java.io.IOException;
import java.lang.Thread.UncaughtExceptionHandler;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import com.hippo.ehviewer.data.Data;
import com.hippo.ehviewer.ehclient.EhClient;
@@ -38,6 +40,7 @@ public class AppContext extends Application implements UncaughtExceptionHandler
@SuppressWarnings("unused")
private static final String TAG = "AppContext";
private DateFormat mFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private Thread.UncaughtExceptionHandler mDefaultHandler;
@@ -98,6 +101,10 @@ public class AppContext extends Application implements UncaughtExceptionHandler
return mImageGeterManager;
}
public DateFormat getDateFormat() {
return mFormatter;
}
@Override
public void uncaughtException(Thread thread, Throwable ex) {
if (!handleException(ex) && mDefaultHandler != null) {
+2
View File
@@ -29,6 +29,7 @@ public class ListUrls {
public static final int NORMAL = 0x0;
public static final int UPLOADER = 0x1;
public static final int TAG = 0x2;
public static final int POPULAR = 0x3;
// Search type
public static final int MISC = 0x1;
@@ -189,6 +190,7 @@ public class ListUrls {
url.append("/").append(page);
} else
url.append(page);
} else if (mMode == POPULAR) {
} else {
@@ -16,13 +16,12 @@
package com.hippo.ehviewer.data;
import java.util.AbstractMap.SimpleEntry;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
public class GalleryDetail extends GalleryInfo{
public String title_jpn;
public int pages;
public String size;
@@ -32,14 +31,14 @@ public class GalleryDetail extends GalleryInfo{
public String language;
public int people;
public String firstPage;
public LinkedHashMap<String, LinkedList<SimpleEntry<String, Integer>>> tags;
public LinkedHashMap<String, LinkedList<String>> tags;
// For Preview
public int previewSum;
public int previewPerPage;
public PreviewList[] previewLists;
public List<Comment> comments;
public GalleryDetail(GalleryInfo galleryInfo) {
gid = galleryInfo.gid;
token = galleryInfo.token;
+8 -8
View File
@@ -19,9 +19,9 @@ package com.hippo.ehviewer.data;
import java.util.ArrayList;
public class PreviewList {
public class Row {
public class Item {
public int xOffset;
public int yOffset;
@@ -37,20 +37,20 @@ public class PreviewList {
this.url = url;
}
}
public String imageUrl;
public ArrayList<Item> itemArray = new ArrayList<Item>();
public int startIndex;
public Row(String imageUrl) {
this.imageUrl = imageUrl;
}
public void addItem(int xOffset, int yOffset, int width, int height,
String url) {
itemArray.add(new Item(xOffset, yOffset, width, height, url));
}
}
private Row curRow;
public ArrayList<Row> rowArray = new ArrayList<Row>();
@@ -66,13 +66,13 @@ public class PreviewList {
curRow.startIndex = lastRow.startIndex + lastRow.itemArray.size();
rowArray.add(curRow);
}
curRow.addItem(Integer.parseInt(xOffset),
Integer.parseInt(yOffset), Integer.parseInt(width),
Integer.parseInt(height), url);
}
public int getSum() {
public int size() {
int sum = 0;
for (Row row : rowArray)
sum += row.itemArray.size();
@@ -19,23 +19,20 @@ package com.hippo.ehviewer.ehclient;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.AbstractMap.SimpleEntry;
import java.util.LinkedList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.hippo.ehviewer.ListUrls;
import com.hippo.ehviewer.data.Comment;
import com.hippo.ehviewer.data.PreviewList;
import com.hippo.ehviewer.util.Log;
public class DetailParser {
private static final String OFFENSIVE_STRING =
"<p>(And if you choose to ignore this warning, you lose all rights to complain about it in the future.)</p>";
private static final String PINING_STRING =
"<p>This gallery is pining for the fjords.</p>";
public static final int DETAIL = 0x1;
public static final int TAG = 0x2;
public static final int PREVIEW_INFO = 0x4;
@@ -43,11 +40,11 @@ public class DetailParser {
public static final int COMMENT = 0x10;
public static final int OFFENSIVE = 0x20;
public static final int PINING = 0x40;
private static final CommentSort cs = new CommentSort();
private int mMode;
public String thumb;
public String title;
public String title_jpn;
@@ -65,27 +62,27 @@ public class DetailParser {
public String firstPage;
public int previewPerPage;
public int previewSum;
public LinkedHashMap<String, LinkedList<SimpleEntry<String, Integer>>> tags;
public LinkedHashMap<String, LinkedList<String>> tags;
public PreviewList previewList;
public LinkedList<Comment> comments;
public void setMode(int mode) {
mMode = mode;
}
public int parser(String pageContent) {
int re = 0;
Pattern p;
Matcher m;
if (pageContent.contains(OFFENSIVE_STRING)) {
return OFFENSIVE;
}
if (pageContent.contains(PINING_STRING)) {
return PINING;
}
// Get detail
if ((mMode & DETAIL) != 0) {
p = Pattern
@@ -114,7 +111,7 @@ public class DetailParser {
m = p.matcher(pageContent);
if (m.find()) {
re |= DETAIL;
thumb = m.group(1);
title = m.group(2);
title_jpn = m.group(3);
@@ -128,45 +125,40 @@ public class DetailParser {
visible = m.group(11);
language = m.group(12);
people = Integer.parseInt(m.group(13).replace(",", ""));
Pattern pattern = Pattern.compile("([\\d|\\.]+)");
Matcher matcher = pattern.matcher(m.group(14));
if (matcher.find())
rating = Float.parseFloat(matcher.group(1));
else
rating = Float.NaN;
firstPage = m.group(15);
}
}
// Get tag
if ((mMode & TAG) != 0) {
tags = new LinkedHashMap<String, LinkedList<SimpleEntry<String, Integer>>>();
tags = new LinkedHashMap<String, LinkedList<String>>();
p = Pattern
.compile("<tr><td[^<>]*>([^<>]+):</td><td>(?:<div[^<>]*><a[^<>]*>[^<>]*</a>[^<>]*<span[^<>]*>\\d+</span>[^<>]*</div>)+</td></tr>");
.compile("<tr><td[^<>]+>([\\w\\s]+):</td><td>(?:<div[^<>]+><a[^<>]+>[\\w\\s]+</a></div>)+</td></tr>");
m = p.matcher(pageContent);
while (m.find()) {
re |= TAG;
String groupName = m.group(1);
LinkedList<SimpleEntry<String, Integer>> group = getTagGroup(m.group(0));
LinkedList<String> group = getTagGroup(m.group(0));
if (group != null) {
tags.put(groupName, group);
}
}
}
// Get preview info
if ((mMode & PREVIEW_INFO) != 0) {
p = Pattern.compile("<p class=\"ip\">Showing ([\\d|,]+) - ([\\d|,]+) of ([\\d|,]+) images</p>");
p = Pattern.compile("<td[^>]+><a[^>]+>([\\d,]+)</a></td><td[^>]+>(?:<a[^>]+>)?&gt;(?:</a>)?</td>");
m = p.matcher(pageContent);
if (m.find()) {
re |= PREVIEW_INFO;
previewPerPage = Integer.parseInt(m.group(2).replace(",",
""))
- Integer.parseInt(m.group(1).replace(",", ""))
+ 1;
int total = Integer.parseInt(m.group(3).replace(",", ""));
previewSum = (total + previewPerPage - 1) / previewPerPage;
previewSum = Integer.valueOf(m.group(1).replace(",", ""));
}
}
// Get preview
@@ -182,6 +174,9 @@ public class DetailParser {
previewList.addItem(m.group(3), m.group(4), "0", m.group(1),
m.group(2), m.group(5));
}
// Set previewPerPage
if (previewList != null)
previewPerPage = previewList.size();
}
// Get comment
if ((mMode & COMMENT) != 0) {
@@ -197,24 +192,21 @@ public class DetailParser {
}
return re;
}
private LinkedList<SimpleEntry<String, Integer>> getTagGroup(String pageContent) {
LinkedList<SimpleEntry<String, Integer>> list =
new LinkedList<SimpleEntry<String, Integer>>();
Pattern p = Pattern.compile("<a[^<>]*>([^<>]+)</a> \\(<span[^<>]*>([\\d|,]+)</span>\\)");
private LinkedList<String> getTagGroup(String pageContent) {
LinkedList<String> list = new LinkedList<String>();
Pattern p = Pattern.compile("<div[^<>]+><a[^<>]+>([\\w\\s]+)</a></div>");
Matcher m = p.matcher(pageContent);
while (m.find())
list.add(new SimpleEntry<String, Integer>(m.group(1),
Integer.parseInt(m.group(2).replace(",", ""))));
list.add(m.group(1));
if (list.size() == 0)
return null;
else
return list;
}
static class CommentSort implements Comparator<Comment> {
private int compareNum(String n1, String n2, int median) {
int re = 0;
@@ -252,7 +244,7 @@ public class DetailParser {
else
return 0;
}
@Override
public int compare(Comment c1, Comment c2) {
int re = 0;
File diff suppressed because it is too large. Load diff
@@ -75,7 +75,7 @@ public abstract class AbstractGalleryActivity extends AbstractSlidingActivity
private TextView mNoneTextView;
private ImageView mSadPanda;
private long taskStamp;
private long mTaskStamp;
private int mFirstIndex;
private int mLastIndex;
@@ -102,12 +102,13 @@ public abstract class AbstractGalleryActivity extends AbstractSlidingActivity
* @return
*/
protected abstract String getTargetUrl(int targetPage);
protected abstract void doGetGallerys(String url, long taskStamp, OnGetListListener listener);
private void getGallerys() {
setGallerysLayout();
taskStamp = System.currentTimeMillis();
mClient.getMangaList(mTargetUrl, taskStamp, new ListGetListener());
mTaskStamp = System.currentTimeMillis();
doGetGallerys(mTargetUrl, mTaskStamp, mListener);
}
@Override
@@ -485,11 +486,16 @@ public abstract class AbstractGalleryActivity extends AbstractSlidingActivity
mList.setSelectionFromTop(position, 0);
}
private class ListGetListener implements EhClient.OnGetMangaListListener {
public interface OnGetListListener {
public void onSuccess(long taskStamp, List<GalleryInfo> gis, int itemPerPage, int maxPage);
public void onFailure(long taskStamp, String eMsg);
}
private OnGetListListener mListener = new OnGetListListener() {
@Override
public void onSuccess(Object checkFlag,
ArrayList<GalleryInfo> gis, int itemPerPage, int maxPage) {
if (taskStamp != (Long)checkFlag)
public void onSuccess(long taskStamp,
List<GalleryInfo> gis, int itemPerPage, int maxPage) {
if (mTaskStamp != taskStamp)
return;
mMaxPage = maxPage;
@@ -574,8 +580,8 @@ public abstract class AbstractGalleryActivity extends AbstractSlidingActivity
mHlv.setAnyRefreshComplete(true);
}
@Override
public void onFailure(Object checkFlag, String eMsg) {
if (taskStamp != (Long)checkFlag)
public void onFailure(long taskStamp, String eMsg) {
if (mTaskStamp != taskStamp)
return;
mWaitProgressBar.setVisibility(View.GONE);
@@ -594,5 +600,5 @@ public abstract class AbstractGalleryActivity extends AbstractSlidingActivity
eMsg, SuperToast.WARNING).show();
mHlv.setAnyRefreshComplete(false);
}
}
};
}
@@ -19,38 +19,9 @@ package com.hippo.ehviewer.ui;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.AbstractMap.SimpleEntry;
import java.util.List;
import java.util.Map.Entry;
import com.hippo.ehviewer.AppContext;
import com.hippo.ehviewer.ImageGeterManager;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.data.Comment;
import com.hippo.ehviewer.data.Data;
import com.hippo.ehviewer.data.GalleryDetail;
import com.hippo.ehviewer.data.GalleryInfo;
import com.hippo.ehviewer.data.PreviewList;
import com.hippo.ehviewer.ehclient.DetailParser;
import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.util.Cache;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Log;
import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.util.Util;
import com.hippo.ehviewer.widget.AlertButton;
import com.hippo.ehviewer.widget.AutoWrapLayout;
import com.hippo.ehviewer.widget.ButtonsDialogBuilder;
import com.hippo.ehviewer.widget.DialogBuilder;
import com.hippo.ehviewer.widget.FswView;
import com.hippo.ehviewer.widget.LoadImageView;
import com.hippo.ehviewer.widget.OlScrollView;
import com.hippo.ehviewer.widget.OnFitSystemWindowsListener;
import com.hippo.ehviewer.widget.OnLayoutListener;
import com.hippo.ehviewer.widget.ProgressiveRatingBar;
import com.hippo.ehviewer.widget.SuperToast;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
@@ -72,8 +43,8 @@ import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
@@ -85,17 +56,44 @@ import android.widget.TextSwitcher;
import android.widget.TextView;
import android.widget.ViewSwitcher.ViewFactory;
import com.hippo.ehviewer.AppContext;
import com.hippo.ehviewer.ImageGeterManager;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.data.Comment;
import com.hippo.ehviewer.data.Data;
import com.hippo.ehviewer.data.GalleryDetail;
import com.hippo.ehviewer.data.GalleryInfo;
import com.hippo.ehviewer.data.PreviewList;
import com.hippo.ehviewer.ehclient.DetailParser;
import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.util.Cache;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Log;
import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.util.Util;
import com.hippo.ehviewer.widget.AlertButton;
import com.hippo.ehviewer.widget.AutoWrapLayout;
import com.hippo.ehviewer.widget.DialogBuilder;
import com.hippo.ehviewer.widget.FswView;
import com.hippo.ehviewer.widget.LoadImageView;
import com.hippo.ehviewer.widget.OlScrollView;
import com.hippo.ehviewer.widget.OnFitSystemWindowsListener;
import com.hippo.ehviewer.widget.OnLayoutListener;
import com.hippo.ehviewer.widget.ProgressiveRatingBar;
import com.hippo.ehviewer.widget.SuperToast;
public class DetailSectionFragment extends Fragment
implements View.OnClickListener {
private static final String TAG = "DetailSectionFragment";
private AppContext mAppContext;
private MangaDetailActivity mActivity;
private EhClient mClient;
private Data mData;
private GalleryDetail mGalleryDetail;
private String mUrl;
private View mRootView;
private OlScrollView mScrollView;
private Button mReadButton;
@@ -118,13 +116,13 @@ public class DetailSectionFragment extends Fragment
private View mFrontButton;
private View mKnownButton;
private View mDivider;
private AlertDialog mGoToDialog;
private AlertDialog mTagDialog;
private int mCurPage;
private boolean mShowPreview = false;
private ShapeDrawable getArrowShapeDrawable(int color, boolean isToLeft) {
Path path = new Path();
if (isToLeft) {
@@ -143,7 +141,7 @@ public class DetailSectionFragment extends Fragment
//d.setBounds(0, 0, Ui.dp2pix(24), Ui.dp2pix(48));
return d;
}
private StateListDrawable getArrowClickDrawable(int color, boolean isToLeft) {
StateListDrawable sld = new StateListDrawable();
ShapeDrawable normal = getArrowShapeDrawable(color, isToLeft);
@@ -157,7 +155,7 @@ public class DetailSectionFragment extends Fragment
//sld.setBounds(0, 0, Ui.dp2pix(24), Ui.dp2pix(48));
return sld;
}
@SuppressWarnings("deprecation")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -166,7 +164,7 @@ public class DetailSectionFragment extends Fragment
mAppContext = (AppContext)mActivity.getApplication();
mClient = mAppContext.getEhClient();
mData = mAppContext.getData();
GalleryInfo galleryInfo = mActivity.getGalleryInfo();
boolean getFromCache = true;
mActivity.mGalleryDetail = Cache.mdCache.get(String.valueOf(galleryInfo.gid));
@@ -177,7 +175,7 @@ public class DetailSectionFragment extends Fragment
mGalleryDetail = mActivity.mGalleryDetail;
mUrl = EhClient.getDetailUrl(
mGalleryDetail.gid, mGalleryDetail.token);
mRootView = inflater.inflate(
R.layout.detail, container, false);
mScrollView = (OlScrollView)mRootView.findViewById(R.id.manga_detail_scrollview);
@@ -192,7 +190,7 @@ public class DetailSectionFragment extends Fragment
mPreviewListLayout = (AutoWrapLayout)mRootView.findViewById(R.id.paper_list_layout);
mWaitPreviewList = (ProgressBar)mRootView.findViewById(R.id.paper_list_wait);
mPreviewRefreshButton = (Button)mRootView.findViewById(R.id.preview_button_refresh);
mBottomPanel = (View)mRootView.findViewById(R.id.bottom_panel);
mBottomPanel = mRootView.findViewById(R.id.bottom_panel);
mPreviewNumText = (TextView)mBottomPanel.findViewById(R.id.preview_num);
mCancelButton = mOffensiveView.findViewById(R.id.detail_button_cancel);
mOnceButton = mOffensiveView.findViewById(R.id.detail_button_once);
@@ -201,7 +199,7 @@ public class DetailSectionFragment extends Fragment
mBackButton = mPreviewListMain.findViewById(R.id.back);
mFrontButton = mPreviewListMain.findViewById(R.id.front);
mDivider = mNormalView.findViewById(R.id.divider);
boolean isRandomColor = Config.getRandomThemeColor();
int color = Config.getThemeColor();
// Set random color
@@ -224,9 +222,9 @@ public class DetailSectionFragment extends Fragment
mPreviewNumText.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
mBackButton.setBackgroundDrawable(getArrowClickDrawable(color, true));
mFrontButton.setBackgroundDrawable(getArrowClickDrawable(color, false));
mRefreshButton.setOnClickListener(this);
FswView align = (FswView)mActivity.findViewById(R.id.alignment);
int paddingLeft = align.getPaddingLeft();
int paddingTop = align.getPaddingTop();
@@ -244,7 +242,7 @@ public class DetailSectionFragment extends Fragment
paddingRight, paddingBottom);
}
});
mScrollView.setOnLayoutListener(new OnLayoutListener() {
@Override
public void onLayout() {
@@ -255,7 +253,7 @@ public class DetailSectionFragment extends Fragment
}
}
});
LoadImageView thumb = (LoadImageView)mRootView.findViewById(R.id.detail_cover);
Bitmap bmp = null;
if (Cache.memoryCache != null &&
@@ -271,17 +269,17 @@ public class DetailSectionFragment extends Fragment
ImageGeterManager.DISK_CACHE | ImageGeterManager.DOWNLOAD,
new LoadImageView.SimpleImageGetListener(thumb));
}
TextView title = (TextView)mRootView.findViewById(R.id.detail_title);
title.setText(mGalleryDetail.title);
TextView uploader = (TextView)mRootView.findViewById(R.id.detail_uploader);
uploader.setText(mGalleryDetail.uploader);
TextView category = (TextView)mRootView.findViewById(R.id.detail_category);
category.setText(Ui.getCategoryText(mGalleryDetail.category));
category.setBackgroundColor(Ui.getCategoryColor(mGalleryDetail.category));
// Make rate and read button same width
// Disable them for temp
Ui.measureView(mReadButton);
@@ -295,26 +293,26 @@ public class DetailSectionFragment extends Fragment
}
mReadButton.setEnabled(false);
mRateButton.setEnabled(false);
// get from cache
if (getFromCache)
layout(mGalleryDetail);
else
mClient.getMangaDetail(mUrl, mGalleryDetail, new MangaDetailGetListener());
return mRootView;
}
private void addPageItem(int page) {
if (mActivity.isFinishing())
return;
if (page != mCurPage)
return;
mWaitPreviewList.setVisibility(View.GONE);
mPreviewRefreshButton.setVisibility(View.GONE);
PreviewList pageList = mGalleryDetail.previewLists[page];
if (pageList == null) {
Log.d(TAG, "WTF, I may check mangaDetail.pageLists[page] is not null");
@@ -337,7 +335,7 @@ public class DetailSectionFragment extends Fragment
public void onClick(View v) {
// Add to read in Data
mData.addRead(mGalleryDetail);
Intent intent = new Intent(mActivity,
MangaActivity.class);
intent.putExtra("url", ((TextViewWithUrl) v).url);
@@ -352,13 +350,13 @@ public class DetailSectionFragment extends Fragment
ColorDrawable white = new ColorDrawable(Color.TRANSPARENT);
white.setBounds(0, 0, item.width, item.height);
tvu.setCompoundDrawables(null, white, null, null);
AutoWrapLayout.LayoutParams lp = new AutoWrapLayout.LayoutParams();
lp.leftMargin = Ui.dp2pix(8);
lp.topMargin = Ui.dp2pix(8);
lp.rightMargin = Ui.dp2pix(8);
lp.bottomMargin = Ui.dp2pix(8);
mPreviewListLayout.addView(tvu, lp);
index++;
}
@@ -369,12 +367,12 @@ public class DetailSectionFragment extends Fragment
rowIndex ++;
}
}
private void refreshPageList() {
mPreviewListLayout.removeAllViews();
mWaitPreviewList.setVisibility(View.VISIBLE);
mPreviewRefreshButton.setVisibility(View.GONE);
mPreviewNumText.setText(String.format("%d / %d",
mCurPage+1, mGalleryDetail.previewSum));
@@ -389,7 +387,7 @@ public class DetailSectionFragment extends Fragment
public void onSuccess(Object checkFlag, PreviewList pageList) {
if (mActivity.isFinishing())
return;
int page = (Integer)checkFlag;
mGalleryDetail.previewLists[page] = pageList;
addPageItem(page);
@@ -400,14 +398,14 @@ public class DetailSectionFragment extends Fragment
public void onFailure(Object checkFlag, String eMsg) {
if (mActivity.isFinishing())
return;
int page = (Integer)checkFlag;
if (page == mCurPage) {
new SuperToast(mActivity).setIcon(R.drawable.ic_warning)
.setMessage(eMsg)
.show();
mWaitPreviewList.setVisibility(View.GONE);
mPreviewRefreshButton.setVisibility(View.VISIBLE);
mPreviewRefreshButton.setVisibility(View.VISIBLE);
}
}
});
@@ -416,7 +414,7 @@ public class DetailSectionFragment extends Fragment
mShowPreview = true;
}
}
private AlertDialog createGoToDialog() {
return new DialogBuilder(mActivity).setTitle(R.string.jump)
.setAdapter(new BaseAdapter() {
@@ -436,7 +434,7 @@ public class DetailSectionFragment extends Fragment
public View getView(int position, View convertView,
ViewGroup parent) {
LayoutInflater inflater = mActivity.getLayoutInflater();
View view = (View)inflater.inflate(R.layout.list_item_text, null);
View view = inflater.inflate(R.layout.list_item_text, null);
TextView tv = (TextView)view.findViewById(android.R.id.text1);
tv.setText(String.format(getString(R.string.some_page), position + 1));
return tv;
@@ -458,12 +456,11 @@ public class DetailSectionFragment extends Fragment
}
}).create();
}
@SuppressWarnings("deprecation")
private void addTags() {
LinearLayout tagsLayout = (LinearLayout)mRootView.findViewById(R.id.tags_layout);
LinkedHashMap<String, LinkedList<SimpleEntry<String, Integer>>> tagGroups =
mGalleryDetail.tags;
LinkedHashMap<String, LinkedList<String>> tagGroups = mGalleryDetail.tags;
tagsLayout.removeAllViews();
int x = Ui.dp2pix(4);
int y = Ui.dp2pix(4);
@@ -471,17 +468,17 @@ public class DetailSectionFragment extends Fragment
// color
boolean isRandomColor = Config.getRandomThemeColor();
int color = Config.getThemeColor();
// Get tag view resources
int tagTextSize = resources.getDimensionPixelOffset(R.dimen.button_small_size);
ColorStateList tagTextColor = resources.getColorStateList(R.color.blue_bn_text);
int tagPaddingX = resources.getDimensionPixelOffset(R.dimen.button_tag_padding_x);
int tagPaddingY = resources.getDimensionPixelOffset(R.dimen.button_tag_padding_y);
for (Entry<String, LinkedList<SimpleEntry<String, Integer>>> tagGroup : tagGroups.entrySet()) {
for (Entry<String, LinkedList<String>> tagGroup : tagGroups.entrySet()) {
LinearLayout tagGroupLayout = new LinearLayout(mActivity);
tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
AutoWrapLayout tagLayout = new AutoWrapLayout(mActivity);
// Group name
final String groupName = tagGroup.getKey();
TextView groupNameView = new TextView(new ContextThemeWrapper(mActivity, R.style.TextTag));
@@ -489,47 +486,28 @@ public class DetailSectionFragment extends Fragment
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.setMargins(x, y, x, y);
tagGroupLayout.addView(groupNameView, lp);
// tags
// get random color
if (isRandomColor)
color = Theme.getRandomDeepColor();
for (SimpleEntry<String, Integer> tag : tagGroup.getValue()) {
final String tagText = tag.getKey();
for (final String tag : tagGroup.getValue()) {
Button tagView = new Button(mActivity);
tagView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tagTextSize);
tagView.setText(String.format("%s (%d)", tagText, tag.getValue()));
tagView.setText(tag);
tagView.setTextColor(tagTextColor);
tagView.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
tagView.setPadding(tagPaddingX, tagPaddingY, tagPaddingX, tagPaddingY);
tagView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AlertButton voteUp = new AlertButton(mActivity);
voteUp.setText(getString(R.string.vote_up));
voteUp.setOnClickListener(new SimpleVote(groupName, tagText, true));
AlertButton voteDown = new AlertButton(mActivity);
voteDown.setText(getString(R.string.vote_down));
voteDown.setOnClickListener(new SimpleVote(groupName, tagText, false));
AlertButton showTagged = new AlertButton(mActivity);
showTagged.setText(getString(R.string.show_tagged));
showTagged.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mTagDialog.dismiss();
Intent intent = new Intent();
intent.putExtra(MangaListActivity.KEY_MODE,
MangaListActivity.MODE_TAG);
intent.putExtra(MangaListActivity.KEY_GROUP, groupName);
intent.putExtra(MangaListActivity.KEY_TAG, tagText);
mActivity.setResult(Activity.RESULT_OK, intent);
mActivity.finish();
}
});
mTagDialog = new ButtonsDialogBuilder(mActivity).setTitle(tagText)
.addButton(voteUp).addButton(voteDown).addButton(showTagged)
.create();
mTagDialog.show();
Intent intent = new Intent();
intent.putExtra(MangaListActivity.KEY_MODE,
MangaListActivity.MODE_TAG);
intent.putExtra(MangaListActivity.KEY_GROUP, groupName);
intent.putExtra(MangaListActivity.KEY_TAG, tag);
mActivity.setResult(Activity.RESULT_OK, intent);
mActivity.finish();
}
});
AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
@@ -539,7 +517,7 @@ public class DetailSectionFragment extends Fragment
tagGroupLayout.addView(tagLayout);
tagsLayout.addView(tagGroupLayout);
}
// Add tag
if (isRandomColor)
color = Theme.getRandomDeepColor();
@@ -565,11 +543,11 @@ public class DetailSectionFragment extends Fragment
lp.setMargins(x, y, x, y);
tagsLayout.addView(addtagView, lp);
}
private void layout(GalleryDetail md) {
if (mActivity.isFinishing())
return;
// Delete progress bar
mWaitPb.setVisibility(View.GONE);
@@ -591,10 +569,10 @@ public class DetailSectionFragment extends Fragment
mReadButton.setOnClickListener(this);
mRateButton.setEnabled(true);
mRateButton.setOnClickListener(this);
RatingBar rate = (RatingBar)mRootView.findViewById(R.id.detail_rate);
rate.setRating(mGalleryDetail.rating);
TextSwitcher averagePeople = (TextSwitcher)mRootView.findViewById(R.id.detail_average_people);
averagePeople.setFactory(new ViewFactory() {
@Override
@@ -605,21 +583,21 @@ public class DetailSectionFragment extends Fragment
});
averagePeople.setCurrentText(String.format("%.2f (%d)",
mGalleryDetail.rating, mGalleryDetail.people));
TextView posted = (TextView)mRootView.findViewById(R.id.detail_posted);
posted.setText(mGalleryDetail.posted);
TextView language = (TextView)mRootView.findViewById(R.id.detail_language);
language.setText(String.format(getString(R.string.detail_language), mGalleryDetail.language));
TextView pagesSize = (TextView)mRootView.findViewById(R.id.detail_pages_size);
pagesSize.setText(String.format(getString(R.string.detail_pages_size),
mGalleryDetail.pages, mGalleryDetail.size));
addTags();
mNormalView.setVisibility(View.VISIBLE);
// paper list
if (mGalleryDetail.previewLists[0] != null) {
mPreviewListMain.setVisibility(View.VISIBLE);
@@ -628,7 +606,7 @@ public class DetailSectionFragment extends Fragment
mPreviewNumText.setText(String.format("%d / %d",
1, mGalleryDetail.previewSum));
mPreviewRefreshButton.setOnClickListener(this);
// Init go to dialog or disable it
if (mGalleryDetail.previewSum > 1) {
mGoToDialog = createGoToDialog();
@@ -640,27 +618,27 @@ public class DetailSectionFragment extends Fragment
mBackButton.setClickable(false);
mFrontButton.setClickable(false);
}
mCurPage = 0;
addPageItem(0);
} else
new SuperToast(mActivity)
.setMessage(R.string.detail_preview_error)
.show();
// Set comments
mActivity.setComments(mGalleryDetail.comments);
}
}
@Override
public void onClick(View v) {
if (v == mRateButton) {
rate(mGalleryDetail.rating);
} else if (v == mReadButton) {
mData.addRead(mGalleryDetail);
Intent intent = new Intent(mActivity,
MangaActivity.class);
intent.putExtra("url", mGalleryDetail.firstPage);
@@ -669,7 +647,7 @@ public class DetailSectionFragment extends Fragment
intent.putExtra("firstPage", 0);
intent.putExtra("pageSum", mGalleryDetail.pages);
startActivity(intent);
} else if (v == mRefreshButton) {
MangaDetailGetListener listener = new MangaDetailGetListener();
mClient.getMangaDetail(mUrl, mGalleryDetail, listener);
@@ -677,11 +655,11 @@ public class DetailSectionFragment extends Fragment
mRefreshButton.setVisibility(View.GONE);
// Add progressBar
mWaitPb.setVisibility(View.VISIBLE);
} else if (v == mCancelButton
| v == mKnownButton) {
mActivity.finish();
} else if (v == mOnceButton) {
// TODO create a class uri
MangaDetailGetListener listener = new MangaDetailGetListener();
@@ -690,7 +668,7 @@ public class DetailSectionFragment extends Fragment
mOffensiveView.setVisibility(View.GONE);
// Add progressBar
mWaitPb.setVisibility(View.VISIBLE);
} else if (v == mEveryButton) {
MangaDetailGetListener listener = new MangaDetailGetListener();
mClient.getMangaDetail(mUrl + "&nw=always", mGalleryDetail, listener);
@@ -698,32 +676,32 @@ public class DetailSectionFragment extends Fragment
mOffensiveView.setVisibility(View.GONE);
// Add progressBar
mWaitPb.setVisibility(View.VISIBLE);
} else if (v == mBackButton) {
if (mCurPage <= 0)
return;
mCurPage--;
refreshPageList();
} else if (v == mFrontButton) {
if (mCurPage >= mGalleryDetail.previewSum - 1)
return;
mCurPage++;
refreshPageList();
} else if (v == mPreviewRefreshButton) {
refreshPageList();
} else if (v == mPreviewNumText) {
mGoToDialog.show();
}
}
private int getSendableRating(float ratingFloat) {
float dr = ratingFloat*2;
float dr = ratingFloat*2;
return (int)(dr + 0.5);
}
public void rate(float defaultRating) {
View view = mActivity.getLayoutInflater().inflate(R.layout.rate, null);
final TextView tv = (TextView)view.findViewById(R.id.rate_text);
@@ -763,7 +741,7 @@ public class DetailSectionFragment extends Fragment
//Reset start
RatingBar rate = (RatingBar)mRootView.findViewById(R.id.detail_rate);
rate.setRating(mGalleryDetail.rating);
TextSwitcher averagePeople = (TextSwitcher)
mRootView.findViewById(R.id.detail_average_people);
averagePeople.setText(String.format("%.2f (%d)",
@@ -787,25 +765,25 @@ public class DetailSectionFragment extends Fragment
}
}).create().show();
}
public List<Comment> getComments() {
if (mGalleryDetail == null)
return null;
else
return mGalleryDetail.comments;
}
private class TextViewWithUrl extends TextView {
private String url;
private final String url;
public TextViewWithUrl(Context context, String url) {
super(context);
this.url = url;
}
}
private class MangaDetailGetListener
implements EhClient.OnGetMangaDetailListener {
@Override
@@ -813,7 +791,7 @@ public class DetailSectionFragment extends Fragment
Cache.mdCache.put(String.valueOf(mGalleryDetail.gid), md);
layout(md);
}
@Override
public void onFailure(String eMsg) {
// Delete progress bar
@@ -840,11 +818,11 @@ public class DetailSectionFragment extends Fragment
mWaitPreviewList.setVisibility(View.GONE);
mPreviewRefreshButton.setVisibility(View.VISIBLE);
}
private void addPageImage(int page, int rowIndex, Bitmap bitmap) {
if (mActivity.isFinishing())
return;
if (page != mCurPage)
return;
PreviewList pageList = mGalleryDetail.previewLists[page];
@@ -852,46 +830,46 @@ public class DetailSectionFragment extends Fragment
Log.d(TAG, "WTF, I may check mangaDetail.pageLists[page] is not null");
return;
}
int maxWidth = bitmap.getWidth();
int maxHeight = bitmap.getHeight();
PreviewList.Row row = pageList.rowArray.get(rowIndex);
ArrayList<PreviewList.Row.Item> items = row.itemArray;
int startIndex = row.startIndex;
int endIndex = startIndex + items.size();
for(int i = startIndex ; i < endIndex; i++) {
PreviewList.Row.Item item = items.get(i - startIndex);
if (item.xOffset + item.width > maxWidth)
item.width = maxWidth - item.xOffset;
if (item.yOffset + item.height > maxHeight)
item.height = maxHeight - item.yOffset;
BitmapDrawable bitmapDrawable = new BitmapDrawable(
getResources(), Bitmap.createBitmap(bitmap,
item.xOffset, item.yOffset, item.width, item.height));
bitmapDrawable.setBounds(0, 0, item.width, item.height);
TextViewWithUrl tvu = (TextViewWithUrl)mPreviewListLayout.getChildAt(i);
tvu.setCompoundDrawables(null, bitmapDrawable, null, null);
}
}
}
private class SimpleVote implements View.OnClickListener {
private String groupName;
private String tagText;
private boolean isUp;
private final String groupName;
private final String tagText;
private final boolean isUp;
public SimpleVote(String groupName, String tagText, boolean isUp) {
this.groupName = groupName;
this.tagText = tagText;
this.isUp = isUp;
}
@Override
public void onClick(View v) {
((AlertButton)v).dialog.dismiss();
@@ -899,12 +877,12 @@ public class DetailSectionFragment extends Fragment
groupName, tagText, isUp, new SimpleVoteListener());
}
}
private class SimpleVoteListener implements EhClient.OnVoteListener {
@Override
public void onSuccess(String tagPane) {
new SuperToast(mActivity).setMessage(R.string.vote_succeeded).show();
DetailParser parser = new DetailParser();
parser.setMode(DetailParser.TAG);
if (parser.parser(tagPane) == DetailParser.TAG) {
@@ -16,7 +16,7 @@
package com.hippo.ehviewer.ui;
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -54,6 +54,7 @@ import com.hippo.ehviewer.data.GalleryInfo;
import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.service.DownloadService;
import com.hippo.ehviewer.service.DownloadServiceConnection;
import com.hippo.ehviewer.ui.AbstractGalleryActivity.OnGetListListener;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Favorite;
import com.hippo.ehviewer.util.Theme;
@@ -508,6 +509,22 @@ public class FavouriteActivity extends AbstractGalleryActivity
return EhClient.getFavoriteUrl(mMenuIndex-1, targetPage);
}
@Override
protected void doGetGallerys(String url, final long taskStamp,
final OnGetListListener listener) {
mClient.getMangaList(url, null, new EhClient.OnGetMangaListListener() {
@Override
public void onSuccess(Object checkFlag, List<GalleryInfo> lmdArray,
int indexPerPage, int maxPage) {
listener.onSuccess(taskStamp, lmdArray, indexPerPage, maxPage);
}
@Override
public void onFailure(Object checkFlag, String eMsg) {
listener.onFailure(taskStamp, eMsg);
}
});
}
private class Modify implements EhClient.OnModifyFavoriteListener {
private String mSuccStr;
private String mFailStr;
@@ -520,7 +537,7 @@ public class FavouriteActivity extends AbstractGalleryActivity
}
@Override
public void onSuccess(ArrayList<GalleryInfo> gis, int indexPerPage,
public void onSuccess(List<GalleryInfo> gis, int indexPerPage,
int maxPage) {
setGalleryInfos(gis, maxPage);
mHlv.setRefreshing(false);
@@ -18,8 +18,12 @@ package com.hippo.ehviewer.ui;
import java.util.List;
import org.json.JSONException;
import org.json.JSONObject;
import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.MapBuilder;
import com.hippo.ehviewer.Analytics;
import com.hippo.ehviewer.AppContext;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.data.Comment;
@@ -49,6 +53,7 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -114,16 +119,8 @@ public class MangaDetailActivity extends AbstractFragmentActivity
} else {
mGalleryInfo = intent.getParcelableExtra(KEY_G_INFO);
}
if (Config.getAllowAnalyics()) {
EasyTracker easyTracker = EasyTracker.getInstance(this);
easyTracker.send(MapBuilder
.createEvent("detail",
"open",
"{\"gid\":" + mGalleryInfo.gid + ",\"token\":" + mGalleryInfo.token +"}",
null)
.build());
}
// Analytics
Analytics.openGallery(this, mGalleryInfo);
}
@Override
@@ -227,6 +224,8 @@ public class MangaDetailActivity extends AbstractFragmentActivity
case -1:
((AppContext)getApplication()).getData().addLocalFavourite(mGalleryInfo);
new SuperToast(this).setMessage(R.string.toast_add_favourite).show();
// Analytics
Analytics.addToFavoriteGallery(MangaDetailActivity.this, mGalleryInfo);
break;
default:
((AppContext)getApplication()).getEhClient().addToFavorite(mGalleryInfo.gid,
@@ -234,6 +233,8 @@ public class MangaDetailActivity extends AbstractFragmentActivity
@Override
public void onSuccess() {
new SuperToast(MangaDetailActivity.this).setMessage(R.string.toast_add_favourite).show();
// Analytics
Analytics.addToFavoriteGallery(MangaDetailActivity.this, mGalleryInfo);
}
@Override
public void onFailure(String eMsg) {
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.commons.lang3.StringEscapeUtils;
import com.hippo.ehviewer.Analytics;
import com.hippo.ehviewer.AppContext;
import com.hippo.ehviewer.ListUrls;
import com.hippo.ehviewer.R;
@@ -58,6 +59,7 @@ import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.app.ActionBar;
import android.app.AlertDialog;
import android.app.SearchManager;
@@ -503,7 +505,7 @@ public class MangaListActivity extends AbstractGalleryActivity
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
GalleryInfo gi;
final GalleryInfo gi;
switch (position) {
case 0: // Add favourite item
gi = getGalleryInfo(longClickItemIndex);
@@ -511,6 +513,8 @@ public class MangaListActivity extends AbstractGalleryActivity
switch (defaultFavorite) {
case -2:
Favorite.getAddToFavoriteDialog(MangaListActivity.this, gi).show();
// Analytics
Analytics.addToFavoriteGallery(MangaListActivity.this, gi);
break;
case -1:
((AppContext)getApplication()).getData().addLocalFavourite(gi);
@@ -522,6 +526,8 @@ public class MangaListActivity extends AbstractGalleryActivity
@Override
public void onSuccess() {
new SuperToast(MangaListActivity.this).setMessage(R.string.toast_add_favourite).show();
// Analytics
Analytics.addToFavoriteGallery(MangaListActivity.this, gi);
}
@Override
public void onFailure(String eMsg) {
@@ -914,6 +920,38 @@ public class MangaListActivity extends AbstractGalleryActivity
}
}
private void showPopularWarningDialog() {
DialogBuilder db = new DialogBuilder(MangaListActivity.this).
setCancelable(false).
setView(R.layout.popular_warning, false);
db.setTitle(R.string.about_analyics_title);
ViewGroup vg = db.getCustomLayout();
final CheckBox cb = (CheckBox)vg.findViewById(R.id.set_default);
db.setPositiveButton(android.R.string.ok, new View.OnClickListener() {
@Override
public void onClick(View v) {
((AlertButton)v).dialog.dismiss();
if (cb.isChecked())
Config.setPopularWarning(false);
Intent intent = new Intent(MangaListActivity.this,
SettingsActivity.class);
intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.AboutFragment.class.getName());
intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
startActivity(intent);
}
});
db.setNegativeButton(android.R.string.cancel, new View.OnClickListener() {
@Override
public void onClick(View v) {
((AlertButton)v).dialog.dismiss();
if (cb.isChecked())
Config.setPopularWarning(false);
}
});
db.create().show();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -994,6 +1032,7 @@ public class MangaListActivity extends AbstractGalleryActivity
R.drawable.ic_action_panda, R.string.mode,
R.drawable.ic_action_search, android.R.string.search_go,
R.drawable.ic_action_favorite, R.string.favourite,
R.drawable.ic_action_popular, R.string.popular,
R.drawable.ic_action_download, R.string.download,
R.drawable.ic_action_settings, R.string.action_settings};
@@ -1058,13 +1097,31 @@ public class MangaListActivity extends AbstractGalleryActivity
startActivity(intent);
break;
case 4: // Download
case 4:
if (isRefreshing()) {
new SuperToast(MangaListActivity.this, R.string.wait_for_last).show();
} else {
lus = new ListUrls();
lus.setMode(ListUrls.POPULAR);
mTitle = mResources.getString(R.string.popular);
setTitle(mTitle);
refresh(true);
showContent();
// Show dialog
if (!Config.getAllowAnalyics() && Config.getPopularWarning())
showPopularWarningDialog();
}
break;
case 5: // Download
intent = new Intent(MangaListActivity.this,
DownloadActivity.class);
startActivity(intent);
break;
case 5: // Settings
case 6: // Settings
intent = new Intent(MangaListActivity.this,
SettingsActivity.class);
startActivity(intent);
@@ -1506,4 +1563,34 @@ public class MangaListActivity extends AbstractGalleryActivity
lus.setPage(targetPage);
return lus.getUrl();
}
@Override
protected void doGetGallerys(String url, final long taskStamp,
final OnGetListListener listener) {
if (lus.getMode() == ListUrls.POPULAR) {
mClient.getPopular(new EhClient.OnGetPopularListener() {
@Override
public void onSuccess(List<GalleryInfo> gis) {
listener.onSuccess(taskStamp, gis, gis.size(), gis.size() == 0 ? 0 : 1);
}
@Override
public void onFailure(String eMsg) {
listener.onFailure(taskStamp, eMsg);
}
});
} else {
mClient.getMangaList(url, null, new EhClient.OnGetMangaListListener() {
@Override
public void onSuccess(Object checkFlag, List<GalleryInfo> lmdArray,
int indexPerPage, int maxPage) {
listener.onSuccess(taskStamp, lmdArray, indexPerPage, maxPage);
}
@Override
public void onFailure(Object checkFlag, String eMsg) {
listener.onFailure(taskStamp, eMsg);
}
});
}
}
}
@@ -71,6 +71,12 @@ public class SettingsActivity extends AbstractPreferenceActivity {
@SuppressWarnings("unused")
private static String TAG = "Settings";
public static final String KEY_FRAGMENT = "FRAGMENT";
public static final int DEFAULT = -0x1;
public static final int DISPLAY = 0x0;
public static final int DATA = 0x1;
public static final int ABOUT = 0x2;
private SystemBarConfig mSystemBarConfig;
private List<TranslucentPreferenceFragment> mFragments;
private ListView mListView;
@@ -136,6 +142,17 @@ public class SettingsActivity extends AbstractPreferenceActivity {
originPaddingBottom = mListView.getPaddingBottom();
adjustPadding();
/*
switch (savedInstanceState.getInt(KEY_FRAGMENT, DEFAULT)) {
case DISPLAY:
this.star.startPreferenceFragment(fragment, true);
break;
case DATA:
break;
case ABOUT:
break;
}*/
}
@Override
@@ -497,7 +514,8 @@ public class SettingsActivity extends AbstractPreferenceActivity {
}
public static class AboutFragment extends TranslucentPreferenceFragment
implements Preference.OnPreferenceClickListener{
implements Preference.OnPreferenceClickListener,
Preference.OnPreferenceChangeListener {
private static final String KEY_AUTHOR = "author";
private static final String KEY_CHANGELOG = "changelog";
@@ -505,6 +523,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
private static final String KEY_WEBSITE = "website";
private static final String KEY_SOURCE = "source";
private static final String KEY_CHECK_UPDATE = "check_for_update";
private static final String KEY_ALLOW_ANALYICS = "allow_analyics";
private static final String KEY_ABOUT_ANALYICS = "about_analyics";
private Preference mAuthor;
@@ -513,6 +532,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
private Preference mWebsite;
private Preference mSource;
private Preference mCheckUpdate;
private CheckBoxPreference mAllowAnalyics;
private Preference mAboutAnalyics;
@Override
@@ -532,6 +552,8 @@ public class SettingsActivity extends AbstractPreferenceActivity {
mSource.setOnPreferenceClickListener(this);
mCheckUpdate = (Preference)findPreference(KEY_CHECK_UPDATE);
mCheckUpdate.setOnPreferenceClickListener(this);
mAllowAnalyics = (CheckBoxPreference)findPreference(KEY_ALLOW_ANALYICS);
mAllowAnalyics.setOnPreferenceChangeListener(this);
mAboutAnalyics = (Preference)findPreference(KEY_ABOUT_ANALYICS);
mAboutAnalyics.setOnPreferenceClickListener(this);
}
@@ -629,5 +651,15 @@ public class SettingsActivity extends AbstractPreferenceActivity {
}
return true;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final String key = preference.getKey();
if (KEY_ALLOW_ANALYICS.equals(key)) {
if (!(Boolean)newValue)
Config.setPopularWarning(true);
}
return true;
}
}
}
+12
View File
@@ -66,6 +66,8 @@ public class Config {
private static final boolean DEFAULT_SET_ANALYTICS = false;
private static final String KEY_ALLOW_ANALYTICS = "allow_analyics";
private static final boolean DEFAULT_ALLOW_ANALYTICS = false;
private static final String KEY_POPULAR_WARNING = "popular_warning";
private static final boolean DEFAULT_POPULAR_WARNING = true;
private static boolean mInit = false;
@@ -309,5 +311,15 @@ public class Config {
public static void setAllowAnalyics(boolean setAnalyics) {
mConfigPre.edit().putBoolean(KEY_ALLOW_ANALYTICS, setAnalyics).apply();
if (!setAnalyics)
setPopularWarning(true);
}
public static boolean getPopularWarning() {
return mConfigPre.getBoolean(KEY_POPULAR_WARNING, DEFAULT_POPULAR_WARNING);
}
public static void setPopularWarning(boolean popularWarning) {
mConfigPre.edit().putBoolean(KEY_POPULAR_WARNING, popularWarning).apply();
}
}
+3 -5
View File
@@ -23,8 +23,6 @@ import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.content.Context;
@@ -34,6 +32,8 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Environment;
import com.hippo.ehviewer.AppContext;
import com.hippo.ehviewer.util.Log;
public class Crash {
@@ -48,8 +48,6 @@ public class Crash {
private static final String LAST_CRASH_POSITION = "last_crash_position";
private static final String LAST_CRASH_NAME = "last_crash_name";
private static DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
private static boolean mInit = false;
/**
@@ -97,7 +95,7 @@ public class Crash {
sb.append(result);
try {
long timestamp = System.currentTimeMillis();
String time = formatter.format(new Date());
String time = ((AppContext)mContext).getDateFormat().format(new Date());
String fileName = "crash-" + time + "-" + timestamp + ".log";
String path = null;
boolean position = false;
@@ -16,6 +16,7 @@
package com.hippo.ehviewer.util;
import com.hippo.ehviewer.Analytics;
import com.hippo.ehviewer.AppContext;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.data.GalleryInfo;
@@ -85,6 +86,8 @@ public class Favorite {
@Override
public void onSuccess() {
new SuperToast(context).setMessage(R.string.toast_add_favourite).show();
// Analytics
Analytics.addToFavoriteGallery(context, gi);
}
@Override
public void onFailure(String eMsg) {