Snap for 7178253 from dee1167409 to sc-release

Change-Id: Id3146cfd6244cc5af845dfbd1ba5b0d18262b1ca
This commit is contained in:
android-build-team Robot committed 2021-03-02 02:08:22 +00:00
commit 76e26b87c4
19 files changed
+149 -105

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@
android:stateNotNeeded="true"
android:windowSoftInputMode="adjustPan"
android:screenOrientation="unspecified"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout"
android:resizeableActivity="true"
android:resumeWhilePausing="true"
android:taskAffinity=""
+1 -1
View File
@@ -49,7 +49,7 @@
android:stateNotNeeded="true"
android:windowSoftInputMode="adjustPan"
android:screenOrientation="unspecified"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|uiMode"
android:resizeableActivity="true"
android:resumeWhilePausing="true"
android:taskAffinity=""
+1 -1
View File
@@ -49,7 +49,7 @@
android:stateNotNeeded="true"
android:windowSoftInputMode="adjustPan"
android:screenOrientation="unspecified"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout"
android:resizeableActivity="true"
android:resumeWhilePausing="true"
android:taskAffinity=""
+1 -1
View File
@@ -71,7 +71,7 @@
android:stateNotNeeded="true"
android:theme="@style/LauncherTheme"
android:screenOrientation="unspecified"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout"
android:resizeableActivity="true"
android:resumeWhilePausing="true"
android:taskAffinity=""/>
+4 -2
View File
@@ -15,14 +15,16 @@
-->
<com.android.launcher3.dragndrop.LivePreviewWidgetCell
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/widget_cell_horizontal_padding"
android:paddingVertical="@dimen/widget_cell_vertical_padding"
android:layout_weight="1"
android:orientation="vertical"
android:focusable="true"
android:background="?android:attr/colorPrimaryDark"
android:gravity="center_horizontal">
<include layout="@layout/widget_cell_content" />
<include layout="@layout/widget_cell_content" />
</com.android.launcher3.dragndrop.LivePreviewWidgetCell>
+3 -1
View File
@@ -15,8 +15,10 @@
-->
<com.android.launcher3.widget.WidgetCell
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/widget_cell_horizontal_padding"
android:paddingVertical="@dimen/widget_cell_vertical_padding"
android:layout_weight="1"
android:orientation="vertical"
android:focusable="true"
+28 -38
View File
@@ -17,47 +17,37 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/widget_preview_label_vertical_padding"
android:paddingBottom="@dimen/widget_preview_label_vertical_padding"
android:paddingLeft="@dimen/widget_preview_label_horizontal_padding"
android:paddingRight="@dimen/widget_preview_label_horizontal_padding"
android:orientation="horizontal">
<!-- The name of the widget. -->
<TextView
android:id="@+id/widget_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:fadingEdge="horizontal"
android:gravity="start"
android:singleLine="true"
android:maxLines="1"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp" />
<!-- The original dimensions of the widget (can't be the same text as above due to different
style. -->
<TextView
android:id="@+id/widget_dims"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp"
android:alpha="0.8" />
</LinearLayout>
<!-- The image of the widget. This view does not support padding. Any placement adjustment
should be done using margins. -->
<com.android.launcher3.widget.WidgetImageView
android:id="@+id/widget_preview"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
android:layout_weight="1"
android:layout_marginVertical="8dp" />
<!-- The name of the widget. -->
<TextView
android:id="@+id/widget_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fadingEdge="horizontal"
android:gravity="center_horizontal"
android:singleLine="true"
android:maxLines="1"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp" />
<!-- The original dimensions of the widget (can't be the same text as above due to different
style. -->
<TextView
android:id="@+id/widget_dims"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp"
android:alpha="0.8" />
</merge>
+11 -6
View File
@@ -44,11 +44,16 @@
android:textSize="14sp"
android:text="@string/long_press_widget_to_add"/>
<include layout="@layout/widgets_scroll_container"
android:id="@+id/widgets"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:layout_marginBottom="40dp"/>
<ScrollView
android:id="@+id/widgets_table_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:layout_marginBottom="40dp">
<include layout="@layout/widgets_table_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</ScrollView>
</com.android.launcher3.widget.WidgetsBottomSheet>
+1
View File
@@ -18,4 +18,5 @@
android:id="@+id/widgets_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:background="?android:attr/colorPrimaryDark" />
+2 -2
View File
@@ -102,8 +102,8 @@
<dimen name="work_profile_footer_text_size">16sp</dimen>
<!-- Widget tray -->
<dimen name="widget_preview_label_vertical_padding">8dp</dimen>
<dimen name="widget_preview_label_horizontal_padding">16dp</dimen>
<dimen name="widget_cell_vertical_padding">8dp</dimen>
<dimen name="widget_cell_horizontal_padding">16dp</dimen>
<dimen name="widget_preview_shadow_blur">0.5dp</dimen>
<dimen name="widget_preview_key_shadow_distance">1dp</dimen>
@@ -34,6 +34,7 @@ import android.os.Process;
import android.text.Selection;
import android.text.SpannableStringBuilder;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -63,6 +64,7 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
@@ -493,6 +495,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
int layout = showTabs ? R.layout.all_apps_tabs : R.layout.all_apps_rv_layout;
View newView = getLayoutInflater().inflate(layout, this, false);
addView(newView, index);
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "should show tabs:" + showTabs,
new Exception());
}
if (showTabs) {
mViewPager = (AllAppsPagedView) newView;
mViewPager.initParentViews(this);
@@ -61,7 +61,8 @@ public interface SearchUiManager {
/**
* Called when activity is destroyed. Used to close search system services
*/
default void destroy(){}
default void destroy() {
}
/**
* Returns true if the QSB should be visible for the given set of visible elements
@@ -75,4 +76,9 @@ public interface SearchUiManager {
*/
@Nullable
EditText getEditText();
/**
* sets highlight result's title
*/
default void setFocusedResultTitle(@Nullable CharSequence title) { }
}
@@ -168,8 +168,8 @@ public class WorkEduView extends AbstractSlideInView
}
private AllAppsPagedView getAllAppsPagedView() {
View v = mLauncher.getAppsView().getContentView();
return (v instanceof AllAppsPagedView) ? (AllAppsPagedView) v : null;
View v = mLauncher.getAppsView().getContentView();
return (v instanceof AllAppsPagedView) ? (AllAppsPagedView) v : null;
}
/**
@@ -24,7 +24,6 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.LinearLayout;
@@ -60,6 +59,8 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
/** Widget preview width is calculated by multiplying this factor to the widget cell width. */
private static final float PREVIEW_SCALE = 0.8f;
private int mPreviewWidth;
private int mPreviewHeight;
protected int mPresetPreviewSize;
private int mCellSize;
@@ -106,6 +107,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
private void setContainerWidth() {
mCellSize = (int) (mDeviceProfile.allAppsIconSizePx * WIDTH_SCALE);
mPresetPreviewSize = (int) (mCellSize * PREVIEW_SCALE);
mPreviewWidth = mPreviewHeight = mPresetPreviewSize;
}
@Override
@@ -128,6 +130,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
mWidgetImage.setBitmap(null, null);
mWidgetName.setText(null);
mWidgetDims.setText(null);
mPreviewWidth = mPreviewHeight = mPresetPreviewSize;
if (mActiveRequest != null) {
mActiveRequest.cancel();
@@ -181,6 +184,11 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
return;
}
if (bitmap != null) {
LayoutParams layoutParams = (LayoutParams) mWidgetImage.getLayoutParams();
layoutParams.width = bitmap.getWidth();
layoutParams.height = bitmap.getHeight();
mWidgetImage.setLayoutParams(layoutParams);
mWidgetImage.setBitmap(bitmap, mWidgetPreviewLoader.getBadgeForUser(mItem.user,
BaseIconFactory.getBadgeSizeForIconSize(mDeviceProfile.allAppsIconSizePx)));
if (mAnimatePreview) {
@@ -197,8 +205,16 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
if (mActiveRequest != null) {
return;
}
mActiveRequest = mWidgetPreviewLoader.getPreview(
mItem, mPresetPreviewSize, mPresetPreviewSize, this);
mActiveRequest = mWidgetPreviewLoader.getPreview(mItem, mPreviewWidth, mPreviewHeight,
this);
}
/** Sets the widget preview image size in number of cells. */
public void setPreviewSize(int spanX, int spanY) {
int padding = 2 * getResources()
.getDimensionPixelSize(R.dimen.widget_preview_shortcut_padding);
mPreviewWidth = mDeviceProfile.cellWidthPx * spanX + padding;
mPreviewHeight = mDeviceProfile.cellHeightPx * spanY + padding;
}
@Override
@@ -232,12 +248,6 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
return "";
}
@Override
public void setLayoutParams(ViewGroup.LayoutParams params) {
params.width = params.height = mCellSize;
super.setLayoutParams(params);
}
@Override
public CharSequence getAccessibilityClassName() {
return WidgetCell.class.getName();
@@ -24,22 +24,25 @@ import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.IntProperty;
import android.util.Pair;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.widget.ScrollView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.ResourceUtils;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.dragndrop.LivePreviewWidgetCell;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.widget.util.WidgetsTableUtils;
import java.util.List;
@@ -65,6 +68,8 @@ public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable {
private static final int DEFAULT_CLOSE_DURATION = 200;
private ItemInfo mOriginalItemInfo;
private Rect mInsets;
private final int mMaxTableHeight;
private int mMaxHorizontalSpan = 4;
public WidgetsBottomSheet(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -75,12 +80,41 @@ public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable {
setWillNotDraw(false);
mInsets = new Rect();
mContent = this;
DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
// Set the max table height to 2 / 3 of the grid height so that the bottom picker won't
// take over the entire view vertically.
mMaxTableHeight = deviceProfile.inv.numRows * 2 / 3 * deviceProfile.cellHeightPx;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int paddingPx = 2 * getResources().getDimensionPixelOffset(
R.dimen.widget_cell_horizontal_padding);
int maxHorizontalSpan = findViewById(R.id.widgets_table).getMeasuredWidth()
/ (mLauncher.getDeviceProfile().cellWidthPx + paddingPx);
if (mMaxHorizontalSpan != maxHorizontalSpan) {
// Ensure the table layout is showing widgets in the right column after measure.
mMaxHorizontalSpan = maxHorizontalSpan;
onWidgetsBound();
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
setTranslationShift(mTranslationShift);
// Ensure the scroll view height is not larger than mMaxTableHeight, which is a value
// smaller than the entire screen height.
ScrollView widgetsTableScrollView = findViewById(R.id.widgets_table_scroll_view);
if (widgetsTableScrollView.getMeasuredHeight() > mMaxTableHeight) {
ViewGroup.LayoutParams layoutParams = widgetsTableScrollView.getLayoutParams();
layoutParams.height = mMaxTableHeight;
widgetsTableScrollView.setLayoutParams(layoutParams);
}
}
public void populateAndShow(ItemInfo itemInfo) {
@@ -101,39 +135,21 @@ public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable {
mOriginalItemInfo.getTargetComponent().getPackageName(),
mOriginalItemInfo.user));
ViewGroup widgetRow = findViewById(R.id.widgets);
ViewGroup widgetCells = widgetRow.findViewById(R.id.widgets_cell_list);
TableLayout widgetsTable = findViewById(R.id.widgets_table);
widgetsTable.removeAllViews();
widgetCells.removeAllViews();
for (int i = 0; i < widgets.size(); i++) {
WidgetCell widget = addItemCell(widgetCells);
widget.applyFromCellItem(widgets.get(i), LauncherAppState.getInstance(mLauncher)
.getWidgetCache());
widget.ensurePreview();
widget.setVisibility(View.VISIBLE);
if (i < widgets.size() - 1) {
addDivider(widgetCells);
}
}
if (widgets.size() == 1) {
// If there is only one widget, we want to center it instead of left-align.
WidgetsBottomSheet.LayoutParams params = (WidgetsBottomSheet.LayoutParams)
widgetRow.getLayoutParams();
params.gravity = Gravity.CENTER_HORIZONTAL;
} else {
// Otherwise, add an empty view to the start as padding (but still scroll edge to edge).
View leftPaddingView = LayoutInflater.from(getContext()).inflate(
R.layout.widget_list_divider, widgetRow, false);
leftPaddingView.getLayoutParams().width = ResourceUtils.pxFromDp(
16, getResources().getDisplayMetrics());
widgetCells.addView(leftPaddingView, 0);
}
}
private void addDivider(ViewGroup parent) {
LayoutInflater.from(getContext()).inflate(R.layout.widget_list_divider, parent, true);
WidgetsTableUtils.groupWidgetItemsIntoTable(widgets, mMaxHorizontalSpan).forEach(row -> {
TableRow tableRow = new TableRow(getContext());
row.forEach(widgetItem -> {
WidgetCell widget = addItemCell(tableRow);
widget.setPreviewSize(widgetItem.spanX, widgetItem.spanY);
widget.applyFromCellItem(widgetItem, LauncherAppState.getInstance(mLauncher)
.getWidgetCache());
widget.ensurePreview();
widget.setVisibility(View.VISIBLE);
});
widgetsTable.addView(tableRow);
});
}
protected WidgetCell addItemCell(ViewGroup parent) {
@@ -232,8 +232,9 @@ public class WidgetsFullSheet extends BaseWidgetSheet
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec),
MeasureSpec.getSize(heightMeasureSpec));
int maxSpansPerRow = getMeasuredWidth() / (deviceProfile.cellWidthPx
+ deviceProfile.workspaceCellPaddingXPx);
int paddingPx = 2 * getResources().getDimensionPixelOffset(
R.dimen.widget_cell_horizontal_padding);
int maxSpansPerRow = getMeasuredWidth() / (deviceProfile.cellWidthPx + paddingPx);
mAdapters.get(AdapterHolder.PRIMARY).mWidgetsListAdapter.setMaxHorizontalSpansPerRow(
maxSpansPerRow);
if (mHasWorkProfile) {
@@ -112,7 +112,9 @@ public final class WidgetsListTableViewHolderBinder
TableRow row = (TableRow) table.getChildAt(i);
row.setVisibility(View.VISIBLE);
WidgetCell widget = (WidgetCell) row.getChildAt(j);
widget.clear();
WidgetItem widgetItem = widgetItemsPerRow.get(j);
widget.setPreviewSize(widgetItem.spanX, widgetItem.spanY);
widget.applyFromCellItem(widgetItem, mWidgetPreviewLoader);
widget.setApplyBitmapDeferred(mApplyBitmapDeferred);
widget.ensurePreview();
+1 -1
View File
@@ -98,7 +98,7 @@
<activity
android:name="com.android.launcher3.testcomponent.TestLauncherActivity"
android:clearTaskOnLaunch="true"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout"
android:enabled="false"
android:label="Test launcher"
android:launchMode="singleTask"
@@ -154,9 +154,12 @@ public class WorkTabTest extends AbstractLauncherUiTest {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work tab not setup. Skipping test");
return false;
}
return ((AllAppsPagedView) l.getAppsView().getContentView()).getCurrentPage()
== WORK_PAGE && ((TextView) workEduView.findViewById(
R.id.content_text)).getText().equals(
if (((AllAppsPagedView) l.getAppsView().getContentView()).getCurrentPage()
!= WORK_PAGE) {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work page not highlighted");
return false;
}
return ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(
l.getResources().getString(R.string.work_profile_edu_work_apps));
}, 60000);
}