git clone of logicmail with some fixes/features added
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Force use of the stub analytics collector if the real collector is disabled by the user, because simply disabling collection wasn't always causing it to be inactive. (fixes #383)

git-svn-id: https://logicmail.svn.sourceforge.net/svnroot/logicmail/trunk@977 5c734088-3d25-0410-9155-b3c3832efda5

octorian c16d0132 b3ad2f54

+38 -7
+31 -2
LogicMail/src/org/logicprobe/LogicMail/AnalyticsDataCollector.java
··· 45 45 */ 46 46 public abstract class AnalyticsDataCollector { 47 47 private static AnalyticsDataCollector instance; 48 + private static boolean instanceIsWebtrends; 48 49 49 50 private static String WEBTRENDS_UIAPPLICATION = "com.webtrends.mobile.rim.WebtrendsUiApplication"; 50 51 private static String WEBTRENDS_DATA_COLLECTOR = "org.logicprobe.LogicMail.LogicMailWebtrendsDataCollector"; 51 52 52 53 public static synchronized AnalyticsDataCollector getInstance() { 53 54 if(instance == null) { 54 - if(!DeviceInfo.isSimulator() && isWebtrendsAvailable()) { 55 + if(!DeviceInfo.isSimulator() && isWebtrendsAvailable() && AppInfo.isAnalyticsEnabled()) { 55 56 instance = createWebtrendsDataCollector(); 57 + instanceIsWebtrends = true; 56 58 } 57 59 else { 58 60 instance = new StubDataCollector(); 61 + instanceIsWebtrends = false; 59 62 } 60 63 } 61 64 return instance; ··· 90 93 } 91 94 92 95 /** 96 + * Checks the value of {@link AppInfo#isAnalyticsEnabled()} and enables or 97 + * disables the analytics service accordingly. 98 + */ 99 + public static synchronized void updateAnalyticsState() { 100 + // No need to do anything if we have not been initialized yet. 101 + if(instance == null) { return; } 102 + 103 + if(AppInfo.isAnalyticsEnabled()) { 104 + // If analytics is enabled, and we were using the stub, throw away 105 + // that stub so we'll be correctly initialized on next use. 106 + if(!instanceIsWebtrends) { 107 + instance.setConfigured(false); 108 + instance = null; 109 + } 110 + } 111 + else { 112 + // If analytics is disabled, and we were collecting, disable and 113 + // throw away the collector so we'll be stubbed out on next use. 114 + if(instanceIsWebtrends) { 115 + instance.setConfigured(false); 116 + instance = null; 117 + } 118 + } 119 + } 120 + 121 + /** 93 122 * Turns on or turns off data collection in an application. 94 123 * The default value is <code>true</code>. 95 124 * 96 125 * @param configured Specify <code>true</code> to turn on data collection, 97 126 * and specify <code>false</code> to turn off data collection. 98 127 */ 99 - public abstract void setConfigured(boolean configured); 128 + protected abstract void setConfigured(boolean configured); 100 129 101 130 /** 102 131 * Invoke this method to track instances that an application starts.
+1
LogicMail/src/org/logicprobe/LogicMail/LogicMail.java
··· 217 217 AppInfo.setLicenseAccepted(true); 218 218 AppInfo.setAnalyticsEnabled(popupDialog.isAnalyticsEnabled()); 219 219 PermissionsHandler.checkStartupPermissions(true); 220 + AnalyticsDataCollector.updateAnalyticsState(); 220 221 foreground = true; 221 222 LogicMail.this.requestForeground(); 222 223 pushScreen(loadingScreen);
+1 -1
LogicMail/src/org/logicprobe/LogicMail/StubDataCollector.java
··· 33 33 import java.util.Hashtable; 34 34 35 35 class StubDataCollector extends AnalyticsDataCollector { 36 - public void setConfigured(boolean configured) { } 36 + protected void setConfigured(boolean configured) { } 37 37 38 38 public void onApplicationStart() { } 39 39
+4 -3
LogicMail/src/org/logicprobe/LogicMail/ui/ConfigScreen.java
··· 1121 1121 private void toggleAnalyticsValue(boolean oldValue, boolean newValue) { 1122 1122 if(oldValue == newValue) { return; } 1123 1123 1124 + AppInfo.setAnalyticsEnabled(newValue); 1125 + 1124 1126 if(oldValue == false && newValue == true) { 1125 - AnalyticsDataCollector.getInstance().setConfigured(true); 1127 + AnalyticsDataCollector.updateAnalyticsState(); 1126 1128 UiApplication.getUiApplication().activate(); 1127 1129 } 1128 1130 else if(oldValue == true && newValue == false) { 1129 - AnalyticsDataCollector.getInstance().setConfigured(false); 1131 + AnalyticsDataCollector.updateAnalyticsState(); 1130 1132 } 1131 - AppInfo.setAnalyticsEnabled(newValue); 1132 1133 } 1133 1134 }
+1 -1
LogicMailStartup/src/org/logicprobe/LogicMail/LogicMailWebtrendsDataCollector.java
··· 56 56 collectorLogger = WebtrendsDataCollector.getLog(); 57 57 } 58 58 59 - public void setConfigured(boolean configured) { 59 + protected void setConfigured(boolean configured) { 60 60 WebtrendsDataCollector.setConfigured(configured); 61 61 } 62 62