Permalink
Browse files

Update android lib to work with types

  • Loading branch information...
1 parent bb81c85 commit 17914066cad0706892afdadfda19f36bf60d19f7 Anlu Wang committed Dec 1, 2011
Showing with 134 additions and 74 deletions.
  1. +8 −0 .classpath
  2. +33 −0 .project
  3. BIN MPMetrics.jar
  4. BIN bin/classes/com/mixpanel/android/mpmetrics/Global.class
  5. BIN bin/classes/com/mixpanel/android/mpmetrics/MPDbAdapter$MPDatabaseHelper.class
  6. BIN bin/classes/com/mixpanel/android/mpmetrics/MPDbAdapter.class
  7. BIN bin/classes/com/mixpanel/android/mpmetrics/MPMetrics$1.class
  8. BIN bin/classes/com/mixpanel/android/mpmetrics/MPMetrics$TrackTask.class
  9. BIN bin/classes/com/mixpanel/android/mpmetrics/MPMetrics.class
  10. BIN bin/classes/com/mixpanel/android/util/Base64Coder.class
  11. BIN bin/classes/com/mixpanel/android/util/StringUtils.class
  12. BIN bin/mixpanel-android.jar
  13. +1 −10 default.properties
  14. +9 −8 demo/Hello Mixpanel/.classpath
  15. +5 −0 demo/Hello Mixpanel/.settings/org.eclipse.jdt.core.prefs
  16. BIN demo/Hello Mixpanel/bin/Hello Mixpanel.apk
  17. BIN demo/Hello Mixpanel/bin/classes.dex
  18. BIN demo/Hello Mixpanel/bin/classes/com/mixpanel/android/hellomixpanel/HelloMixpanel$1.class
  19. BIN demo/Hello Mixpanel/bin/{ → classes}/com/mixpanel/android/hellomixpanel/HelloMixpanel.class
  20. BIN demo/Hello Mixpanel/bin/{ → classes}/com/mixpanel/android/hellomixpanel/R$attr.class
  21. BIN demo/Hello Mixpanel/bin/{ → classes}/com/mixpanel/android/hellomixpanel/R$drawable.class
  22. BIN demo/Hello Mixpanel/bin/{ → classes}/com/mixpanel/android/hellomixpanel/R$id.class
  23. BIN demo/Hello Mixpanel/bin/{ → classes}/com/mixpanel/android/hellomixpanel/R$layout.class
  24. BIN demo/Hello Mixpanel/bin/{ → classes}/com/mixpanel/android/hellomixpanel/R$string.class
  25. BIN demo/Hello Mixpanel/bin/{ → classes}/com/mixpanel/android/hellomixpanel/R.class
  26. BIN demo/Hello Mixpanel/bin/com/mixpanel/android/hellomixpanel/HelloMixpanel$1.class
  27. BIN demo/Hello Mixpanel/bin/res/drawable/icon.png
  28. BIN demo/Hello Mixpanel/bin/resources.ap_
  29. +26 −26 demo/Hello Mixpanel/gen/com/mixpanel/android/hellomixpanel/R.java
  30. BIN demo/Hello Mixpanel/lib/MPMetrics.jar
  31. +3 −3 demo/Hello Mixpanel/{default.properties → project.properties}
  32. +13 −6 demo/Hello Mixpanel/src/com/mixpanel/android/hellomixpanel/HelloMixpanel.java
  33. +12 −0 project.properties
  34. +24 −21 src/com/mixpanel/android/mpmetrics/MPMetrics.java
