diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 61160de3f..60e26ef93 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -366,7 +366,7 @@
首页
模式
收藏
- 好评
+ 热门
下载
2 星
diff --git a/src/com/hippo/ehviewer/Analytics.java b/src/com/hippo/ehviewer/Analytics.java
new file mode 100644
index 000000000..d0c195ea5
--- /dev/null
+++ b/src/com/hippo/ehviewer/Analytics.java
@@ -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);
+ }
+}
diff --git a/src/com/hippo/ehviewer/ui/MangaDetailActivity.java b/src/com/hippo/ehviewer/ui/MangaDetailActivity.java
index c0d2f925b..0e8d18eed 100644
--- a/src/com/hippo/ehviewer/ui/MangaDetailActivity.java
+++ b/src/com/hippo/ehviewer/ui/MangaDetailActivity.java
@@ -23,6 +23,7 @@ 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;
@@ -118,15 +119,8 @@ public class MangaDetailActivity extends AbstractFragmentActivity
} else {
mGalleryInfo = intent.getParcelableExtra(KEY_G_INFO);
}
-
- if (!Config.getAllowAnalyics())
- return;
- try {
- JSONObject js = new JSONObject();
- js.put("gid", mGalleryInfo.gid).put("token", mGalleryInfo.token);
- EasyTracker easyTracker = EasyTracker.getInstance(this);
- easyTracker.send(MapBuilder.createEvent("gallery", "open", js.toString(), null).build());
- } catch (Exception e) {}
+ // Analytics
+ Analytics.openGallery(this, mGalleryInfo);
}
@Override
@@ -230,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,
@@ -237,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) {
diff --git a/src/com/hippo/ehviewer/ui/MangaListActivity.java b/src/com/hippo/ehviewer/ui/MangaListActivity.java
index 26af8ac7d..6859e6eea 100644
--- a/src/com/hippo/ehviewer/ui/MangaListActivity.java
+++ b/src/com/hippo/ehviewer/ui/MangaListActivity.java
@@ -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;
@@ -504,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);
@@ -512,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);
@@ -523,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) {
diff --git a/src/com/hippo/ehviewer/util/Favorite.java b/src/com/hippo/ehviewer/util/Favorite.java
index 961432673..d8f746646 100644
--- a/src/com/hippo/ehviewer/util/Favorite.java
+++ b/src/com/hippo/ehviewer/util/Favorite.java
@@ -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) {