diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabFragment.kt
index 93acec1e..ec47b5b6 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabFragment.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabFragment.kt
@@ -8,6 +8,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -17,6 +18,8 @@ import pl.szczodrzynski.edziennik.MainActivity
import pl.szczodrzynski.edziennik.databinding.TemplateFragmentBinding
import pl.szczodrzynski.edziennik.ext.addOnPageSelectedListener
import pl.szczodrzynski.edziennik.ui.base.lazypager.FragmentLazyPagerAdapter
+import pl.szczodrzynski.edziennik.ui.login.LoginActivity
+import pl.szczodrzynski.edziennik.utils.SwipeRefreshLayoutNoTouch
import kotlin.coroutines.CoroutineContext
class LabFragment : Fragment(), CoroutineScope {
@@ -26,7 +29,7 @@ class LabFragment : Fragment(), CoroutineScope {
}
private lateinit var app: App
- private lateinit var activity: MainActivity
+ private lateinit var activity: AppCompatActivity
private lateinit var b: TemplateFragmentBinding
private val job: Job = Job()
@@ -36,11 +39,14 @@ class LabFragment : Fragment(), CoroutineScope {
// local/private variables go here
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- activity = (getActivity() as MainActivity?) ?: return null
+ activity = (getActivity() as AppCompatActivity?) ?: return null
context ?: return null
app = activity.application as App
b = TemplateFragmentBinding.inflate(inflater)
- b.refreshLayout.setParent(activity.swipeRefreshLayout)
+ when (activity) {
+ is MainActivity -> b.refreshLayout.setParent((activity as MainActivity).swipeRefreshLayout)
+ is LoginActivity -> b.refreshLayout.setParent((activity as LoginActivity).swipeRefreshLayout)
+ }
b.refreshLayout.isEnabled = false
return b.root
}
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPageFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPageFragment.kt
index 8c9e46fe..aecbecb1 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPageFragment.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPageFragment.kt
@@ -9,6 +9,7 @@ import android.os.Process
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.sqlite.db.SimpleSQLiteQuery
import com.chuckerteam.chucker.api.Chucker
@@ -35,7 +36,7 @@ class LabPageFragment : LazyFragment(), CoroutineScope {
}
private lateinit var app: App
- private lateinit var activity: MainActivity
+ private lateinit var activity: AppCompatActivity
private lateinit var b: LabFragmentBinding
private val job: Job = Job()
@@ -45,7 +46,7 @@ class LabPageFragment : LazyFragment(), CoroutineScope {
// local/private variables go here
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- activity = (getActivity() as MainActivity?) ?: return null
+ activity = (getActivity() as AppCompatActivity?) ?: return null
context ?: return null
app = activity.application as App
b = LabFragmentBinding.inflate(inflater)
@@ -55,6 +56,16 @@ class LabPageFragment : LazyFragment(), CoroutineScope {
override fun onPageCreated(): Boolean {
b.app = app
+ if (app.profile.id == 0) {
+ b.last10unseen.isVisible = false
+ b.fullSync.isVisible = false
+ b.clearProfile.isVisible = false
+ b.rodo.isVisible = false
+ b.removeHomework.isVisible = false
+ b.unarchive.isVisible = false
+ b.profile.isVisible = false
+ }
+
b.last10unseen.onClick {
launch(Dispatchers.Default) {
val events = app.db.eventDao().getAllNow(App.profileId)
@@ -139,7 +150,8 @@ class LabPageFragment : LazyFragment(), CoroutineScope {
b.profile += profiles.map { TextInputDropDown.Item(it.id.toLong(), "${it.id} ${it.name} archived ${it.archived}", tag = it) }
b.profile.select(app.profileId.toLong())
b.profile.setOnChangeListener {
- activity.loadProfile(it.id.toInt())
+ if (activity is MainActivity)
+ (activity as MainActivity).loadProfile(it.id.toInt())
return@setOnChangeListener true
}
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabProfileFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabProfileFragment.kt
index 995f3133..5b289ea4 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabProfileFragment.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabProfileFragment.kt
@@ -8,6 +8,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@@ -22,6 +23,7 @@ import pl.szczodrzynski.edziennik.ext.input
import pl.szczodrzynski.edziennik.ext.set
import pl.szczodrzynski.edziennik.ext.startCoroutineTimer
import pl.szczodrzynski.edziennik.ui.base.lazypager.LazyFragment
+import pl.szczodrzynski.edziennik.ui.login.LoginActivity
import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration
import kotlin.coroutines.CoroutineContext
@@ -31,7 +33,7 @@ class LabProfileFragment : LazyFragment(), CoroutineScope {
}
private lateinit var app: App
- private lateinit var activity: MainActivity
+ private lateinit var activity: AppCompatActivity
private lateinit var b: TemplateListPageFragmentBinding
private val job: Job = Job()
@@ -45,7 +47,7 @@ class LabProfileFragment : LazyFragment(), CoroutineScope {
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- activity = (getActivity() as MainActivity?) ?: return null
+ activity = (getActivity() as AppCompatActivity?) ?: return null
context ?: return null
app = activity.application as App
b = TemplateListPageFragmentBinding.inflate(inflater)
@@ -142,7 +144,10 @@ class LabProfileFragment : LazyFragment(), CoroutineScope {
.show()
}
catch (e: Exception) {
- activity.error(ApiError.fromThrowable(TAG, e))
+ if (activity is MainActivity)
+ (activity as MainActivity).error(ApiError.fromThrowable(TAG, e))
+ if (activity is LoginActivity)
+ (activity as LoginActivity).error(ApiError.fromThrowable(TAG, e))
}
})
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginActivity.kt
index 1f8fb442..61aa4520 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginActivity.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginActivity.kt
@@ -20,6 +20,7 @@ import pl.szczodrzynski.edziennik.data.api.models.ApiError
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
import pl.szczodrzynski.edziennik.databinding.LoginActivityBinding
import pl.szczodrzynski.edziennik.ui.error.ErrorSnackbar
+import pl.szczodrzynski.edziennik.utils.SwipeRefreshLayoutNoTouch
import kotlin.coroutines.CoroutineContext
class LoginActivity : AppCompatActivity(), CoroutineScope {
@@ -32,6 +33,7 @@ class LoginActivity : AppCompatActivity(), CoroutineScope {
lateinit var navOptions: NavOptions
val nav by lazy { Navigation.findNavController(this, R.id.nav_host_fragment) }
val errorSnackbar: ErrorSnackbar by lazy { ErrorSnackbar(this) }
+ val swipeRefreshLayout: SwipeRefreshLayoutNoTouch by lazy { b.swipeRefreshLayout }
private val job: Job = Job()
override val coroutineContext: CoroutineContext
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginChooserFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginChooserFragment.kt
index b793b34b..1bfe0abd 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginChooserFragment.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginChooserFragment.kt
@@ -66,6 +66,8 @@ class LoginChooserFragment : Fragment(), CoroutineScope {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
if (!isAdded) return
+ val adapter = LoginChooserAdapter(activity, this::onLoginModeClicked)
+
b.versionText.setText(
R.string.login_chooser_version_format,
app.buildManager.versionName,
@@ -73,10 +75,33 @@ class LoginChooserFragment : Fragment(), CoroutineScope {
)
b.versionText.onClick {
app.buildManager.showVersionDialog(activity)
+ if (!App.devMode)
+ return@onClick
+ if (adapter.items.firstOrNull { it is LoginInfo.Register && it.internalName == "lab" } != null)
+ return@onClick
+ adapter.items.add(
+ index = 0,
+ element = LoginInfo.Register(
+ loginType = 999999,
+ internalName = "lab",
+ registerName = R.string.menu_lab,
+ registerLogo = R.drawable.face_2,
+ loginModes = listOf(
+ LoginInfo.Mode(
+ loginMode = 0,
+ name = 0,
+ icon = 0,
+ guideText = 0,
+ credentials = listOf(),
+ errorCodes = mapOf()
+ )
+ )
+ )
+ )
+ adapter.notifyItemInserted(0)
+ b.list.smoothScrollToPosition(0)
}
- val adapter = LoginChooserAdapter(activity, this::onLoginModeClicked)
-
LoginInfo.chooserList = LoginInfo.chooserList
?: LoginInfo.list.toMutableList()
@@ -164,7 +189,7 @@ class LoginChooserFragment : Fragment(), CoroutineScope {
anim.fillAfter = true
activity.getRootView().startAnimation(anim)
- b.list.smoothScrollToPosition(0)
+ adapter.items.removeAll { it !is LoginInfo.Register }
adapter.items.add(
LoginInfo.Register(
loginType = 74,
@@ -183,7 +208,8 @@ class LoginChooserFragment : Fragment(), CoroutineScope {
)
)
)
- adapter.notifyItemInserted(adapter.items.size - 1)
+ adapter.notifyDataSetChanged()
+ b.list.smoothScrollToPosition(adapter.items.size - 1)
}
when {
@@ -216,6 +242,11 @@ class LoginChooserFragment : Fragment(), CoroutineScope {
return
}
+ if (loginType.internalName == "lab") {
+ nav.navigate(R.id.labFragment, null, activity.navOptions)
+ return
+ }
+
if (!app.config.privacyPolicyAccepted) {
MaterialAlertDialogBuilder(activity)
.setTitle(R.string.privacy_policy)
diff --git a/app/src/main/res/drawable/face_2.png b/app/src/main/res/drawable/face_2.png
new file mode 100644
index 00000000..c9c67b2b
Binary files /dev/null and b/app/src/main/res/drawable/face_2.png differ
diff --git a/app/src/main/res/layout/login_activity.xml b/app/src/main/res/layout/login_activity.xml
index 52bccaec..d8aa5ca4 100644
--- a/app/src/main/res/layout/login_activity.xml
+++ b/app/src/main/res/layout/login_activity.xml
@@ -19,13 +19,19 @@
android:orientation="vertical"
android:visibility="visible">
-
+ android:layout_height="match_parent">
+
+
+
+
+