View
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
View
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>mixpanel-android</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
View
@@ -1,12 +1,3 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
+android.library=true
# Project target.
target=android-4
-android.library=true
@@ -1,8 +1,9 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="lib" path="D:/projects/mp-workspace/Hello Mixpanel/lib/MPMetrics.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="lib" path="lib/MPMetrics.jar"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
@@ -0,0 +1,5 @@
+#Thu Dec 01 12:06:30 PST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
View
Binary file not shown.
View
BIN demo/Hello Mixpanel/bin/classes.dex 100755 → 100644
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Binary file not shown.
@@ -1,26 +1,26 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package com.mixpanel.android.hellomixpanel;
-
-public final class R {
- public static final class attr {
- }
- public static final class drawable {
- public static final int icon=0x7f020000;
- }
- public static final class id {
- public static final int button=0x7f050000;
- }
- public static final class layout {
- public static final int main=0x7f030000;
- }
- public static final class string {
- public static final int app_name=0x7f040001;
- public static final int hello=0x7f040000;
- }
-}
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.mixpanel.android.hellomixpanel;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int icon=0x7f020000;
+ }
+ public static final class id {
+ public static final int button=0x7f050000;
+ }
+ public static final class layout {
+ public static final int main=0x7f030000;
+ }
+ public static final class string {
+ public static final int app_name=0x7f040001;
+ public static final int hello=0x7f040000;
+ }
+}
View
Binary file not shown.
@@ -1,10 +1,10 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
+#
# This file must be checked in Version Control Systems.
-#
+#
# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
@@ -1,6 +1,8 @@
package com.mixpanel.android.hellomixpanel;
-import java.util.HashMap;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
import com.mixpanel.android.mpmetrics.MPMetrics;
@@ -20,16 +22,21 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
- mMPMetrics = new MPMetrics(this, "c0cf87b23e9a08ba5842f119d367775b");
+ mMPMetrics = new MPMetrics(this, "c35a4b5163ee2c097de447765f691544");
mButton = (Button) findViewById(R.id.button);
mButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
- HashMap<String, String> properties = new HashMap<String, String>();
- properties.put("gender", "male");
- mMPMetrics.event("Button Clicked", properties);
+ JSONObject properties = new JSONObject();
+ try {
+ properties.put("gender", "male");
+ properties.put("age", 24);
+ properties.put("registered", true);
+ properties.put("some list", new JSONArray("[1,2,3,4,5]"));
+ } catch(JSONException e) { }
+ mMPMetrics.track("Button Clicked", properties);
}
});
}
-}
+}
View
@@ -0,0 +1,12 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+android.library=true
+# Project target.
+target=android-4
@@ -2,8 +2,8 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.StringTokenizer;
import java.util.Timer;
import java.util.TimerTask;
@@ -50,7 +50,7 @@
private String mVersion;
private String mDeviceId;
- private Map<String, String> mSuperProperties;
+ private JSONObject mSuperProperties;
private MPDbAdapter mDbAdapter;
@@ -70,6 +70,8 @@ public MPMetrics(Context context, String token) {
mModel = getModel();
mVersion = getVersion();
mDeviceId = getDeviceId();
+
+ mSuperProperties = new JSONObject();
mDbAdapter = new MPDbAdapter(mContext);
mDbAdapter.cleanupEvents(System.currentTimeMillis() - DATA_EXPIRATION);
@@ -85,20 +87,21 @@ public void run() {
/**
* Register super properties for events
- * @param superProperties A map containing the key value pairs of the super properties to register
+ * @param superProperties A JSONObject containing super properties to register
* @param type Indicates which types of events to apply the super properties. Must be SUPER_PROPERTY_TYPE_ALL,
* SUPER_PROPERTY_TYPE_EVENTS, or SUPER_PROPERTY_TYPE_FUNNELS
*/
- public void registerSuperProperties(Map<String, String> superProperties) {
+ public void registerSuperProperties(JSONObject superProperties) {
if (Global.DEBUG) Log.d(LOGTAG, "registerSuperProperties");
- if (mSuperProperties == null) {
- mSuperProperties = superProperties;
- } else {
- for (Map.Entry<String, String> entry: superProperties.entrySet()) {
- mSuperProperties.put(entry.getKey(), entry.getValue());
- }
- }
+ for (Iterator<String> iter = superProperties.keys(); iter.hasNext(); ) {
+ String key = iter.next();
+ try {
+ mSuperProperties.put(key, superProperties.get(key));
+ } catch (JSONException e) {
+ Log.e(LOGTAG, "Exception registering super property.", e);
+ }
+ }
}
/**
@@ -113,10 +116,10 @@ public void clearSuperProperties() {
* Track an event.
*
* @param eventName The name of the event to send
- * @param properties A Map containing the key value pairs of the properties to include in this event.
+ * @param properties A JSONObject containing the key value pairs of the properties to include in this event.
* Pass null if no extra properties exist.
*/
- public void event(String eventName, Map<String, String> properties) {
+ public void track(String eventName, JSONObject properties) {
String time = Long.toString(System.currentTimeMillis() / 1000);
JSONObject dataObj = new JSONObject();
@@ -131,16 +134,16 @@ public void event(String eventName, Map<String, String> properties) {
propertiesObj.put("version", mVersion == null ? "UNKNOWN" : mVersion);
propertiesObj.put("mp_lib", "android");
- if (mSuperProperties != null) {
- for (Map.Entry<String, String> entry: mSuperProperties.entrySet()) {
- propertiesObj.put(entry.getKey(), entry.getValue());
- }
- }
+ for (Iterator<String> iter = mSuperProperties.keys(); iter.hasNext(); ) {
+ String key = iter.next();
+ propertiesObj.put(key, mSuperProperties.get(key));
+ }
if (properties != null) {
- for (Map.Entry<String, String> entry: properties.entrySet()) {
- propertiesObj.put(entry.getKey(), entry.getValue());
- }
+ for (Iterator<String> iter = properties.keys(); iter.hasNext();) {
+ String key = iter.next();
+ propertiesObj.put(key, properties.get(key));
+ }
}
dataObj.put("properties", propertiesObj);

0 comments on commit 1791406

Please sign in to comment.