From 8183d7d5a0f9f62e7d63a8a42f15817525e11d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Fri, 9 Feb 2024 16:35:18 +0100 Subject: [PATCH] Change default symbol for standard register variant (#2421) --- app/build.gradle | 2 +- .../java/io/github/wulkanowy/ui/modules/login/LoginData.kt | 3 ++- .../ui/modules/login/advanced/LoginAdvancedPresenter.kt | 2 +- .../wulkanowy/ui/modules/login/form/LoginFormPresenter.kt | 4 ++-- .../ui/modules/login/recover/LoginRecoverPresenter.kt | 4 ++-- .../login/studentselect/LoginStudentSelectFragment.kt | 2 -- .../login/studentselect/LoginStudentSelectPresenter.kt | 6 +++--- .../ui/modules/login/support/LoginSupportDialog.kt | 2 +- .../ui/modules/login/symbol/LoginSymbolPresenter.kt | 6 +++--- app/src/main/res/values/api_hosts.xml | 4 ++-- app/src/test/java/io/github/wulkanowy/TestEnityCreator.kt | 1 + .../login/studentselect/LoginStudentSelectPresenterTest.kt | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b60dc3b4b..65a42ce1d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -195,7 +195,7 @@ ext { } dependencies { - implementation 'io.github.wulkanowy:sdk:2.3.7' + implementation 'io.github.wulkanowy:sdk:2.3.8-SNAPSHOT' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginData.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginData.kt index 2c11bb6d5..b066cceb9 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginData.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginData.kt @@ -7,5 +7,6 @@ data class LoginData( val password: String, val baseUrl: String, val domainSuffix: String, - val symbol: String?, + val defaultSymbol: String, + val userEnteredSymbol: String? = null, ) : Serializable diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedPresenter.kt index fc26f3765..009f26e17 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedPresenter.kt @@ -155,7 +155,7 @@ class LoginAdvancedPresenter @Inject constructor( password = view?.formPassValue.orEmpty().trim(), baseUrl = view?.formHostValue.orEmpty().trim(), domainSuffix = view?.formDomainSuffix.orEmpty().trim(), - symbol = view?.formSymbolValue.orEmpty().trim().getNormalizedSymbol(), + defaultSymbol = view?.formSymbolValue.orEmpty().trim().getNormalizedSymbol(), ) when (it.data.symbols.size) { 0 -> view?.navigateToSymbol(loginData) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt index 26b15bff0..af89f147c 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt @@ -148,7 +148,7 @@ class LoginFormPresenter @Inject constructor( password = password, baseUrl = host, domainSuffix = domainSuffix, - symbol = symbol + defaultSymbol = symbol ) } @@ -167,7 +167,7 @@ class LoginFormPresenter @Inject constructor( password = loginData.password, scrapperBaseUrl = loginData.baseUrl, domainSuffix = loginData.domainSuffix, - symbol = loginData.symbol.orEmpty(), + symbol = loginData.defaultSymbol, ) } .logResourceStatus("login") diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt index 879055a9a..18902e014 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt @@ -60,7 +60,7 @@ class LoginRecoverPresenter @Inject constructor( resourceFlow { recoverRepository.getReCaptchaSiteKey( host, - symbol.ifBlank { "Default" }) + symbol.ifBlank { "default" }) }.onEach { when (it) { is Resource.Loading -> view?.run { @@ -103,7 +103,7 @@ class LoginRecoverPresenter @Inject constructor( fun onReCaptchaVerified(reCaptchaResponse: String) { val username = view?.recoverNameValue.orEmpty() val host = view?.recoverHostValue.orEmpty() - val symbol = view?.formHostSymbol.ifNullOrBlank { "Default" } + val symbol = view?.formHostSymbol.ifNullOrBlank { "default" } resourceFlow { recoverRepository.sendRecoverRequest( diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectFragment.kt index 06efd8d98..0fe36aa99 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectFragment.kt @@ -10,13 +10,11 @@ import io.github.wulkanowy.data.pojos.RegisterUser import io.github.wulkanowy.data.repositories.PreferencesRepository import io.github.wulkanowy.databinding.FragmentLoginStudentSelectBinding import io.github.wulkanowy.ui.base.BaseFragment -import io.github.wulkanowy.ui.modules.auth.AuthDialog import io.github.wulkanowy.ui.modules.login.LoginActivity import io.github.wulkanowy.ui.modules.login.LoginData import io.github.wulkanowy.ui.modules.login.support.LoginSupportDialog import io.github.wulkanowy.ui.modules.login.support.LoginSupportInfo import io.github.wulkanowy.utils.AppInfo -import io.github.wulkanowy.utils.openEmailClient import io.github.wulkanowy.utils.openInternetBrowser import io.github.wulkanowy.utils.serializable import javax.inject.Inject diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenter.kt index 6cbdfbb85..344414180 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenter.kt @@ -111,8 +111,8 @@ class LoginStudentSelectPresenter @Inject constructor( val notEmptySymbols = registerUser.symbols.filter { it.schools.isNotEmpty() } val emptySymbols = registerUser.symbols.filter { it.schools.isEmpty() } - if (emptySymbols.isNotEmpty() && notEmptySymbols.isNotEmpty() && emptySymbols.any { it.symbol == loginData.symbol }) { - add(createEmptySymbolItem(emptySymbols.first { it.symbol == loginData.symbol })) + if (emptySymbols.isNotEmpty() && notEmptySymbols.isNotEmpty() && emptySymbols.any { it.symbol == loginData.userEnteredSymbol }) { + add(createEmptySymbolItem(emptySymbols.first { it.symbol == loginData.userEnteredSymbol })) } addAll(createNotEmptySymbolItems(notEmptySymbols, students)) @@ -317,7 +317,7 @@ class LoginStudentSelectPresenter @Inject constructor( loginData = loginData, registerUser = registerUser, lastErrorMessage = lastError?.message, - enteredSymbol = loginData.symbol, + enteredSymbol = loginData.userEnteredSymbol, ) ) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/support/LoginSupportDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/support/LoginSupportDialog.kt index fcf7f51c9..4be2dbaad 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/support/LoginSupportDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/support/LoginSupportDialog.kt @@ -105,7 +105,7 @@ class LoginSupportDialog : BaseDialogFragment() { "${appInfo.systemManufacturer} ${appInfo.systemModel}", appInfo.systemVersion.toString(), "${appInfo.versionName}-${appInfo.buildFlavor}", - supportInfo.loginData.baseUrl + "/" + supportInfo.loginData.symbol, + supportInfo.loginData.let { "${it.baseUrl}/${it.defaultSymbol}/${it.userEnteredSymbol}" }, preferencesRepository.installationId, getLastErrorFromStudentSelectScreen(), dialogLoginSupportSchoolInput.text.takeIf { !it.isNullOrBlank() } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/symbol/LoginSymbolPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/symbol/LoginSymbolPresenter.kt index 02bfde5d7..cc88b09e9 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/symbol/LoginSymbolPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/symbol/LoginSymbolPresenter.kt @@ -60,7 +60,7 @@ class LoginSymbolPresenter @Inject constructor( } loginData = loginData.copy( - symbol = view?.symbolValue?.getNormalizedSymbol(), + userEnteredSymbol = view?.symbolValue?.getNormalizedSymbol(), ) resourceFlow { studentRepository.getUserSubjectsFromScrapper( @@ -68,7 +68,7 @@ class LoginSymbolPresenter @Inject constructor( password = loginData.password, scrapperBaseUrl = loginData.baseUrl, domainSuffix = loginData.domainSuffix, - symbol = loginData.symbol.orEmpty(), + symbol = loginData.userEnteredSymbol.orEmpty(), ) }.onEach { user -> registerUser = user.dataOrNull @@ -93,7 +93,7 @@ class LoginSymbolPresenter @Inject constructor( else -> { val enteredSymbolDetails = user.data.symbols .firstOrNull() - ?.takeIf { it.symbol == loginData.symbol } + ?.takeIf { it.symbol == loginData.userEnteredSymbol } if (enteredSymbolDetails?.error is InvalidSymbolException) { view?.run { diff --git a/app/src/main/res/values/api_hosts.xml b/app/src/main/res/values/api_hosts.xml index 94ef8abdc..6439b462f 100644 --- a/app/src/main/res/values/api_hosts.xml +++ b/app/src/main/res/values/api_hosts.xml @@ -47,7 +47,7 @@ https://wulkanowy.net.pl/?email - Default + warszawa opole gdansk lublin @@ -66,7 +66,7 @@ gminaulanmajorat gminaozorkow gminalopiennikgorny - Default + warszawa powiatwulkanowy diff --git a/app/src/test/java/io/github/wulkanowy/TestEnityCreator.kt b/app/src/test/java/io/github/wulkanowy/TestEnityCreator.kt index eac1389f4..9f5d731b6 100644 --- a/app/src/test/java/io/github/wulkanowy/TestEnityCreator.kt +++ b/app/src/test/java/io/github/wulkanowy/TestEnityCreator.kt @@ -42,6 +42,7 @@ fun getSemesterPojo(diaryId: Int, semesterId: Int, start: LocalDate, end: LocalD diaryName = "$semesterId", schoolYear = 1970, classId = 0, + className = "Ti", semesterNumber = semesterName, unitId = 1, start = start, diff --git a/app/src/test/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenterTest.kt b/app/src/test/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenterTest.kt index fad6436d8..34965f00d 100644 --- a/app/src/test/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenterTest.kt +++ b/app/src/test/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenterTest.kt @@ -58,7 +58,7 @@ class LoginStudentSelectPresenterTest { login = "", password = "", baseUrl = "", - symbol = null, + defaultSymbol = "warszawa", domainSuffix = "", )