Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #26 from alexstyl/develop
Browse files Browse the repository at this point in the history
Release 3.8
  • Loading branch information
alexstyl authored Sep 6, 2016
2 parents f8ab1f0 + 9843581 commit 1bf6030
Show file tree
Hide file tree
Showing 37 changed files with 331 additions and 229 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ captures/
# Mac
.DS_Store

# secrets
secret.gradle
/mobile/google-services.json
15 changes: 13 additions & 2 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,27 @@ android {
compileSdkVersion 23
buildToolsVersion '23.0.2'


applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(
output.outputFile.parent,
output.outputFile.name.replace(".apk", "-${variant.versionName}.apk"))
}
}


defaultConfig {
applicationId 'com.alexstyl.specialdates'
minSdkVersion 16
targetSdkVersion 22
versionCode 56
versionName '3.7'
versionCode 57
versionName '3.8'

manifestPlaceholders = [crashlyticsApiKey: crashlyticsKey]
buildConfigField 'String', 'API_KEY_VENDING', '\"' + androidVendingKey + "\""
}

buildTypes {
release {
minifyEnabled true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public void onStartAction(Context context) throws ActivityNotFoundException {
startActivity(intent);

}

@Override
public String getName() {
return "date debug";
}
};
Utils.openIntentSafely(getActivity(), i);
}
Expand Down
5 changes: 5 additions & 0 deletions mobile/src/main/java/com/alexstyl/specialdates/Navigator.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public void onStartAction(Context context) throws ActivityNotFoundException {
Intent intent = Utils.getSupportEmailIntent(context);
context.startActivity(intent);
}

