use of android.appwidget.AppWidgetProviderInfo in project robolectric by robolectric.
the class ShadowAppWidgetHostTest method createView_shouldSetViewsAppWidgetInfo.
@Test
public void createView_shouldSetViewsAppWidgetInfo() throws Exception {
AppWidgetProviderInfo info = new AppWidgetProviderInfo();
AppWidgetHostView hostView = appWidgetHost.createView(context, 0, info);
assertThat(hostView.getAppWidgetInfo()).isSameAs(info);
}
use of android.appwidget.AppWidgetProviderInfo in project robolectric by robolectric.
the class ShadowAppWidgetHostViewTest method shouldKnowItsAppWidgetProviderInfo.
@Test
public void shouldKnowItsAppWidgetProviderInfo() throws Exception {
AppWidgetProviderInfo providerInfo = new AppWidgetProviderInfo();
appWidgetHostView.setAppWidget(0, providerInfo);
assertThat(appWidgetHostView.getAppWidgetInfo()).isSameAs(providerInfo);
}
use of android.appwidget.AppWidgetProviderInfo in project robolectric by robolectric.
the class ShadowAppWidgetManagerTest method bindAppWidgetId_shouldRecordAppWidgetInfo.
@Test
public void bindAppWidgetId_shouldRecordAppWidgetInfo() throws Exception {
ComponentName provider = new ComponentName("abc", "123");
AppWidgetProviderInfo providerInfo = new AppWidgetProviderInfo();
providerInfo.provider = provider;
shadowAppWidgetManager.addInstalledProvider(providerInfo);
appWidgetManager.bindAppWidgetIdIfAllowed(90210, provider);
assertSame(providerInfo, appWidgetManager.getAppWidgetInfo(90210));
}
use of android.appwidget.AppWidgetProviderInfo in project robolectric by robolectric.
the class ShadowAppWidgetManagerTest method getAppWidgetInfo_shouldReturnSpecifiedAppWidgetInfo.
@Test
public void getAppWidgetInfo_shouldReturnSpecifiedAppWidgetInfo() throws Exception {
AppWidgetProviderInfo expectedWidgetInfo = new AppWidgetProviderInfo();
shadowAppWidgetManager.addBoundWidget(26, expectedWidgetInfo);
assertEquals(expectedWidgetInfo, appWidgetManager.getAppWidgetInfo(26));
assertEquals(null, appWidgetManager.getAppWidgetInfo(27));
}
use of android.appwidget.AppWidgetProviderInfo in project Launcher3 by chislon.
the class LauncherModel method resolveWidgetsForMimeType.
/**
* Returns a list of all the widgets that can handle configuration with a particular mimeType.
*/
List<WidgetMimeTypeHandlerData> resolveWidgetsForMimeType(Context context, String mimeType) {
final PackageManager packageManager = context.getPackageManager();
final List<WidgetMimeTypeHandlerData> supportedConfigurationActivities = new ArrayList<WidgetMimeTypeHandlerData>();
final Intent supportsIntent = new Intent(InstallWidgetReceiver.ACTION_SUPPORTS_CLIPDATA_MIMETYPE);
supportsIntent.setType(mimeType);
// Create a set of widget configuration components that we can test against
final List<AppWidgetProviderInfo> widgets = AppWidgetManager.getInstance(context).getInstalledProviders();
final HashMap<ComponentName, AppWidgetProviderInfo> configurationComponentToWidget = new HashMap<ComponentName, AppWidgetProviderInfo>();
for (AppWidgetProviderInfo info : widgets) {
configurationComponentToWidget.put(info.configure, info);
}
// Run through each of the intents that can handle this type of clip data, and cross
// reference them with the components that are actual configuration components
final List<ResolveInfo> activities = packageManager.queryIntentActivities(supportsIntent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo info : activities) {
final ActivityInfo activityInfo = info.activityInfo;
final ComponentName infoComponent = new ComponentName(activityInfo.packageName, activityInfo.name);
if (configurationComponentToWidget.containsKey(infoComponent)) {
supportedConfigurationActivities.add(new InstallWidgetReceiver.WidgetMimeTypeHandlerData(info, configurationComponentToWidget.get(infoComponent)));
}
}
return supportedConfigurationActivities;
}
Aggregations