mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 03:28:52 +01:00
Cleaned up the base application and added an interface for the analytics manager
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
|
||||
<application
|
||||
android:name=".QKSMSApp_"
|
||||
android:name=".QKSMSApp"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher_teal"
|
||||
android:label="@string/app_name"
|
||||
|
||||
+6
-6
@@ -45,13 +45,13 @@ import com.squareup.leakcanary.RefWatcher;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class QKSMSApp extends Application {
|
||||
public class QKSMSAppBase extends Application {
|
||||
public static final String LOG_TAG = "Mms";
|
||||
|
||||
private SearchRecentSuggestions mRecentSuggestions;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private String mCountryIso;
|
||||
private static QKSMSApp sQKSMSApp = null;
|
||||
private static QKSMSAppBase sQKSMSAppBase = null;
|
||||
private PduLoaderManager mPduLoaderManager;
|
||||
private ThumbnailManager mThumbnailManager;
|
||||
private DrmManagerClient mDrmManagerClient;
|
||||
@@ -69,7 +69,7 @@ public class QKSMSApp extends Application {
|
||||
new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
|
||||
}
|
||||
|
||||
sQKSMSApp = this;
|
||||
sQKSMSAppBase = this;
|
||||
|
||||
loadDefaultPreferenceValues();
|
||||
|
||||
@@ -100,7 +100,7 @@ public class QKSMSApp extends Application {
|
||||
}
|
||||
|
||||
public static RefWatcher getRefWatcher(Context context) {
|
||||
QKSMSApp application = (QKSMSApp) context.getApplicationContext();
|
||||
QKSMSAppBase application = (QKSMSAppBase) context.getApplicationContext();
|
||||
return application.refWatcher;
|
||||
}
|
||||
|
||||
@@ -122,8 +122,8 @@ public class QKSMSApp extends Application {
|
||||
//sendBroadcast(new Intent(SmsReceiverService.ACTION_SEND_INACTIVE_MESSAGE, null, this, SmsReceiver.class));
|
||||
}
|
||||
|
||||
synchronized public static QKSMSApp getApplication() {
|
||||
return sQKSMSApp;
|
||||
synchronized public static QKSMSAppBase getApplication() {
|
||||
return sQKSMSAppBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.moez.QKSMS.common;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
interface AnalyticsManagerBase {
|
||||
String TAG = "AnalyticsManager";
|
||||
boolean LOCAL_LOGV = false;
|
||||
String CATEGORY_MESSAGES = "messages";
|
||||
// Note: For preferences events, the action will just be the preference value.
|
||||
String CATEGORY_PREFERENCE_CHANGE = "preference_change";
|
||||
String CATEGORY_PREFERENCE_CLICK = "preference_click";
|
||||
String CATEGORY_REPORT = "report";
|
||||
String ACTION_SEND_MESSAGE = "send_message";
|
||||
String ACTION_ATTACH_IMAGE = "attach_image";
|
||||
String ACTION_ATTACH_FROM_CAMERA = "attach_from_camera";
|
||||
|
||||
void init(Context context);
|
||||
|
||||
void sendEvent(String category, String action, String label);
|
||||
|
||||
void sendEvent(String category, String action, String label, long value);
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import android.util.Log;
|
||||
|
||||
import com.android.mms.transaction.MmsMessageSender;
|
||||
import com.google.android.mms.pdu_alt.PduHeaders;
|
||||
import com.moez.QKSMS.QKSMSAppBase;
|
||||
import com.moez.QKSMS.mmssms.Utils;
|
||||
import com.moez.QKSMS.LogTag;
|
||||
import com.moez.QKSMS.QKSMSApp;
|
||||
@@ -802,7 +803,7 @@ public class Conversation {
|
||||
sDeletingThreads = true;
|
||||
String selection = deleteAll ? null : "locked=0";
|
||||
|
||||
QKSMSApp app = QKSMSApp.getApplication();
|
||||
QKSMSAppBase app = QKSMSApp.getApplication();
|
||||
//app.getPduLoaderManager().clear();
|
||||
//app.getThumbnailManager().clear();
|
||||
|
||||
|
||||
@@ -624,7 +624,7 @@ public class ThemeManager {
|
||||
|
||||
public static void setColour(int color) {
|
||||
|
||||
AnalyticsManager.INSTANCE.sendEvent(
|
||||
AnalyticsManager.getInstance().sendEvent(
|
||||
AnalyticsManager.CATEGORY_PREFERENCE_CHANGE,
|
||||
SettingsFragment.CATEGORY_THEME,
|
||||
getColorString(color)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.moez.QKSMS;
|
||||
|
||||
public class QKSMSApp extends QKSMSAppBase {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.moez.QKSMS;
|
||||
|
||||
public class QKSMSApp_ extends QKSMSApp {
|
||||
}
|
||||
@@ -2,30 +2,30 @@ package com.moez.QKSMS.common;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public enum AnalyticsManager {
|
||||
INSTANCE;
|
||||
public class AnalyticsManager implements AnalyticsManagerBase {
|
||||
private AnalyticsManager() {
|
||||
}
|
||||
|
||||
private final static String TAG = "AnalyticsManager";
|
||||
private final static boolean LOCAL_LOGV = false;
|
||||
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";
|
||||
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 static class AnalyticsManagerHolder {
|
||||
private final static AnalyticsManager INSTANCE = new AnalyticsManager();
|
||||
}
|
||||
|
||||
public static AnalyticsManager getInstance() {
|
||||
return INSTANCE;
|
||||
return AnalyticsManagerHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEvent(String category, String action, String label) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEvent(String category, String action, String label, long value) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package com.moez.QKSMS;
|
||||
|
||||
import com.crittercism.app.Crittercism;
|
||||
|
||||
public class QKSMSApp_ extends QKSMSApp {
|
||||
public class QKSMSApp extends QKSMSAppBase {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
@@ -8,35 +8,22 @@ import com.google.android.gms.analytics.HitBuilders;
|
||||
import com.google.android.gms.analytics.Tracker;
|
||||
import com.moez.QKSMS.R;
|
||||
|
||||
public enum AnalyticsManager {
|
||||
INSTANCE;
|
||||
public class AnalyticsManager implements AnalyticsManagerBase {
|
||||
private AnalyticsManager() {
|
||||
}
|
||||
|
||||
private final static String TAG = "AnalyticsManager";
|
||||
private final static boolean LOCAL_LOGV = false;
|
||||
private static class AnalyticsManagerHolder {
|
||||
private final static AnalyticsManager INSTANCE = new AnalyticsManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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";
|
||||
public static AnalyticsManager getInstance() {
|
||||
return AnalyticsManagerHolder.INSTANCE;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user