fixed bug in nextcloud auth
This commit is contained in:
parent
8ae7365852
commit
1b0d10183f
|
@ -22,6 +22,7 @@ class NextcloudLoginFlow(private val httpClient: OkHttpClient, private val rawHo
|
||||||
private val hostname = HostnameParser(rawHostUrl)
|
private val hostname = HostnameParser(rawHostUrl)
|
||||||
private var token: String? = null
|
private var token: String? = null
|
||||||
private var endpoint: String? = null
|
private var endpoint: String? = null
|
||||||
|
private var isWaitingForBrowser:Boolean = false
|
||||||
|
|
||||||
fun saveInstanceState(): ArrayList<String?> {
|
fun saveInstanceState(): ArrayList<String?> {
|
||||||
val state = ArrayList<String?>()
|
val state = ArrayList<String?>()
|
||||||
|
@ -51,7 +52,7 @@ class NextcloudLoginFlow(private val httpClient: OkHttpClient, private val rawHo
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(result))
|
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(result))
|
||||||
context.startActivity(browserIntent)
|
context.startActivity(browserIntent)
|
||||||
poll()
|
isWaitingForBrowser = true
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
Log.e(TAG, Log.getStackTraceString(e))
|
Log.e(TAG, Log.getStackTraceString(e))
|
||||||
|
@ -79,6 +80,13 @@ class NextcloudLoginFlow(private val httpClient: OkHttpClient, private val rawHo
|
||||||
throw RuntimeException("Maximum retries exceeded")
|
throw RuntimeException("Maximum retries exceeded")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onResume(){ //trigger poll only when returning from the browser
|
||||||
|
if (token != null && isWaitingForBrowser){
|
||||||
|
poll()
|
||||||
|
isWaitingForBrowser = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun poll() {
|
private fun poll() {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -285,6 +285,8 @@ class SynchronizationPreferencesFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
nextcloudLoginFlow?.onResume()
|
||||||
|
|
||||||
if (shouldDismiss) dismiss()
|
if (shouldDismiss) dismiss()
|
||||||
}
|
}
|
||||||
override fun onNextcloudAuthenticated(server: String, username: String, password: String) {
|
override fun onNextcloudAuthenticated(server: String, username: String, password: String) {
|
||||||
|
|
Loading…
Reference in New Issue