Search in sources :

Example 11 with AppWidgetProviderInfo

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);
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Test(org.junit.Test)

Example 12 with AppWidgetProviderInfo

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);
}
Also used : AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Test(org.junit.Test)

Example 13 with AppWidgetProviderInfo

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));
}
Also used : AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 14 with AppWidgetProviderInfo

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));
}
Also used : AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Test(org.junit.Test)

Example 15 with AppWidgetProviderInfo

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;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WidgetMimeTypeHandlerData(com.android.launcher3.InstallWidgetReceiver.WidgetMimeTypeHandlerData) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) WidgetMimeTypeHandlerData(com.android.launcher3.InstallWidgetReceiver.WidgetMimeTypeHandlerData)

Aggregations

AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)91 Point (android.graphics.Point)24 ComponentName (android.content.ComponentName)21 AppWidgetHostView (android.appwidget.AppWidgetHostView)18 Bundle (android.os.Bundle)18 WidgetBackupProvider (com.android.server.WidgetBackupProvider)15 ActivityInfo (android.content.pm.ActivityInfo)14 ResolveInfo (android.content.pm.ResolveInfo)14 ArrayList (java.util.ArrayList)13 IOException (java.io.IOException)12 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)12 Intent (android.content.Intent)10 PackageManager (android.content.pm.PackageManager)9 Resources (android.content.res.Resources)7 View (android.view.View)7 Context (android.content.Context)6 IPackageManager (android.content.pm.IPackageManager)6 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)6 TypedArray (android.content.res.TypedArray)6 XmlResourceParser (android.content.res.XmlResourceParser)6