forked from upstream-mirrors/quik
Create two different flavors: with analytics disabled for a free (as in
"free-speech") flavors and the usual version for Google Play
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.moez.QKSMS;
|
||||
|
||||
import com.crittercism.app.Crittercism;
|
||||
|
||||
public class QKSMSApp_ extends QKSMSApp {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Crittercism.initialize(getApplicationContext(), getString(R.string.crtsm_key));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.moez.QKSMS.common;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.analytics.GoogleAnalytics;
|
||||
import com.google.android.gms.analytics.HitBuilders;
|
||||
import com.google.android.gms.analytics.Tracker;
|
||||
import com.moez.QKSMS.R;
|
||||
|
||||
public enum AnalyticsManager {
|
||||
INSTANCE;
|
||||
|
||||
private final static String TAG = "AnalyticsManager";
|
||||
private final static boolean LOCAL_LOGV = false;
|
||||
|
||||
/**
|
||||
* Event categories
|
||||
*/
|
||||
public final static String CATEGORY_MESSAGES = "messages";
|
||||
// Note: For preferences events, the action will just be the preference value.
|
||||
public final static String CATEGORY_PREFERENCE_CHANGE = "preference_change";
|
||||
public final static String CATEGORY_PREFERENCE_CLICK = "preference_click";
|
||||
public final static String CATEGORY_REPORT = "report";
|
||||
|
||||
/**
|
||||
* Event actions
|
||||
*/
|
||||
public final static String ACTION_SEND_MESSAGE = "send_message";
|
||||
public final static String ACTION_ATTACH_IMAGE = "attach_image";
|
||||
public final static String ACTION_ATTACH_FROM_CAMERA = "attach_from_camera";
|
||||
|
||||
private boolean mNeedsInit = true;
|
||||
private Context mContext;
|
||||
private Tracker mTracker;
|
||||
|
||||
public static AnalyticsManager getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void init(Context context) {
|
||||
if (LOCAL_LOGV) Log.v(TAG, "init called. mNeedsInit: " + mNeedsInit);
|
||||
|
||||
if (mNeedsInit) {
|
||||
mNeedsInit = false;
|
||||
mContext = context;
|
||||
|
||||
// Initialize tracker
|
||||
GoogleAnalytics analytics = GoogleAnalytics.getInstance(mContext);
|
||||
mTracker = analytics.newTracker(R.xml.google_analytics_tracker);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendEvent(String category, String action, String label) {
|
||||
if (LOCAL_LOGV) Log.v(TAG, "sendEvent category:" + category + ", action:" + action +
|
||||
", label:" + label);
|
||||
|
||||
HitBuilders.EventBuilder b = new HitBuilders.EventBuilder();
|
||||
if (category != null) b.setCategory(category);
|
||||
if (action != null) b.setAction(action);
|
||||
if (label != null) b.setLabel(label);
|
||||
|
||||
mTracker.send(b.build());
|
||||
}
|
||||
|
||||
public void sendEvent(String category, String action, String label, long value) {
|
||||
if (LOCAL_LOGV) Log.v(TAG, "sendEvent category:" + category + ", action:" + action +
|
||||
", label:" + label + ", value:" + value);
|
||||
|
||||
HitBuilders.EventBuilder b = new HitBuilders.EventBuilder();
|
||||
if (category != null) b.setCategory(category);
|
||||
if (action != null) b.setAction(action);
|
||||
if (label != null) b.setLabel(label);
|
||||
b.setValue(value);
|
||||
|
||||
mTracker.send(b.build());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user