From 124437fd73145a6afb9d5dedf3ff3719b1f7d6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 11 Nov 2019 18:41:39 +0100 Subject: [PATCH] [Login] Allow fake login with DevMode. --- .../java/pl/szczodrzynski/edziennik/api/v2/models/Data.kt | 7 +++++-- .../edziennik/ui/modules/login/LoginChooserFragment.java | 3 +-- .../edziennik/ui/modules/login/LoginProgressFragment.java | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/models/Data.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/models/Data.kt index a89d5ff2..aedbc4ef 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/models/Data.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/models/Data.kt @@ -5,7 +5,7 @@ import android.util.SparseArray import androidx.core.util.size import com.google.gson.JsonObject import im.wangchao.mhttp.Response -import pl.szczodrzynski.edziennik.* +import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.api.v2.DataNotifications import pl.szczodrzynski.edziennik.api.v2.EXCEPTION_NOTIFY_AND_SYNC import pl.szczodrzynski.edziennik.api.v2.ServerSync @@ -38,8 +38,11 @@ import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsence import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsenceType import pl.szczodrzynski.edziennik.data.db.modules.teams.Team +import pl.szczodrzynski.edziennik.singleOrNull +import pl.szczodrzynski.edziennik.toSparseArray import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.models.Date +import pl.szczodrzynski.edziennik.values import java.io.InterruptedIOException import java.net.SocketTimeoutException import java.net.UnknownHostException @@ -162,7 +165,7 @@ open class Data(val app: App, val profile: Profile?, val loginStore: LoginStore) val db: AppDb by lazy { app.db } init { - if (BuildConfig.DEBUG) { + if (App.devMode) { fakeLogin = loginStore.hasLoginData("fakeLogin") } clear() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginChooserFragment.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginChooserFragment.java index 2aff483c..95e53cc4 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginChooserFragment.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginChooserFragment.java @@ -14,7 +14,6 @@ import androidx.navigation.NavController; import androidx.navigation.Navigation; import pl.szczodrzynski.edziennik.App; -import pl.szczodrzynski.edziennik.BuildConfig; import pl.szczodrzynski.edziennik.R; import pl.szczodrzynski.edziennik.databinding.FragmentLoginChooserBinding; import pl.szczodrzynski.edziennik.ui.modules.feedback.FeedbackActivity; @@ -73,7 +72,7 @@ public class LoginChooserFragment extends Fragment { b.cancelButton.setVisibility(View.GONE); } - b.fakeLogin.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE); + b.fakeLogin.setVisibility(App.devMode ? View.VISIBLE : View.GONE); b.fakeLogin.setChecked(fakeLogin); b.fakeLogin.setOnCheckedChangeListener((v, isChecked) -> fakeLogin = isChecked); diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginProgressFragment.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginProgressFragment.java index 08c7e919..bce2a0be 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginProgressFragment.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginProgressFragment.java @@ -19,7 +19,6 @@ import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import pl.szczodrzynski.edziennik.App; -import pl.szczodrzynski.edziennik.BuildConfig; import pl.szczodrzynski.edziennik.R; import pl.szczodrzynski.edziennik.api.v2.events.ApiTaskErrorEvent; import pl.szczodrzynski.edziennik.api.v2.events.FirstLoginFinishedEvent; @@ -90,7 +89,7 @@ public class LoginProgressFragment extends Fragment { LoginStore loginStore = new LoginStore(-1, loginType, new JsonObject()); loginStore.copyFrom(args); - if (BuildConfig.DEBUG && LoginChooserFragment.fakeLogin) { + if (App.devMode && LoginChooserFragment.fakeLogin) { loginStore.putLoginData("fakeLogin", true); }