use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class AppWidgetResizeFrame method setupForWidget.
private void setupForWidget(LauncherAppWidgetHostView widgetView, CellLayout cellLayout, DragLayer dragLayer) {
mCellLayout = cellLayout;
if (mWidgetView != null) {
mWidgetView.removeOnAttachStateChangeListener(mWidgetViewAttachStateChangeListener);
}
mWidgetView = widgetView;
mWidgetView.addOnAttachStateChangeListener(mWidgetViewAttachStateChangeListener);
LauncherAppWidgetProviderInfo info = (LauncherAppWidgetProviderInfo) widgetView.getAppWidgetInfo();
mDragLayer = dragLayer;
mMinHSpan = info.minSpanX;
mMinVSpan = info.minSpanY;
mMaxHSpan = info.maxSpanX;
mMaxVSpan = info.maxSpanY;
mWidgetPadding = getDefaultPaddingForWidget(getContext(), widgetView.getAppWidgetInfo().provider, null);
mReconfigureButton = (ImageButton) findViewById(R.id.widget_reconfigure_button);
if (info.isReconfigurable()) {
mReconfigureButton.setVisibility(VISIBLE);
mReconfigureButton.setOnClickListener(view -> {
mLauncher.setWaitingForResult(PendingRequestArgs.forWidgetInfo(mWidgetView.getAppWidgetId(), /* widgetHandler= */
null, (ItemInfo) mWidgetView.getTag()));
mLauncher.getAppWidgetHost().startConfigActivity(mLauncher, mWidgetView.getAppWidgetId(), Launcher.REQUEST_RECONFIGURE_APPWIDGET);
});
if (!hasSeenReconfigurableWidgetEducationTip()) {
post(() -> {
if (showReconfigurableWidgetEducationTip() != null) {
mLauncher.getSharedPrefs().edit().putBoolean(KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN, true).apply();
}
});
}
}
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) mWidgetView.getLayoutParams();
ItemInfo widgetInfo = (ItemInfo) mWidgetView.getTag();
lp.cellX = lp.tmpCellX = widgetInfo.cellX;
lp.cellY = lp.tmpCellY = widgetInfo.cellY;
lp.cellHSpan = widgetInfo.spanX;
lp.cellVSpan = widgetInfo.spanY;
lp.isLockedToGrid = true;
// When we create the resize frame, we first mark all cells as unoccupied. The appropriate
// cells (same if not resized, or different) will be marked as occupied when the resize
// frame is dismissed.
mCellLayout.markCellsAsUnoccupiedForView(mWidgetView);
mLauncher.getStatsLogManager().logger().withInstanceId(logInstanceId).withItemInfo(widgetInfo).log(LAUNCHER_WIDGET_RESIZE_STARTED);
setOnKeyListener(this);
}
use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class LauncherAppWidgetProviderInfoTest method initSpans_minResizeWidthWithCellSpacingAndWidgetInset_shouldInitializeMinSpans.
@Test
public void initSpans_minResizeWidthWithCellSpacingAndWidgetInset_shouldInitializeMinSpans() {
InvariantDeviceProfile idp = createIDP();
DeviceProfile dp = idp.supportedProfiles.get(0);
Rect padding = new Rect();
AppWidgetHostView.getDefaultPaddingForWidget(mContext, null, padding);
int maxPadding = Math.max(Math.max(padding.left, padding.right), Math.max(padding.top, padding.bottom));
dp.cellLayoutBorderSpacePx.x = dp.cellLayoutBorderSpacePx.y = maxPadding + 1;
Mockito.when(dp.shouldInsetWidgets()).thenReturn(true);
LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo();
info.minWidth = CELL_SIZE * 3;
info.minHeight = CELL_SIZE * 3;
info.minResizeWidth = CELL_SIZE * 2 + maxPadding;
info.minResizeHeight = CELL_SIZE * 2 + maxPadding;
info.initSpans(mContext, idp);
assertThat(info.minSpanX).isEqualTo(2);
assertThat(info.minSpanY).isEqualTo(2);
}
use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class LauncherAppWidgetProviderInfoTest method initSpans_minResizeWidthHeightLargerThanMinWidth_shouldUseMinWidthHeightAsMinSpans.
@Test
public void initSpans_minResizeWidthHeightLargerThanMinWidth_shouldUseMinWidthHeightAsMinSpans() {
LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo();
info.minWidth = 20;
info.minHeight = 20;
info.minResizeWidth = 80;
info.minResizeHeight = 80;
InvariantDeviceProfile idp = createIDP();
info.initSpans(mContext, idp);
assertThat(info.minSpanX).isEqualTo(1);
assertThat(info.minSpanY).isEqualTo(1);
}
use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class LauncherAppWidgetProviderInfoTest method isMinSizeFulfilled_minWidthAndMinResizeWidthExceededGridColumns_shouldReturnFalse.
@Test
public void isMinSizeFulfilled_minWidthAndMinResizeWidthExceededGridColumns_shouldReturnFalse() {
LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo();
info.minWidth = CELL_SIZE * (NUM_OF_COLS + 2);
info.minHeight = 80;
info.minResizeWidth = CELL_SIZE * (NUM_OF_COLS + 1);
info.minResizeHeight = 50;
InvariantDeviceProfile idp = createIDP();
info.initSpans(mContext, idp);
assertThat(info.isMinSizeFulfilled()).isFalse();
}
use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class LauncherAppWidgetProviderInfoTest method initSpans_minWidthSmallerThanCellWidth_shouldInitializeSpansToOne.
@Test
public void initSpans_minWidthSmallerThanCellWidth_shouldInitializeSpansToOne() {
LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo();
info.minWidth = 20;
info.minHeight = 20;
InvariantDeviceProfile idp = createIDP();
info.initSpans(mContext, idp);
assertThat(info.spanX).isEqualTo(1);
assertThat(info.spanY).isEqualTo(1);
}
Aggregations