Snap for 9366140 from 7b467addea to tm-qpr2-release

Change-Id: Id38a61e0f0116260b3f5cc01bae1a0b40ca5ba93
This commit is contained in:
Android Build Coastguard Worker
2022-12-03 22:29:20 +00:00
12 changed files with 64 additions and 26 deletions
@@ -193,7 +193,7 @@ public class HotseatEduDialog extends AbstractSlideInView<Launcher> implements I
icon.setEnabled(false);
icon.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
icon.verifyHighRes();
CellLayoutLayoutParams lp = new CellLayoutLayoutParams(i, 0, 1, 1);
CellLayoutLayoutParams lp = new CellLayoutLayoutParams(i, 0, 1, 1, -1);
mSampleHotseat.addViewToCellLayout(icon, i, info.getViewId(), lp, true);
}
}
+2 -2
View File
@@ -14,6 +14,6 @@
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/system_neutral1_50" android:state_selected="true"/>
<item android:color="@android:color/system_neutral2_700"/>
<item android:color="@android:color/system_neutral2_700" android:state_selected="true"/>
<item android:color="@android:color/system_accent2_100"/>
</selector>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/system_neutral1_800"/>
</selector>
@@ -423,14 +423,15 @@ public abstract class ButtonDropTarget extends TextView
float textSize = Utilities.pxToSp(getTextSize());
int availableWidth = getMeasuredWidth();
while (textSize > minSize) {
if (isTextTruncated(availableWidth)) {
textSize -= step;
while (isTextTruncated(availableWidth)) {
textSize -= step;
if (textSize < minSize) {
textSize = minSize;
setTextSize(textSize);
} else {
return textSize;
break;
}
setTextSize(textSize);
}
return minSize;
return textSize;
}
}
+1 -1
View File
@@ -267,7 +267,7 @@ public class CellLayout extends ViewGroup {
mDragCell[0] = mDragCell[1] = -1;
mDragCellSpan[0] = mDragCellSpan[1] = -1;
for (int i = 0; i < mDragOutlines.length; i++) {
mDragOutlines[i] = new CellLayoutLayoutParams(0, 0, 0, 0);
mDragOutlines[i] = new CellLayoutLayoutParams(0, 0, 0, 0, -1);
}
mDragOutlinePaint.setColor(Themes.getAttrColor(context, R.attr.workspaceTextColor));
+1 -1
View File
@@ -582,7 +582,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
}
int cellHSpan = mLauncher.getDeviceProfile().inv.numSearchContainerColumns;
CellLayoutLayoutParams lp = new CellLayoutLayoutParams(0, 0, cellHSpan, 1);
CellLayoutLayoutParams lp = new CellLayoutLayoutParams(0, 0, cellHSpan, 1, FIRST_SCREEN_ID);
lp.canReorder = false;
if (!firstPage.addViewToCellLayout(
mFirstPagePinnedItem, 0, R.id.search_container_workspace, lp, true)) {
@@ -114,7 +114,7 @@ public interface WorkspaceLayoutManager {
ViewGroup.LayoutParams genericLp = child.getLayoutParams();
CellLayoutLayoutParams lp;
if (genericLp == null || !(genericLp instanceof CellLayoutLayoutParams)) {
lp = new CellLayoutLayoutParams(x, y, spanX, spanY);
lp = new CellLayoutLayoutParams(x, y, spanX, spanY, screenId);
} else {
lp = (CellLayoutLayoutParams) genericLp;
lp.cellX = x;
@@ -28,6 +28,9 @@ import androidx.annotation.Nullable;
* Represents the logic of where a view is in a CellLayout and its size
*/
public class CellLayoutLayoutParams extends ViewGroup.MarginLayoutParams {
public int screenId = -1;
/**
* Horizontal location of the item in the grid.
*/
@@ -106,14 +109,20 @@ public class CellLayoutLayoutParams extends ViewGroup.MarginLayoutParams {
this.cellY = source.cellY;
this.cellHSpan = source.cellHSpan;
this.cellVSpan = source.cellVSpan;
this.screenId = source.screenId;
this.tmpCellX = source.tmpCellX;
this.tmpCellY = source.tmpCellY;
this.useTmpCoords = source.useTmpCoords;
}
public CellLayoutLayoutParams(int cellX, int cellY, int cellHSpan, int cellVSpan) {
public CellLayoutLayoutParams(int cellX, int cellY, int cellHSpan, int cellVSpan,
int screenId) {
super(CellLayoutLayoutParams.MATCH_PARENT, CellLayoutLayoutParams.MATCH_PARENT);
this.cellX = cellX;
this.cellY = cellY;
this.cellHSpan = cellHSpan;
this.cellVSpan = cellVSpan;
this.screenId = screenId;
}
/**
@@ -23,6 +23,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ADD_EXTERNAL_ITEM_PLACED_AUTOMATICALLY;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ADD_EXTERNAL_ITEM_START;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import static com.android.launcher3.widget.WidgetSections.NO_CATEGORY;
import android.annotation.TargetApi;
import android.app.ActivityOptions;
@@ -63,10 +64,11 @@ import com.android.launcher3.R;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.ItemInstallQueue;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.PackageItemInfo;
import com.android.launcher3.pm.PinRequestHelper;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.views.AbstractSlideInView;
import com.android.launcher3.views.BaseDragLayer;
@@ -80,6 +82,7 @@ import com.android.launcher3.widget.WidgetCell;
import com.android.launcher3.widget.WidgetCellPreview;
import com.android.launcher3.widget.WidgetImageView;
import com.android.launcher3.widget.WidgetManagerHelper;
import com.android.launcher3.widget.WidgetSections;
import java.util.function.Supplier;
@@ -142,7 +145,7 @@ public class AddItemActivity extends BaseActivity
mAccessibilityManager =
getApplicationContext().getSystemService(AccessibilityManager.class);
PackageUserKey targetApp = null;
final PackageItemInfo targetApp;
switch (mRequest.getRequestType()) {
case PinItemRequest.REQUEST_TYPE_SHORTCUT:
targetApp = setupShortcut();
@@ -150,6 +153,9 @@ public class AddItemActivity extends BaseActivity
case PinItemRequest.REQUEST_TYPE_APPWIDGET:
targetApp = setupWidget();
break;
default:
targetApp = null;
break;
}
if (targetApp == null) {
// TODO: show error toast?
@@ -157,7 +163,7 @@ public class AddItemActivity extends BaseActivity
return;
}
ApplicationInfo info = new PackageManagerHelper(this)
.getApplicationInfo(targetApp.mPackageName, targetApp.mUser, 0);
.getApplicationInfo(targetApp.packageName, targetApp.user, 0);
if (info == null) {
finish();
return;
@@ -177,7 +183,10 @@ public class AddItemActivity extends BaseActivity
// Set the label synchronously instead of via IconCache as this is the first thing
// user sees
TextView widgetAppName = findViewById(R.id.widget_appName);
widgetAppName.setText(info.loadLabel(getPackageManager()));
WidgetSections.WidgetSection section = targetApp.widgetCategory == NO_CATEGORY ? null
: WidgetSections.getWidgetSections(this).get(targetApp.widgetCategory);
widgetAppName.setText(section == null ? info.loadLabel(getPackageManager())
: getString(section.mSectionTitle));
mSlideInView = findViewById(R.id.add_item_bottom_sheet);
mSlideInView.addOnCloseListener(this);
@@ -266,19 +275,18 @@ public class AddItemActivity extends BaseActivity
}
}
private PackageUserKey setupShortcut() {
private PackageItemInfo setupShortcut() {
PinShortcutRequestActivityInfo shortcutInfo =
new PinShortcutRequestActivityInfo(mRequest, this);
mWidgetCell.getWidgetView().setTag(new PendingAddShortcutInfo(shortcutInfo));
applyWidgetItemAsync(
() -> new WidgetItem(shortcutInfo, mApp.getIconCache(), getPackageManager()));
return new PackageUserKey(
mRequest.getShortcutInfo().getPackage(),
return new PackageItemInfo(mRequest.getShortcutInfo().getPackage(),
mRequest.getShortcutInfo().getUserHandle());
}
private PackageUserKey setupWidget() {
LauncherAppWidgetProviderInfo widgetInfo = LauncherAppWidgetProviderInfo
private PackageItemInfo setupWidget() {
final LauncherAppWidgetProviderInfo widgetInfo = LauncherAppWidgetProviderInfo
.fromProviderInfo(this, mRequest.getAppWidgetProviderInfo(this));
if (widgetInfo.minSpanX > mIdp.numColumns || widgetInfo.minSpanY > mIdp.numRows) {
// Cannot add widget
@@ -297,7 +305,8 @@ public class AddItemActivity extends BaseActivity
mWidgetCell.getWidgetView().setTag(pendingInfo);
applyWidgetItemAsync(() -> new WidgetItem(widgetInfo, mIdp, mApp.getIconCache()));
return new PackageUserKey(widgetInfo.provider.getPackageName(), widgetInfo.getUser());
return WidgetsModel.newPendingItemInfo(this, widgetInfo.getComponent(),
widgetInfo.getUser());
}
private void applyWidgetItemAsync(final Supplier<WidgetItem> itemProvider) {
@@ -223,7 +223,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> implements Cli
CellLayoutLayoutParams lp = (CellLayoutLayoutParams) textView.getLayoutParams();
if (lp == null) {
textView.setLayoutParams(new CellLayoutLayoutParams(
item.cellX, item.cellY, item.spanX, item.spanY));
item.cellX, item.cellY, item.spanX, item.spanY, item.screenId));
} else {
lp.cellX = item.cellX;
lp.cellY = item.cellY;
@@ -534,7 +534,7 @@ public class LauncherPreviewRenderer extends ContextWrapper
View qsb = mHomeElementInflater.inflate(R.layout.qsb_preview, firstScreen,
false);
CellLayoutLayoutParams lp = new CellLayoutLayoutParams(0, 0, firstScreen.getCountX(),
1);
1, FIRST_SCREEN_ID);
lp.canReorder = false;
firstScreen.addViewToCellLayout(qsb, 0, R.id.search_container_workspace, lp, true);
}
@@ -779,7 +779,8 @@ public class StatsLogManager implements ResourceBasedOverride {
FAIL(4),
COLD_USERWAITING(5),
ATOMIC(6),
CONTROLLED(7);
CONTROLLED(7),
CACHED(8);
private final int mId;
LatencyType(int id) {