[Login] Allow fake login with DevMode.

This commit is contained in:
Kuba Szczodrzyński 2019-11-11 18:41:39 +01:00
parent 69b512e3d1
commit 124437fd73
3 changed files with 7 additions and 6 deletions

View File

@ -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()

View File

@ -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);

View File

@ -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);
}