1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 03:39:08 -05:00

Add a selection of multiple students to login (#318)

This commit is contained in:
Rafał Borcz 2019-04-18 12:18:58 +02:00 committed by Mikołaj Pich
parent 034b99c7ab
commit 7431738366
17 changed files with 141 additions and 74 deletions

View File

@ -86,7 +86,7 @@ play {
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation('com.github.wulkanowy:api:fe4ffeb') { exclude module: "threetenbp" } implementation 'com.github.wulkanowy:api:3335bd6'
implementation "androidx.legacy:legacy-support-v4:1.0.0" implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.appcompat:appcompat:1.0.2" implementation "androidx.appcompat:appcompat:1.0.2"

View File

@ -39,7 +39,7 @@ class StudentLocalTest {
@Test @Test
fun saveAndReadTest() { fun saveAndReadTest() {
studentLocal.saveStudent(Student(email = "test", password = "test123", schoolSymbol = "23", endpoint = "fakelog.cf", loginType = "AUTO", isCurrent = true, studentName = "", schoolName = "", studentId = 0, classId = 1, symbol = "", registrationDate = now(), className = "")) studentLocal.saveStudents(listOf(Student(email = "test", password = "test123", schoolSymbol = "23", endpoint = "fakelog.cf", loginType = "AUTO", isCurrent = true, studentName = "", schoolName = "", studentId = 0, classId = 1, symbol = "", registrationDate = now(), className = "")))
.blockingGet() .blockingGet()
val student = studentLocal.getCurrentStudent(true).blockingGet() val student = studentLocal.getCurrentStudent(true).blockingGet()

View File

@ -34,6 +34,7 @@
android:name=".ui.modules.login.LoginActivity" android:name=".ui.modules.login.LoginActivity"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
android:label="@string/login_title" android:label="@string/login_title"
android:theme="@style/WulkanowyTheme.NoActionBar"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".ui.modules.main.MainActivity" android:name=".ui.modules.main.MainActivity"

View File

@ -14,7 +14,7 @@ import javax.inject.Singleton
interface StudentDao { interface StudentDao {
@Insert(onConflict = ABORT) @Insert(onConflict = ABORT)
fun insert(student: Student): Long fun insertAll(student: List<Student>): List<Long>
@Delete @Delete
fun delete(student: Student) fun delete(student: Student)

View File

@ -17,8 +17,8 @@ class StudentLocal @Inject constructor(
private val context: Context private val context: Context
) { ) {
fun saveStudent(student: Student): Single<Long> { fun saveStudents(students: List<Student>): Single<List<Long>> {
return Single.fromCallable { studentDb.insert(student.copy(password = encrypt(student.password, context))) } return Single.fromCallable { studentDb.insertAll(students.map { it.copy(password = encrypt(it.password, context)) }) }
} }
fun getStudents(decryptPass: Boolean): Maybe<List<Student>> { fun getStudents(decryptPass: Boolean): Maybe<List<Student>> {

View File

@ -41,8 +41,8 @@ class StudentRepository @Inject constructor(
.toSingle() .toSingle()
} }
fun saveStudent(student: Student): Single<Long> { fun saveStudents(students: List<Student>): Single<List<Long>> {
return local.saveStudent(student) return local.saveStudents(students)
} }
fun switchStudent(student: Student): Completable { fun switchStudent(student: Student): Completable {

View File

@ -8,7 +8,6 @@ import android.view.View
import android.view.View.GONE import android.view.View.GONE
import android.view.View.VISIBLE import android.view.View.VISIBLE
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
@ -45,6 +44,7 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
} }
override fun initView() { override fun initView() {
loginStudentSelectSignIn.setOnClickListener { presenter.onSignIn() }
loginAdapter.apply { setOnItemClickListener { presenter.onItemSelected(it) } } loginAdapter.apply { setOnItemClickListener { presenter.onItemSelected(it) } }
loginStudentSelectRecycler.apply { loginStudentSelectRecycler.apply {
@ -54,7 +54,7 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
} }
override fun updateData(data: List<LoginStudentSelectItem>) { override fun updateData(data: List<LoginStudentSelectItem>) {
loginAdapter.updateDataSet(data, true) loginAdapter.updateDataSet(data)
} }
override fun openMainView() { override fun openMainView() {
@ -69,11 +69,11 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
} }
override fun showContent(show: Boolean) { override fun showContent(show: Boolean) {
loginStudentSelectRecycler.visibility = if (show) VISIBLE else GONE loginStudentSelectContent.visibility = if (show) VISIBLE else GONE
} }
override fun showActionBar(show: Boolean) { override fun enableSignIn(enable: Boolean) {
(activity as? AppCompatActivity)?.supportActionBar?.run { if (show) show() else hide() } loginStudentSelectSignIn.isEnabled = enable
} }
fun onParentInitStudentSelectFragment(students: List<Student>) { fun onParentInitStudentSelectFragment(students: List<Student>) {

View File

@ -13,15 +13,15 @@ import kotlinx.android.synthetic.main.item_login_student_select.*
class LoginStudentSelectItem(val student: Student) : AbstractFlexibleItem<LoginStudentSelectItem.ItemViewHolder>() { class LoginStudentSelectItem(val student: Student) : AbstractFlexibleItem<LoginStudentSelectItem.ItemViewHolder>() {
override fun getLayoutRes(): Int = R.layout.item_login_student_select override fun getLayoutRes() = R.layout.item_login_student_select
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<*>>): ItemViewHolder { override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<*>>): ItemViewHolder {
return ItemViewHolder(view, adapter) return ItemViewHolder(view, adapter)
} }
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<*>>, holder: ItemViewHolder, position: Int, payloads: MutableList<Any>?) { override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<*>>, holder: ItemViewHolder, position: Int, payloads: MutableList<Any>) {
holder.run { holder.apply {
loginItemName.text = "${student.studentName} ${student.className}" loginItemName.text = "${student.studentName} ${student.className}"
loginItemSchool.text = student.schoolName loginItemSchool.text = student.schoolName
} }
@ -43,7 +43,17 @@ class LoginStudentSelectItem(val student: Student) : AbstractFlexibleItem<LoginS
} }
class ItemViewHolder(view: View, adapter: FlexibleAdapter<*>) : FlexibleViewHolder(view, adapter), LayoutContainer { class ItemViewHolder(view: View, adapter: FlexibleAdapter<*>) : FlexibleViewHolder(view, adapter), LayoutContainer {
override val containerView: View override val containerView: View
get() = itemView get() = itemView
init {
loginItemCheck.setOnClickListener { super.onClick(loginItemContainer) }
}
override fun onClick(view: View?) {
super.onClick(view)
loginItemCheck.apply { isChecked = !isChecked }
}
} }
} }

View File

@ -8,7 +8,6 @@ import io.github.wulkanowy.ui.base.BasePresenter
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
import io.github.wulkanowy.utils.SchedulersProvider import io.github.wulkanowy.utils.SchedulersProvider
import io.reactivex.Single
import timber.log.Timber import timber.log.Timber
import java.io.Serializable import java.io.Serializable
import javax.inject.Inject import javax.inject.Inject
@ -22,10 +21,13 @@ class LoginStudentSelectPresenter @Inject constructor(
var students = emptyList<Student>() var students = emptyList<Student>()
var selectedStudents = mutableListOf<Student>()
fun onAttachView(view: LoginStudentSelectView, students: Serializable?) { fun onAttachView(view: LoginStudentSelectView, students: Serializable?) {
super.onAttachView(view) super.onAttachView(view)
view.run { view.run {
initView() initView()
enableSignIn(false)
errorHandler.onStudentDuplicate = { errorHandler.onStudentDuplicate = {
showMessage(it) showMessage(it)
Timber.i("The student already registered in the app was selected") Timber.i("The student already registered in the app was selected")
@ -37,13 +39,21 @@ class LoginStudentSelectPresenter @Inject constructor(
} }
} }
fun onSignIn() {
registerStudents(selectedStudents)
}
fun onParentInitStudentSelectView(students: List<Student>) { fun onParentInitStudentSelectView(students: List<Student>) {
loadData(students) loadData(students)
if (students.size == 1) registerStudents(students)
} }
fun onItemSelected(item: AbstractFlexibleItem<*>?) { fun onItemSelected(item: AbstractFlexibleItem<*>?) {
if (item is LoginStudentSelectItem) { if (item is LoginStudentSelectItem) {
registerStudent(item.student) selectedStudents.removeAll { it == item.student }
.let { if (!it) selectedStudents.add(item.student) }
view?.enableSignIn(selectedStudents.isNotEmpty())
} }
} }
@ -54,33 +64,30 @@ class LoginStudentSelectPresenter @Inject constructor(
} }
} }
private fun registerStudent(student: Student) { private fun registerStudents(students: List<Student>) {
disposable.add(studentRepository.saveStudent(student) disposable.add(studentRepository.saveStudents(students)
.map { student.apply { id = it } } .map { students.first().apply { id = it.first() } }
.onErrorResumeNext { studentRepository.logoutStudent(student).andThen(Single.error(it)) } .flatMapCompletable { studentRepository.switchStudent(it) }
.flatMapCompletable { studentRepository.switchStudent(student) }
.subscribeOn(schedulers.backgroundThread) .subscribeOn(schedulers.backgroundThread)
.observeOn(schedulers.mainThread) .observeOn(schedulers.mainThread)
.doOnSubscribe { .doOnSubscribe {
view?.apply { view?.apply {
showProgress(true) showProgress(true)
showContent(false) showContent(false)
showActionBar(false)
} }
Timber.i("Registration started") Timber.i("Registration started")
} }
.subscribe({ .subscribe({
analytics.logEvent("registration_student_select", SUCCESS to true, "endpoint" to student.endpoint, "symbol" to student.symbol, "error" to "No error") students.forEach { analytics.logEvent("registration_student_select", SUCCESS to true, "endpoint" to it.endpoint, "symbol" to it.symbol, "error" to "No error") }
Timber.i("Registration result: Success") Timber.i("Registration result: Success")
view?.openMainView() view?.openMainView()
}, { }, { error ->
analytics.logEvent("registration_student_select", SUCCESS to false, "endpoint" to student.endpoint, "symbol" to student.symbol, "error" to it.localizedMessage) students.forEach { analytics.logEvent("registration_student_select", SUCCESS to false, "endpoint" to it.endpoint, "symbol" to it.symbol, "error" to error.localizedMessage) }
Timber.i("Registration result: An exception occurred ") Timber.i("Registration result: An exception occurred ")
errorHandler.dispatch(it) errorHandler.dispatch(error)
view?.apply { view?.apply {
showProgress(false) showProgress(false)
showContent(true) showContent(true)
showActionBar(true)
} }
})) }))
} }

View File

@ -14,5 +14,5 @@ interface LoginStudentSelectView : BaseView {
fun showContent(show: Boolean) fun showContent(show: Boolean)
fun showActionBar(show: Boolean) fun enableSignIn(enable: Boolean)
} }

View File

@ -30,7 +30,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="32dp" android:layout_marginStart="32dp"
android:layout_marginLeft="32dp" android:layout_marginLeft="32dp"
android:layout_marginTop="48dp" android:layout_marginTop="32dp"
android:layout_marginEnd="32dp" android:layout_marginEnd="32dp"
android:layout_marginRight="32dp" android:layout_marginRight="32dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
@ -150,7 +150,7 @@
android:layout_marginTop="48dp" android:layout_marginTop="48dp"
android:layout_marginEnd="24dp" android:layout_marginEnd="24dp"
android:layout_marginRight="24dp" android:layout_marginRight="24dp"
android:layout_marginBottom="48dp" android:layout_marginBottom="16dp"
android:text="@string/login_sign_in" android:text="@string/login_sign_in"
android:textAppearance="?android:textAppearanceSmall" android:textAppearance="?android:textAppearanceSmall"
android:textColor="@android:color/white" android:textColor="@android:color/white"

View File

@ -1,4 +1,5 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -12,10 +13,60 @@
android:indeterminate="true" android:indeterminate="true"
android:visibility="gone" /> android:visibility="gone" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/loginStudentSelectContent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/loginStudentSelectHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:layout_marginBottom="32dp"
android:gravity="center_horizontal"
android:text="@string/login_select_student"
android:textSize="16sp"
app:fontFamily="sans-serif-light"
app:layout_constraintBottom_toTopOf="@id/loginStudentSelectRecycler"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/loginStudentSelectRecycler" android:id="@+id/loginStudentSelectRecycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
tools:itemCount="5" android:minHeight="144dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@id/loginStudentSelectSignIn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_max="432dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/loginStudentSelectHeader"
tools:itemCount="6"
tools:listitem="@layout/item_login_student_select" /> tools:listitem="@layout/item_login_student_select" />
<com.google.android.material.button.MaterialButton
android:id="@+id/loginStudentSelectSignIn"
style="@style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:layout_marginBottom="32dp"
android:text="@string/login_sign_in"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="@android:color/white"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/loginStudentSelectRecycler" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout> </FrameLayout>

View File

@ -29,7 +29,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="32dp" android:layout_marginStart="32dp"
android:layout_marginLeft="32dp" android:layout_marginLeft="32dp"
android:layout_marginTop="48dp" android:layout_marginTop="32dp"
android:layout_marginEnd="32dp" android:layout_marginEnd="32dp"
android:layout_marginRight="32dp" android:layout_marginRight="32dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
@ -79,11 +79,10 @@
style="@style/Widget.MaterialComponents.Button" style="@style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="48dp" android:layout_marginTop="48dp"
android:layout_marginEnd="24dp" android:layout_marginEnd="24dp"
android:layout_marginRight="24dp" android:layout_marginRight="24dp"
android:layout_marginBottom="48dp" android:layout_marginBottom="16dp"
android:text="@string/login_sign_in" android:text="@string/login_sign_in"
android:textAppearance="?android:textAppearanceSmall" android:textAppearance="?android:textAppearanceSmall"
android:textColor="@android:color/white" android:textColor="@android:color/white"
@ -91,8 +90,7 @@
app:backgroundTint="@color/colorPrimary" app:backgroundTint="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/loginSymbolNameLayout" app:layout_constraintTop_toBottomOf="@+id/loginSymbolNameLayout" />
app:layout_constraintVertical_bias="1" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
</FrameLayout> </FrameLayout>

View File

@ -1,46 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/loginItemContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="72dp" android:layout_height="72dp"
android:background="?attr/selectableItemBackground" android:background="?selectableItemBackground"
android:clickable="true" android:orientation="horizontal">
android:focusable="true"
android:padding="16dp"
tools:context=".ui.modules.login.studentselect.LoginStudentSelectItem">
<androidx.appcompat.widget.AppCompatImageView <CheckBox
android:id="@+id/loginItemImage" android:id="@+id/loginItemCheck"
android:layout_width="40dp" android:layout_width="26dp"
android:layout_height="40dp" android:layout_height="24dp"
android:layout_marginEnd="16dp" android:layout_marginStart="16dp"
android:layout_marginRight="16dp" android:layout_marginLeft="16dp"
app:srcCompat="@drawable/ic_all_account_24dp" android:layout_marginTop="16dp"
app:tint="?android:textColorPrimary" /> android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
tools:text=" " />
<TextView <TextView
android:id="@+id/loginItemName" android:id="@+id/loginItemName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toEndOf="@id/loginItemImage" android:layout_toEndOf="@id/loginItemCheck"
android:layout_toRightOf="@id/loginItemImage" android:layout_toRightOf="@id/loginItemCheck"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/app_name"
android:textSize="16sp" android:textSize="16sp"
app:firstBaselineToTopHeight="16dp" /> app:firstBaselineToTopHeight="32dp"
tools:text="Jan Kowalski" />
<TextView <TextView
android:id="@+id/loginItemSchool" android:id="@+id/loginItemSchool"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toEndOf="@id/loginItemImage" android:layout_below="@id/loginItemName"
android:layout_toRightOf="@id/loginItemImage" android:layout_toEndOf="@id/loginItemCheck"
android:ellipsize="end" android:layout_toRightOf="@id/loginItemCheck"
android:maxLines="1" android:textColor="?android:textColorSecondary"
android:text="@string/app_name"
android:textSize="12sp" android:textSize="12sp"
app:firstBaselineToTopHeight="36dp" /> app:firstBaselineToTopHeight="20dp"
tools:text="Szkoła Wulkanowego nr 1" />
</RelativeLayout> </RelativeLayout>

View File

@ -3,7 +3,7 @@
<!--Activity/Fragment title--> <!--Activity/Fragment title-->
<string name="login_title">Wybierz ucznia</string> <string name="login_title">Logowanie</string>
<string name="main_title">Wulkanowy</string> <string name="main_title">Wulkanowy</string>
<string name="grade_title">Oceny</string> <string name="grade_title">Oceny</string>
<string name="attendance_title">Frekwencja</string> <string name="attendance_title">Frekwencja</string>
@ -31,8 +31,9 @@
<string name="login_incorrect_password">Dane logowania są niepoprawne</string> <string name="login_incorrect_password">Dane logowania są niepoprawne</string>
<string name="login_incorrect_symbol">Nie znaleziono ucznia. Sprawdź symbol</string> <string name="login_incorrect_symbol">Nie znaleziono ucznia. Sprawdź symbol</string>
<string name="login_field_required">To pole jest wymagane</string> <string name="login_field_required">To pole jest wymagane</string>
<string name="login_duplicate_student">Ten student jest już zalogowany</string> <string name="login_duplicate_student">Wybrany uczeń jest już zalogowany</string>
<string name="login_symbol_helper">Symbol znajduje się na stronie dziennika w zakładce Dostęp Mobilny</string> <string name="login_symbol_helper">Symbol znajduje się na stronie dziennika w zakładce Dostęp Mobilny</string>
<string name="login_select_student">Wybierz uczniów do zalogowania w aplikacji</string>
<string name="login_privacy_policy">Polityka prywatności</string> <string name="login_privacy_policy">Polityka prywatności</string>

View File

@ -3,7 +3,7 @@
<!--Activity/Fragment title--> <!--Activity/Fragment title-->
<string name="login_title">Select student</string> <string name="login_title">Login</string>
<string name="main_title">Wulkanowy</string> <string name="main_title">Wulkanowy</string>
<string name="grade_title">Grades</string> <string name="grade_title">Grades</string>
<string name="attendance_title">Attendance</string> <string name="attendance_title">Attendance</string>
@ -31,8 +31,9 @@
<string name="login_incorrect_password">Login details are incorrect</string> <string name="login_incorrect_password">Login details are incorrect</string>
<string name="login_incorrect_symbol">Student not found. Check the symbol</string> <string name="login_incorrect_symbol">Student not found. Check the symbol</string>
<string name="login_field_required">This field is required</string> <string name="login_field_required">This field is required</string>
<string name="login_duplicate_student">This student has already been logged in</string> <string name="login_duplicate_student">The selected student is already logged in</string>
<string name="login_symbol_helper">The symbol is located on the register page in the Mobile Access tab</string> <string name="login_symbol_helper">The symbol is located on the register page in the Mobile Access tab</string>
<string name="login_select_student">Select students to log in to the application</string>
<string name="login_privacy_policy">Privacy policy</string> <string name="login_privacy_policy">Privacy policy</string>

View File

@ -51,9 +51,10 @@ class LoginStudentSelectPresenterTest {
@Test @Test
fun onSelectedStudentTest() { fun onSelectedStudentTest() {
doReturn(Single.just(1L)).`when`(studentRepository).saveStudent(testStudent) doReturn(Single.just(listOf(1L))).`when`(studentRepository).saveStudents(listOf(testStudent))
doReturn(Completable.complete()).`when`(studentRepository).switchStudent(testStudent) doReturn(Completable.complete()).`when`(studentRepository).switchStudent(testStudent)
presenter.onItemSelected(LoginStudentSelectItem(testStudent)) presenter.onItemSelected(LoginStudentSelectItem(testStudent))
presenter.onSignIn()
verify(loginStudentSelectView).showContent(false) verify(loginStudentSelectView).showContent(false)
verify(loginStudentSelectView).showProgress(true) verify(loginStudentSelectView).showProgress(true)
verify(loginStudentSelectView).openMainView() verify(loginStudentSelectView).openMainView()
@ -61,9 +62,10 @@ class LoginStudentSelectPresenterTest {
@Test @Test
fun onSelectedStudentErrorTest() { fun onSelectedStudentErrorTest() {
doReturn(Single.error<Student>(testException)).`when`(studentRepository).saveStudent(testStudent) doReturn(Single.error<Student>(testException)).`when`(studentRepository).saveStudents(listOf(testStudent))
doReturn(Completable.complete()).`when`(studentRepository).logoutStudent(testStudent) doReturn(Completable.complete()).`when`(studentRepository).logoutStudent(testStudent)
presenter.onItemSelected(LoginStudentSelectItem(testStudent)) presenter.onItemSelected(LoginStudentSelectItem(testStudent))
presenter.onSignIn()
verify(loginStudentSelectView).showContent(false) verify(loginStudentSelectView).showContent(false)
verify(loginStudentSelectView).showProgress(true) verify(loginStudentSelectView).showProgress(true)
verify(errorHandler).dispatch(testException) verify(errorHandler).dispatch(testException)