diff --git a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.java b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.java index e4fd7ca9c..2ecc51090 100644 --- a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.java +++ b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.java @@ -3,6 +3,7 @@ package io.github.wulkanowy; import android.app.Application; import com.crashlytics.android.Crashlytics; +import com.crashlytics.android.answers.Answers; import com.crashlytics.android.core.CrashlyticsCore; import com.jakewharton.threetenabp.AndroidThreeTen; @@ -61,9 +62,12 @@ public class WulkanowyApp extends Application { private void initializeFabric() { Fabric.with(new Fabric.Builder(this) - .kits(new Crashlytics.Builder() - .core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()) - .build()) + .kits( + new Crashlytics.Builder() + .core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()) + .build(), + new Answers() + ) .debuggable(BuildConfig.DEBUG) .build()); } diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/DbContract.java b/app/src/main/java/io/github/wulkanowy/data/db/dao/DbContract.java index 38115cc45..34541d3ea 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/DbContract.java +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/DbContract.java @@ -4,6 +4,7 @@ import java.util.List; import io.github.wulkanowy.data.db.dao.entities.Grade; import io.github.wulkanowy.data.db.dao.entities.Subject; +import io.github.wulkanowy.data.db.dao.entities.Symbol; import io.github.wulkanowy.data.db.dao.entities.Week; public interface DbContract { @@ -20,6 +21,8 @@ public interface DbContract { long getCurrentSymbolId(); + Symbol getCurrentSymbol(); + long getCurrentDiaryId(); long getSemesterId(int name); diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/DbRepository.java b/app/src/main/java/io/github/wulkanowy/data/db/dao/DbRepository.java index 6757c48e7..43eee87ed 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/DbRepository.java +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/DbRepository.java @@ -12,6 +12,7 @@ import io.github.wulkanowy.data.db.dao.entities.Semester; import io.github.wulkanowy.data.db.dao.entities.SemesterDao; import io.github.wulkanowy.data.db.dao.entities.StudentDao; import io.github.wulkanowy.data.db.dao.entities.Subject; +import io.github.wulkanowy.data.db.dao.entities.Symbol; import io.github.wulkanowy.data.db.dao.entities.SymbolDao; import io.github.wulkanowy.data.db.dao.entities.Week; import io.github.wulkanowy.data.db.dao.entities.WeekDao; @@ -57,10 +58,15 @@ public class DbRepository implements DbContract { } @Override - public long getCurrentSymbolId() { + public Symbol getCurrentSymbol() { return daoSession.getSymbolDao().queryBuilder().where( SymbolDao.Properties.UserId.eq(sharedPref.getCurrentUserId()) - ).unique().getId(); + ).unique(); + } + + @Override + public long getCurrentSymbolId() { + return getCurrentSymbol().getId(); } @Override diff --git a/app/src/main/java/io/github/wulkanowy/ui/login/LoginPresenter.java b/app/src/main/java/io/github/wulkanowy/ui/login/LoginPresenter.java index 3140ad785..e5b37a6ee 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/login/LoginPresenter.java +++ b/app/src/main/java/io/github/wulkanowy/ui/login/LoginPresenter.java @@ -11,6 +11,7 @@ import io.github.wulkanowy.api.login.BadCredentialsException; import io.github.wulkanowy.data.RepositoryContract; import io.github.wulkanowy.ui.base.BasePresenter; import io.github.wulkanowy.utils.AppConstant; +import io.github.wulkanowy.utils.FabricUtils; public class LoginPresenter extends BasePresenter implements LoginContract.Presenter { @@ -84,6 +85,7 @@ public class LoginPresenter extends BasePresenter @Override public void onEndAsync(boolean success, Exception exception) { if (success) { + FabricUtils.logRegister(true, getRepository().getDbRepo().getCurrentSymbol().getSymbol()); getView().openMainActivity(); return; } else if (exception instanceof BadCredentialsException) { @@ -93,6 +95,7 @@ public class LoginPresenter extends BasePresenter getView().setErrorSymbolRequired(); getView().showSoftInput(); } else { + FabricUtils.logRegister(false, symbol); getView().onError(getRepository().getResRepo().getErrorLoginMessage(exception)); } diff --git a/app/src/main/java/io/github/wulkanowy/ui/main/attendance/AttendanceTabPresenter.java b/app/src/main/java/io/github/wulkanowy/ui/main/attendance/AttendanceTabPresenter.java index 47927feb4..72cab5d33 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/main/attendance/AttendanceTabPresenter.java +++ b/app/src/main/java/io/github/wulkanowy/ui/main/attendance/AttendanceTabPresenter.java @@ -10,6 +10,7 @@ import io.github.wulkanowy.data.db.dao.entities.AttendanceLesson; import io.github.wulkanowy.data.db.dao.entities.Day; import io.github.wulkanowy.data.db.dao.entities.Week; import io.github.wulkanowy.ui.base.BasePresenter; +import io.github.wulkanowy.utils.FabricUtils; import io.github.wulkanowy.utils.async.AbstractTask; import io.github.wulkanowy.utils.async.AsyncListeners; @@ -88,6 +89,8 @@ public class AttendanceTabPresenter extends BasePresenter getView().onError(getRepository().getResRepo().getErrorLoginMessage(exception)); } getView().hideRefreshingBar(); + + FabricUtils.logRefresh("Exams", result, date); } @Override diff --git a/app/src/main/java/io/github/wulkanowy/ui/main/grades/GradesPresenter.java b/app/src/main/java/io/github/wulkanowy/ui/main/grades/GradesPresenter.java index 0927d1458..1e99bbdea 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/main/grades/GradesPresenter.java +++ b/app/src/main/java/io/github/wulkanowy/ui/main/grades/GradesPresenter.java @@ -1,5 +1,8 @@ package io.github.wulkanowy.ui.main.grades; +import com.crashlytics.android.answers.Answers; +import com.crashlytics.android.answers.CustomEvent; + import java.util.ArrayList; import java.util.List; @@ -10,6 +13,7 @@ import io.github.wulkanowy.data.db.dao.entities.Grade; import io.github.wulkanowy.data.db.dao.entities.Subject; import io.github.wulkanowy.ui.base.BasePresenter; import io.github.wulkanowy.ui.main.OnFragmentIsReadyListener; +import io.github.wulkanowy.utils.FabricUtils; import io.github.wulkanowy.utils.async.AbstractTask; import io.github.wulkanowy.utils.async.AsyncListeners; @@ -59,6 +63,9 @@ public class GradesPresenter extends BasePresenter getView().setCurrentSemester(which); reloadGrades(); + + Answers.getInstance().logCustom(new CustomEvent("Semester change") + .putCustomAttribute("Name", semesterName)); } private void reloadGrades() { @@ -100,8 +107,8 @@ public class GradesPresenter extends BasePresenter } @Override - public void onEndRefreshAsync(boolean success, Exception exception) { - if (success) { + public void onEndRefreshAsync(boolean result, Exception exception) { + if (result) { reloadGrades(); int numberOfNewGrades = getRepository().getDbRepo().getNewGrades(semesterName).size(); @@ -115,6 +122,8 @@ public class GradesPresenter extends BasePresenter getView().onError(getRepository().getResRepo().getErrorLoginMessage(exception)); } getView().hideRefreshingBar(); + + FabricUtils.logRefresh("Grades", result, null); } @Override diff --git a/app/src/main/java/io/github/wulkanowy/ui/main/timetable/TimetableTabPresenter.java b/app/src/main/java/io/github/wulkanowy/ui/main/timetable/TimetableTabPresenter.java index ca582726c..ef41c4c75 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/main/timetable/TimetableTabPresenter.java +++ b/app/src/main/java/io/github/wulkanowy/ui/main/timetable/TimetableTabPresenter.java @@ -1,6 +1,5 @@ package io.github.wulkanowy.ui.main.timetable; - import java.util.ArrayList; import java.util.List; @@ -11,6 +10,7 @@ import io.github.wulkanowy.data.db.dao.entities.Day; import io.github.wulkanowy.data.db.dao.entities.TimetableLesson; import io.github.wulkanowy.data.db.dao.entities.Week; import io.github.wulkanowy.ui.base.BasePresenter; +import io.github.wulkanowy.utils.FabricUtils; import io.github.wulkanowy.utils.async.AbstractTask; import io.github.wulkanowy.utils.async.AsyncListeners; @@ -91,6 +91,8 @@ public class TimetableTabPresenter extends BasePresenter