This repository has been archived by the owner on Jan 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from alexstyl/develop
Release 3.8
- Loading branch information
Showing
37 changed files
with
331 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,6 @@ captures/ | |
# Mac | ||
.DS_Store | ||
|
||
# secrets | ||
secret.gradle | ||
/mobile/google-services.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
mobile/src/main/java/com/alexstyl/specialdates/analytics/Action.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
mobile/src/main/java/com/alexstyl/specialdates/analytics/ActionWithParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
30 changes: 4 additions & 26 deletions
30
mobile/src/main/java/com/alexstyl/specialdates/analytics/Analytics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
53 changes: 0 additions & 53 deletions
53
mobile/src/main/java/com/alexstyl/specialdates/analytics/AnalyticsEvent.java
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
mobile/src/main/java/com/alexstyl/specialdates/analytics/Firebase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
20 changes: 12 additions & 8 deletions
20
mobile/src/main/java/com/alexstyl/specialdates/analytics/Screen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.