From 21108679408f34dbdcc31ff3af746f998b98029a Mon Sep 17 00:00:00 2001 From: Mufanc Date: Fri, 24 May 2024 00:38:55 +0800 Subject: [PATCH] refactor: toast when no available provider was found --- .../applock/ui/widgets/ScopeProviderSelectorDialog.kt | 6 ++++++ app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 8 insertions(+) diff --git a/app/src/main/java/xyz/mufanc/applock/ui/widgets/ScopeProviderSelectorDialog.kt b/app/src/main/java/xyz/mufanc/applock/ui/widgets/ScopeProviderSelectorDialog.kt index 31832c5..dd14c3c 100644 --- a/app/src/main/java/xyz/mufanc/applock/ui/widgets/ScopeProviderSelectorDialog.kt +++ b/app/src/main/java/xyz/mufanc/applock/ui/widgets/ScopeProviderSelectorDialog.kt @@ -9,6 +9,7 @@ import android.os.Bundle import android.view.View import android.view.ViewGroup import android.widget.ArrayAdapter +import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.lifecycle.asLiveData import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -31,6 +32,11 @@ class ScopeProviderSelectorDialog private constructor( val service = AppLockService.client() ?: return null val availableProviders = service.availableProviders.toSet() + if (availableProviders.isEmpty()) { + Toast.makeText(activity, R.string.message_no_available_provider, Toast.LENGTH_SHORT).show() + return null + } + Log.d(TAG, "available providers: $availableProviders") Log.d(TAG, "disabled providers: ${disabledProviders.value?.all?.keys}") diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index f07fe9c..6225790 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -30,6 +30,7 @@ 点击查看 + 无可用的提供器 默认 媒体会话 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 31da648..17936e4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,6 +33,7 @@ Click to show + No available provider Default Default