use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by crdroidandroid.
the class Launcher method startBinding.
/**
* Refreshes the shortcuts shown on the workspace.
*
* Implementation of the method from LauncherModel.Callbacks.
*/
public void startBinding() {
Object traceToken = TraceHelper.INSTANCE.beginSection("startBinding");
// Floating panels (except the full widget sheet) are associated with individual icons. If
// we are starting a fresh bind, close all such panels as all the icons are about
// to go away.
AbstractFloatingView.closeOpenViews(this, true, TYPE_ALL & ~TYPE_REBIND_SAFE);
setWorkspaceLoading(true);
// Clear the workspace because it's going to be rebound
mDragController.cancelDrag();
mWorkspace.clearDropTargets();
mWorkspace.removeAllWorkspaceScreens();
mAppWidgetHost.clearViews();
if (mHotseat != null) {
mHotseat.resetLayout(getDeviceProfile().isVerticalBarLayout());
}
TraceHelper.INSTANCE.endSection(traceToken);
}
use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by crdroidandroid.
the class Launcher method completeRestoreAppWidget.
/**
* Restores a pending widget.
*
* @param appWidgetId The app widget id
*/
private LauncherAppWidgetInfo completeRestoreAppWidget(int appWidgetId, int finalRestoreFlag) {
LauncherAppWidgetHostView view = mWorkspace.getWidgetForAppWidgetId(appWidgetId);
if ((view == null) || !(view instanceof PendingAppWidgetHostView)) {
Log.e(TAG, "Widget update called, when the widget no longer exists.");
return null;
}
LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag();
info.restoreStatus = finalRestoreFlag;
if (info.restoreStatus == LauncherAppWidgetInfo.RESTORE_COMPLETED) {
info.pendingItemInfo = null;
}
if (((PendingAppWidgetHostView) view).isReinflateIfNeeded()) {
view.reInflate();
}
getModelWriter().updateItemInDatabase(info);
return info;
}
use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by crdroidandroid.
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();
}
use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by crdroidandroid.
the class ShortcutAndWidgetContainer method layoutChild.
/**
* Core logic to layout a child for this ViewGroup.
*/
public void layoutChild(View child) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
if (child instanceof NavigableAppWidgetHostView) {
NavigableAppWidgetHostView nahv = (NavigableAppWidgetHostView) child;
// Scale and center the widget to fit within its cells.
DeviceProfile profile = mActivity.getDeviceProfile();
float scaleX = profile.appWidgetScale.x;
float scaleY = profile.appWidgetScale.y;
nahv.setScaleToFit(Math.min(scaleX, scaleY));
nahv.setTranslationForCentering(-(lp.width - (lp.width * scaleX)) / 2.0f, -(lp.height - (lp.height * scaleY)) / 2.0f);
}
int childLeft = lp.x;
int childTop = lp.y;
child.layout(childLeft, childTop, childLeft + lp.width, childTop + lp.height);
if (lp.dropped) {
lp.dropped = false;
final int[] cellXY = mTmpCellXY;
getLocationOnScreen(cellXY);
mWallpaperManager.sendWallpaperCommand(getWindowToken(), WallpaperManager.COMMAND_DROP, cellXY[0] + childLeft + lp.width / 2, cellXY[1] + childTop + lp.height / 2, 0, null);
}
}
use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by crdroidandroid.
the class AppsSearchContainerLayout method onLayout.
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
// Shift the widget horizontally so that its centered in the parent (b/63428078)
View parent = (View) getParent();
int availableWidth = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight();
int myWidth = right - left;
int expectedLeft = parent.getPaddingLeft() + (availableWidth - myWidth) / 2;
int shift = expectedLeft - left;
setTranslationX(shift);
offsetTopAndBottom(mContentOverlap);
}
Aggregations