Skip to content

Commit

Permalink
Adding GA
Browse files Browse the repository at this point in the history
gotosleep committed May 10, 2014
1 parent f146578 commit f2db85b
Showing 10 changed files with 85 additions and 0 deletions.
3 changes: 3 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
@@ -20,6 +21,8 @@
android:icon="@drawable/ic_itch"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".activities.ItchActivity"
android:label="@string/app_name" >
17 changes: 17 additions & 0 deletions proguard-project.txt
Original file line number Diff line number Diff line change
@@ -18,3 +18,20 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
1 change: 1 addition & 0 deletions project.properties
Original file line number Diff line number Diff line change
@@ -12,3 +12,4 @@

# Project target.
target=android-19
android.library.reference.1=../google-play-services_lib
7 changes: 7 additions & 0 deletions res/xml/ga.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes">
<integer name="ga_sessionTimeout">300</integer>
<bool name="ga_autoActivityTracking">true</bool>
<bool name="ga_reportUncaughtExceptions">true</bool>
<string name="ga_trackingId">UA-50860805-1</string>
</resources>
17 changes: 17 additions & 0 deletions src/io/itch/ItchApp.java
Original file line number Diff line number Diff line change
@@ -3,12 +3,29 @@
import io.itch.api.ItchApiClient;
import android.app.Application;

import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;

public class ItchApp extends Application {

private static final Object LOCK = new Object();
private Tracker tracker;

@Override
public void onCreate() {
super.onCreate();
ItchApiClient.loadKeyStore(this);
}

public Tracker getTracker() {
if (this.tracker == null) {
synchronized (LOCK) {
if (this.tracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
this.tracker = analytics.newTracker(R.xml.ga);
}
}
}
return this.tracker;
}
}
13 changes: 13 additions & 0 deletions src/io/itch/activities/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package io.itch.activities;

import io.itch.ItchApp;
import io.itch.R;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;

abstract class BaseActivity extends Activity {

public View getEmptyView() {
@@ -21,4 +25,13 @@ public int getEmptyViewMessageId() {
return R.string.activity_empty_default;
}

@Override
protected void onStart() {
super.onStart();
Tracker t = ((ItchApp) this.getApplication()).getTracker();
t.setScreenName(getScreenPath());
t.send(new HitBuilders.AppViewBuilder().build());
}

protected abstract String getScreenPath();
}
5 changes: 5 additions & 0 deletions src/io/itch/activities/GameActivity.java
Original file line number Diff line number Diff line change
@@ -65,4 +65,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}

@Override
protected String getScreenPath() {
return "Game";
}

}
5 changes: 5 additions & 0 deletions src/io/itch/activities/ItchActivity.java
Original file line number Diff line number Diff line change
@@ -47,4 +47,9 @@ private void openMyGames() {
finish();
}

@Override
protected String getScreenPath() {
return "Start";
}

}
12 changes: 12 additions & 0 deletions src/io/itch/activities/LoginActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.itch.activities;

import io.itch.ItchApp;
import io.itch.R;
import io.itch.api.ItchApiClient;
import io.itch.api.responses.KeyResponse;
@@ -21,6 +22,9 @@
import android.widget.EditText;
import android.widget.TextView;

import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;

/**
* Activity which displays a login screen to the user, offering registration as
* well.
@@ -97,6 +101,14 @@ public void onClick(View view) {
});
}

@Override
protected void onStart() {
super.onStart();
Tracker t = ((ItchApp) this.getApplication()).getTracker();
t.setScreenName("Login");
t.send(new HitBuilders.AppViewBuilder().build());
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
5 changes: 5 additions & 0 deletions src/io/itch/activities/MyGamesActivity.java
Original file line number Diff line number Diff line change
@@ -125,4 +125,9 @@ public void failure(RetrofitError e) {
});
}

@Override
protected String getScreenPath() {
return "My Games";
}

}

0 comments on commit f2db85b

Please sign in to comment.