Snap for 7158291 from dfdeddc66a to sc-v2-release

Change-Id: I6f32714004ba8606086b4c12c39efd7f0b5b97f7
This commit is contained in:
android-build-team Robot committed 2021-02-20 02:08:33 +00:00
commit 82e19e2e27
29 files changed
+405 -273

No files matched your search

@@ -222,7 +222,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
mTaskbarController.cleanup();
mTaskbarController = null;
}
if (FeatureFlags.ENABLE_TASKBAR.get() && mDeviceProfile.isTablet) {
if (mDeviceProfile.isTaskbarPresent) {
TaskbarActivityContext taskbarActivityContext = new TaskbarActivityContext(this);
mTaskbarController = new TaskbarController(this,
taskbarActivityContext.getTaskbarContainerView());
@@ -130,7 +130,7 @@ public class PredictionRowView extends LinearLayout implements
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
mDecorationHandler = new AllAppsSectionDecorator.SectionDecorationHandler(getContext(),
false);
false, 0, true, true);
}
updateVisibility();
@@ -164,7 +164,7 @@ public class PredictionRowView extends LinearLayout implements
for (int i = 0; i < childrenCount; i++) {
mDecorationHandler.extendBounds(getChildAt(i));
}
mDecorationHandler.onDraw(canvas);
mDecorationHandler.onGroupDraw(canvas);
mDecorationHandler.onFocusDraw(canvas, getFocusedChild());
mLauncher.getAppsView().getActiveRecyclerView().invalidateItemDecorations();
}
@@ -89,8 +89,7 @@ public class TaskbarController {
mTaskbarView = mTaskbarContainerView.findViewById(R.id.taskbar_view);
mTaskbarView.construct(createTaskbarViewCallbacks());
mWindowManager = mLauncher.getWindowManager();
mTaskbarSize = new Point(MATCH_PARENT,
mLauncher.getResources().getDimensionPixelSize(R.dimen.taskbar_size));
mTaskbarSize = new Point(MATCH_PARENT, mLauncher.getDeviceProfile().taskbarSize);
mTaskbarStateHandler = mLauncher.getTaskbarStateHandler();
mTaskbarVisibilityController = new TaskbarVisibilityController(mLauncher,
createTaskbarVisibilityControllerCallbacks());
@@ -233,14 +232,10 @@ public class TaskbarController {
}
private void removeFromWindowManager() {
if (mTaskbarContainerView.isAttachedToWindow()) {
mWindowManager.removeViewImmediate(mTaskbarContainerView);
}
mWindowManager.removeViewImmediate(mTaskbarContainerView);
}
private void addToWindowManager() {
removeFromWindowManager();
final int gravity = Gravity.BOTTOM;
mWindowLayoutParams = new WindowManager.LayoutParams(
@@ -378,7 +373,8 @@ public class TaskbarController {
* @return Whether the given View is in the same window as Taskbar.
*/
public boolean isViewInTaskbar(View v) {
return mTaskbarContainerView.getWindowId().equals(v.getWindowId());
return mTaskbarContainerView.isAttachedToWindow()
&& mTaskbarContainerView.getWindowId().equals(v.getWindowId());
}
/**
+1 -29
View File
@@ -40,35 +40,7 @@
<include layout="@layout/floating_header_content" />
<com.android.launcher3.allapps.PersonalWorkSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_header_tab_height"
android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
android:orientation="horizontal"
style="@style/TextHeadline">
<Button
android:id="@+id/tab_personal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:text="@string/all_apps_personal_tab"
android:textColor="@color/all_apps_tab_text"
android:textSize="14sp" />
<Button
android:id="@+id/tab_work"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:text="@string/all_apps_work_tab"
android:textColor="@color/all_apps_tab_text"
android:textSize="14sp" />
</com.android.launcher3.allapps.PersonalWorkSlidingTabStrip>
<include layout="@layout/personal_work_tabs" />
</com.android.launcher3.allapps.FloatingHeaderView>
<include
+28
View File
@@ -0,0 +1,28 @@
<?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.
-->
<com.android.launcher3.dragndrop.LivePreviewWidgetCell
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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" />
</com.android.launcher3.dragndrop.LivePreviewWidgetCell>
+47
View File
@@ -0,0 +1,47 @@
<?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.
-->
<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_header_tab_height"
android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
android:orientation="horizontal"
style="@style/TextHeadline">
<Button
android:id="@+id/tab_personal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:text="@string/all_apps_personal_tab"
android:textColor="@color/all_apps_tab_text"
android:textSize="14sp" />
<Button
android:id="@+id/tab_work"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:text="@string/all_apps_work_tab"
android:textColor="@color/all_apps_tab_text"
android:textSize="14sp" />
</com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip>
+2 -2
View File
@@ -67,7 +67,7 @@
android:paddingTop="@dimen/all_apps_header_top_padding"
android:orientation="vertical" >
<com.android.launcher3.allapps.PersonalWorkSlidingTabStrip
<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_header_tab_height"
@@ -97,7 +97,7 @@
android:textAllCaps="true"
android:textColor="@color/all_apps_tab_text"
android:textSize="14sp" />
</com.android.launcher3.allapps.PersonalWorkSlidingTabStrip>
</com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip>
</com.android.launcher3.allapps.FloatingHeaderView>
<com.android.launcher3.allapps.search.AppsSearchContainerLayout
+9 -3
View File
@@ -170,7 +170,8 @@
<!-- Deep shortcuts -->
<dimen name="deep_shortcuts_elevation">9dp</dimen>
<dimen name="bg_popup_item_width">260dp</dimen>
<!-- also update deep_shortcuts_divider_width -->
<dimen name="bg_popup_item_width">234dp</dimen>
<dimen name="bg_popup_item_height">56dp</dimen>
<dimen name="bg_popup_item_condensed_height">48dp</dimen>
<dimen name="pre_drag_view_scale">6dp</dimen>
@@ -193,7 +194,7 @@
<!-- popup_padding_start + icon_size + 10dp -->
<dimen name="deep_shortcuts_text_padding_start">56dp</dimen>
<!-- popup_item_width - deep_shortcuts_text_padding_start -->
<dimen name="deep_shortcuts_divider_width">164dp</dimen>
<dimen name="deep_shortcuts_divider_width">178dp</dimen>
<dimen name="system_shortcut_icon_size">24dp</dimen>
<!-- popup_arrow_center_start - system_shortcut_icon_size / 2 -->
<dimen name="system_shortcut_margin_start">16dp</dimen>
@@ -253,10 +254,15 @@
<!-- Search related -->
<dimen name="search_hero_title_size">16sp</dimen>
<dimen name="search_hero_subtitle_size">15sp</dimen>
<dimen name="search_hero_subtitle_size">14sp</dimen>
<dimen name="search_hero_inline_button_size">12sp</dimen>
<dimen name="search_settings_icon_size">36dp</dimen>
<dimen name="search_settings_icon_vertical_offset">16dp</dimen>
<dimen name="search_line_spacing">4dp</dimen>
<dimen name="search_decoration_corner_radius">28dp</dimen>
<dimen name="search_decoration_padding">1dp</dimen>
<!-- Taskbar related (placeholders to compile in Launcher3 without Quickstep) -->
<dimen name="taskbar_size">0dp</dimen>
</resources>
+1 -14
View File
@@ -53,7 +53,6 @@ import androidx.annotation.UiThread;
import com.android.launcher3.Launcher.OnResumeCallback;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.allapps.AllAppsSectionDecorator;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.dragndrop.DraggableView;
@@ -84,7 +83,7 @@ import java.text.NumberFormat;
* too aggressive.
*/
public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, OnResumeCallback,
IconLabelDotView, DraggableView, Reorderable, AllAppsSectionDecorator.SelfDecoratingView {
IconLabelDotView, DraggableView, Reorderable {
private static final int DISPLAY_WORKSPACE = 0;
private static final int DISPLAY_ALL_APPS = 1;
@@ -954,16 +953,4 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
setCompoundDrawables(null, newIcon, null, null);
}
}
@Override
public void decorate(int color) {
mHighlightColor = color;
invalidate();
}
@Override
public void removeDecoration() {
mHighlightColor = Color.TRANSPARENT;
invalidate();
}
}
+26 -2
View File
@@ -25,9 +25,12 @@ import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.view.Surface;
import android.view.WindowInsets;
import android.view.WindowManager;
import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.DevicePaddings.DevicePadding;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.IconShape;
import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.icons.IconNormalizer;
@@ -149,6 +152,10 @@ public class DeviceProfile {
public DotRenderer mDotRendererWorkSpace;
public DotRenderer mDotRendererAllApps;
// Taskbar
public boolean isTaskbarPresent;
public int taskbarSize;
DeviceProfile(Context context, InvariantDeviceProfile inv, Info info,
Point minSize, Point maxSize, int width, int height, boolean isLandscape,
boolean isMultiWindowMode, boolean transposeLayoutWithOrientation,
@@ -163,12 +170,13 @@ public class DeviceProfile {
// Determine sizes.
widthPx = width;
heightPx = height;
int nonFinalAvailableHeightPx;
if (isLandscape) {
availableWidthPx = maxSize.x;
availableHeightPx = minSize.y;
nonFinalAvailableHeightPx = minSize.y;
} else {
availableWidthPx = minSize.x;
availableHeightPx = maxSize.y;
nonFinalAvailableHeightPx = maxSize.y;
}
mInfo = info;
@@ -192,6 +200,22 @@ public class DeviceProfile {
: Configuration.ORIENTATION_PORTRAIT);
final Resources res = context.getResources();
isTaskbarPresent = isTablet && FeatureFlags.ENABLE_TASKBAR.get();
if (isTaskbarPresent) {
// Taskbar will be added later, but provides bottom insets that we should subtract
// from availableHeightPx.
taskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_size);
WindowInsets windowInsets = DisplayController.INSTANCE.get(context).getHolder(mInfo.id)
.getDisplayContext().getSystemService(WindowManager.class)
.getCurrentWindowMetrics().getWindowInsets();
int nonOverlappingTaskbarInset =
taskbarSize - windowInsets.getSystemWindowInsetBottom();
if (nonOverlappingTaskbarInset > 0) {
nonFinalAvailableHeightPx -= nonOverlappingTaskbarInset;
}
}
availableHeightPx = nonFinalAvailableHeightPx;
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
desiredWorkspaceLeftRightMarginPx = isVerticalBarLayout() ? 0 : edgeMarginPx;
@@ -67,12 +67,13 @@ import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.RecyclerViewFastScroller;
import com.android.launcher3.views.SpringRelativeLayout;
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.OnActivePageChangedListener;
/**
* The all apps view container.
*/
public class AllAppsContainerView extends SpringRelativeLayout implements DragSource,
Insettable, OnDeviceProfileChangeListener {
Insettable, OnDeviceProfileChangeListener, OnActivePageChangedListener {
private static final float FLING_VELOCITY_MULTIPLIER = 135f;
// Starts the springs after at least 55% of the animation has passed.
@@ -434,7 +435,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
.setOnClickListener((View view) -> mViewPager.snapToPage(AdapterHolder.MAIN));
findViewById(R.id.tab_work)
.setOnClickListener((View view) -> mViewPager.snapToPage(AdapterHolder.WORK));
onTabChanged(mViewPager.getNextPage());
onActivePageChanged(mViewPager.getNextPage());
} else {
mAH[AdapterHolder.MAIN].setup(findViewById(R.id.apps_list_view), null);
mAH[AdapterHolder.WORK].recyclerView = null;
@@ -483,7 +484,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
if (showTabs) {
mViewPager = (AllAppsPagedView) newView;
mViewPager.initParentViews(this);
mViewPager.getPageIndicator().setContainerView(this);
mViewPager.getPageIndicator().setOnActivePageChangedListener(this);
} else {
mViewPager = null;
}
@@ -493,14 +494,15 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
return mViewPager != null ? mViewPager : findViewById(R.id.apps_list_view);
}
public void onTabChanged(int pos) {
mHeader.setMainActive(pos == 0);
if (mAH[pos].recyclerView != null) {
mAH[pos].recyclerView.bindFastScrollbar();
@Override
public void onActivePageChanged(int currentActivePage) {
mHeader.setMainActive(currentActivePage == 0);
if (mAH[currentActivePage].recyclerView != null) {
mAH[currentActivePage].recyclerView.bindFastScrollbar();
}
reset(true /* animate */);
if (mWorkModeSwitch != null) {
mWorkModeSwitch.setWorkTabVisible(pos == AdapterHolder.WORK
mWorkModeSwitch.setWorkTabVisible(currentActivePage == AdapterHolder.WORK
&& mAllAppsStore.hasModelFlag(
FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION));
}
@@ -42,8 +42,7 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.allapps.search.SearchSectionInfo;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.allapps.search.SectionDecorationInfo;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.util.PackageManagerHelper;
@@ -109,7 +108,7 @@ public class AllAppsGridAdapter extends
// The index of this app not including sections
public int appIndex = -1;
// Search section associated to result
public SearchSectionInfo searchSectionInfo = null;
public SectionDecorationInfo sectionDecorationInfo = null;
/**
* Factory method for AppIcon AdapterItem
@@ -372,10 +371,6 @@ public class AllAppsGridAdapter extends
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()
&& holder.itemView instanceof AllAppsSectionDecorator.SelfDecoratingView) {
((AllAppsSectionDecorator.SelfDecoratingView) holder.itemView).removeDecoration();
}
switch (holder.getItemViewType()) {
case VIEW_TYPE_ICON:
AdapterItem adapterItem = mApps.getAdapterItems().get(position);
@@ -409,10 +404,6 @@ public class AllAppsGridAdapter extends
@Override
public void onViewRecycled(@NonNull ViewHolder holder) {
super.onViewRecycled(holder);
if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) return;
if (holder.itemView instanceof AllAppsSectionDecorator.SelfDecoratingView) {
((AllAppsSectionDecorator.SelfDecoratingView) holder.itemView).removeDecoration();
}
}
@Override
@@ -17,17 +17,17 @@ package com.android.launcher3.allapps;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.workprofile.PersonalWorkPagedView;
public class AllAppsPagedView extends PagedView<PersonalWorkSlidingTabStrip> {
static final float START_DAMPING_TOUCH_SLOP_ANGLE = (float) Math.PI / 6;
static final float MAX_SWIPE_ANGLE = (float) Math.PI / 3;
static final float TOUCH_SLOP_DAMPING_FACTOR = 4;
/**
* A {@link PagedView} for showing different views for the personal and work profile respectively
* in the {@link AllAppsContainerView}.
*/
public class AllAppsPagedView extends PersonalWorkPagedView {
public AllAppsPagedView(Context context) {
this(context, null);
@@ -44,52 +44,4 @@ public class AllAppsPagedView extends PagedView<PersonalWorkSlidingTabStrip> {
R.dimen.all_apps_header_top_padding);
setPadding(0, topPadding, 0, 0);
}
@Override
protected String getCurrentPageDescription() {
// Not necessary, tab-bar already has two tabs with their own descriptions.
return "";
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
mPageIndicator.setScroll(l, mMaxScroll);
}
@Override
protected void determineScrollingStart(MotionEvent ev) {
float absDeltaX = Math.abs(ev.getX() - getDownMotionX());
float absDeltaY = Math.abs(ev.getY() - getDownMotionY());
if (Float.compare(absDeltaX, 0f) == 0) return;
float slope = absDeltaY / absDeltaX;
float theta = (float) Math.atan(slope);
if (absDeltaX > mTouchSlop || absDeltaY > mTouchSlop) {
cancelCurrentPageLongPress();
}
if (theta > MAX_SWIPE_ANGLE) {
return;
} else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) {
theta -= START_DAMPING_TOUCH_SLOP_ANGLE;
float extraRatio = (float)
Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE)));
super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio);
} else {
super.determineScrollingStart(ev);
}
}
@Override
public boolean hasOverlappingRendering() {
return false;
}
@Override
protected boolean canScroll(float absVScroll, float absHScroll) {
return (absHScroll > absVScroll) && super.canScroll(absVScroll, absHScroll);
}
}
@@ -18,16 +18,18 @@ package com.android.launcher3.allapps;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;
import androidx.recyclerview.widget.RecyclerView;
import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsGridAdapter.AppsGridLayoutManager;
import com.android.launcher3.allapps.search.SearchSectionInfo;
import com.android.launcher3.allapps.search.SectionDecorationInfo;
import com.android.launcher3.util.Themes;
import java.util.List;
@@ -45,52 +47,51 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
// Iterate through views in recylerview and draw bounds around views in the same section.
// Since views in the same section will follow each other, we can skip to a last view in
// a section to get the bounds of the section without having to iterate on every item.
int itemCount = parent.getChildCount();
List<AllAppsGridAdapter.AdapterItem> adapterItems = mAppsView.getApps().getAdapterItems();
SectionDecorationHandler lastDecorationHandler = null;
int i = 0;
while (i < itemCount) {
boolean drawFallbackFocusedView = true;
for (int i = 0; i < parent.getChildCount(); i++) {
View view = parent.getChildAt(i);
if (view instanceof SelfDecoratingView) {
((SelfDecoratingView) view).removeDecoration();
}
int position = parent.getChildAdapterPosition(view);
AllAppsGridAdapter.AdapterItem adapterItem = adapterItems.get(position);
if (adapterItem.searchSectionInfo != null) {
SearchSectionInfo sectionInfo = adapterItem.searchSectionInfo;
int endIndex = Math.min(i + sectionInfo.getPosEnd() - position, itemCount - 1);
if (adapterItem.sectionDecorationInfo != null) {
SectionDecorationInfo sectionInfo = adapterItem.sectionDecorationInfo;
SectionDecorationHandler decorationHandler = sectionInfo.getDecorationHandler();
if (decorationHandler != lastDecorationHandler && lastDecorationHandler != null) {
drawDecoration(c, lastDecorationHandler, parent);
}
lastDecorationHandler = decorationHandler;
if (decorationHandler != null) {
decorationHandler.extendBounds(view);
}
if (endIndex > i) {
i = endIndex;
continue;
if (sectionInfo.isFocusedView()) {
decorationHandler.onFocusDraw(c, view);
drawFallbackFocusedView = false;
} else {
decorationHandler.onGroupDraw(c);
}
}
}
i++;
}
if (lastDecorationHandler != null) {
drawDecoration(c, lastDecorationHandler, parent);
// fallback logic in case none of the SearchTarget is labeled as focused item
if (drawFallbackFocusedView) {
for (int i = 0; i < parent.getChildCount(); i++) {
View view = parent.getChildAt(i);
int position = parent.getChildAdapterPosition(view);
AllAppsGridAdapter.AdapterItem adapterItem = adapterItems.get(position);
if (adapterItem.sectionDecorationInfo != null) {
SectionDecorationInfo sectionInfo = adapterItem.sectionDecorationInfo;
SectionDecorationHandler decorationHandler = sectionInfo.getDecorationHandler();
if (decorationHandler != null) {
drawDecoration(c, decorationHandler, parent);
}
}
}
}
}
private void drawDecoration(Canvas c, SectionDecorationHandler decorationHandler,
RecyclerView parent) {
if (decorationHandler == null) return;
// Fallback logic in case non of the SearchTarget is labeled as focused item.
private void drawDecoration(@NonNull Canvas c,
@NonNull SectionDecorationHandler decorationHandler,
@NonNull RecyclerView parent) {
if (decorationHandler.mIsFullWidth) {
decorationHandler.mBounds.left = parent.getPaddingLeft();
decorationHandler.mBounds.right = parent.getWidth() - parent.getPaddingRight();
}
decorationHandler.onDraw(c);
if (mAppsView.getFloatingHeaderView().getFocusedChild() == null
&& mAppsView.getApps().getFocusedChild() != null) {
int index = mAppsView.getApps().getFocusedChildIndex();
@@ -109,23 +110,41 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
* Handles grouping and drawing of items in the same all apps sections.
*/
public static class SectionDecorationHandler {
private static final int FILL_ALPHA = 0;
protected RectF mBounds = new RectF();
private final boolean mIsFullWidth;
private final float mRadius;
protected int mFocusColor;
protected int mFillcolor;
protected final int mFocusColor; // main focused item color
protected final int mFillcolor; // grouping color
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final boolean mIsTopRound;
private final boolean mIsBottomRound;
private float [] mCorners;
private float mFillSpacing;
public SectionDecorationHandler(Context context, boolean isFullWidth, int fillAlpha,
boolean isTopRound, boolean isBottomRound) {
public SectionDecorationHandler(Context context, boolean isFullWidth) {
mIsFullWidth = isFullWidth;
int endScrim = Themes.getColorBackground(context);
mFillcolor = ColorUtils.setAlphaComponent(endScrim, FILL_ALPHA);
mFocusColor = endScrim;
mRadius = Themes.getDialogCornerRadius(context);
mFillcolor = ColorUtils.setAlphaComponent(endScrim, fillAlpha);
mFocusColor = ColorUtils.setAlphaComponent(endScrim, fillAlpha);
mIsTopRound = isTopRound;
mIsBottomRound = isBottomRound;
mRadius = context.getResources().getDimensionPixelSize(
R.dimen.search_decoration_corner_radius);
mFillSpacing = context.getResources().getDimensionPixelSize(
R.dimen.search_decoration_padding);
mCorners = new float[]{
mIsTopRound ? mRadius : 0, mIsTopRound ? mRadius : 0, // Top left radius in px
mIsTopRound ? mRadius : 0, mIsTopRound ? mRadius : 0, // Top right radius in px
mIsBottomRound ? mRadius : 0, mIsBottomRound ? mRadius : 0, // Bottom right
mIsBottomRound ? mRadius : 0, mIsBottomRound ? mRadius : 0 // Bottom left
};
}
/**
@@ -147,9 +166,9 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
/**
* Draw bounds onto canvas.
*/
public void onDraw(Canvas canvas) {
public void onGroupDraw(Canvas canvas) {
mPaint.setColor(mFillcolor);
canvas.drawRoundRect(mBounds, mRadius, mRadius, mPaint);
onDraw(canvas);
}
/**
@@ -159,13 +178,20 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
if (view == null) {
return;
}
if (view instanceof SelfDecoratingView) {
((SelfDecoratingView) view).decorate(mFocusColor);
return;
}
mPaint.setColor(mFocusColor);
canvas.drawRoundRect(view.getLeft(), view.getTop(),
view.getRight(), view.getBottom(), mRadius, mRadius, mPaint);
mBounds.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
onDraw(canvas);
}
private void onDraw(Canvas canvas) {
final Path path = new Path();
RectF finalBounds = new RectF(mBounds.left + mFillSpacing,
mBounds.top + mFillSpacing,
mBounds.right - mFillSpacing,
mBounds.bottom - mFillSpacing);
path.addRoundRect(finalBounds, mCorners, Path.Direction.CW);
canvas.drawPath(path, mPaint);
}
/**
@@ -175,19 +201,4 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
mBounds.setEmpty();
}
}
/**
* An interface for a view to draw highlight indicator
*/
public interface SelfDecoratingView {
/**
* Removes decorations drawing if focus is acquired by another view
*/
void removeDecoration();
/**
* Draws highlight indicator on view.
*/
void decorate(int focusColor);
}
}
@@ -20,7 +20,7 @@ import android.content.Context;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem;
import com.android.launcher3.allapps.search.SearchSectionInfo;
import com.android.launcher3.allapps.search.SectionDecorationInfo;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.util.ItemInfoMatcher;
@@ -201,20 +201,11 @@ public class AlphabeticalAppsList implements AllAppsStore.OnUpdateListener {
}
void updateSearchAdapterItems(ArrayList<AdapterItem> list, int offset) {
SearchSectionInfo lastSection = null;
for (int i = 0; i < list.size(); i++) {
AdapterItem adapterItem = list.get(i);
adapterItem.position = offset + i;
mAdapterItems.add(adapterItem);
if (adapterItem.searchSectionInfo != lastSection) {
if (adapterItem.searchSectionInfo != null) {
adapterItem.searchSectionInfo.setPosStart(adapterItem.position);
}
if (lastSection != null) {
lastSection.setPosEnd(adapterItem.position - 1);
}
lastSection = adapterItem.searchSectionInfo;
}
if (adapterItem.isCountedForAccessibility()) {
mAccessibilityResultsCount++;
}
@@ -295,16 +286,16 @@ public class AlphabeticalAppsList implements AllAppsStore.OnUpdateListener {
mFastScrollerSections.clear();
mAdapterItems.clear();
SearchSectionInfo appSection = new SearchSectionInfo();
SectionDecorationInfo appSection = new SectionDecorationInfo();
appSection.setDecorationHandler(
new AllAppsSectionDecorator.SectionDecorationHandler(mLauncher, true));
new AllAppsSectionDecorator.SectionDecorationHandler(mLauncher, true,
0, false, false));
// Recreate the filtered and sectioned apps (for convenience for the grid layout) from the
// ordered set of sections
if (!hasFilter()) {
mAccessibilityResultsCount = mApps.size();
appSection.setPosStart(position);
for (AppInfo info : mApps) {
String sectionName = info.sectionName;
@@ -321,11 +312,10 @@ public class AlphabeticalAppsList implements AllAppsStore.OnUpdateListener {
lastFastScrollerSectionInfo.fastScrollToItem = appItem;
}
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
appItem.searchSectionInfo = appSection;
appItem.sectionDecorationInfo = appSection;
}
mAdapterItems.add(appItem);
}
appSection.setPosEnd(mApps.isEmpty() ? appSection.getPosStart() : position - 1);
} else {
updateSearchAdapterItems(mSearchResults, 0);
if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
@@ -87,17 +87,18 @@ public class LauncherAllAppsContainerView extends AllAppsContainerView {
}
@Override
public void onTabChanged(int pos) {
super.onTabChanged(pos);
public void onActivePageChanged(int currentActivePage) {
super.onActivePageChanged(currentActivePage);
if (mUsingTabs) {
// Log tab switches only when the launcher is in AllApps state
if (mLauncher.getStateManager().getCurrentStableState() == LauncherState.ALL_APPS) {
mLauncher.getStatsLogManager().logger()
.log(pos == AdapterHolder.WORK ? LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB
.log(currentActivePage == AdapterHolder.WORK
? LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB
: LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB);
}
if (pos == AdapterHolder.WORK) {
if (currentActivePage == AdapterHolder.WORK) {
WorkEduView.showWorkEduIfNeeded(mLauncher);
} else {
mWorkTabListener = WorkEduView.showEduFlowIfNeeded(mLauncher, mWorkTabListener);
@@ -37,14 +37,14 @@ public class AppsSearchPipeline implements SearchPipeline {
private static final int MAX_RESULTS_COUNT = 5;
private final SearchSectionInfo mSearchSectionInfo;
private final SectionDecorationInfo mSearchSectionInfo;
private final LauncherAppState mLauncherAppState;
public AppsSearchPipeline(Context context, LauncherAppState launcherAppState) {
mLauncherAppState = launcherAppState;
mSearchSectionInfo = new SearchSectionInfo();
mSearchSectionInfo = new SectionDecorationInfo();
mSearchSectionInfo.setDecorationHandler(
new SectionDecorationHandler(context, true));
new SectionDecorationHandler(context, true, 0, true, true));
}
@Override
@@ -81,7 +81,7 @@ public class AppsSearchPipeline implements SearchPipeline {
ArrayList<AdapterItem> items = new ArrayList<>();
for (int i = 0; i < matchingApps.size() && i < MAX_RESULTS_COUNT; i++) {
AdapterItem appItem = AdapterItem.asApp(i, "", matchingApps.get(i), i);
appItem.searchSectionInfo = mSearchSectionInfo;
appItem.sectionDecorationInfo = mSearchSectionInfo;
items.add(appItem);
}
@@ -18,37 +18,30 @@ package com.android.launcher3.allapps.search;
import com.android.launcher3.allapps.AllAppsSectionDecorator.SectionDecorationHandler;
/**
* Info class for a search section
* Info class for a search section that is primarily used for decoration.
*/
public class SearchSectionInfo {
public class SectionDecorationInfo {
public static final int QUICK_LAUNCH = 1 << 0;
public static final int GROUPING = 1 << 1;
private String mSectionId;
private boolean mFocused;
private SectionDecorationHandler mDecorationHandler;
public int getPosStart() {
return mPosStart;
public boolean isFocusedView() {
return mFocused;
}
public void setPosStart(int posStart) {
mPosStart = posStart;
public void setFocusedView(boolean focused) {
mFocused = focused;
}
public int getPosEnd() {
return mPosEnd;
}
public void setPosEnd(int posEnd) {
mPosEnd = posEnd;
}
private int mPosStart;
private int mPosEnd;
public SearchSectionInfo() {
public SectionDecorationInfo() {
this(null);
}
public SearchSectionInfo(String sectionId) {
public SectionDecorationInfo(String sectionId) {
mSectionId = sectionId;
}
@@ -56,7 +49,6 @@ public class SearchSectionInfo {
mDecorationHandler = sectionDecorationHandler;
}
public SectionDecorationHandler getDecorationHandler() {
return mDecorationHandler;
}
@@ -10,7 +10,9 @@ import android.widget.RemoteViews;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.WidgetPreviewLoader;
import com.android.launcher3.icons.BitmapRenderer;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.widget.WidgetCell;
/**
@@ -36,6 +38,15 @@ public class LivePreviewWidgetCell extends WidgetCell {
mPreview = view;
}
public RemoteViews getPreview() {
return mPreview;
}
/** Resets any resource. This should be called before recycling this view. */
public void reset() {
mPreview = null;
}
@Override
public void ensurePreview() {
if (mPreview != null && mActiveRequest == null) {
@@ -49,6 +60,18 @@ public class LivePreviewWidgetCell extends WidgetCell {
super.ensurePreview();
}
@Override
public void applyFromCellItem(WidgetItem item, WidgetPreviewLoader loader) {
if (mPreview == null
&& item.widgetInfo != null
&& item.widgetInfo.previewLayout != View.NO_ID) {
mPreview = new RemoteViews(item.widgetInfo.provider.getPackageName(),
item.widgetInfo.previewLayout);
}
super.applyFromCellItem(item, loader);
}
/**
* Generates a bitmap by inflating {@param views}.
* @see com.android.launcher3.WidgetPreviewLoader#generateWidgetPreview
@@ -31,8 +31,6 @@ import com.android.launcher3.logger.LauncherAtom.ToState;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.ResourceBasedOverride;
import java.util.Optional;
/**
* Handles the user event logging in R+.
*
@@ -486,7 +484,9 @@ public class StatsLogManager implements ResourceBasedOverride {
*/
public StatsLogger logger() {
StatsLogger logger = createLogger();
Optional.ofNullable(mInstanceId).ifPresent(logger::withInstanceId);
if (mInstanceId != null) {
return logger.withInstanceId(mInstanceId);
}
return logger;
}
@@ -136,7 +136,7 @@ public class AllAppsList {
if (findAppInfo(info.componentName, info.user) != null) {
return;
}
mIconCache.getTitleAndIcon(info, activityInfo, true /* useLowResIcon */);
mIconCache.getTitleAndIcon(info, activityInfo, false /* useLowResIcon */);
info.sectionName = mIndex.computeSectionName(info.title);
data.add(info);
@@ -280,7 +280,7 @@ public class AllAppsList {
} else {
Intent launchIntent = AppInfo.makeLaunchIntent(info);
mIconCache.getTitleAndIcon(applicationInfo, info, true /* useLowResIcon */);
mIconCache.getTitleAndIcon(applicationInfo, info, false /* useLowResIcon */);
applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title);
applicationInfo.setProgressLevel(
PackageManagerHelper.getLoadingProgress(info),
@@ -197,6 +197,10 @@ public class DisplayController implements DisplayListener {
return new Info(displayContext, display);
}
public Context getDisplayContext() {
return mDisplayContext;
}
protected void handleOnChange() {
Info oldInfo = mInfo;
Info newInfo = createInfoForContext(mDisplayContext);
@@ -158,6 +158,14 @@ public class OptionsPopupView extends ArrowPopup
*/
public static ArrayList<OptionItem> getOptions(Launcher launcher) {
ArrayList<OptionItem> options = new ArrayList<>();
options.add(new OptionItem(R.string.settings_button_text, R.drawable.ic_setting,
LAUNCHER_SETTINGS_BUTTON_TAP_OR_LONGPRESS,
OptionsPopupView::startSettings));
if (!WidgetsModel.GO_DISABLE_WIDGETS) {
options.add(new OptionItem(R.string.widget_button_text, R.drawable.ic_widget,
LAUNCHER_WIDGETSTRAY_BUTTON_TAP_OR_LONGPRESS,
OptionsPopupView::onWidgetsClicked));
}
int resString = Utilities.existsStyleWallpapers(launcher) ?
R.string.styles_wallpaper_button_text : R.string.wallpaper_button_text;
int resDrawable = Utilities.existsStyleWallpapers(launcher) ?
@@ -165,15 +173,6 @@ public class OptionsPopupView extends ArrowPopup
options.add(new OptionItem(resString, resDrawable,
IGNORE,
OptionsPopupView::startWallpaperPicker));
if (!WidgetsModel.GO_DISABLE_WIDGETS) {
options.add(new OptionItem(R.string.widget_button_text, R.drawable.ic_widget,
LAUNCHER_WIDGETSTRAY_BUTTON_TAP_OR_LONGPRESS,
OptionsPopupView::onWidgetsClicked));
}
options.add(new OptionItem(R.string.settings_button_text, R.drawable.ic_setting,
LAUNCHER_SETTINGS_BUTTON_TAP_OR_LONGPRESS,
OptionsPopupView::startSettings));
return options;
}
@@ -30,6 +30,7 @@ import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.LivePreviewWidgetCell;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
@@ -99,12 +100,16 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView
return false;
}
PendingItemDragHelper dragHelper = new PendingItemDragHelper(v);
if (v instanceof LivePreviewWidgetCell) {
dragHelper.setPreview(((LivePreviewWidgetCell) v).getPreview());
}
int[] loc = new int[2];
getPopupContainer().getLocationInDragLayer(image, loc);
new PendingItemDragHelper(v).startDrag(
image.getBitmapBounds(), image.getBitmap().getWidth(), image.getWidth(),
new Point(loc[0], loc[1]), this, new DragOptions());
dragHelper.startDrag(image.getBitmapBounds(), image.getBitmap().getWidth(),
image.getWidth(), new Point(loc[0], loc[1]), this, new DragOptions());
close(true);
return true;
}
@@ -25,6 +25,8 @@ import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.RemoteViews;
import androidx.annotation.Nullable;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DragSource;
import com.android.launcher3.Launcher;
@@ -48,14 +50,14 @@ public class PendingItemDragHelper extends DragPreviewProvider {
private final PendingAddItemInfo mAddInfo;
private int[] mEstimatedCellSize;
private RemoteViews mPreview;
@Nullable private RemoteViews mPreview;
public PendingItemDragHelper(View view) {
super(view);
mAddInfo = (PendingAddItemInfo) view.getTag();
}
public void setPreview(RemoteViews preview) {
public void setPreview(@Nullable RemoteViews preview) {
mPreview = preview;
}
@@ -36,6 +36,7 @@ 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;
@@ -136,8 +137,8 @@ public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable {
}
protected WidgetCell addItemCell(ViewGroup parent) {
WidgetCell widget = (WidgetCell) LayoutInflater.from(getContext()).inflate(
R.layout.widget_cell, parent, false);
LivePreviewWidgetCell widget = (LivePreviewWidgetCell) LayoutInflater.from(
getContext()).inflate(R.layout.live_preview_widget_cell, parent, false);
widget.setOnClickListener(this);
widget.setOnLongClickListener(this);
@@ -25,6 +25,7 @@ import android.view.ViewGroup;
import com.android.launcher3.R;
import com.android.launcher3.WidgetPreviewLoader;
import com.android.launcher3.dragndrop.LivePreviewWidgetCell;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.recyclerview.ViewHolderBinder;
import com.android.launcher3.widget.WidgetCell;
@@ -107,8 +108,8 @@ public class WidgetsListRowViewHolderBinder
mLayoutInflater.inflate(R.layout.widget_list_divider, row);
} else {
// Add cell for even index
WidgetCell widget = (WidgetCell) mLayoutInflater.inflate(
R.layout.widget_cell, row, false);
LivePreviewWidgetCell widget = (LivePreviewWidgetCell) mLayoutInflater.inflate(
R.layout.live_preview_widget_cell, row, false);
// set up touch.
widget.setOnClickListener(mIconClickListener);
@@ -124,7 +125,8 @@ public class WidgetsListRowViewHolderBinder
// Bind the view in the widget horizontal tray region.
for (int i = 0; i < infoList.size(); i++) {
WidgetCell widget = (WidgetCell) row.getChildAt(2 * i);
LivePreviewWidgetCell widget = (LivePreviewWidgetCell) row.getChildAt(2 * i);
widget.reset();
widget.applyFromCellItem(infoList.get(i), mWidgetPreviewLoader);
widget.setApplyBitmapDeferred(mApplyBitmapDeferred);
widget.ensurePreview();
@@ -0,0 +1,92 @@
/*
* 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.
*/
package com.android.launcher3.workprofile;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import com.android.launcher3.PagedView;
/**
* A {@link PagedView} for showing different views for the personal and work profile respectively.
*/
public class PersonalWorkPagedView extends PagedView<PersonalWorkSlidingTabStrip> {
static final float START_DAMPING_TOUCH_SLOP_ANGLE = (float) Math.PI / 6;
static final float MAX_SWIPE_ANGLE = (float) Math.PI / 3;
static final float TOUCH_SLOP_DAMPING_FACTOR = 4;
public PersonalWorkPagedView(Context context) {
this(context, null);
}
public PersonalWorkPagedView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public PersonalWorkPagedView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected String getCurrentPageDescription() {
// Not necessary, tab-bar already has two tabs with their own descriptions.
return "";
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
mPageIndicator.setScroll(l, mMaxScroll);
}
@Override
protected void determineScrollingStart(MotionEvent ev) {
float absDeltaX = Math.abs(ev.getX() - getDownMotionX());
float absDeltaY = Math.abs(ev.getY() - getDownMotionY());
if (Float.compare(absDeltaX, 0f) == 0) return;
float slope = absDeltaY / absDeltaX;
float theta = (float) Math.atan(slope);
if (absDeltaX > mTouchSlop || absDeltaY > mTouchSlop) {
cancelCurrentPageLongPress();
}
if (theta > MAX_SWIPE_ANGLE) {
return;
} else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) {
theta -= START_DAMPING_TOUCH_SLOP_ANGLE;
float extraRatio = (float)
Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE)));
super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio);
} else {
super.determineScrollingStart(ev);
}
}
@Override
public boolean hasOverlappingRendering() {
return false;
}
@Override
protected boolean canScroll(float absVScroll, float absHScroll) {
return (absHScroll > absVScroll) && super.canScroll(absVScroll, absHScroll);
}
}
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.allapps;
package com.android.launcher3.workprofile;
import android.content.Context;
import android.graphics.Canvas;
@@ -35,9 +35,6 @@ import com.android.launcher3.util.Themes;
* Supports two indicator colors, dedicated for personal and work tabs.
*/
public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageIndicator {
private static final int POSITION_PERSONAL = 0;
private static final int POSITION_WORK = 1;
private final Paint mSelectedIndicatorPaint;
private final Paint mDividerPaint;
@@ -47,7 +44,7 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
private float mScrollOffset;
private int mSelectedPosition = 0;
private AllAppsContainerView mContainerView;
private OnActivePageChangedListener mOnActivePageChangedListener;
private int mLastActivePage = 0;
private boolean mIsRtl;
@@ -123,7 +120,7 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
float y = getHeight() - mDividerPaint.getStrokeWidth();
canvas.drawLine(getPaddingLeft(), y, getWidth() - getPaddingRight(), y, mDividerPaint);
canvas.drawRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
mIndicatorRight, getHeight(), mSelectedIndicatorPaint);
mIndicatorRight, getHeight(), mSelectedIndicatorPaint);
}
@Override
@@ -135,15 +132,15 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
@Override
public void setActiveMarker(int activePage) {
updateTabTextColor(activePage);
if (mContainerView != null && mLastActivePage != activePage) {
if (mOnActivePageChangedListener != null && mLastActivePage != activePage) {
updateIndicatorPosition(activePage);
mContainerView.onTabChanged(activePage);
mOnActivePageChangedListener.onActivePageChanged(activePage);
}
mLastActivePage = activePage;
}
public void setContainerView(AllAppsContainerView containerView) {
mContainerView = containerView;
public void setOnActivePageChangedListener(OnActivePageChangedListener listener) {
mOnActivePageChangedListener = listener;
}
@Override
@@ -153,4 +150,12 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
public boolean hasOverlappingRendering() {
return false;
}
/**
* Interface definition for a callback to be invoked when an active page has been changed.
*/
public interface OnActivePageChangedListener {
/** Called when the active page has been changed. */
void onActivePageChanged(int currentActivePage);
}
}