mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 12:48:20 +01:00
Add form dialog to login e-mail support (#2306)
This commit is contained in:
parent
711de0f77f
commit
fca69e7234
@ -17,6 +17,8 @@ import io.github.wulkanowy.ui.base.BaseFragment
|
|||||||
import io.github.wulkanowy.ui.modules.dashboard.viewholders.AdminMessageViewHolder
|
import io.github.wulkanowy.ui.modules.dashboard.viewholders.AdminMessageViewHolder
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginData
|
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.*
|
import io.github.wulkanowy.utils.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -282,20 +284,7 @@ class LoginFormFragment : BaseFragment<FragmentLoginFormBinding>(R.layout.fragme
|
|||||||
presenter.updateCustomDomainSuffixVisibility()
|
presenter.updateCustomDomainSuffixVisibility()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openEmail(lastError: String) {
|
override fun openEmail(supportInfo: LoginSupportInfo) {
|
||||||
context?.openEmailClient(
|
LoginSupportDialog.newInstance(supportInfo).show(childFragmentManager, "support_dialog")
|
||||||
chooserTitle = requireContext().getString(R.string.login_email_intent_title),
|
|
||||||
email = "wulkanowyinc@gmail.com",
|
|
||||||
subject = requireContext().getString(R.string.login_email_subject),
|
|
||||||
body = requireContext().getString(
|
|
||||||
R.string.login_email_text,
|
|
||||||
"${appInfo.systemManufacturer} ${appInfo.systemModel}",
|
|
||||||
appInfo.systemVersion.toString(),
|
|
||||||
"${appInfo.versionName}-${appInfo.buildFlavor}",
|
|
||||||
"$formHostValue/$formHostSymbol",
|
|
||||||
preferencesRepository.installationId,
|
|
||||||
lastError
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import io.github.wulkanowy.domain.adminmessage.GetAppropriateAdminMessageUseCase
|
|||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginData
|
import io.github.wulkanowy.ui.modules.login.LoginData
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
||||||
|
import io.github.wulkanowy.ui.modules.login.support.LoginSupportInfo
|
||||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.ifNullOrBlank
|
import io.github.wulkanowy.utils.ifNullOrBlank
|
||||||
@ -133,7 +134,7 @@ class LoginFormPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onSignInClick() {
|
private fun getLoginData(): LoginData {
|
||||||
val email = view?.formUsernameValue.orEmpty().trim()
|
val email = view?.formUsernameValue.orEmpty().trim()
|
||||||
val password = view?.formPassValue.orEmpty().trim()
|
val password = view?.formPassValue.orEmpty().trim()
|
||||||
val host = view?.formHostValue.orEmpty().trim()
|
val host = view?.formHostValue.orEmpty().trim()
|
||||||
@ -142,15 +143,27 @@ class LoginFormPresenter @Inject constructor(
|
|||||||
}.orEmpty()
|
}.orEmpty()
|
||||||
val symbol = view?.formHostSymbol.orEmpty().trim()
|
val symbol = view?.formHostSymbol.orEmpty().trim()
|
||||||
|
|
||||||
if (!validateCredentials(email, password, host)) return
|
return LoginData(
|
||||||
|
login = email,
|
||||||
|
password = password,
|
||||||
|
baseUrl = host,
|
||||||
|
domainSuffix = domainSuffix,
|
||||||
|
symbol = symbol
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onSignInClick() {
|
||||||
|
val loginData = getLoginData()
|
||||||
|
|
||||||
|
if (!validateCredentials(loginData.login, loginData.password, loginData.baseUrl)) return
|
||||||
|
|
||||||
resourceFlow {
|
resourceFlow {
|
||||||
studentRepository.getUserSubjectsFromScrapper(
|
studentRepository.getUserSubjectsFromScrapper(
|
||||||
email = email,
|
email = loginData.login,
|
||||||
password = password,
|
password = loginData.password,
|
||||||
scrapperBaseUrl = host,
|
scrapperBaseUrl = loginData.baseUrl,
|
||||||
domainSuffix = domainSuffix,
|
domainSuffix = loginData.domainSuffix,
|
||||||
symbol = symbol
|
symbol = loginData.symbol.orEmpty(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.logResourceStatus("login")
|
.logResourceStatus("login")
|
||||||
@ -162,7 +175,6 @@ class LoginFormPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onResourceSuccess {
|
.onResourceSuccess {
|
||||||
val loginData = LoginData(email, password, host, domainSuffix, symbol)
|
|
||||||
when (it.symbols.size) {
|
when (it.symbols.size) {
|
||||||
0 -> view?.navigateToSymbol(loginData)
|
0 -> view?.navigateToSymbol(loginData)
|
||||||
else -> view?.navigateToStudentSelect(loginData, it)
|
else -> view?.navigateToStudentSelect(loginData, it)
|
||||||
@ -170,7 +182,7 @@ class LoginFormPresenter @Inject constructor(
|
|||||||
analytics.logEvent(
|
analytics.logEvent(
|
||||||
"registration_form",
|
"registration_form",
|
||||||
"success" to true,
|
"success" to true,
|
||||||
"scrapperBaseUrl" to host,
|
"scrapperBaseUrl" to loginData.baseUrl,
|
||||||
"error" to "No error"
|
"error" to "No error"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -187,7 +199,7 @@ class LoginFormPresenter @Inject constructor(
|
|||||||
analytics.logEvent(
|
analytics.logEvent(
|
||||||
"registration_form",
|
"registration_form",
|
||||||
"success" to false,
|
"success" to false,
|
||||||
"scrapperBaseUrl" to host,
|
"scrapperBaseUrl" to loginData.baseUrl,
|
||||||
"error" to it.message.ifNullOrBlank { "No message" }
|
"error" to it.message.ifNullOrBlank { "No message" }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -199,7 +211,14 @@ class LoginFormPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onEmailClick() {
|
fun onEmailClick() {
|
||||||
view?.openEmail(lastError?.message.ifNullOrBlank { "none" })
|
view?.openEmail(
|
||||||
|
LoginSupportInfo(
|
||||||
|
loginData = getLoginData(),
|
||||||
|
lastErrorMessage = lastError?.message,
|
||||||
|
registerUser = null,
|
||||||
|
enteredSymbol = null,
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onRecoverClick() {
|
fun onRecoverClick() {
|
||||||
|
@ -4,6 +4,7 @@ import io.github.wulkanowy.data.db.entities.AdminMessage
|
|||||||
import io.github.wulkanowy.data.pojos.RegisterUser
|
import io.github.wulkanowy.data.pojos.RegisterUser
|
||||||
import io.github.wulkanowy.ui.base.BaseView
|
import io.github.wulkanowy.ui.base.BaseView
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginData
|
import io.github.wulkanowy.ui.modules.login.LoginData
|
||||||
|
import io.github.wulkanowy.ui.modules.login.support.LoginSupportInfo
|
||||||
|
|
||||||
interface LoginFormView : BaseView {
|
interface LoginFormView : BaseView {
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ interface LoginFormView : BaseView {
|
|||||||
|
|
||||||
fun openFaqPage()
|
fun openFaqPage()
|
||||||
|
|
||||||
fun openEmail(lastError: String)
|
fun openEmail(supportInfo: LoginSupportInfo)
|
||||||
|
|
||||||
fun openAdvancedLogin()
|
fun openAdvancedLogin()
|
||||||
|
|
||||||
|
@ -10,8 +10,11 @@ import io.github.wulkanowy.data.pojos.RegisterUser
|
|||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import io.github.wulkanowy.databinding.FragmentLoginStudentSelectBinding
|
import io.github.wulkanowy.databinding.FragmentLoginStudentSelectBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
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.LoginActivity
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginData
|
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.AppInfo
|
||||||
import io.github.wulkanowy.utils.openEmailClient
|
import io.github.wulkanowy.utils.openEmailClient
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
@ -106,21 +109,8 @@ class LoginStudentSelectFragment :
|
|||||||
context?.openInternetBrowser("https://discord.gg/vccAQBr", ::showMessage)
|
context?.openInternetBrowser("https://discord.gg/vccAQBr", ::showMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openEmail(lastError: String) {
|
override fun openEmail(supportInfo: LoginSupportInfo) {
|
||||||
context?.openEmailClient(
|
LoginSupportDialog.newInstance(supportInfo).show(childFragmentManager, "support_dialog")
|
||||||
chooserTitle = requireContext().getString(R.string.login_email_intent_title),
|
|
||||||
email = "wulkanowyinc@gmail.com",
|
|
||||||
subject = requireContext().getString(R.string.login_email_subject),
|
|
||||||
body = requireContext().getString(
|
|
||||||
R.string.login_email_text,
|
|
||||||
"${appInfo.systemManufacturer} ${appInfo.systemModel}",
|
|
||||||
appInfo.systemVersion.toString(),
|
|
||||||
"${appInfo.versionName}-${appInfo.buildFlavor}",
|
|
||||||
"Select users to log in",
|
|
||||||
preferencesRepository.installationId,
|
|
||||||
lastError
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
@ -12,15 +12,14 @@ import io.github.wulkanowy.data.pojos.RegisterUser
|
|||||||
import io.github.wulkanowy.data.repositories.SchoolsRepository
|
import io.github.wulkanowy.data.repositories.SchoolsRepository
|
||||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||||
import io.github.wulkanowy.data.resourceFlow
|
import io.github.wulkanowy.data.resourceFlow
|
||||||
import io.github.wulkanowy.sdk.scrapper.login.AccountPermissionException
|
|
||||||
import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException
|
import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException
|
||||||
import io.github.wulkanowy.services.sync.SyncManager
|
import io.github.wulkanowy.services.sync.SyncManager
|
||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginData
|
import io.github.wulkanowy.ui.modules.login.LoginData
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
||||||
|
import io.github.wulkanowy.ui.modules.login.support.LoginSupportInfo
|
||||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.ifNullOrBlank
|
|
||||||
import io.github.wulkanowy.utils.isCurrent
|
import io.github.wulkanowy.utils.isCurrent
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -311,28 +310,14 @@ class LoginStudentSelectPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun onEmailClick() {
|
private fun onEmailClick() {
|
||||||
view?.openEmail(lastError?.message.ifNullOrBlank {
|
view?.openEmail(
|
||||||
loginData.baseUrl + "/" + loginData.symbol + "\n" + registerUser.symbols.filterNot {
|
LoginSupportInfo(
|
||||||
(it.error is AccountPermissionException || it.error is InvalidSymbolException) && it.symbol != loginData.symbol
|
loginData = loginData,
|
||||||
}.joinToString(";\n") { symbol ->
|
registerUser = registerUser,
|
||||||
buildString {
|
lastErrorMessage = lastError?.message,
|
||||||
append(" -")
|
enteredSymbol = loginData.symbol,
|
||||||
append(symbol.symbol)
|
)
|
||||||
append("(${symbol.error?.message?.let { it.take(46) + "..." } ?: symbol.schools.size})")
|
)
|
||||||
if (symbol.schools.isNotEmpty()) {
|
|
||||||
append(": ")
|
|
||||||
}
|
|
||||||
append(symbol.schools.joinToString(", ") { unit ->
|
|
||||||
buildString {
|
|
||||||
append(unit.schoolShortName)
|
|
||||||
append("(${unit.error?.message?.let { it.take(46) + "..." } ?: unit.students.size})")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} + "\nPozostałe: " + registerUser.symbols.filter {
|
|
||||||
it.error is AccountPermissionException || it.error is InvalidSymbolException
|
|
||||||
}.joinToString(", ") { it.symbol }
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun logRegisterEvent(
|
private fun logRegisterEvent(
|
||||||
|
@ -2,6 +2,7 @@ package io.github.wulkanowy.ui.modules.login.studentselect
|
|||||||
|
|
||||||
import io.github.wulkanowy.ui.base.BaseView
|
import io.github.wulkanowy.ui.base.BaseView
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginData
|
import io.github.wulkanowy.ui.modules.login.LoginData
|
||||||
|
import io.github.wulkanowy.ui.modules.login.support.LoginSupportInfo
|
||||||
|
|
||||||
interface LoginStudentSelectView : BaseView {
|
interface LoginStudentSelectView : BaseView {
|
||||||
|
|
||||||
@ -23,5 +24,5 @@ interface LoginStudentSelectView : BaseView {
|
|||||||
|
|
||||||
fun openDiscordInvite()
|
fun openDiscordInvite()
|
||||||
|
|
||||||
fun openEmail(lastError: String)
|
fun openEmail(supportInfo: LoginSupportInfo)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,133 @@
|
|||||||
|
package io.github.wulkanowy.ui.modules.login.support
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
|
import androidx.core.widget.doOnTextChanged
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
|
import io.github.wulkanowy.databinding.DialogLoginSupportBinding
|
||||||
|
import io.github.wulkanowy.sdk.scrapper.login.AccountPermissionException
|
||||||
|
import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException
|
||||||
|
import io.github.wulkanowy.ui.base.BaseDialogFragment
|
||||||
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
|
import io.github.wulkanowy.utils.openEmailClient
|
||||||
|
import io.github.wulkanowy.utils.serializable
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class LoginSupportDialog : BaseDialogFragment<DialogLoginSupportBinding>() {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var appInfo: AppInfo
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var preferencesRepository: PreferencesRepository
|
||||||
|
|
||||||
|
private lateinit var supportInfo: LoginSupportInfo
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val ARGUMENT_KEY = "info"
|
||||||
|
|
||||||
|
fun newInstance(info: LoginSupportInfo) = LoginSupportDialog().apply {
|
||||||
|
arguments = bundleOf(ARGUMENT_KEY to info)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setStyle(STYLE_NO_FRAME, R.style.WulkanowyTheme_NoActionBar)
|
||||||
|
supportInfo = requireArguments().serializable(ARGUMENT_KEY)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
val binding = DialogLoginSupportBinding.inflate(inflater)
|
||||||
|
.apply { binding = this }
|
||||||
|
binding.dialogLoginSupportToolbar.setNavigationOnClickListener { dismiss() }
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
with(binding) {
|
||||||
|
dialogLoginSupportSchoolInput.doOnTextChanged { _, _, _, _ ->
|
||||||
|
with(dialogLoginSupportSchoolLayout) {
|
||||||
|
isErrorEnabled = false
|
||||||
|
error = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogLoginSupportSubmit.setOnClickListener {
|
||||||
|
if (dialogLoginSupportSchoolInput.text.isNullOrBlank()) {
|
||||||
|
with(dialogLoginSupportSchoolLayout) {
|
||||||
|
isErrorEnabled = true
|
||||||
|
error = getString(R.string.error_field_required)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
onSubmitClick()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onSubmitClick() {
|
||||||
|
with(binding) {
|
||||||
|
context?.openEmailClient(
|
||||||
|
chooserTitle = requireContext().getString(R.string.login_email_intent_title),
|
||||||
|
email = "wulkanowyinc@gmail.com",
|
||||||
|
subject = requireContext().getString(R.string.login_email_subject),
|
||||||
|
body = requireContext().getString(
|
||||||
|
R.string.login_email_text,
|
||||||
|
"${appInfo.systemManufacturer} ${appInfo.systemModel}",
|
||||||
|
appInfo.systemVersion.toString(),
|
||||||
|
"${appInfo.versionName}-${appInfo.buildFlavor}",
|
||||||
|
supportInfo.loginData.baseUrl + "/" + supportInfo.loginData.symbol,
|
||||||
|
preferencesRepository.installationId,
|
||||||
|
getLastErrorFromStudentSelectScreen(),
|
||||||
|
dialogLoginSupportSchoolInput.text.takeIf { !it.isNullOrBlank() }
|
||||||
|
?: return@with,
|
||||||
|
dialogLoginSupportAdditionalInput.text,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getLastErrorFromStudentSelectScreen(): String {
|
||||||
|
if (!supportInfo.lastErrorMessage.isNullOrBlank()) {
|
||||||
|
return supportInfo.lastErrorMessage!!
|
||||||
|
}
|
||||||
|
if (supportInfo.registerUser?.symbols.isNullOrEmpty()) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return "\n" + supportInfo.registerUser?.symbols?.filterNot {
|
||||||
|
(it.error is AccountPermissionException || it.error is InvalidSymbolException) &&
|
||||||
|
it.symbol != supportInfo.enteredSymbol
|
||||||
|
}?.joinToString(";\n") { symbol ->
|
||||||
|
buildString {
|
||||||
|
append(" -")
|
||||||
|
append(symbol.symbol)
|
||||||
|
append("(${symbol.error?.message?.let { it.take(46) + "..." } ?: symbol.schools.size})")
|
||||||
|
if (symbol.schools.isNotEmpty()) {
|
||||||
|
append(": ")
|
||||||
|
}
|
||||||
|
append(symbol.schools.joinToString(", ") { unit ->
|
||||||
|
buildString {
|
||||||
|
append(unit.schoolShortName)
|
||||||
|
append("(${unit.error?.message?.let { it.take(46) + "..." } ?: unit.students.size})")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} + "\nPozostałe: " + supportInfo.registerUser?.symbols?.filter {
|
||||||
|
it.error is AccountPermissionException || it.error is InvalidSymbolException
|
||||||
|
}?.joinToString(", ") { it.symbol }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package io.github.wulkanowy.ui.modules.login.support
|
||||||
|
|
||||||
|
import io.github.wulkanowy.data.pojos.RegisterUser
|
||||||
|
import io.github.wulkanowy.ui.modules.login.LoginData
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
data class LoginSupportInfo(
|
||||||
|
val loginData: LoginData,
|
||||||
|
val registerUser: RegisterUser?,
|
||||||
|
val lastErrorMessage: String?,
|
||||||
|
val enteredSymbol: String?,
|
||||||
|
) : Serializable
|
@ -18,7 +18,13 @@ import io.github.wulkanowy.databinding.FragmentLoginSymbolBinding
|
|||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginData
|
import io.github.wulkanowy.ui.modules.login.LoginData
|
||||||
import io.github.wulkanowy.utils.*
|
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.hideSoftInput
|
||||||
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
|
import io.github.wulkanowy.utils.serializable
|
||||||
|
import io.github.wulkanowy.utils.showSoftInput
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@ -170,20 +176,7 @@ class LoginSymbolFragment :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openEmail(host: String, lastError: String) {
|
override fun openSupportDialog(supportInfo: LoginSupportInfo) {
|
||||||
context?.openEmailClient(
|
LoginSupportDialog.newInstance(supportInfo).show(childFragmentManager, "support_dialog")
|
||||||
chooserTitle = requireContext().getString(R.string.login_email_intent_title),
|
|
||||||
email = "wulkanowyinc@gmail.com",
|
|
||||||
subject = requireContext().getString(R.string.login_email_subject),
|
|
||||||
body = requireContext().getString(
|
|
||||||
R.string.login_email_text,
|
|
||||||
"${appInfo.systemManufacturer} ${appInfo.systemModel}",
|
|
||||||
appInfo.systemVersion.toString(),
|
|
||||||
"${appInfo.versionName}-${appInfo.buildFlavor}",
|
|
||||||
"$host/${binding.loginSymbolName.text}",
|
|
||||||
preferencesRepository.installationId,
|
|
||||||
lastError
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException
|
|||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginData
|
import io.github.wulkanowy.ui.modules.login.LoginData
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
||||||
|
import io.github.wulkanowy.ui.modules.login.support.LoginSupportInfo
|
||||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||||
import io.github.wulkanowy.utils.ifNullOrBlank
|
import io.github.wulkanowy.utils.ifNullOrBlank
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
@ -78,6 +79,7 @@ class LoginSymbolPresenter @Inject constructor(
|
|||||||
showProgress(true)
|
showProgress(true)
|
||||||
showContent(false)
|
showContent(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
is Resource.Success -> {
|
is Resource.Success -> {
|
||||||
when (user.data.symbols.size) {
|
when (user.data.symbols.size) {
|
||||||
0 -> {
|
0 -> {
|
||||||
@ -87,6 +89,7 @@ class LoginSymbolPresenter @Inject constructor(
|
|||||||
showContact(true)
|
showContact(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
val enteredSymbolDetails = user.data.symbols
|
val enteredSymbolDetails = user.data.symbols
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
@ -111,6 +114,7 @@ class LoginSymbolPresenter @Inject constructor(
|
|||||||
"error" to "No error"
|
"error" to "No error"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is Resource.Error -> {
|
is Resource.Error -> {
|
||||||
Timber.i("Login with symbol result: An exception occurred")
|
Timber.i("Login with symbol result: An exception occurred")
|
||||||
analytics.logEvent(
|
analytics.logEvent(
|
||||||
@ -146,12 +150,13 @@ class LoginSymbolPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onEmailClick() {
|
fun onEmailClick() {
|
||||||
view?.openEmail(loginData.baseUrl, lastError?.message.ifNullOrBlank {
|
view?.openSupportDialog(
|
||||||
registerUser?.symbols?.flatMap { symbol ->
|
LoginSupportInfo(
|
||||||
symbol.schools.map { it.error?.message } + symbol.error?.message
|
loginData = loginData,
|
||||||
}?.filterNotNull()?.distinct()?.joinToString(";") {
|
registerUser = registerUser,
|
||||||
it.take(46) + "..."
|
lastErrorMessage = lastError?.message,
|
||||||
} ?: "blank"
|
enteredSymbol = view?.symbolValue,
|
||||||
})
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package io.github.wulkanowy.ui.modules.login.symbol
|
|||||||
import io.github.wulkanowy.data.pojos.RegisterUser
|
import io.github.wulkanowy.data.pojos.RegisterUser
|
||||||
import io.github.wulkanowy.ui.base.BaseView
|
import io.github.wulkanowy.ui.base.BaseView
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginData
|
import io.github.wulkanowy.ui.modules.login.LoginData
|
||||||
|
import io.github.wulkanowy.ui.modules.login.support.LoginSupportInfo
|
||||||
|
|
||||||
interface LoginSymbolView : BaseView {
|
interface LoginSymbolView : BaseView {
|
||||||
|
|
||||||
@ -42,5 +43,5 @@ interface LoginSymbolView : BaseView {
|
|||||||
|
|
||||||
fun openFaqPage()
|
fun openFaqPage()
|
||||||
|
|
||||||
fun openEmail(host: String, lastError: String)
|
fun openSupportDialog(supportInfo: LoginSupportInfo)
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,6 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
|||||||
|
|
||||||
//https://developer.android.com/guide/playcore/in-app-updates#status_callback
|
//https://developer.android.com/guide/playcore/in-app-updates#status_callback
|
||||||
@Deprecated("Deprecated in Java")
|
@Deprecated("Deprecated in Java")
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
updateHelper.onActivityResult(requestCode, resultCode)
|
updateHelper.onActivityResult(requestCode, resultCode)
|
||||||
|
92
app/src/main/res/layout/dialog_login_support.xml
Normal file
92
app/src/main/res/layout/dialog_login_support.xml
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:windowBackground"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@+id/dialog_login_support_toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:navigationIcon="?attr/homeAsUpIndicator"
|
||||||
|
app:navigationIconTint="?attr/colorOnSurfaceVariant"
|
||||||
|
app:title="@string/login_support_title" />
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/dialog_login_support_school_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="20dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/login_support_school_hint" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/dialog_login_support_school_layout"
|
||||||
|
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:placeholderText="@string/login_support_school_placeholder"
|
||||||
|
app:placeholderTextColor="?colorTertiary">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/dialog_login_support_school_input"
|
||||||
|
style="@style/Widget.Material3.TextInputEditText.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="top" />
|
||||||
|
|
||||||
|
<requestFocus />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:text="@string/login_support_additional_hint" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="top"
|
||||||
|
app:placeholderText="@string/login_support_additional_placeholder"
|
||||||
|
app:placeholderTextColor="?colorTertiary">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/dialog_login_support_additional_input"
|
||||||
|
style="@style/Widget.Material3.TextInputEditText.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="top"
|
||||||
|
android:minLines="3" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/dialog_login_support_submit"
|
||||||
|
style="@style/Widget.Material3.Button.TextButton.Dialog"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:insetLeft="0dp"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetRight="0dp"
|
||||||
|
android:insetBottom="0dp"
|
||||||
|
android:text="@string/login_support_submit" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -26,7 +26,8 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingTop="6dp"
|
android:paddingTop="6dp"
|
||||||
android:paddingBottom="6dp" />
|
android:paddingBottom="6dp"
|
||||||
|
tools:listitem="@layout/item_dashboard_grades" />
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -79,4 +80,4 @@
|
|||||||
android:text="@string/all_retry" />
|
android:text="@string/all_retry" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
<string name="login_contact_discord">Discord</string>
|
<string name="login_contact_discord">Discord</string>
|
||||||
<string name="login_email_intent_title">Send email</string>
|
<string name="login_email_intent_title">Send email</string>
|
||||||
<string name="login_email_subject" translatable="false">Zgłoszenie: Problemy z logowaniem</string>
|
<string name="login_email_subject" translatable="false">Zgłoszenie: Problemy z logowaniem</string>
|
||||||
<string name="login_email_text" translatable="false">Informacje o aplikacji:\n\nUrządzenie: %1$s\nWersja SDK: %2$s\nWersja aplikacji: %3$s\nDodatkowe informacje: %4$s\nIdentyfikator instalacji: %5$s\nOstatni błąd: %6$s\n\nNazwa szkoły i miejscowość: </string>
|
<string name="login_email_text" translatable="false">Informacje o aplikacji:\n\nUrządzenie: %1$s\nWersja SDK: %2$s\nWersja aplikacji: %3$s\nDodatkowe informacje: %4$s\nIdentyfikator instalacji: %5$s\nOstatni błąd: %6$s\n\nNazwa szkoły i miejscowość: %7$s\nDodatkowe informacje: %8$s</string>
|
||||||
<string name="login_recover_warning">Make sure you select the correct UONET+ register variation!</string>
|
<string name="login_recover_warning">Make sure you select the correct UONET+ register variation!</string>
|
||||||
<string name="login_recover_button">Reset password</string>
|
<string name="login_recover_button">Reset password</string>
|
||||||
<string name="login_recover_title">Recover your account</string>
|
<string name="login_recover_title">Recover your account</string>
|
||||||
@ -86,6 +86,12 @@
|
|||||||
<string name="login_other_search_locations">Other search locations</string>
|
<string name="login_other_search_locations">Other search locations</string>
|
||||||
<string name="login_no_active_student">No active students found</string>
|
<string name="login_no_active_student">No active students found</string>
|
||||||
<string name="login_symbol_enter">Enter a different symbol</string>
|
<string name="login_symbol_enter">Enter a different symbol</string>
|
||||||
|
<string name="login_support_title">Get help</string>
|
||||||
|
<string name="login_support_school_hint">Full school name (required)</string>
|
||||||
|
<string name="login_support_school_placeholder">Np. ZSTiO Jarosław lub SP nr 99 w Łodzi</string>
|
||||||
|
<string name="login_support_additional_hint">Additional information in Polish (optional)</string>
|
||||||
|
<string name="login_support_additional_placeholder">Np. \"Ostatnio zmieniłem szkołę i…\" albo \"Jestem rodzicem i nie widzę drugiego dziecka…\"</string>
|
||||||
|
<string name="login_support_submit">Submit</string>
|
||||||
|
|
||||||
|
|
||||||
<!--Notifications-->
|
<!--Notifications-->
|
||||||
|
@ -82,7 +82,6 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="FullScreenDialogStyle" parent="WulkanowyTheme">
|
<style name="FullScreenDialogStyle" parent="WulkanowyTheme">
|
||||||
<item name="android:windowFullscreen">true</item>
|
|
||||||
<item name="android:windowIsFloating">false</item>
|
<item name="android:windowIsFloating">false</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user