mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 18:42:44 +01:00
Fix crash when no webview activity (#338)
This commit is contained in:
parent
103ab95c80
commit
d169f964f2
@ -12,6 +12,7 @@ import io.github.wulkanowy.BuildConfig
|
|||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import io.github.wulkanowy.utils.withOnExtraListener
|
import io.github.wulkanowy.utils.withOnExtraListener
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -57,11 +58,11 @@ class AboutFragment : BaseFragment(), AboutView, MainView.TitledView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun openDiscordInviteView() {
|
override fun openDiscordInviteView() {
|
||||||
startActivity(Intent.parseUri("https://discord.gg/vccAQBr", 0))
|
context?.openInternetBrowser("https://discord.gg/vccAQBr", ::showMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openHomepageWebView() {
|
override fun openHomepageWebView() {
|
||||||
startActivity(Intent.parseUri("https://wulkanowy.github.io/", 0))
|
context?.openInternetBrowser("https://wulkanowy.github.io/", ::showMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openEmailClientView() {
|
override fun openEmailClientView() {
|
||||||
@ -80,7 +81,7 @@ class AboutFragment : BaseFragment(), AboutView, MainView.TitledView {
|
|||||||
if (intent.resolveActivity(it.packageManager) != null) {
|
if (intent.resolveActivity(it.packageManager) != null) {
|
||||||
startActivity(Intent.createChooser(intent, getString(R.string.about_feedback)))
|
startActivity(Intent.createChooser(intent, getString(R.string.about_feedback)))
|
||||||
} else {
|
} else {
|
||||||
startActivity(Intent.parseUri("https://github.com/wulkanowy/wulkanowy/issues", 0))
|
it.openInternetBrowser("https://github.com/wulkanowy/wulkanowy/issues", ::showMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package io.github.wulkanowy.ui.modules.login.form
|
package io.github.wulkanowy.ui.modules.login.form
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -17,6 +16,7 @@ import io.github.wulkanowy.data.db.entities.Student
|
|||||||
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.utils.hideSoftInput
|
import io.github.wulkanowy.utils.hideSoftInput
|
||||||
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import io.github.wulkanowy.utils.setOnItemSelectedListener
|
import io.github.wulkanowy.utils.setOnItemSelectedListener
|
||||||
import io.github.wulkanowy.utils.setOnTextChangedListener
|
import io.github.wulkanowy.utils.setOnTextChangedListener
|
||||||
import io.github.wulkanowy.utils.showSoftInput
|
import io.github.wulkanowy.utils.showSoftInput
|
||||||
@ -145,7 +145,7 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun openPrivacyPolicyPage() {
|
override fun openPrivacyPolicyPage() {
|
||||||
startActivity(Intent.parseUri("https://wulkanowy.github.io/polityka-prywatnosci.html", 0))
|
context?.openInternetBrowser("https://wulkanowy.github.io/polityka-prywatnosci.html", ::showMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
@ -4,7 +4,6 @@ import android.app.Activity
|
|||||||
import android.content.Context.INPUT_METHOD_SERVICE
|
import android.content.Context.INPUT_METHOD_SERVICE
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
|
||||||
|
|
||||||
fun Activity.showSoftInput() {
|
fun Activity.showSoftInput() {
|
||||||
(getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager?)?.run {
|
(getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager?)?.run {
|
||||||
if (currentFocus != null) showSoftInput(currentFocus, 0)
|
if (currentFocus != null) showSoftInput(currentFocus, 0)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package io.github.wulkanowy.utils
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.AttrRes
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
@ -18,3 +19,10 @@ fun Context.getThemeAttrColor(@AttrRes colorAttr: Int): Int {
|
|||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun Context.getCompatColor(@ColorRes colorRes: Int) = ContextCompat.getColor(this, colorRes)
|
fun Context.getCompatColor(@ColorRes colorRes: Int) = ContextCompat.getColor(this, colorRes)
|
||||||
|
|
||||||
|
fun Context.openInternetBrowser(uri: String, onActivityNotFound: (uri: String) -> Unit) {
|
||||||
|
Intent.parseUri(uri, 0).let {
|
||||||
|
if (it.resolveActivity(packageManager) != null) startActivity(it)
|
||||||
|
else onActivityNotFound(uri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user