diff --git a/components/feature/search/src/main/java/mozilla/components/feature/search/widget/AppSearchWidgetProvider.kt b/components/feature/search/src/main/java/mozilla/components/feature/search/widget/AppSearchWidgetProvider.kt index 520cbbbdd3b..3a941c715a7 100644 --- a/components/feature/search/src/main/java/mozilla/components/feature/search/widget/AppSearchWidgetProvider.kt +++ b/components/feature/search/src/main/java/mozilla/components/feature/search/widget/AppSearchWidgetProvider.kt @@ -22,7 +22,7 @@ import androidx.annotation.VisibleForTesting import androidx.appcompat.content.res.AppCompatResources import androidx.core.graphics.drawable.toBitmap import mozilla.components.feature.search.R -import mozilla.components.feature.search.widget.VoiceSearchActivity.Companion.SPEECH_PROCESSING +import mozilla.components.feature.search.widget.BaseVoiceSearchActivity.Companion.SPEECH_PROCESSING import mozilla.components.support.utils.PendingIntentUtils /** @@ -81,7 +81,7 @@ abstract class AppSearchWidgetProvider : AppWidgetProvider() { /** * Activity that extends VoiceSearchActivity */ - abstract fun voiceSearchActivity(): VoiceSearchActivity + abstract fun voiceSearchActivity(): BaseVoiceSearchActivity /** * Config that sets the icons and the strings for search widget @@ -239,18 +239,17 @@ abstract class AppSearchWidgetProvider : AppWidgetProvider() { /** * It updates AppSearchWidgetProvider size and microphone icon visibility */ - fun updateAllWidgets(context: Context, widgetClassNameApp: AppSearchWidgetProvider) { + fun updateAllWidgets(context: Context, clazz: Class) { val widgetManager = AppWidgetManager.getInstance(context) val widgetIds = widgetManager.getAppWidgetIds( ComponentName( context, - widgetClassNameApp::class.java + clazz ) ) - if (widgetIds.isNotEmpty()) { context.sendBroadcast( - Intent(context, widgetClassNameApp::class.java).apply { + Intent(context, clazz).apply { action = AppWidgetManager.ACTION_APPWIDGET_UPDATE putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds) } diff --git a/components/feature/search/src/main/java/mozilla/components/feature/search/widget/VoiceSearchActivity.kt b/components/feature/search/src/main/java/mozilla/components/feature/search/widget/BaseVoiceSearchActivity.kt similarity index 96% rename from components/feature/search/src/main/java/mozilla/components/feature/search/widget/VoiceSearchActivity.kt rename to components/feature/search/src/main/java/mozilla/components/feature/search/widget/BaseVoiceSearchActivity.kt index 5e91ebdd70a..517ee67ad75 100644 --- a/components/feature/search/src/main/java/mozilla/components/feature/search/widget/VoiceSearchActivity.kt +++ b/components/feature/search/src/main/java/mozilla/components/feature/search/widget/BaseVoiceSearchActivity.kt @@ -18,7 +18,7 @@ import java.util.Locale /** * Launches voice recognition then uses it to start a new web search. */ -abstract class VoiceSearchActivity : AppCompatActivity() { +abstract class BaseVoiceSearchActivity : AppCompatActivity() { /** * Holds the intent that initially started this activity @@ -125,7 +125,7 @@ abstract class VoiceSearchActivity : AppCompatActivity() { const val PREVIOUS_INTENT = "org.mozilla.components.previous_intent" /** - * In [VoiceSearchActivity] activity, used to store if the speech processing should start. + * In [BaseVoiceSearchActivity] activity, used to store if the speech processing should start. */ const val SPEECH_PROCESSING = "speech_processing" } diff --git a/components/feature/search/src/test/java/mozilla/components/feature/search/widget/VoiceSearchActivityExtendedForTests.kt b/components/feature/search/src/test/java/mozilla/components/feature/search/widget/VoiceSearchActivityExtendedForTests.kt index 0fa7668041a..51560436961 100644 --- a/components/feature/search/src/test/java/mozilla/components/feature/search/widget/VoiceSearchActivityExtendedForTests.kt +++ b/components/feature/search/src/test/java/mozilla/components/feature/search/widget/VoiceSearchActivityExtendedForTests.kt @@ -6,7 +6,7 @@ package mozilla.components.feature.search.widget import java.util.Locale -class VoiceSearchActivityExtendedForTests : VoiceSearchActivity() { +class VoiceSearchActivityExtendedForTests : BaseVoiceSearchActivity() { override fun getCurrentLocale(): Locale { return Locale.getDefault() diff --git a/components/feature/search/src/test/java/mozilla/components/feature/search/widget/VoiceSearchActivityTest.kt b/components/feature/search/src/test/java/mozilla/components/feature/search/widget/VoiceSearchActivityTest.kt index 6f3be55d9ce..f5cf91f5a92 100644 --- a/components/feature/search/src/test/java/mozilla/components/feature/search/widget/VoiceSearchActivityTest.kt +++ b/components/feature/search/src/test/java/mozilla/components/feature/search/widget/VoiceSearchActivityTest.kt @@ -13,8 +13,8 @@ import android.os.Bundle import android.speech.RecognizerIntent.ACTION_RECOGNIZE_SPEECH import android.speech.RecognizerIntent.EXTRA_RESULTS import androidx.activity.result.ActivityResult -import mozilla.components.feature.search.widget.VoiceSearchActivity.Companion.PREVIOUS_INTENT -import mozilla.components.feature.search.widget.VoiceSearchActivity.Companion.SPEECH_PROCESSING +import mozilla.components.feature.search.widget.BaseVoiceSearchActivity.Companion.PREVIOUS_INTENT +import mozilla.components.feature.search.widget.BaseVoiceSearchActivity.Companion.SPEECH_PROCESSING import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse