From cfe9846ebbdaad5d575cbe906cf38e8552736613 Mon Sep 17 00:00:00 2001 From: tateisu Date: Mon, 24 Feb 2020 13:00:58 +0900 Subject: [PATCH] fix #134, add error message when browser app is not installed. --- .../main/java/jp/juggler/subwaytooter/App1.kt | 7 +++++-- .../subwaytooter/dialog/DlgAppPicker.kt | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/jp/juggler/subwaytooter/App1.kt b/app/src/main/java/jp/juggler/subwaytooter/App1.kt index 61b04aa4..ce2a46eb 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/App1.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/App1.kt @@ -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 ) diff --git a/app/src/main/java/jp/juggler/subwaytooter/dialog/DlgAppPicker.kt b/app/src/main/java/jp/juggler/subwaytooter/dialog/DlgAppPicker.kt index 72592e71..d7bec958 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/dialog/DlgAppPicker.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/dialog/DlgAppPicker.kt @@ -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,12 +99,17 @@ class DlgAppPicker( @SuppressLint("InflateParams") fun show() { - dialog?.run { - window?.setLayout( - WindowManager.LayoutParams.MATCH_PARENT, - WindowManager.LayoutParams.WRAP_CONTENT - ) - this.show() + if( list.isEmpty()){ + dialog?.dismissSafe() + showToast(activity,true,emptyError) + }else { + dialog?.run { + window?.setLayout( + WindowManager.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.WRAP_CONTENT + ) + this.show() + } } }