Search in sources :

Example 91 with AppWidgetProviderInfo

use of android.appwidget.AppWidgetProviderInfo in project qksms by moezbhatti.

the class WidgetProvider method isSmallWidget.

/**
 * Returns 1 when widget has less than 4 columns, else 0
 */
@TargetApi(16)
private static int isSmallWidget(AppWidgetManager appWidgetManager, int appWidgetId) {
    int size;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
        size = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
    } else {
        AppWidgetProviderInfo appWidgetInfo = appWidgetManager.getAppWidgetInfo(appWidgetId);
        size = appWidgetInfo.minWidth;
    }
    int n = 2;
    while (70 * n - 30 < size) {
        ++n;
    }
    int columns = n - 1;
    if (columns < 4)
        return 1;
    else
        return 0;
}
Also used : Bundle(android.os.Bundle) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) TargetApi(android.annotation.TargetApi)

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