Search in sources :

Example 86 with AppWidgetHostView

use of android.appwidget.AppWidgetHostView in project Neo-Launcher by NeoApplications.

the class SecondaryDropTarget method supportsAccessibilityDrop.

@Override
public boolean supportsAccessibilityDrop(ItemInfo info, View view) {
    if (view instanceof AppWidgetHostView) {
        if (getReconfigurableWidgetId(view) != INVALID_APPWIDGET_ID) {
            setupUi(RECONFIGURE);
            return true;
        } else if (getWidgetCustomizeIntent(view) != null) {
            setupUi(CUSTOMIZE);
            return true;
        }
        return false;
    }
    setupUi(UNINSTALL);
    Boolean uninstallDisabled = mUninstallDisabledCache.get(info.user);
    if (uninstallDisabled == null) {
        UserManager userManager = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
        Bundle restrictions = userManager.getUserRestrictions(info.user);
        uninstallDisabled = restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false) || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false);
        mUninstallDisabledCache.put(info.user, uninstallDisabled);
    }
    // Cancel any pending alarm and set cache expiry after some time
    mCacheExpireAlarm.setAlarm(CACHE_EXPIRE_TIMEOUT);
    if (uninstallDisabled) {
        return false;
    }
    if (info instanceof ItemInfoWithIcon) {
        ItemInfoWithIcon iconInfo = (ItemInfoWithIcon) info;
        if ((iconInfo.runtimeStatusFlags & FLAG_SYSTEM_MASK) != 0) {
            return (iconInfo.runtimeStatusFlags & FLAG_SYSTEM_NO) != 0;
        }
    }
    return getUninstallTarget(info) != null;
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) UserManager(android.os.UserManager) Bundle(android.os.Bundle)

Example 87 with AppWidgetHostView

use of android.appwidget.AppWidgetHostView in project Neo-Launcher by NeoApplications.

the class SecondaryDropTarget method getReconfigurableWidgetId.

/**
 * Verifies that the view is an reconfigurable widget and returns the corresponding widget Id,
 * otherwise return {@code INVALID_APPWIDGET_ID}
 */
private int getReconfigurableWidgetId(View view) {
    if (!(view instanceof AppWidgetHostView)) {
        return INVALID_APPWIDGET_ID;
    }
    AppWidgetHostView hostView = (AppWidgetHostView) view;
    AppWidgetProviderInfo widgetInfo = hostView.getAppWidgetInfo();
    if (widgetInfo == null || widgetInfo.configure == null) {
        return INVALID_APPWIDGET_ID;
    }
    if ((LauncherAppWidgetProviderInfo.fromProviderInfo(getContext(), widgetInfo).getWidgetFeatures() & WIDGET_FEATURE_RECONFIGURABLE) == 0) {
        return INVALID_APPWIDGET_ID;
    }
    return hostView.getAppWidgetId();
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) CustomAppWidgetProviderInfo(com.android.launcher3.widget.custom.CustomAppWidgetProviderInfo)

Aggregations

AppWidgetHostView (android.appwidget.AppWidgetHostView)87 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)32 View (android.view.View)23 Bundle (android.os.Bundle)22 Point (android.graphics.Point)19 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)16 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)16 Context (android.content.Context)15 SuppressLint (android.annotation.SuppressLint)13 TextView (android.widget.TextView)12 Intent (android.content.Intent)10 ImageView (android.widget.ImageView)9 AppWidgetHost (android.appwidget.AppWidgetHost)7 ViewGroup (android.view.ViewGroup)7 LinearLayout (android.widget.LinearLayout)7 DragView (com.android.launcher3.dragndrop.DragView)7 PendingAddWidgetInfo (com.android.launcher3.widget.PendingAddWidgetInfo)7 Test (org.junit.Test)5 Rect (android.graphics.Rect)4 DraggableView (com.android.launcher3.dragndrop.DraggableView)4