Merge changes I03636e28,I6cf6d52e into tm-qpr-dev

* changes:
  Fix page indicator dots height in workspace
  Change delightful pagination flag and use it for workspace
This commit is contained in:
Federico Baron
2022-10-19 19:33:18 +00:00
committed by Android (Google) Code Review
6 changed files with 84 additions and 32 deletions

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2022 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.
-->
<com.android.launcher3.pageindicators.PageIndicatorDots xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/page_indicator"
android:layout_width="match_parent"
android:layout_height="@dimen/workspace_page_indicator_height"
android:layout_gravity="bottom | center_horizontal"
android:theme="@style/HomeScreenElementTheme" />

View File

@@ -43,6 +43,7 @@ import static com.android.launcher3.LauncherState.SPRING_LOADED;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.getSupportedActions;
import static com.android.launcher3.anim.Interpolators.EMPHASIZED;
import static com.android.launcher3.config.FeatureFlags.SHOW_DELIGHTFUL_PAGINATION;
import static com.android.launcher3.logging.StatsLogManager.EventEnum;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
@@ -97,6 +98,7 @@ import android.os.Trace;
import android.os.UserHandle;
import android.text.TextUtils;
import android.text.method.TextKeyListener;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Log;
import android.util.SparseArray;
@@ -163,6 +165,7 @@ import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.notification.NotificationListener;
import com.android.launcher3.pageindicators.WorkspacePageIndicator;
import com.android.launcher3.pm.PinRequestHelper;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.popup.ArrowPopup;
@@ -1291,6 +1294,16 @@ public class Launcher extends StatefulActivity<LauncherState>
mAllAppsController.setupViews(mScrimView, mAppsView);
}
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
if (SHOW_DELIGHTFUL_PAGINATION.get()
&& WorkspacePageIndicator.class.getName().equals(name)) {
return LayoutInflater.from(context).inflate(R.layout.page_indicator_dots,
(ViewGroup) parent, false);
}
return super.onCreateView(parent, name, context, attrs);
}
/**
* Creates a view representing a shortcut.
*

View File

@@ -53,12 +53,14 @@ import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;
import android.widget.Toast;
import androidx.annotation.Nullable;
@@ -325,6 +327,26 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
updateCellLayoutPadding();
updateWorkspaceWidgetsSizes();
setPageIndicatorInset();
}
private void setPageIndicatorInset() {
DeviceProfile grid = mLauncher.getDeviceProfile();
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mPageIndicator.getLayoutParams();
// Set insets for page indicator
Rect padding = grid.workspacePadding;
if (grid.isVerticalBarLayout()) {
lp.leftMargin = padding.left + grid.workspaceCellPaddingXPx;
lp.rightMargin = padding.right + grid.workspaceCellPaddingXPx;
lp.bottomMargin = padding.bottom;
} else {
lp.leftMargin = lp.rightMargin = 0;
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
lp.bottomMargin = grid.hotseatBarSizePx;
}
mPageIndicator.setLayoutParams(lp);
}
private void updateCellLayoutPadding() {

View File

@@ -285,11 +285,10 @@ public final class FeatureFlags {
public static final BooleanFlag ENABLE_WIDGET_PICKER_DEPTH = new DeviceFlag(
"ENABLE_WIDGET_PICKER_DEPTH", true, "Enable changing depth in widget picker.");
public static final BooleanFlag SHOW_DELIGHTFUL_PAGINATION_FOLDER = new DeviceFlag(
"SHOW_DELIGHTFUL_PAGINATION_FOLDER", false,
"Enable showing the new 'delightful pagination'"
+ " which is a brand new animation for folder pagination");
public static final BooleanFlag SHOW_DELIGHTFUL_PAGINATION = new DeviceFlag(
"SHOW_DELIGHTFUL_PAGINATION", false,
"Enable showing the new 'delightful pagination' which is a brand"
+ " new animation for folder pagination and workspace pagination");
public static final BooleanFlag POPUP_MATERIAL_U = new DeviceFlag(
"POPUP_MATERIAL_U", false, "Switch popup UX to use material U");

View File

@@ -16,7 +16,7 @@
package com.android.launcher3.pageindicators;
import static com.android.launcher3.config.FeatureFlags.SHOW_DELIGHTFUL_PAGINATION_FOLDER;
import static com.android.launcher3.config.FeatureFlags.SHOW_DELIGHTFUL_PAGINATION;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -29,6 +29,7 @@ import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
@@ -38,6 +39,7 @@ import android.view.ViewOutlineProvider;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.Interpolators;
@@ -47,7 +49,7 @@ import com.android.launcher3.util.Themes;
* {@link PageIndicator} which shows dots per page. The active page is shown with the current
* accent color.
*/
public class PageIndicatorDots extends View implements PageIndicator {
public class PageIndicatorDots extends View implements Insettable, PageIndicator {
private static final float SHIFT_PER_ANIMATION = 0.5f;
private static final float SHIFT_THRESHOLD = 0.1f;
@@ -128,8 +130,7 @@ public class PageIndicatorDots extends View implements PageIndicator {
mPaginationPaint.setColor(Themes.getAttrColor(context, R.attr.folderPaginationColor));
mDotRadius = getResources().getDimension(R.dimen.page_indicator_dot_size) / 2;
if (SHOW_DELIGHTFUL_PAGINATION_FOLDER.get()) {
if (SHOW_DELIGHTFUL_PAGINATION.get()) {
mPageIndicatorSize = getResources().getDimension(
R.dimen.page_indicator_size);
mPageIndicatorRadius = mPageIndicatorSize / 2;
@@ -144,7 +145,7 @@ public class PageIndicatorDots extends View implements PageIndicator {
mPageIndicatorDrawable = null;
mCircleGap = DOT_GAP_FACTOR * mDotRadius;
}
if (!SHOW_DELIGHTFUL_PAGINATION_FOLDER.get()) {
if (!SHOW_DELIGHTFUL_PAGINATION.get()) {
setOutlineProvider(new MyOutlineProver());
}
mIsRtl = Utilities.isRtl(getResources());
@@ -161,7 +162,7 @@ public class PageIndicatorDots extends View implements PageIndicator {
currentScroll = totalScroll - currentScroll;
}
if (SHOW_DELIGHTFUL_PAGINATION_FOLDER.get()) {
if (SHOW_DELIGHTFUL_PAGINATION.get()) {
mCurrentScroll = currentScroll;
mTotalScroll = totalScroll;
invalidate();
@@ -296,7 +297,7 @@ public class PageIndicatorDots extends View implements PageIndicator {
}
for (int i = 0; i < mEntryAnimationRadiusFactors.length; i++) {
mPaginationPaint.setAlpha(i == mActivePage ? PAGE_INDICATOR_ALPHA : DOT_ALPHA);
if (SHOW_DELIGHTFUL_PAGINATION_FOLDER.get()) {
if (SHOW_DELIGHTFUL_PAGINATION.get()) {
if (i != mActivePage) {
canvas.drawCircle(x, y, mDotRadius * mEntryAnimationRadiusFactors[i],
mPaginationPaint);
@@ -313,7 +314,7 @@ public class PageIndicatorDots extends View implements PageIndicator {
// Here we draw the dots
mPaginationPaint.setAlpha(DOT_ALPHA);
for (int i = 0; i < mNumPages; i++) {
if (SHOW_DELIGHTFUL_PAGINATION_FOLDER.get()) {
if (SHOW_DELIGHTFUL_PAGINATION.get()) {
canvas.drawCircle(x, y, getRadius(x), mPaginationPaint);
} else {
canvas.drawCircle(x, y, mDotRadius, mPaginationPaint);
@@ -323,7 +324,7 @@ public class PageIndicatorDots extends View implements PageIndicator {
// Here we draw the current page indicator
mPaginationPaint.setAlpha(PAGE_INDICATOR_ALPHA);
if (SHOW_DELIGHTFUL_PAGINATION_FOLDER.get()) {
if (SHOW_DELIGHTFUL_PAGINATION.get()) {
drawPageIndicator(canvas, 1);
} else {
canvas.drawRoundRect(getActiveRect(), mDotRadius, mDotRadius, mPaginationPaint);
@@ -389,7 +390,7 @@ public class PageIndicatorDots extends View implements PageIndicator {
float diameter = 2 * mDotRadius;
float startX;
if (SHOW_DELIGHTFUL_PAGINATION_FOLDER.get()) {
if (SHOW_DELIGHTFUL_PAGINATION.get()) {
startX = ((getWidth() - (mNumPages * mCircleGap) + mDotRadius) / 2) - getOffset();
sTempRect.top = (getHeight() - mPageIndicatorSize) * 0.5f;
sTempRect.bottom = (getHeight() + mPageIndicatorSize) * 0.5f;
@@ -483,4 +484,12 @@ public class PageIndicatorDots extends View implements PageIndicator {
}
}
}
/**
* We need to override setInsets to prevent InsettableFrameLayout from applying different
* margins on the pagination.
*/
@Override
public void setInsets(Rect insets) {
}
}

View File

@@ -14,12 +14,9 @@ import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.Property;
import android.view.Gravity;
import android.view.View;
import android.view.ViewConfiguration;
import android.widget.FrameLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
@@ -258,21 +255,11 @@ public class WorkspacePageIndicator extends View implements Insettable, PageIndi
}
}
/**
* We need to override setInsets to prevent InsettableFrameLayout from applying different
* margins on the page indicator.
*/
@Override
public void setInsets(Rect insets) {
DeviceProfile grid = mLauncher.getDeviceProfile();
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
if (grid.isVerticalBarLayout()) {
Rect padding = grid.workspacePadding;
lp.leftMargin = padding.left + grid.workspaceCellPaddingXPx;
lp.rightMargin = padding.right + grid.workspaceCellPaddingXPx;
lp.bottomMargin = padding.bottom;
} else {
lp.leftMargin = lp.rightMargin = 0;
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
lp.bottomMargin = grid.hotseatBarSizePx;
}
setLayoutParams(lp);
}
}