root / src / com / rackspacecloud / android / GaListActivity.java @ 038ac9a4
History | View | Annotate | Download (2.9 kB)
1 |
package com.rackspacecloud.android; |
---|---|
2 |
|
3 |
import com.google.android.apps.analytics.GoogleAnalyticsTracker; |
4 |
|
5 |
import android.app.ListActivity; |
6 |
import android.os.Build; |
7 |
import android.os.Bundle; |
8 |
import android.util.Log; |
9 |
|
10 |
public class GaListActivity extends ListActivity { |
11 |
|
12 |
protected static final String CATEGORY_FILE = "file"; |
13 |
protected static final String CATEGORY_SERVER = "server"; |
14 |
protected static final String CATEGORY_CONTAINER = "containers"; |
15 |
protected static final String CATEGORY_LOAD_BALANCER = "load_balancer"; |
16 |
|
17 |
protected static final String PAGE_ROOT = "/Root"; |
18 |
protected static final String PAGE_SERVERS = "/Servers"; |
19 |
protected static final String PAGE_SERVER = "/Server"; |
20 |
protected static final String PAGE_CONTAINERS = "/Containers"; |
21 |
protected static final String PAGE_FOLDER = "/Folder"; |
22 |
protected static final String PAGE_STORAGE_OBJECT = "/StorageObject"; |
23 |
protected static final String PAGE_ADD_SERVER = "/AddServer"; |
24 |
protected static final String PAGE_CONTACT = "/ContactInformation"; |
25 |
protected static final String PAGE_ADD_CONTAINER = "/AddContainer"; |
26 |
protected static final String PAGE_PASSCODE = "/Passcode"; |
27 |
protected static final String PAGE_PROVIDERS = "/Providers"; |
28 |
protected static final String PAGE_CONTAINER_DETAILS = "/ContainerDetail"; |
29 |
protected static final String PAGE_ADD_OBJECT = "/AddObject"; |
30 |
|
31 |
protected static final String EVENT_CREATE = "created"; |
32 |
protected static final String EVENT_DELETE = "deleted"; |
33 |
protected static final String EVENT_PING = "pinged"; |
34 |
protected static final String EVENT_REBOOT = "reboot"; |
35 |
protected static final String EVENT_BACKUP = "backup_schedule_changed"; |
36 |
protected static final String EVENT_RESIZE = "resized"; |
37 |
protected static final String EVENT_PASSWORD = "password_changed"; |
38 |
protected static final String EVENT_UPDATED = "updated"; |
39 |
protected static final String EVENT_REBUILD = "rebuilt"; |
40 |
protected static final String EVENT_RENAME = "renamed"; |
41 |
|
42 |
private GoogleAnalyticsTracker tracker;
|
43 |
|
44 |
@Override
|
45 |
public void onCreate(Bundle savedInstanceState) { |
46 |
super.onCreate(savedInstanceState);
|
47 |
startTracker(); |
48 |
} |
49 |
|
50 |
public void startTracker() { |
51 |
if (!"google_sdk".equals(Build.PRODUCT) && !"sdk".equals(Build.PRODUCT)) { |
52 |
Log.d("tracker", "Creating Tracker"); |
53 |
tracker = GoogleAnalyticsTracker.getInstance(); |
54 |
tracker.start(Config.WEB_PROPERTY_ID, 20, this); |
55 |
} else {
|
56 |
Log.d("tracker", "Not Creating Tracker"); |
57 |
} |
58 |
} |
59 |
|
60 |
public void trackPageView(String page) { |
61 |
if (tracker != null) { |
62 |
Log.d("tracker", "Tracking pageview: " + page); |
63 |
tracker.trackPageView(page); |
64 |
} |
65 |
} |
66 |
|
67 |
@Override
|
68 |
protected void onDestroy() { |
69 |
super.onDestroy();
|
70 |
if (tracker != null) { |
71 |
tracker.stop(); |
72 |
} |
73 |
} |
74 |
|
75 |
public void trackEvent(String category, String action, String label, |
76 |
int value) {
|
77 |
if (tracker != null) { |
78 |
Log.d("tracker", "Tracking event: " + category + " " + action); |
79 |
tracker.trackEvent(category, action, label, value); |
80 |
} |
81 |
} |
82 |
|
83 |
} |