Permalink
Browse files

[!] Updated to the latest MixPanel code

[*] upstream update for ActionBarSherlock
  • Loading branch information...
1 parent 6804398 commit fa3f8fb868e286477d0c3668a6a5bb44fd684e2b @artiomchi committed Jan 15, 2012
2 lib/ActionBarSherlock
@@ -1 +1 @@
-Subproject commit e7e5c00ec17e4a1d20aa0ca988b8877b7de0cf29
+Subproject commit 4d60626151204b0219526efaa77aeb0dbdb0a6eb
View
8 project.properties
@@ -9,8 +9,8 @@
# Project target.
target=android-13
-android.library.reference.1=lib/AChartEngine
-android.library.reference.2=lib/ActionBarSherlock/library
-android.library.reference.3=lib/ActionBarSherlock/plugins/preference
-android.library.reference.4=lib/AndroidBilling/AndroidBillingLibrary
+android.library.reference.1=lib/ActionBarSherlock/library
+android.library.reference.2=lib/ActionBarSherlock/plugins/preference
+android.library.reference.3=lib/AndroidBilling/AndroidBillingLibrary
+android.library.reference.4=lib/AChartEngine
android.library.reference.5=lib/MixPanel
View
14 src/org/flexlabs/widgets/dualbattery/MixPanelComponent.java
@@ -18,6 +18,8 @@
import android.content.Context;
import com.mixpanel.android.mpmetrics.MPMetrics;
+import org.json.JSONException;
+import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
@@ -41,12 +43,16 @@ public MixPanelComponent(Context context) {
mpMetrics = new MPMetrics(context, API_KEY);
}
- public void event(String eventName, Map<String, String> properties) {
+ public void track(String eventName, JSONObject properties) {
if (!ENABLED || mpMetrics == null) return;
if (properties == null)
- properties = new HashMap<String, String>();
- properties.put("appVersion", Constants.VERSION);
- mpMetrics.event(eventName, properties);
+ properties = new JSONObject();
+ try {
+ properties.put("appVersion", Constants.VERSION);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ mpMetrics.track(eventName, properties);
}
public void flush() {
View
32 src/org/flexlabs/widgets/dualbattery/widgetsettings/BatteryInfoViewManager.java
@@ -55,6 +55,8 @@
import org.flexlabs.widgets.dualbattery.MixPanelComponent;
import org.flexlabs.widgets.dualbattery.R;
import org.flexlabs.widgets.dualbattery.storage.BatteryLevelAdapter;
+import org.json.JSONException;
+import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.FileReader;
@@ -122,9 +124,13 @@ public void loadData(Activity activity, View view, int appWidgetId) {
@Override
public void onPurchaseStateChanged(String itemId, Transaction.PurchaseState state) {
if (state == Transaction.PurchaseState.PURCHASED) {
- HashMap<String, String> properties = new HashMap<String, String>();
- properties.put("item", itemId);
- mMixPanel.event(MixPanelComponent.DONATE_MARKET_CONFIRMED, properties);
+ JSONObject properties = new JSONObject();
+ try {
+ properties.put("item", itemId);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ mMixPanel.track(MixPanelComponent.DONATE_MARKET_CONFIRMED, properties);
Toast.makeText(mActivity, "Thanks a lot for supporting me!", Toast.LENGTH_LONG).show();
}
}
@@ -137,7 +143,7 @@ public void onPurchaseStateChanged(String itemId, Transaction.PurchaseState stat
if (mMixPanel == null) {
mMixPanel = new MixPanelComponent(mActivity);
- mMixPanel.event(MixPanelComponent.BATTERY_INFO, null);
+ mMixPanel.track(MixPanelComponent.BATTERY_INFO, null);
}
}
@@ -310,7 +316,7 @@ public boolean onMenuItemSelected(MenuItem item) {
return true;
case R.id.feedback :
- mMixPanel.event(MixPanelComponent.BATTERY_INFO_FEEDBACK, null);
+ mMixPanel.track(MixPanelComponent.BATTERY_INFO_FEEDBACK, null);
Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.FeedbackDestination });
intent.putExtra(Intent.EXTRA_SUBJECT, "Dual Battery Widget Feedback");
@@ -324,17 +330,17 @@ public boolean onMenuItemSelected(MenuItem item) {
return true;
case R.id.donate_payPal :
- mMixPanel.event(MixPanelComponent.DONATE_PAYPAL, null);
+ mMixPanel.track(MixPanelComponent.DONATE_PAYPAL, null);
mActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.URI_PAYPAL)));
return true;
case R.id.donate_market :
- mMixPanel.event(MixPanelComponent.DONATE_MARKET, null);
+ mMixPanel.track(MixPanelComponent.DONATE_MARKET, null);
mActivity.showDialog(DIALOG_DONATE_MARKET);
return true;
case R.id.about :
- mMixPanel.event(MixPanelComponent.BATTERY_INFO_ABOUT, null);
+ mMixPanel.track(MixPanelComponent.BATTERY_INFO_ABOUT, null);
mActivity.showDialog(DIALOG_ABOUT);
return true;
@@ -457,9 +463,13 @@ public void onClick(DialogInterface dialogInterface, int i) {
case 2:
marketItem = "donation.amount.7.77"; break;
}
- HashMap<String, String> properties = new HashMap<String, String>();
- properties.put("item", marketItem);
- mMixPanel.event(MixPanelComponent.DONATE_MARKET_PACKAGE, properties);
+ JSONObject properties = new JSONObject();
+ try {
+ properties.put("item", marketItem);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ mMixPanel.track(MixPanelComponent.DONATE_MARKET_PACKAGE, properties);
BillingController.requestPurchase(mActivity, marketItem, true);
}
})

0 comments on commit fa3f8fb

Please sign in to comment.