Merge "[Search] Show search suggestions with in Recyclerview" into sc-v2-dev am: 4112ae6a5b

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/16172124

Change-Id: Ia70b58dae6b9f7c10c85c2d8f88408828b361f85
This commit is contained in:
Samuel Fufa
2021-11-04 21:05:52 +00:00
committed by Automerger Merge Worker
3 changed files with 11 additions and 67 deletions
-9
View File
@@ -43,15 +43,6 @@
<include layout="@layout/all_apps_personal_work_tabs" /> <include layout="@layout/all_apps_personal_work_tabs" />
<Button
android:id="@+id/all_apps_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/all_apps_label"
android:background="@drawable/padded_rounded_action_button"
android:visibility="gone"/>
</com.android.launcher3.allapps.FloatingHeaderView> </com.android.launcher3.allapps.FloatingHeaderView>
<include layout="@layout/search_container_all_apps" /> <include layout="@layout/search_container_all_apps" />
@@ -42,6 +42,7 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.BubbleTextView; import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.PackageManagerHelper;
import java.util.Arrays; import java.util.Arrays;
@@ -95,16 +96,15 @@ public class AllAppsGridAdapter extends
// The type of this item // The type of this item
public int viewType; public int viewType;
/** App-only properties */ // The section name of this item. Note that there can be multiple items with different
// The section name of this app. Note that there can be multiple items with different
// sectionNames in the same section // sectionNames in the same section
public String sectionName = null; public String sectionName = null;
// The row that this item shows up on // The row that this item shows up on
public int rowIndex; public int rowIndex;
// The index of this app in the row // The index of this app in the row
public int rowAppIndex; public int rowAppIndex;
// The associated AppInfo for the app // The associated ItemInfoWithIcon for the item
public AppInfo appInfo = null; public ItemInfoWithIcon itemInfo = null;
// The index of this app not including sections // The index of this app not including sections
public int appIndex = -1; public int appIndex = -1;
// Search section associated to result // Search section associated to result
@@ -119,7 +119,7 @@ public class AllAppsGridAdapter extends
item.viewType = VIEW_TYPE_ICON; item.viewType = VIEW_TYPE_ICON;
item.position = pos; item.position = pos;
item.sectionName = sectionName; item.sectionName = sectionName;
item.appInfo = appInfo; item.itemInfo = appInfo;
item.appIndex = appIndex; item.appIndex = appIndex;
return item; return item;
} }
@@ -373,7 +373,7 @@ public class AllAppsGridAdapter extends
if (adapterProvider != null) { if (adapterProvider != null) {
return adapterProvider.onCreateViewHolder(mLayoutInflater, parent, viewType); return adapterProvider.onCreateViewHolder(mLayoutInflater, parent, viewType);
} }
throw new RuntimeException("Unexpected view type"); throw new RuntimeException("Unexpected view type" + viewType);
} }
} }
@@ -382,10 +382,13 @@ public class AllAppsGridAdapter extends
switch (holder.getItemViewType()) { switch (holder.getItemViewType()) {
case VIEW_TYPE_ICON: case VIEW_TYPE_ICON:
AdapterItem adapterItem = mApps.getAdapterItems().get(position); AdapterItem adapterItem = mApps.getAdapterItems().get(position);
AppInfo info = adapterItem.appInfo;
BubbleTextView icon = (BubbleTextView) holder.itemView; BubbleTextView icon = (BubbleTextView) holder.itemView;
icon.reset(); icon.reset();
icon.applyFromApplicationInfo(info); if (adapterItem.itemInfo instanceof AppInfo) {
icon.applyFromApplicationInfo((AppInfo) adapterItem.itemInfo);
} else {
icon.applyFromItemInfoWithIcon(adapterItem.itemInfo);
}
break; break;
case VIEW_TYPE_EMPTY_SEARCH: case VIEW_TYPE_EMPTY_SEARCH:
TextView emptyViewText = (TextView) holder.itemView; TextView emptyViewText = (TextView) holder.itemView;
@@ -47,7 +47,6 @@ public class FloatingHeaderView extends LinearLayout implements
ValueAnimator.AnimatorUpdateListener, PluginListener<AllAppsRow>, Insettable, ValueAnimator.AnimatorUpdateListener, PluginListener<AllAppsRow>, Insettable,
OnHeightUpdatedListener { OnHeightUpdatedListener {
private static final long ALL_APPS_CONTENT_ANIM_DURATION = 150;
private final Rect mRVClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE); private final Rect mRVClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
private final Rect mHeaderClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE); private final Rect mHeaderClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
private final ValueAnimator mAnimator = ValueAnimator.ofInt(0, 0); private final ValueAnimator mAnimator = ValueAnimator.ofInt(0, 0);
@@ -110,13 +109,6 @@ public class FloatingHeaderView extends LinearLayout implements
private FloatingHeaderRow[] mAllRows = FloatingHeaderRow.NO_ROWS; private FloatingHeaderRow[] mAllRows = FloatingHeaderRow.NO_ROWS;
// members for handling suggestion state
private final ValueAnimator mAllAppsContentAnimator = ValueAnimator.ofFloat(0, 0);
private View mAllAppsButton;
private int mAllAppsContentFadeInOffset;
private boolean mInSuggestionMode = false;
public FloatingHeaderView(@NonNull Context context) { public FloatingHeaderView(@NonNull Context context) {
this(context, null); this(context, null);
} }
@@ -127,20 +119,12 @@ public class FloatingHeaderView extends LinearLayout implements
.getDimensionPixelSize(R.dimen.all_apps_header_top_padding); .getDimensionPixelSize(R.dimen.all_apps_header_top_padding);
mHeaderProtectionSupported = context.getResources().getBoolean( mHeaderProtectionSupported = context.getResources().getBoolean(
R.bool.config_header_protection_supported); R.bool.config_header_protection_supported);
mAllAppsContentFadeInOffset = context.getResources()
.getDimensionPixelSize(R.dimen.all_apps_content_fade_in_offset);
mAllAppsContentAnimator.setDuration(ALL_APPS_CONTENT_ANIM_DURATION);
mAllAppsContentAnimator.addUpdateListener(this::onAllAppsContentAnimationUpdate);
} }
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
mTabLayout = findViewById(R.id.tabs); mTabLayout = findViewById(R.id.tabs);
mAllAppsButton = findViewById(R.id.all_apps_button);
if (mAllAppsButton != null) {
mAllAppsButton.setOnClickListener(this::onAllAppsButtonClicked);
}
// Find all floating header rows. // Find all floating header rows.
ArrayList<FloatingHeaderRow> rows = new ArrayList<>(); ArrayList<FloatingHeaderRow> rows = new ArrayList<>();
@@ -329,7 +313,6 @@ public class FloatingHeaderView extends LinearLayout implements
} }
mTabLayout.setTranslationY(mTranslationY); mTabLayout.setTranslationY(mTranslationY);
setSuggestionMode(false);
int clipHeight = mHeaderTopPadding - getPaddingBottom(); int clipHeight = mHeaderTopPadding - getPaddingBottom();
mRVClip.top = mTabsHidden ? clipHeight : 0; mRVClip.top = mTabsHidden ? clipHeight : 0;
@@ -365,7 +348,6 @@ public class FloatingHeaderView extends LinearLayout implements
mTranslationY = 0; mTranslationY = 0;
applyVerticalMove(); applyVerticalMove();
} }
setSuggestionMode(false);
mHeaderCollapsed = false; mHeaderCollapsed = false;
mSnappedScrolledY = -mMaxTranslation; mSnappedScrolledY = -mMaxTranslation;
mCurrentRV.scrollToTop(); mCurrentRV.scrollToTop();
@@ -461,38 +443,6 @@ public class FloatingHeaderView extends LinearLayout implements
} }
return Math.max(getHeight() - getPaddingTop() + mTranslationY, 0); return Math.max(getHeight() - getPaddingTop() + mTranslationY, 0);
} }
/**
* When suggestion mode is enabled, hides AllApps content view and shows AllApps button.
*/
public void setSuggestionMode(boolean isSuggestMode) {
if (mInSuggestionMode == isSuggestMode || mAllAppsButton == null) return;
if (!FeatureFlags.ENABLE_ONE_SEARCH.get()) return;
AllAppsContainerView allApps = (AllAppsContainerView) getParent();
mInSuggestionMode = isSuggestMode;
if (isSuggestMode) {
mTabLayout.setVisibility(GONE);
mAllAppsButton.setVisibility(VISIBLE);
allApps.getContentView().setVisibility(GONE);
} else {
mTabLayout.setVisibility(mTabsHidden ? GONE : VISIBLE);
mAllAppsButton.setVisibility(GONE);
allApps.getContentView().setVisibility(VISIBLE);
}
}
private void onAllAppsButtonClicked(View view) {
setSuggestionMode(false);
mAllAppsContentAnimator.start();
}
private void onAllAppsContentAnimationUpdate(ValueAnimator valueAnimator) {
float prog = valueAnimator.getAnimatedFraction();
View allAppsList = ((AllAppsContainerView) getParent()).getContentView();
allAppsList.setAlpha(255 * prog);
allAppsList.setTranslationY((1 - prog) * mAllAppsContentFadeInOffset);
}
} }