|
|
|
@ -16,6 +16,7 @@ import org.koitharu.kotatsu.R
|
|
|
|
import org.koitharu.kotatsu.base.ui.BaseActivity
|
|
|
|
import org.koitharu.kotatsu.base.ui.BaseActivity
|
|
|
|
import org.koitharu.kotatsu.browser.BrowserCallback
|
|
|
|
import org.koitharu.kotatsu.browser.BrowserCallback
|
|
|
|
import org.koitharu.kotatsu.browser.BrowserClient
|
|
|
|
import org.koitharu.kotatsu.browser.BrowserClient
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.browser.ProgressChromeClient
|
|
|
|
import org.koitharu.kotatsu.core.model.MangaSource
|
|
|
|
import org.koitharu.kotatsu.core.model.MangaSource
|
|
|
|
import org.koitharu.kotatsu.core.parser.MangaRepositoryAuthProvider
|
|
|
|
import org.koitharu.kotatsu.core.parser.MangaRepositoryAuthProvider
|
|
|
|
import org.koitharu.kotatsu.databinding.ActivityBrowserBinding
|
|
|
|
import org.koitharu.kotatsu.databinding.ActivityBrowserBinding
|
|
|
|
@ -33,7 +34,7 @@ class SourceAuthActivity : BaseActivity<ActivityBrowserBinding>(), BrowserCallba
|
|
|
|
setContentView(ActivityBrowserBinding.inflate(layoutInflater))
|
|
|
|
setContentView(ActivityBrowserBinding.inflate(layoutInflater))
|
|
|
|
val source = intent?.getParcelableExtra<MangaSource>(EXTRA_SOURCE)
|
|
|
|
val source = intent?.getParcelableExtra<MangaSource>(EXTRA_SOURCE)
|
|
|
|
if (source == null) {
|
|
|
|
if (source == null) {
|
|
|
|
finish()
|
|
|
|
finishAfterTransition()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
repository = mangaRepositoryOf(source) as? MangaRepositoryAuthProvider ?: run {
|
|
|
|
repository = mangaRepositoryOf(source) as? MangaRepositoryAuthProvider ?: run {
|
|
|
|
@ -53,6 +54,10 @@ class SourceAuthActivity : BaseActivity<ActivityBrowserBinding>(), BrowserCallba
|
|
|
|
javaScriptEnabled = true
|
|
|
|
javaScriptEnabled = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
binding.webView.webViewClient = BrowserClient(this)
|
|
|
|
binding.webView.webViewClient = BrowserClient(this)
|
|
|
|
|
|
|
|
binding.webView.webChromeClient = ProgressChromeClient(binding.progressBar)
|
|
|
|
|
|
|
|
if (savedInstanceState != null) {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
val url = repository.authUrl
|
|
|
|
val url = repository.authUrl
|
|
|
|
onTitleChanged(
|
|
|
|
onTitleChanged(
|
|
|
|
source.title,
|
|
|
|
source.title,
|
|
|
|
@ -61,6 +66,21 @@ class SourceAuthActivity : BaseActivity<ActivityBrowserBinding>(), BrowserCallba
|
|
|
|
binding.webView.loadUrl(url)
|
|
|
|
binding.webView.loadUrl(url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onSaveInstanceState(outState: Bundle) {
|
|
|
|
|
|
|
|
super.onSaveInstanceState(outState)
|
|
|
|
|
|
|
|
binding.webView.saveState(outState)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
|
|
|
|
|
|
|
super.onRestoreInstanceState(savedInstanceState)
|
|
|
|
|
|
|
|
binding.webView.restoreState(savedInstanceState)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onDestroy() {
|
|
|
|
|
|
|
|
super.onDestroy()
|
|
|
|
|
|
|
|
binding.webView.destroy()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
|
|
|
|
android.R.id.home -> {
|
|
|
|
android.R.id.home -> {
|
|
|
|
binding.webView.stopLoading()
|
|
|
|
binding.webView.stopLoading()
|
|
|
|
|