forked from github/wulkanowy-mirror
Fix very rare crash in login recovery (#1231)
This commit is contained in:
parent
5bee155f1e
commit
1560335749
@ -9,6 +9,7 @@ import android.view.View.VISIBLE
|
|||||||
import android.webkit.JavascriptInterface
|
import android.webkit.JavascriptInterface
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.webkit.WebViewClient
|
import android.webkit.WebViewClient
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
@ -42,10 +43,12 @@ class LoginRecoverFragment :
|
|||||||
private lateinit var hostSymbols: Array<String>
|
private lateinit var hostSymbols: Array<String>
|
||||||
|
|
||||||
override val recoverHostValue: String
|
override val recoverHostValue: String
|
||||||
get() = hostValues.getOrNull(hostKeys.indexOf(bindingLocal.loginRecoverHost.text.toString())).orEmpty()
|
get() = hostValues.getOrNull(hostKeys.indexOf(bindingLocal.loginRecoverHost.text.toString()))
|
||||||
|
.orEmpty()
|
||||||
|
|
||||||
override val formHostSymbol: String
|
override val formHostSymbol: String
|
||||||
get() = hostSymbols.getOrNull(hostKeys.indexOf(bindingLocal.loginRecoverHost.text.toString())).orEmpty()
|
get() = hostSymbols.getOrNull(hostKeys.indexOf(bindingLocal.loginRecoverHost.text.toString()))
|
||||||
|
.orEmpty()
|
||||||
|
|
||||||
override val recoverNameValue: String
|
override val recoverNameValue: String
|
||||||
get() = bindingLocal.loginRecoverName.text.toString().trim()
|
get() = bindingLocal.loginRecoverName.text.toString().trim()
|
||||||
@ -82,7 +85,9 @@ class LoginRecoverFragment :
|
|||||||
|
|
||||||
with(bindingLocal.loginRecoverHost) {
|
with(bindingLocal.loginRecoverHost) {
|
||||||
setText(hostKeys.getOrNull(0).orEmpty())
|
setText(hostKeys.getOrNull(0).orEmpty())
|
||||||
setAdapter(LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
|
setAdapter(
|
||||||
|
LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys)
|
||||||
|
)
|
||||||
setOnClickListener { if (bindingLocal.loginRecoverFormContainer.visibility == GONE) dismissDropDown() }
|
setOnClickListener { if (bindingLocal.loginRecoverFormContainer.visibility == GONE) dismissDropDown() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,6 +132,7 @@ class LoginRecoverFragment :
|
|||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
bindingLocal.loginRecoverError.visibility = if (show) VISIBLE else GONE
|
bindingLocal.loginRecoverError.visibility = if (show) VISIBLE else GONE
|
||||||
|
bindingLocal.loginRecoverErrorDetails.isVisible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
@ -166,7 +172,7 @@ class LoginRecoverFragment :
|
|||||||
with(bindingLocal.loginRecoverWebView) {
|
with(bindingLocal.loginRecoverWebView) {
|
||||||
settings.javaScriptEnabled = true
|
settings.javaScriptEnabled = true
|
||||||
webViewClient = object : WebViewClient() {
|
webViewClient = object : WebViewClient() {
|
||||||
private var recoverWebViewSuccess: Boolean = true
|
private var recoverWebViewSuccess = true
|
||||||
|
|
||||||
override fun onPageFinished(view: WebView?, url: String?) {
|
override fun onPageFinished(view: WebView?, url: String?) {
|
||||||
if (recoverWebViewSuccess) {
|
if (recoverWebViewSuccess) {
|
||||||
@ -175,10 +181,16 @@ class LoginRecoverFragment :
|
|||||||
} else {
|
} else {
|
||||||
showProgress(false)
|
showProgress(false)
|
||||||
showErrorView(true)
|
showErrorView(true)
|
||||||
|
bindingLocal.loginRecoverErrorDetails.isVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String) {
|
override fun onReceivedError(
|
||||||
|
view: WebView,
|
||||||
|
errorCode: Int,
|
||||||
|
description: String,
|
||||||
|
failingUrl: String
|
||||||
|
) {
|
||||||
recoverWebViewSuccess = false
|
recoverWebViewSuccess = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="16dp"
|
android:paddingBottom="16dp"
|
||||||
android:visibility="visible">
|
android:visibility="gone">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/loginFormHeader"
|
android:id="@+id/loginFormHeader"
|
||||||
@ -85,9 +85,9 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:autofillHints="emailAddress"
|
android:autofillHints="emailAddress"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
android:inputType="textEmailAddress"
|
android:inputType="textEmailAddress"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:imeOptions="actionDone"
|
|
||||||
tools:targetApi="o" />
|
tools:targetApi="o" />
|
||||||
|
|
||||||
<requestFocus />
|
<requestFocus />
|
||||||
@ -156,7 +156,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
tools:ignore="UseCompoundDrawables"
|
tools:ignore="UseCompoundDrawables"
|
||||||
tools:visibility="invisible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
@ -175,12 +175,10 @@
|
|||||||
android:text="@string/error_unknown"
|
android:text="@string/error_unknown"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp">
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/loginRecoverErrorDetails"
|
android:id="@+id/loginRecoverErrorDetails"
|
||||||
@ -189,14 +187,21 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:text="@string/all_details" />
|
android:text="@string/all_details"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/loginRecoverErrorRetry"
|
||||||
|
app:layout_constraintHorizontal_chainStyle="packed"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/loginRecoverErrorRetry"
|
android:id="@+id/loginRecoverErrorRetry"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/all_retry" />
|
android:text="@string/all_retry"
|
||||||
</LinearLayout>
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/loginRecoverErrorDetails"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
@ -206,7 +211,7 @@
|
|||||||
android:fillViewport="true"
|
android:fillViewport="true"
|
||||||
android:scrollbars="none"
|
android:scrollbars="none"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
tools:visibility="invisible">
|
tools:visibility="gone">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -253,6 +258,5 @@
|
|||||||
android:layout_marginBottom="30dp"
|
android:layout_marginBottom="30dp"
|
||||||
android:text="@android:string/ok" />
|
android:text="@android:string/ok" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user