Unverified Commit b7b69ad3 authored by Tamás Szabó's avatar Tamás Szabó Committed by GitHub
Browse files

Merge pull request #14 from szakitom/development

labor 7
parents cc7d05fb 74a05b12
......@@ -41,6 +41,29 @@ android {
abortOnError false
}
testOptions.unitTests.includeAndroidResources true
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
ext {
......@@ -95,4 +118,10 @@ dependencies {
testImplementation 'com.google.dagger:dagger:2.11'
testAnnotationProcessor 'com.google.dagger:dagger-compiler:2.11'
testCompileOnly 'javax.annotation:jsr250-api:1.0'
//Analytics
implementation('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
transitive = true;
}
implementation 'com.google.android.gms:play-services-analytics:15.0.2'
}
#Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public.
#Thu May 10 08:27:52 CEST 2018
apiSecret=09239bd53054ab397883ae3e88cf2d99d3dec138880fa23d2a322457b95b63c3
......@@ -3,6 +3,7 @@
package="me.szaki.xkcd.xkcdbrowser">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:name=".XKCDBrowserApplication"
......@@ -35,6 +36,9 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="me.szaki.xkcd.xkcdbrowser.ui.favorites.FavoritesActivity" />
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="f85cd0b403e1dfb12558c873554e71e36c8eda3d" />
</application>
</manifest>
\ No newline at end of file
......@@ -2,15 +2,38 @@ package me.szaki.xkcd.xkcdbrowser;
import android.app.Application;
import com.crashlytics.android.Crashlytics;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
import io.fabric.sdk.android.Fabric;
import me.szaki.xkcd.xkcdbrowser.database.DBModule;
import me.szaki.xkcd.xkcdbrowser.ui.UIModule;
public class XKCDBrowserApplication extends Application {
public static XKCDBrowserApplicationComponent injector;
private static GoogleAnalytics sAnalytics;
private static Tracker sTracker;
@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
sAnalytics = GoogleAnalytics.getInstance(this);
sAnalytics.setLocalDispatchPeriod(15);
injector = DaggerXKCDBrowserApplicationComponent.builder().uIModule(new UIModule(this)).dBModule(new DBModule(this)).build();
}
/**
* 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;
}
}
......@@ -7,8 +7,12 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.widget.ImageView;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
......@@ -26,6 +30,7 @@ public class DetailActivity extends AppCompatActivity implements DetailScreen {
private ImageView detailImageView;
private Long num;
private Tracker mTracker;
public DetailActivity() {
XKCDBrowserApplication.injector.inject(this);
......@@ -34,6 +39,10 @@ public class DetailActivity extends AppCompatActivity implements DetailScreen {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
XKCDBrowserApplication application = (XKCDBrowserApplication) getApplication();
mTracker = application.getDefaultTracker();
setContentView(R.layout.activity_detail);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
......@@ -86,4 +95,13 @@ public class DetailActivity extends AppCompatActivity implements DetailScreen {
};
mainHandler.post(myRunnable);
}
@Override
protected void onResume() {
super.onResume();
String name = "Detail";
Log.i("HP", "Setting screen name: " + name);
mTracker.setScreenName("Image~" + name);
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
}
......@@ -13,10 +13,14 @@ import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import java.util.List;
import javax.inject.Inject;
......@@ -34,6 +38,7 @@ public class FavoritesActivity extends AppCompatActivity
@Inject
FavoritesPresenter favoritesPresenter;
private FavoriteListAdapter mAdapter;
private Tracker mTracker;
public FavoritesActivity() {
XKCDBrowserApplication.injector.inject(this);
......@@ -42,6 +47,10 @@ public class FavoritesActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
XKCDBrowserApplication application = (XKCDBrowserApplication) getApplication();
mTracker = application.getDefaultTracker();
setContentView(R.layout.activity_favorites);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
......@@ -77,6 +86,10 @@ public class FavoritesActivity extends AppCompatActivity
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Action")
.setAction("Back")
.build());
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
......@@ -120,6 +133,10 @@ public class FavoritesActivity extends AppCompatActivity
@Override
public void onClick(int position, View v) {
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Action")
.setAction("Select")
.build());
Intent i = new Intent(getApplicationContext(), DetailActivity.class);
i.putExtra("num", mAdapter.getComicStripByNum(position).getNum());
startActivity(i);
......@@ -127,6 +144,10 @@ public class FavoritesActivity extends AppCompatActivity
@Override
public void onDeleteClick(int position, View v) {
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Action")
.setAction("Delete")
.build());
favoritesPresenter.deleteData(mAdapter.getComicStripByNum(position));
}
......@@ -151,5 +172,14 @@ public class FavoritesActivity extends AppCompatActivity
favoritesPresenter.getData();
}
@Override
protected void onResume() {
super.onResume();
String name = "Favorite";
Log.i("HP", "Setting screen name: " + name);
mTracker.setScreenName("Image~" + name);
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
}
......@@ -3,24 +3,23 @@ package me.szaki.xkcd.xkcdbrowser.ui.main;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageButton;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import java.io.IOException;
import java.net.MalformedURLException;
......@@ -32,7 +31,6 @@ import me.szaki.xkcd.xkcdbrowser.R;
import me.szaki.xkcd.xkcdbrowser.XKCDBrowserApplication;
import me.szaki.xkcd.xkcdbrowser.network.model.Comic;
import me.szaki.xkcd.xkcdbrowser.ui.favorites.FavoritesActivity;
import me.szaki.xkcd.xkcdbrowser.ui.favorites.FavoritesPresenter;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, MainScreen {
......@@ -43,12 +41,17 @@ public class MainActivity extends AppCompatActivity
private ImageView imageView;
private Comic currentComic;
private MenuItem favoriteButton;
private Tracker mTracker;
@Override
protected void onCreate(Bundle savedInstanceState) {
XKCDBrowserApplication.injector.inject(this);
super.onCreate(savedInstanceState);
XKCDBrowserApplication application = (XKCDBrowserApplication) getApplication();
mTracker = application.getDefaultTracker();
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
......@@ -67,6 +70,11 @@ public class MainActivity extends AppCompatActivity
findViewById(R.id.next_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Action")
.setAction("Next")
.build());
favoriteButton.setCheckable(false);
mainPresenter.getNext();
}
......@@ -75,6 +83,10 @@ public class MainActivity extends AppCompatActivity
findViewById(R.id.previous_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Action")
.setAction("Previous")
.build());
favoriteButton.setCheckable(false);
mainPresenter.getPrevious();
}
......@@ -83,6 +95,10 @@ public class MainActivity extends AppCompatActivity
findViewById(R.id.random_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Action")
.setAction("Random")
.build());
favoriteButton.setCheckable(false);
mainPresenter.getRandom();
}
......@@ -105,6 +121,10 @@ public class MainActivity extends AppCompatActivity
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Action")
.setAction("Save")
.build());
//noinspection SimplifiableIfStatement
if (id == R.id.favorite_button) {
......@@ -119,6 +139,10 @@ public class MainActivity extends AppCompatActivity
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Action")
.setAction("Back")
.build());
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
......@@ -228,4 +252,13 @@ public class MainActivity extends AppCompatActivity
}
@Override
protected void onResume() {
super.onResume();
String name = "Main";
Log.i("HP", "Setting screen name: " + name);
mTracker.setScreenName("Image~" + name);
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="ga_trackingId" translatable="false">UA-119008810-1</string>
</resources>
\ No newline at end of file
......@@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment