Search UI clean up
- Resolve spacing issue when work profile is installed - Cache play icons and use icon shape - Only draw focus indicator for the first result Bug: 170487752 Bug: 170665892 Change-Id: I864d2e796786637132e127ef9b418c0a76c74d6e
This commit is contained in:
parent
2727434c44
commit
2afcab804b
|
@ -26,7 +26,6 @@
|
|||
android:clipChildren="true"
|
||||
android:clipToPadding="false"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:paddingTop="@dimen/all_apps_header_top_padding"
|
||||
launcher:pageIndicator="@+id/tabs" >
|
||||
|
||||
<include layout="@layout/all_apps_rv_layout" />
|
||||
|
|
|
@ -585,10 +585,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
|||
int padding = mHeader.getMaxTranslation();
|
||||
for (int i = 0; i < mAH.length; i++) {
|
||||
mAH[i].padding.top = padding;
|
||||
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && mUsingTabs) {
|
||||
//add extra space between tabs and recycler view
|
||||
mAH[i].padding.top += mLauncher.getDeviceProfile().edgeMarginPx;
|
||||
}
|
||||
mAH[i].applyPadding();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import android.util.AttributeSet;
|
|||
import android.view.MotionEvent;
|
||||
|
||||
import com.android.launcher3.PagedView;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
|
||||
public class AllAppsPagedView extends PagedView<PersonalWorkSlidingTabStrip> {
|
||||
|
||||
|
@ -37,6 +39,9 @@ public class AllAppsPagedView extends PagedView<PersonalWorkSlidingTabStrip> {
|
|||
|
||||
public AllAppsPagedView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
int topPadding = FeatureFlags.ENABLE_DEVICE_SEARCH.get() ? 0
|
||||
: context.getResources().getDimensionPixelOffset(
|
||||
R.dimen.all_apps_header_top_padding);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,6 +26,7 @@ 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.util.Themes;
|
||||
|
||||
|
@ -90,7 +91,10 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
|
|||
if (mAppsView.getFloatingHeaderView().getFocusedChild() == null
|
||||
&& mAppsView.getApps().getFocusedChild() != null) {
|
||||
int index = mAppsView.getApps().getFocusedChildIndex();
|
||||
if (index >= 0 && index < parent.getChildCount()) {
|
||||
AppsGridLayoutManager layoutManager = (AppsGridLayoutManager)
|
||||
mAppsView.getActiveRecyclerView().getLayoutManager();
|
||||
if (layoutManager.findFirstVisibleItemPosition() == index
|
||||
&& index < parent.getChildCount()) {
|
||||
decorationHandler.onFocusDraw(c, parent.getChildAt(index));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,12 +44,14 @@ import com.android.launcher3.R;
|
|||
import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItemWithPayload;
|
||||
import com.android.launcher3.allapps.search.AllAppsSearchBarController;
|
||||
import com.android.launcher3.icons.BitmapRenderer;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.systemui.plugins.AllAppsSearchPlugin;
|
||||
import com.android.systemui.plugins.shared.SearchTarget;
|
||||
import com.android.systemui.plugins.shared.SearchTargetEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
* A View representing a PlayStore item.
|
||||
|
@ -58,7 +60,6 @@ public class SearchResultPlayItem extends LinearLayout implements
|
|||
AllAppsSearchBarController.PayloadResultHandler<Bundle> {
|
||||
|
||||
private static final int BITMAP_CROP_MASK_COLOR = 0xff424242;
|
||||
private static final float ICON_RADIUS_FACTOR = .5f;
|
||||
|
||||
private final DeviceProfile mDeviceProfile;
|
||||
private View mIconView;
|
||||
|
@ -71,6 +72,7 @@ public class SearchResultPlayItem extends LinearLayout implements
|
|||
private final Object[] mTargetInfo = createTargetInfo();
|
||||
|
||||
final Paint mIconPaint = new Paint();
|
||||
final Rect mTempRect = new Rect();
|
||||
|
||||
|
||||
public SearchResultPlayItem(Context context) {
|
||||
|
@ -125,13 +127,15 @@ public class SearchResultPlayItem extends LinearLayout implements
|
|||
mIconView.setBackgroundResource(R.drawable.ic_deepshortcut_placeholder);
|
||||
UI_HELPER_EXECUTOR.execute(() -> {
|
||||
try {
|
||||
// TODO: Handle caching
|
||||
URL url = new URL(bundle.getString("icon_url"));
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
|
||||
BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(),
|
||||
Bitmap.createScaledBitmap(getRoundedBitmap(bitmap),
|
||||
mDeviceProfile.allAppsIconSizePx, mDeviceProfile.allAppsIconSizePx,
|
||||
false));
|
||||
URLConnection con = url.openConnection();
|
||||
// TODO: monitor memory and investigate if it's better to use glide
|
||||
con.addRequestProperty("Cache-Control", "max-age: 0");
|
||||
con.setUseCaches(true);
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(con.getInputStream());
|
||||
BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), getRoundedBitmap(
|
||||
Bitmap.createScaledBitmap(bitmap, mDeviceProfile.allAppsIconSizePx,
|
||||
mDeviceProfile.allAppsIconSizePx, false)));
|
||||
mIconView.post(() -> mIconView.setBackground(bitmapDrawable));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -141,24 +145,23 @@ public class SearchResultPlayItem extends LinearLayout implements
|
|||
|
||||
|
||||
private Bitmap getRoundedBitmap(Bitmap bitmap) {
|
||||
int iconSize = bitmap.getWidth();
|
||||
final int iconSize = bitmap.getWidth();
|
||||
final float radius = Themes.getDialogCornerRadius(getContext());
|
||||
|
||||
Bitmap output = BitmapRenderer.createHardwareBitmap(iconSize, iconSize, (canvas) -> {
|
||||
final Rect rect = new Rect(0, 0, iconSize, iconSize);
|
||||
final RectF rectF = new RectF(rect);
|
||||
mTempRect.set(0, 0, iconSize, iconSize);
|
||||
final RectF rectF = new RectF(mTempRect);
|
||||
|
||||
mIconPaint.setAntiAlias(true);
|
||||
mIconPaint.reset();
|
||||
canvas.drawARGB(0, 0, 0, 0);
|
||||
mIconPaint.setColor(BITMAP_CROP_MASK_COLOR);
|
||||
int radius = (int) (iconSize * ICON_RADIUS_FACTOR);
|
||||
canvas.drawRoundRect(rectF, radius, radius, mIconPaint);
|
||||
|
||||
mIconPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas.drawBitmap(bitmap, rect, rect, mIconPaint);
|
||||
canvas.drawBitmap(bitmap, mTempRect, mTempRect, mIconPaint);
|
||||
});
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue