Compare commits

...
9 Commits
Author SHA1 Message Date
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
92 changed files with 399 additions and 52 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="18"
android:versionName="0.5.3" >
<uses-sdk
android:minSdkVersion="14"
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>
+3
View File
@@ -1,3 +1,6 @@
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 {
+84 -19
View File
@@ -34,6 +34,7 @@ import java.util.regex.Pattern;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.http.conn.ConnectTimeoutException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -94,6 +95,8 @@ public class EhClient {
public static final String EX_HEADER = "http://exhentai.org/";
public static final String LOFI_HEADER = "http://lofi.e-hentai.org/";
private static final String EHVIEWER_API = "http://www.ehviewer.com/API";
private boolean mLogin = false;
private String mUsername;
private String mDisplayName;
@@ -548,20 +551,20 @@ public class EhClient {
// Get Manga List
public interface OnGetMangaListListener {
public void onSuccess(Object checkFlag, ArrayList<GalleryInfo> lmdArray,
public void onSuccess(Object checkFlag, List<GalleryInfo> lmdArray,
int indexPerPage, int maxPage);
public void onFailure(Object checkFlag, String eMsg);
}
private class GetMangaListPackage {
public Object checkFlag;
public ArrayList<GalleryInfo> lmdArray;
public List<GalleryInfo> lmdArray;
public int indexPerPage;
public int maxPage;
public OnGetMangaListListener listener;
public String eMsg;
public GetMangaListPackage(Object checkFlag, ArrayList<GalleryInfo> lmdArray, int indexPerPage,
public GetMangaListPackage(Object checkFlag, List<GalleryInfo> lmdArray, int indexPerPage,
int maxPage, OnGetMangaListListener listener, String eMsg) {
this.checkFlag = checkFlag;
this.lmdArray = lmdArray;
@@ -1669,26 +1672,28 @@ public class EhClient {
ListUrls.UNKNOWN
};
private static String CATEGORY_STRINGS[] = {
"misc",
"doujinshi",
"manga",
"artistcg",
"gamecg",
"imageset",
"cosplay",
"asianporn",
"non-h",
"western",
"unknown"
private static 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", "Asian Porn"},
new String[]{"asianporn"},
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++) {
if (CATEGORY_STRINGS[i].equals(type))
break;
for (String str : CATEGORY_STRINGS[i])
if (str.equalsIgnoreCase(type))
return CATEGORY_VALUES[i];
}
return CATEGORY_VALUES[i];
}
@@ -1698,13 +1703,13 @@ public class EhClient {
if (CATEGORY_VALUES[i] == type)
break;
}
return CATEGORY_STRINGS[i];
return CATEGORY_STRINGS[i][0];
}
// modifyFavorite
public interface OnModifyFavoriteListener {
void onSuccess(ArrayList<GalleryInfo> gis,
void onSuccess(List<GalleryInfo> gis,
int indexPerPage, int maxPage);
void onFailure(String eMsg);
}
@@ -1775,6 +1780,66 @@ public class EhClient {
}).start();
}
public interface OnGetPopularListener {
void onSuccess(List<GalleryInfo> gis);
void onFailure(String eMsg);
}
public void getPopular(final OnGetPopularListener listener) {
final JSONObject json = new JSONObject();
try {
json.put("method", "popular");
} catch (JSONException e) {
listener.onFailure(e.getMessage());
return;
}
new Thread(new Runnable() {
@Override
public void run() {
HttpHelper hp = new HttpHelper(mAppContext);
hp.setOnRespondListener(new HttpHelper.OnRespondListener() {
@Override
public void onSuccess(String pageContext) {
try {
List<GalleryInfo> gis = new ArrayList<GalleryInfo>();
JSONObject js = new JSONObject(pageContext);
js = js.getJSONObject("popular");
if (!js.has("galleries")) {
listener.onFailure(js.getString("error"));
return;
}
JSONArray ja = js.getJSONArray("galleries");
for (int i = 0; i < ja.length(); i++) {
JSONObject j = ja.getJSONObject(i);
GalleryInfo gi = new GalleryInfo();
gi.gid = j.getInt("gid");
gi.token = j.getString("token");
gi.title = StringEscapeUtils.unescapeHtml4(j.getString("title"));
gi.posted = mAppContext.getDateFormat().format(Long.parseLong(j.getString("posted")) * 1000);
gi.thumb = j.getString("thumb");
gi.category = getType(j.getString("category"));
gi.uploader = j.getString("uploader");
gi.rating = Float.parseFloat(j.getString("rating"));
gis.add(gi);
}
listener.onSuccess(gis);
} catch (JSONException e) {
listener.onFailure(e.getMessage());
}
}
@Override
public void onFailure(String eMsg) {
listener.onFailure(eMsg);
}
});
hp.postJson(EHVIEWER_API, json);
}
}).start();
}
/*
private static class GetGalleryMetadataPackage {
public Map<String, ListMangaDetail> lmds;
@@ -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);
}
}
};
}
@@ -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) {