diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f2d8310 --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# Built application files +*.apk +*.ap_ + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# Intellij +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/dictionaries +.idea/libraries + +# Keystore files +# Uncomment the following line if you do not want to check your keystore files in. +#*.jks + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0df5560 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.8 + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7c4ca73 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ea7d363 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +tracking id is removed. Add ga_trackingId in app/src/main/res/xml/analytics_tracker_config before testing. diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..9ef72a3 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,31 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + buildToolsVersion "26.0.1" + defaultConfig { + applicationId "com.goodrx" + minSdkVersion 14 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:26.+' + compile 'com.android.support.constraint:constraint-layout:1.0.2' + compile 'com.google.android.gms:play-services-analytics:11.0.4' + testCompile 'junit:junit:4.12' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..37dfa8f --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/kaiguo/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/goodrx/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/goodrx/ExampleInstrumentedTest.java new file mode 100644 index 0000000..2869daf --- /dev/null +++ b/app/src/androidTest/java/com/goodrx/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.goodrx; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.goodrx", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9421a5e --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/goodrx/AnalyticsApplication.java b/app/src/main/java/com/goodrx/AnalyticsApplication.java new file mode 100644 index 0000000..f5adf65 --- /dev/null +++ b/app/src/main/java/com/goodrx/AnalyticsApplication.java @@ -0,0 +1,39 @@ +package com.goodrx; + +import android.app.Application; + +import com.google.android.gms.analytics.GoogleAnalytics; +import com.google.android.gms.analytics.Tracker; + +/** + * Created by kaiguo on 10/10/17. + */ + +public class AnalyticsApplication extends Application{ + private static GoogleAnalytics sAnalytics; + private static Tracker sTracker; + + @Override + public void onCreate() { + super.onCreate(); + sAnalytics = GoogleAnalytics.getInstance(this); + sAnalytics.setLocalDispatchPeriod(1); + } + + /** + * 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.analytics_tracker_config); + } + + return sTracker; + } + + synchronized public void dispatchEvents() { + sAnalytics.dispatchLocalHits(); + } +} diff --git a/app/src/main/java/com/goodrx/MainActivity.java b/app/src/main/java/com/goodrx/MainActivity.java new file mode 100644 index 0000000..8daa735 --- /dev/null +++ b/app/src/main/java/com/goodrx/MainActivity.java @@ -0,0 +1,35 @@ +package com.goodrx; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.Button; +import android.widget.Toast; + +import com.google.android.gms.analytics.HitBuilders; +import com.google.android.gms.analytics.Tracker; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + AnalyticsApplication application = (AnalyticsApplication) getApplication(); + final Tracker tracker = application.getDefaultTracker(); + + Button btn = (Button) findViewById(R.id.button); + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + tracker.send(new HitBuilders.EventBuilder() + .setCategory("test category") + .setAction("test action") + .setLabel("test label") + .build()); + Toast.makeText(MainActivity.this, "event sent", Toast.LENGTH_LONG).show(); + } + }); + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..ba745bb --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,20 @@ + + + +