fix #134, add error message when browser app is not installed.
This commit is contained in:
parent
0ae804a4dc
commit
cfe9846ebb
|
@ -599,6 +599,7 @@ class App1 : Application() {
|
|||
private fun startActivityExcludeMyApp(
|
||||
activity : AppCompatActivity,
|
||||
intent : Intent,
|
||||
emptyError:String,
|
||||
startAnimationBundle : Bundle? = null
|
||||
) {
|
||||
try {
|
||||
|
@ -613,6 +614,7 @@ class App1 : Application() {
|
|||
DlgAppPicker(
|
||||
activity,
|
||||
intent,
|
||||
emptyError,
|
||||
autoSelect = true,
|
||||
filter = {it.activityInfo.packageName != activity.packageName }
|
||||
) {
|
||||
|
@ -632,7 +634,7 @@ class App1 : Application() {
|
|||
}
|
||||
|
||||
fun openBrowser(activity : AppCompatActivity, uri : Uri?) {
|
||||
if(uri != null) startActivityExcludeMyApp(activity, Intent(Intent.ACTION_VIEW, uri))
|
||||
if(uri != null) startActivityExcludeMyApp(activity, Intent(Intent.ACTION_VIEW, uri),"there is no app that can open $uri")
|
||||
}
|
||||
|
||||
fun openBrowser(activity : AppCompatActivity, url : String?) =
|
||||
|
@ -681,13 +683,13 @@ class App1 : Application() {
|
|||
)
|
||||
it.data = url.toUri()
|
||||
},
|
||||
"chrome(product line) is not installed.",
|
||||
customTabsIntent.startAnimationBundle
|
||||
)
|
||||
return
|
||||
} catch(ex2 : Throwable) {
|
||||
log.e(ex2, "openChromeTab: missing chrome. retry to other application.")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Chromeがないようなのでcomponent指定なしでリトライ
|
||||
|
@ -701,6 +703,7 @@ class App1 : Application() {
|
|||
customTabsIntent.intent.also {
|
||||
it.data = url.toUri()
|
||||
},
|
||||
"the app that supports custom tabs is not installed.",
|
||||
customTabsIntent.startAnimationBundle
|
||||
)
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import jp.juggler.util.*
|
|||
class DlgAppPicker(
|
||||
val activity : AppCompatActivity,
|
||||
val intent : Intent,
|
||||
val emptyError: String ,
|
||||
val autoSelect : Boolean = false,
|
||||
val filter : (ResolveInfo) -> Boolean = { true },
|
||||
val callback : (String) -> Unit
|
||||
|
@ -98,6 +99,10 @@ class DlgAppPicker(
|
|||
|
||||
@SuppressLint("InflateParams")
|
||||
fun show() {
|
||||
if( list.isEmpty()){
|
||||
dialog?.dismissSafe()
|
||||
showToast(activity,true,emptyError)
|
||||
}else {
|
||||
dialog?.run {
|
||||
window?.setLayout(
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
|
@ -106,6 +111,7 @@ class DlgAppPicker(
|
|||
this.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class MyAdapter : BaseAdapter(), AdapterView.OnItemClickListener {
|
||||
|
||||
|
|
Loading…
Reference in New Issue