11package org .droidplanner .android ;
22
3- import org .droidplanner .BuildConfig ;
4- import org .droidplanner .R ;
53import org .droidplanner .android .gcs .FollowMe ;
4+ import org .droidplanner .android .utils .analytics .GAUtils ;
65import org .droidplanner .core .bus .events .DroneConnectedEvent ;
76import org .droidplanner .core .bus .events .DroneDisconnectedEvent ;
87import org .droidplanner .android .proxy .mission .MissionProxy ;
1817import org .droidplanner .core .drone .DroneInterfaces .Clock ;
1918import org .droidplanner .core .drone .DroneInterfaces .DroneEventsType ;
2019import org .droidplanner .core .drone .DroneInterfaces .Handler ;
21- import org .droidplanner .core .drone .Preferences ;
2220
21+ import android .content .Context ;
2322import android .os .SystemClock ;
2423
2524import com .MAVLink .Messages .MAVLinkMessage ;
26- import com .google .android .gms .analytics .GoogleAnalytics ;
27- import com .google .android .gms .analytics .Logger ;
28- import com .google .android .gms .analytics .Tracker ;
29-
30- import java .util .concurrent .atomic .AtomicReference ;
3125
3226import de .greenrobot .event .EventBus ;
3327
@@ -39,11 +33,6 @@ public class DroidPlannerApp extends ErrorReportApp implements MAVLinkStreams.Ma
3933 public MissionProxy missionProxy ;
4034 private MavLinkMsgHandler mavLinkMsgHandler ;
4135
42- /**
43- * Stores a reference to the google analytics app tracker.
44- */
45- private Tracker mAppTracker ;
46-
4736 /**
4837 * Handles dispatching of status bar, and audible notification.
4938 */
@@ -53,7 +42,8 @@ public class DroidPlannerApp extends ErrorReportApp implements MAVLinkStreams.Ma
5342 public void onCreate () {
5443 super .onCreate ();
5544
56- mNotificationHandler = new NotificationHandler (getApplicationContext ());
45+ final Context context = getApplicationContext ();
46+ mNotificationHandler = new NotificationHandler (context );
5747
5848 MAVLinkClient MAVClient = new MAVLinkClient (this , this );
5949 Clock clock = new Clock () {
@@ -75,17 +65,19 @@ public void postDelayed(Runnable thread, long timeout) {
7565 handler .postDelayed (thread , timeout );
7666 }
7767 };
78- DroidplannerPrefs pref = new DroidplannerPrefs (getApplicationContext ());
68+
69+ DroidplannerPrefs pref = new DroidplannerPrefs (context );
7970 drone = new Drone (MAVClient , clock , handler , pref );
8071 drone .events .addDroneListener (this );
8172
8273 missionProxy = new MissionProxy (drone .mission );
8374 mavLinkMsgHandler = new org .droidplanner .core .MAVLink .MavLinkMsgHandler (drone );
8475
8576 followMe = new FollowMe (this , drone );
86- NetworkStateReceiver .register (getApplicationContext () );
77+ NetworkStateReceiver .register (context );
8778
88- initGATracker (pref );
79+ GAUtils .initGATracker (this );
80+ GAUtils .startNewSession (context );
8981 }
9082
9183 @ Override
@@ -127,28 +119,4 @@ public void onDroneEvent(DroneEventsType event, Drone drone) {
127119 break ;
128120 }
129121 }
130-
131- private void initGATracker (DroidplannerPrefs pref ){
132- final GoogleAnalytics analytics = GoogleAnalytics .getInstance (this );
133- //Call is needed for now to allow dispatching of auto activity reports
134- // (http://stackoverflow.com/a/23256722/1088814)
135- analytics .enableAutoActivityReports (this );
136-
137- analytics .setAppOptOut (!pref .isUsageStatisticsEnabled ());
138-
139- //If we're in debug mode, set log level to verbose.
140- if (BuildConfig .DEBUG ){
141- analytics .getLogger ().setLogLevel (Logger .LogLevel .VERBOSE );
142- }
143-
144- mAppTracker = analytics .newTracker (R .xml .google_analytics_tracker );
145- }
146-
147- /**
148- * @return handles to the google analytics tracker.
149- */
150- public Tracker getTracker (){
151- return mAppTracker ;
152- }
153-
154122}
0 commit comments