This commit is contained in:
Mygod
2018-12-30 17:57:53 +08:00
parent f0a89d5498
commit 5abd3661c3
2 changed files with 7 additions and 10 deletions

View File

@@ -9,7 +9,6 @@ import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.browser.customtabs.CustomTabsIntent import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
@@ -35,15 +34,13 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
.build() .build()
} }
fun launchUrl(url: Uri) = if (packageManager.hasSystemFeature("android.hardware.faketouch")) try { fun launchUrl(url: Uri) {
customTabsIntent.launchUrl(this, url) if (packageManager.hasSystemFeature("android.hardware.faketouch")) try {
} catch (e: ActivityNotFoundException) { customTabsIntent.launchUrl(this, url)
DebugHelper.logEvent("launch_url", bundleOf(Pair("message", e.message))) return
} catch (_: ActivityNotFoundException) { } catch (_: SecurityException) { }
SmartSnackbar.make(url.toString()).show() SmartSnackbar.make(url.toString()).show()
} catch (e: SecurityException) { }
DebugHelper.logEvent("launch_url", bundleOf(Pair("message", e.message)))
SmartSnackbar.make(url.toString()).show()
} else SmartSnackbar.make(url.toString()).show()
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)

View File

@@ -54,7 +54,7 @@ object ManageBar : Manager() {
private fun startAlternative(context: Context, e: RuntimeException) { private fun startAlternative(context: Context, e: RuntimeException) {
try { try {
context.startActivity(Intent().setClassName("com.android.settings", SETTINGS_2)) context.startActivity(Intent().setClassName(SETTINGS_PACKAGE, SETTINGS_2))
DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e.message))) DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e.message)))
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e.message), Pair(SETTINGS_2, e.message))) DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e.message), Pair(SETTINGS_2, e.message)))