Commit 37dd591d by Kunj Gupta

UOFLMA-64: Integrated Google Analytics.

parent 8bddb5d7
......@@ -47,4 +47,5 @@ dependencies {
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.google.android.gms:play-services-analytics:9.2.0'
}
{
"project_info": {
"project_number": "593992849158",
"project_id": "uofl-servicenow-android"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:593992849158:android:84f481659dc7e412",
"android_client_info": {
"package_name": "com.vsoft.uoflservicenow"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyBEzc7fo12bQLx8CkogSGIb2j-vivdbJNg"
}
],
"services": {
"analytics_service": {
"status": 2,
"analytics_property": {
"tracking_id": "UA-83545030-1"
}
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 1
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
......@@ -77,8 +77,7 @@
android:windowSoftInputMode="stateHidden|adjustResize"/>
<activity
android:name=".ui.MyRequestActivity"
android:screenOrientation="portrait"
/>
android:screenOrientation="portrait" />
<activity
android:name=".ui.MyIncidentScreen"
android:screenOrientation="portrait"/>
......
......@@ -5,10 +5,14 @@ import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
public class CatalogueApplication extends Application {
private ConnectivityManager mConMgr;
private static Context mContext;
private Tracker mTracker;
@Override
public void onCreate() {
......@@ -21,6 +25,15 @@ public class CatalogueApplication extends Application {
return mContext;
}
synchronized public Tracker getDefaultTracker() {
if (mTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
// To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
mTracker = analytics.newTracker(R.xml.global_tracker);
}
return mTracker;
}
public boolean isNetConnected() {
if(mConMgr==null)
mConMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
......
......@@ -15,6 +15,7 @@ import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.adapters.CatalogueCategoryItemAdapter;
......@@ -24,6 +25,7 @@ import com.vsoft.uofl_catalogue.db.models.CatalogueItem;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.CatalogueLog;
import com.vsoft.uofl_catalogue.utils.Constants;
import com.vsoft.uofl_catalogue.utils.Util;
import java.util.List;
......@@ -68,6 +70,10 @@ public class CatalogueItemScreen extends AppCompatActivity {
actionBar.setDisplayShowTitleEnabled(true);
}
Tracker tracker = application.getDefaultTracker();
// Send initial screen view hit.
Util.sendScreenName(tracker, actionBar.getTitle().toString());
if(application.isNetConnected()) {
new FetchCatalogueItem().execute();
} else {
......
......@@ -14,6 +14,7 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.adapters.CatalogueCategoryAdapter;
......@@ -23,6 +24,7 @@ import com.vsoft.uofl_catalogue.db.models.Catalogue;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.CatalogueLog;
import com.vsoft.uofl_catalogue.utils.Constants;
import com.vsoft.uofl_catalogue.utils.Util;
import java.util.List;
......@@ -59,6 +61,10 @@ public class CatalogueScreen extends AppCompatActivity {
actionBar.setDisplayShowTitleEnabled(true);
}
Tracker tracker = application.getDefaultTracker();
// Send initial screen view hit.
Util.sendScreenName(tracker, actionBar.getTitle().toString());
if(application.isNetConnected()) {
new FetchCatalogue().execute();
} else {
......
......@@ -24,6 +24,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.TimePicker;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.api.listeners.get.GetCatalogueVariableApiListener;
......@@ -102,6 +103,10 @@ public class CatalogueVariableScreen extends AppCompatActivity {
actionBar.setDisplayShowTitleEnabled(true);
}
Tracker tracker = mApplication.getDefaultTracker();
// Send initial screen view hit.
Util.sendScreenName(tracker, actionBar.getTitle().toString());
if(mApplication.isNetConnected()) {
new FetchCatalogueVariable().execute();
} else {
......
......@@ -2,11 +2,15 @@ package com.vsoft.uofl_catalogue.ui;
import android.app.Activity;
import android.content.Intent;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.widget.GridView;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.adapters.HomeScreenAdapter;
import com.vsoft.uofl_catalogue.utils.Util;
import butterknife.BindView;
import butterknife.ButterKnife;
......@@ -25,7 +29,17 @@ public class HomeScreen extends Activity {
setContentView(R.layout.home_screen);
ButterKnife.bind(this);
mGridView.setAdapter(new HomeScreenAdapter(this, getResources().getStringArray(R.array.home_screen_array),getResources().obtainTypedArray(R.array.home_screen_icon_array)));
CatalogueApplication application = (CatalogueApplication) getApplication();
Tracker tracker = application.getDefaultTracker();
// Send initial screen view hit.
Util.sendScreenName(tracker, getString(R.string.home_screen_string));
String[] gridValuesArray = getResources().getStringArray(R.array.home_screen_array);
TypedArray gridViewIcons = getResources().obtainTypedArray(R.array.home_screen_icon_array);
HomeScreenAdapter adapter = new HomeScreenAdapter(this, gridValuesArray, gridViewIcons);
mGridView.setAdapter(adapter);
}
@OnItemClick(R.id.home_screen_grid_view)
......
......@@ -8,6 +8,8 @@ import android.os.Bundle;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.api.listeners.get.GetUserApiListener;
import com.vsoft.uofl_catalogue.api.managers.LoginApiManger;
......@@ -15,6 +17,7 @@ import com.vsoft.uofl_catalogue.api.managers.UserApiManager;
import com.vsoft.uofl_catalogue.db.models.UserApiValues;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.PrefManager;
import com.vsoft.uofl_catalogue.utils.Util;
import java.util.List;
......@@ -40,6 +43,12 @@ public class LoginScreen extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_screen);
ButterKnife.bind(this);
CatalogueApplication application = (CatalogueApplication) getApplication();
Tracker tracker = application.getDefaultTracker();
// Send initial screen view hit.
Util.sendScreenName(tracker, getString(R.string.login_screen_string));
}
@OnClick(R.id.login_screen_login_text_view)
......
......@@ -11,6 +11,7 @@ import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.ListView;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.adapters.MyIncidentsAdapter;
......@@ -19,6 +20,7 @@ import com.vsoft.uofl_catalogue.api.managers.IncidentApiManager;
import com.vsoft.uofl_catalogue.db.models.Incident;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.CatalogueLog;
import com.vsoft.uofl_catalogue.utils.Util;
import java.util.List;
......@@ -56,6 +58,10 @@ public class MyIncidentScreen extends AppCompatActivity {
actionBar.setDisplayShowTitleEnabled(true);
}
Tracker tracker = application.getDefaultTracker();
// Send initial screen view hit.
Util.sendScreenName(tracker, actionBar.getTitle().toString());
if(application.isNetConnected()) {
new FetchIncident().execute();
} else {
......
......@@ -10,6 +10,8 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.ListView;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.adapters.MyRequestAdapter;
......@@ -17,6 +19,8 @@ import com.vsoft.uofl_catalogue.api.listeners.get.GetMyRequestApiListener;
import com.vsoft.uofl_catalogue.api.managers.MyRequestApiManager;
import com.vsoft.uofl_catalogue.db.models.MyRequest;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.Util;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
......@@ -54,6 +58,10 @@ public class MyRequestActivity extends AppCompatActivity {
actionBar.setDisplayShowTitleEnabled(true);
}
Tracker tracker = application.getDefaultTracker();
// Send initial screen view hit.
Util.sendScreenName(tracker, actionBar.getTitle().toString());
if(application.isNetConnected()) {
new FetchMyRequestData().execute();
} else {
......
......@@ -18,6 +18,7 @@ import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.api.managers.IncidentApiManager;
......@@ -69,6 +70,10 @@ public class ReportIncidentScreen extends AppCompatActivity {
actionBar.setDisplayShowTitleEnabled(true);
}
Tracker tracker = mApplication.getDefaultTracker();
// Send initial screen view hit.
Util.sendScreenName(tracker, actionBar.getTitle().toString());
// Creating adapter for spinner
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.incident_impact_array));
......
......@@ -18,6 +18,8 @@ import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.db.models.CatalogueVariable;
import com.vsoft.uofl_catalogue.db.models.Reference;
......@@ -283,6 +285,12 @@ public class Util {
return dateFormat.format(date.getTime());
}
/*Record a screen view hit for the visible*/
public static void sendScreenName(Tracker tracker, String name) {
tracker.setScreenName(name);
tracker.send(new HitBuilders.ScreenViewBuilder().build());
}
public static void hideSoftKeyboard(Context context, View view) {
InputMethodManager imm =(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
......
......@@ -8,6 +8,8 @@
<string name="none_string">-None-</string>
<string name="search_for_reference_string">Reference</string>
<string name="internet_validation_string">Please connect to internet and try again.</string>
<string name="home_screen_string">Home Screen</string>
<string name="login_screen_string">Login Screen</string>
<string name="loading_string">Loading&#8230;</string>
<string name="select_date_string">Select Date</string>
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Replace placeholder ID with your tracking ID -->
<string name="ga_trackingId">UA-83545030-1</string>
<!-- Enable automatic activity tracking -->
<bool name="ga_autoActivityTracking">true</bool>
<!-- Enable automatic exception tracking -->
<bool name="ga_reportUncaughtExceptions">true</bool>
</resources>
\ No newline at end of file
......@@ -7,6 +7,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment