From 7d0d16b30aa08c5618c4f00d363b8260792f7102 Mon Sep 17 00:00:00 2001 From: cagryInside Date: Mon, 2 Mar 2015 11:47:25 -0500 Subject: [PATCH] Fix #237 - If custom url reporting disabled when it is null. Also Api region reporting removed from MapStopIcon event as discussed in https://github.com/OneBusAway/onebusaway-android/issues/233#issuecomment-76745031. --- .../com/joulespersecond/oba/ObaAnalytics.java | 2 -- .../seattlebusbot/Application.java | 9 +------ .../seattlebusbot/PreferencesActivity.java | 22 +++++++++++----- .../map/googlemapsv1/StopOverlay.java | 26 +++---------------- .../src/main/res/values/do_not_translate.xml | 8 +++--- 5 files changed, 25 insertions(+), 42 deletions(-) diff --git a/onebusaway-android/src/main/java/com/joulespersecond/oba/ObaAnalytics.java b/onebusaway-android/src/main/java/com/joulespersecond/oba/ObaAnalytics.java index 8ffc87bfa..a41321397 100644 --- a/onebusaway-android/src/main/java/com/joulespersecond/oba/ObaAnalytics.java +++ b/onebusaway-android/src/main/java/com/joulespersecond/oba/ObaAnalytics.java @@ -226,8 +226,6 @@ private static String getObaRegionName() { } catch (Exception e) { regionName = Application.get().getString(R.string.analytics_label_custom_url); } - } else { - regionName = Application.get().getString(R.string.analytics_label_custom_url); } return regionName; } diff --git a/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/Application.java b/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/Application.java index fdea32e17..3aa720bd5 100644 --- a/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/Application.java +++ b/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/Application.java @@ -254,7 +254,7 @@ private void reportAnalytics() { ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.APP_SETTINGS.toString(), getString(R.string.analytics_action_configured_region), getString(R.string.analytics_label_region) + getCurrentRegion().getName()); - } else { + } else if (Application.get().getCustomApiUrl() != null) { String customUrl = null; MessageDigest digest = null; try { @@ -270,13 +270,6 @@ private void reportAnalytics() { + customUrl); } - if (getCurrentRegion() != null) { - Boolean showExperimentalRegions = getCurrentRegion().getExperimental(); - ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.APP_SETTINGS.toString(), - getString(R.string.analytics_action_configured_region), getString(R.string.analytics_label_region) - + (showExperimentalRegions ? "YES" : "NO")); - } - Boolean experimentalRegions = getPrefs().getBoolean(getString(R.string.preference_key_experimental_regions), Boolean.FALSE); Boolean autoRegion = getPrefs().getBoolean(getString(R.string.preference_key_auto_select_region), diff --git a/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/PreferencesActivity.java b/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/PreferencesActivity.java index 443820402..6cf533d53 100644 --- a/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/PreferencesActivity.java +++ b/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/PreferencesActivity.java @@ -216,9 +216,14 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin // Wait to change the region preference description until the task callback //Analytics - ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(), - getString(R.string.analytics_action_button_press), - getString(R.string.analytics_label_button_press_experimental) + experimentalServers); + if (experimentalServers) + ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(), + getString(R.string.analytics_action_button_press), + getString(R.string.analytics_label_button_press_experimental_on)); + else + ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(), + getString(R.string.analytics_action_button_press), + getString(R.string.analytics_label_button_press_experimental_off)); } else if (key.equals(getString(R.string.preference_key_oba_api_url))) { // Change the region preference description to show we're not using a region changePreferenceSummary(key); @@ -229,9 +234,14 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin //Analytics boolean autoSelect = settings .getBoolean(getString(R.string.preference_key_auto_select_region), false); - ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(), - getString(R.string.analytics_action_button_press), - getString(R.string.analytics_label_button_press_auto) + autoSelect); + if (autoSelect) + ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(), + getString(R.string.analytics_action_button_press), + getString(R.string.analytics_label_button_press_auto)); + else + ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(), + getString(R.string.analytics_action_button_press), + getString(R.string.analytics_label_button_press_manual)); } else if (key.equalsIgnoreCase(getString(R.string.preferences_key_analytics))) { Boolean isAnalyticsActive = settings.getBoolean(Application.get(). getString(R.string.preferences_key_analytics), Boolean.FALSE); diff --git a/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/map/googlemapsv1/StopOverlay.java b/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/map/googlemapsv1/StopOverlay.java index 97dcae381..e6756b334 100644 --- a/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/map/googlemapsv1/StopOverlay.java +++ b/onebusaway-android/src/main/java/com/joulespersecond/seattlebusbot/map/googlemapsv1/StopOverlay.java @@ -26,14 +26,11 @@ import com.google.android.maps.MapView; import com.google.android.maps.OverlayItem; import com.joulespersecond.oba.ObaAnalytics; -import com.joulespersecond.oba.elements.ObaRegion; import com.joulespersecond.oba.elements.ObaStop; -import com.joulespersecond.seattlebusbot.Application; import com.joulespersecond.seattlebusbot.ArrivalsListActivity; import com.joulespersecond.seattlebusbot.R; import com.joulespersecond.seattlebusbot.util.LocationHelp; -import java.security.MessageDigest; import java.util.List; public class StopOverlay extends ItemizedOverlay { @@ -214,28 +211,11 @@ protected boolean onTap(int index) { //Track analytics Location myLocation = LocationHelp.getLocation2(mActivity, null); - ObaRegion region = Application.get().getCurrentRegion(); ObaStop stop = mStops.get(index); Location stopLocation = stop.getLocation(); - if (region != null && region.getName() != null) { - ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(), - mActivity.getString(R.string.analytics_action_button_press), - mActivity.getString(R.string.analytics_label_button_press_map_icon) + region.getName()); - } else { - String customUrl = null; - MessageDigest digest = null; - try { - digest = MessageDigest.getInstance("SHA-1"); - digest.update(Application.get().getCustomApiUrl().getBytes()); - customUrl = Application.get().getString(R.string.analytics_label_custom_url) + - ": " + Application.getHex(digest.digest()); - } catch (Exception e) { - customUrl = Application.get().getString(R.string.analytics_label_custom_url); - } - ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(), - mActivity.getString(R.string.analytics_action_button_press), - mActivity.getString(R.string.analytics_label_button_press_map_icon) + customUrl); - } + ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(), + mActivity.getString(R.string.analytics_action_button_press), + mActivity.getString(R.string.analytics_label_button_press_map_icon)); ObaAnalytics.trackBusStopDistance(stop.getId(), myLocation, stopLocation); } return true; diff --git a/onebusaway-android/src/main/res/values/do_not_translate.xml b/onebusaway-android/src/main/res/values/do_not_translate.xml index 35862825e..4cc1ffe2a 100644 --- a/onebusaway-android/src/main/res/values/do_not_translate.xml +++ b/onebusaway-android/src/main/res/values/do_not_translate.xml @@ -55,13 +55,15 @@ Clicked Donate Link Clicked Help Link Clicked Send Feedback Link - Clicked MapStopIcon from\u0020 + Clicked MapStopIcon Search box selected Search button clicked Clicked My Location Button - ExperimentalRegionCell:\u0020 + Turned on Experimental Regions + Turned off Experimental Regions Show Experimental Regions:\u0020 - Set region automatically:\u0020 + Set region automatically + Set region manually Edited Bookmark Edited Bookmark Group Deleted Set Region:\u0020