diff --git a/app/build.gradle b/app/build.gradle index 42fbd3d..0cee55e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,7 +72,8 @@ dependencies { implementation 'com.getbase:floatingactionbutton:1.10.1' implementation 'org.apache.commons:commons-collections4:4.0' implementation 'com.android.support:design:27.1.1' - - // spinner loaders library implementation 'com.github.ybq:Android-SpinKit:1.2.0' + implementation 'com.google.android.gms:play-services-analytics:16.0.6' + implementation 'com.google.firebase:firebase-core:16.0.6' } +apply plugin: 'com.google.gms.google-services' diff --git a/app/src/main/java/com/uam/wmi/findmytutor/FindMyTutor.java b/app/src/main/java/com/uam/wmi/findmytutor/FindMyTutor.java index 3c2eabf..e3de971 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/FindMyTutor.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/FindMyTutor.java @@ -19,12 +19,24 @@ import org.acra.sender.HttpSender; import java.util.HashMap; import java.util.Map; +import com.google.android.gms.analytics.GoogleAnalytics; +import com.google.android.gms.analytics.Tracker; @AcraNotification(resText = R.string.notification_text, resTitle = R.string.notification_title, resChannelName = R.string.notification_channel) @AcraLimiter(failedReportLimit = 2) public class FindMyTutor extends Application { + private static GoogleAnalytics sAnalytics; + private static Tracker sTracker; + + @Override + public void onCreate() { + super.onCreate(); + + sAnalytics = GoogleAnalytics.getInstance(this); + } + @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); @@ -76,4 +88,17 @@ public class FindMyTutor extends Application { public void onLowMemory() { super.onLowMemory(); } + /** + * Gets the default {@link Tracker} for this {@link Application}. + * @return tracker + */ + synchronized public Tracker getDefaultTracker() { + // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG + if (sTracker == null) { + sTracker = sAnalytics.newTracker(R.xml.global_tracker); + } + + return sTracker; + } + } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java index ab0acf7..1ee31ea 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java @@ -32,6 +32,8 @@ import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.Toast; +import com.google.android.gms.analytics.Tracker; +import com.uam.wmi.findmytutor.FindMyTutor; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.service.BackgroundLocalizationService; import com.uam.wmi.findmytutor.utils.ActiveFragment; @@ -99,6 +101,10 @@ public abstract class BaseActivity super.onCreate(savedInstanceState); setContentView(getContentViewId()); + //Google Analytics + FindMyTutor application = (FindMyTutor) getApplication(); + Tracker mTracker = application.getDefaultTracker(); + drawerNavigationView = findViewById(R.id.nav_view); sideDrawer = findViewById(R.id.activity_container); feedbackUtils = new FeedbackUtils(BaseActivity.this); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/BlackList.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/BlackList.java index 91cc203..33b8d6d 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/BlackList.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/BlackList.java @@ -33,9 +33,11 @@ import android.widget.Toast; import android.widget.ToggleButton; import com.github.ybq.android.spinkit.SpinKitView; +import com.google.android.gms.analytics.Tracker; import com.jakewharton.retrofit2.adapter.rxjava2.HttpException; import com.mapbox.geojson.Point; import com.mapbox.mapboxsdk.geometry.LatLng; +import com.uam.wmi.findmytutor.FindMyTutor; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.adapters.BlackListAdapter; import com.uam.wmi.findmytutor.model.IsUsingListBool; @@ -109,6 +111,9 @@ public class BlackList extends AppCompatActivity { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); setContentView(R.layout.activity_black_list); ButterKnife.bind(this); + //Google Analytics + FindMyTutor application = (FindMyTutor) getApplication(); + Tracker mTracker = application.getDefaultTracker(); tutorId = PrefUtils.getUserId(getApplicationContext()); userService = ApiClient.getClient(getApplicationContext()) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java index d865b1c..840252d 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java @@ -19,7 +19,9 @@ import android.widget.EditText; import com.auth0.android.jwt.Claim; import com.auth0.android.jwt.JWT; +import com.google.android.gms.analytics.Tracker; import com.jakewharton.retrofit2.adapter.rxjava2.HttpException; +import com.uam.wmi.findmytutor.FindMyTutor; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.model.JwtToken; import com.uam.wmi.findmytutor.model.LdapUser; @@ -61,6 +63,9 @@ LoginActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); + //Google Analytics + FindMyTutor application = (FindMyTutor) getApplication(); + Tracker mTracker = application.getDefaultTracker(); mLoginNameView = findViewById(R.id.email); ldapService = ApiClient.getClient(getApplicationContext()) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java index f77be00..824715d 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java @@ -15,6 +15,8 @@ import android.util.DisplayMetrics; import android.util.Log; import android.view.MenuItem; +import com.google.android.gms.analytics.Tracker; +import com.uam.wmi.findmytutor.FindMyTutor; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.utils.LocaleHelper; import com.uam.wmi.findmytutor.utils.LocaleUtils; @@ -33,7 +35,9 @@ public class SettingsActivity extends AppCompatPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + //Google Analytics + FindMyTutor application = (FindMyTutor) getApplication(); + Tracker mTracker = application.getDefaultTracker(); getFragmentManager().beginTransaction().replace(android.R.id.content, new MainPreferenceFragment()).commit(); } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java index 5ce1844..b034226 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java @@ -160,6 +160,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + //Google Analytics + addPreferencesFromResource(R.xml.pref_sharing); locationSharing = (SwitchPreference) findPreference("key_sharing_enabled"); statusSwitch = (SwitchPreference) findPreference("key_status_enabled"); diff --git a/app/src/main/res/xml/global_tracker.xml b/app/src/main/res/xml/global_tracker.xml new file mode 100644 index 0000000..71581e7 --- /dev/null +++ b/app/src/main/res/xml/global_tracker.xml @@ -0,0 +1,4 @@ + + + UA-132330555-1 + diff --git a/build.gradle b/build.gradle index 8d3ef8e..42d5c2d 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' - + classpath 'com.google.gms:google-services:4.2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files