@Override
public String getName() {
return "email support";
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import com.alexstyl.specialdates.R;
import com.alexstyl.specialdates.addevent.ui.ContactHeroView;
import com.alexstyl.specialdates.addevent.ui.ContactsAutoCompleteView;
import com.alexstyl.specialdates.analytics.Action;
import com.alexstyl.specialdates.analytics.Analytics;
import com.alexstyl.specialdates.analytics.AnalyticsEvent;
import com.alexstyl.specialdates.analytics.ActionWithParameters;
import com.alexstyl.specialdates.analytics.Firebase;
import com.alexstyl.specialdates.analytics.Screen;
import com.alexstyl.specialdates.contact.Birthday;
import com.alexstyl.specialdates.contact.Contact;
Expand All @@ -33,7 +35,7 @@ public class AddBirthdayActivity extends ThemedActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

analytics = Analytics.get(this);
analytics = Firebase.get(this);
analytics.trackScreen(Screen.ADD_BIRTHDAY);
MementoTheme theme = Themer.get().getCurrentTheme();
setContentView(R.layout.activity_add_birthday, theme);
Expand Down Expand Up @@ -98,21 +100,21 @@ protected void onDestroy() {
}

private void trackEventCreation() {
AnalyticsEvent analyticsEvent;
ActionWithParameters actionWithParameters;
if (eventCreated) {
analyticsEvent = birthdayCreationSuccess();
actionWithParameters = birthdayCreationSuccess();
} else {
analyticsEvent = birthdayCreationFailed();
actionWithParameters = birthdayCreationFailed();
}
analytics.track(analyticsEvent);
analytics.trackAction(actionWithParameters);
}

private AnalyticsEvent birthdayCreationSuccess() {
return new AnalyticsEvent(AnalyticsEvent.Events.ADD_BIRTHDAY).withData("success", "true");
private ActionWithParameters birthdayCreationSuccess() {
return new ActionWithParameters(Action.ADD_BIRTHDAY, "success", "true");
}

private AnalyticsEvent birthdayCreationFailed() {
return new AnalyticsEvent(AnalyticsEvent.Events.ADD_BIRTHDAY).withData("success", "false");
private ActionWithParameters birthdayCreationFailed() {
return new ActionWithParameters(Action.ADD_BIRTHDAY, "success", "false");
}

private final BirthdayLabelView.OnEditListener onBirthdayLabelClicked = new BirthdayLabelView.OnEditListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ public Birthday getDisplayingBirthday() {
int month = getMonth();
if (isDisplayingYear()) {
int year = getYear();
return new Birthday(dayOfMonth, month, year);
return Birthday.on(dayOfMonth, month, year);
} else {
return new Birthday(dayOfMonth, month);
return Birthday.on(dayOfMonth, month);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.alexstyl.specialdates.analytics;

public enum Action {
ADD_BIRTHDAY("add birthday"),
DAILY_REMINDER("enable daily reminder"),
DONATION("donate"),
INTERACT_CONTACT("interact contact"),
SELECT_THEME("select theme"),
GO_TO_TODAY("go to today");

private final String name;

Action(String name) {
this.name = name;
}

public String getName() {
return name;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.alexstyl.specialdates.analytics;

public final class ActionWithParameters {

private final Action actionName;
private final String label;
private final String value;

public ActionWithParameters(Action actionName, String label, String value) {
this.actionName = actionName;
this.label = label;
this.value = value;
}

public ActionWithParameters(Action action, String label, boolean value) {
this.actionName = action;
this.label = label;
this.value = value ? "true" : "false";
}

public String getName() {
return actionName.getName();
}

public String getLabel() {
return label;
}

public String getValue() {
return value;
}

}
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
package com.alexstyl.specialdates.analytics;

import android.content.Context;
public interface Analytics {
void trackAction(Action goToToday);

import com.google.firebase.analytics.FirebaseAnalytics;
void trackAction(ActionWithParameters event);

public class Analytics {

private final FirebaseAnalytics firebaseAnalytics;

private static Analytics INSTANCE;

public static Analytics get(Context context) {
if (INSTANCE == null) {
INSTANCE = new Analytics(FirebaseAnalytics.getInstance(context));
}
return INSTANCE;
}

public Analytics(FirebaseAnalytics firebaseAnalytics) {
this.firebaseAnalytics = firebaseAnalytics;
}

public void track(AnalyticsEvent event) {
firebaseAnalytics.logEvent(event.getName(), event.data());
}

public void trackScreen(Screen screen) {
firebaseAnalytics.logEvent("screen_view", screen.getData());
}
void trackScreen(Screen screen);
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.alexstyl.specialdates.analytics;

import android.content.Context;
import android.os.Bundle;

import com.google.firebase.analytics.FirebaseAnalytics;
import com.novoda.notils.logger.simple.Log;

import java.util.Locale;

public class Firebase implements Analytics {

private static final Bundle NO_DATA = null;

private final FirebaseAnalytics firebaseAnalytics;

private static Firebase INSTANCE;

public static Firebase get(Context context) {
if (INSTANCE == null) {
INSTANCE = new Firebase(FirebaseAnalytics.getInstance(context));
}
return INSTANCE;
}

private Firebase(FirebaseAnalytics firebaseAnalytics) {
this.firebaseAnalytics = firebaseAnalytics;
}

@Override
public void trackAction(Action goToToday) {
String actionName = goToToday.getName();
firebaseAnalytics.logEvent(actionName, NO_DATA);
Log.d("Tracking event:" + actionName);
}

@Override
public void trackAction(ActionWithParameters action) {
String formattedAction = format(action);
firebaseAnalytics.logEvent(formattedAction, NO_DATA);
Log.d("Tracking event:" + formattedAction);
}

@Override
public void trackScreen(Screen screen) {
firebaseAnalytics.logEvent("screen_view:" + screen.screenName(), NO_DATA);
Log.d("Tracking screen_view:" + screen);
}

private String format(ActionWithParameters action) {
return String.format(Locale.US, "%s:%s:%s", action.getName(), action.getLabel(), action.getValue());
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
package com.alexstyl.specialdates.analytics;

import android.os.Bundle;

public enum Screen {
HOME("home"),
ADD_BIRTHDAY("add birthday"),
SEARCH("search"),
SETTINGS("settings"),
DATE_DETAILS("date details");
DATE_DETAILS("date details"),
DONATE("donate"),
ABOUT("about");

private final Bundle data;
private final String screenName;

Screen(String screenName) {
data = new Bundle(1);
data.putString("screen", screenName);
this.screenName = screenName;
}

public String screenName() {
return screenName;
}

public Bundle getData() {
return data;
@Override
public String toString() {
return screenName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.alexstyl.specialdates.Optional;
import com.alexstyl.specialdates.date.AnnualEvent;
import com.alexstyl.specialdates.date.Date;
import com.alexstyl.specialdates.date.DateDisplayStringCreator;
import com.alexstyl.specialdates.date.DayDate;

Expand All @@ -11,16 +12,27 @@ public class Birthday implements ShortDate {
private final Optional<Integer> yearOfBirth;

public static Birthday on(DayDate date) {
return new Birthday(date.getDayOfMonth(), date.getMonth(), date.getYear());
if (date.getYear() == Date.NO_YEAR) {
return new Birthday(date.getDayOfMonth(), date.getMonth(), Optional.<Integer>absent());
} else {
return new Birthday(date.getDayOfMonth(), date.getMonth(), new Optional<>(date.getYear()));
}
}

public static Birthday on(int dayOfMonth, int month) {
return new Birthday(dayOfMonth, month, Optional.<Integer>absent());
}

public Birthday(int day, int month) {
this(day, month, DayDate.NO_YEAR);
public static Birthday on(int dayOfMonth, int month, int year) {
if (year <= Date.NO_YEAR) {
throw new IllegalArgumentException("A birthday cannot have negative year");
}
return new Birthday(dayOfMonth, month, new Optional<>(year));
}

public Birthday(int dayOfMonth, int month, int year) {
private Birthday(int dayOfMonth, int month, Optional<Integer> year) {
this.date = new AnnualEvent(dayOfMonth, month);
this.yearOfBirth = new Optional<>(year);
this.yearOfBirth = year;
}

public int getDayOfMonth() {
Expand Down
Loading

0 comments on commit 1bf6030

Please sign in to comment.