From ab4fbfefc95a3dc73868d822636ddd05d57cf61c Mon Sep 17 00:00:00 2001 From: Saul Henriquez Date: Sun, 7 Feb 2021 10:42:52 -0600 Subject: [PATCH] actualizar codigo para Folder Icon Signed-off-by: Saul Henriquez --- .../saggitt/omega/icons/CustomIconProvider.kt | 10 +++++----- .../saggitt/omega/qsb/AbstractQsbLayout.java | 6 +++--- .../saggitt/omega/qsb/AllAppsQsbLayout.java | 2 -- .../saggitt/omega/search/SearchThread.java | 19 ++++++++++++------- .../search/providers/GoogleSearchProvider.kt | 4 +++- assets/changelog.htm | 4 ++-- src/com/android/launcher3/Utilities.java | 4 ++++ src/com/android/launcher3/Workspace.java | 5 +++-- src/com/android/launcher3/folder/Folder.java | 16 +++++++++------- .../android/launcher3/folder/FolderIcon.java | 16 +++++++++++----- .../launcher3/folder/PreviewBackground.java | 1 + .../launcher3/folder/PreviewItemManager.java | 17 ++++++++++++----- .../launcher3/views/FloatingIconView.java | 2 +- 13 files changed, 66 insertions(+), 40 deletions(-) diff --git a/Omega/src/com/saggitt/omega/icons/CustomIconProvider.kt b/Omega/src/com/saggitt/omega/icons/CustomIconProvider.kt index 8c4ee226b8..f0aa570751 100644 --- a/Omega/src/com/saggitt/omega/icons/CustomIconProvider.kt +++ b/Omega/src/com/saggitt/omega/icons/CustomIconProvider.kt @@ -37,24 +37,24 @@ class CustomIconProvider(context: Context) : DynamicIconProvider(context) { private val iconPackManager by lazy { IconPackManager.getInstance(context) } override fun getIcon(launcherActivityInfo: LauncherActivityInfo, iconDpi: Int, flattenDrawable: Boolean): Drawable { - return iconPackManager.getIcon(launcherActivityInfo, iconDpi, flattenDrawable, null, this)//.assertNotAdaptiveIconDrawable(launcherActivityInfo) + return iconPackManager.getIcon(launcherActivityInfo, iconDpi, flattenDrawable, null, this).assertNotAdaptiveIconDrawable(launcherActivityInfo) } fun getIcon(launcherActivityInfo: LauncherActivityInfo, itemInfo: ItemInfo, iconDpi: Int, flattenDrawable: Boolean): Drawable { - return iconPackManager.getIcon(launcherActivityInfo, iconDpi, flattenDrawable, itemInfo, this)//.assertNotAdaptiveIconDrawable(launcherActivityInfo) + return iconPackManager.getIcon(launcherActivityInfo, iconDpi, flattenDrawable, itemInfo, this).assertNotAdaptiveIconDrawable(launcherActivityInfo) } fun getIcon(shortcutInfo: ShortcutInfoCompat, iconDpi: Int): Drawable? { - return iconPackManager.getIcon(shortcutInfo, iconDpi)//.assertNotAdaptiveIconDrawable(shortcutInfo) + return iconPackManager.getIcon(shortcutInfo, iconDpi).assertNotAdaptiveIconDrawable(shortcutInfo) } fun getIcon(shortcutInfo: ShortcutInfo, iconDpi: Int): Drawable? { - return iconPackManager.getIcon(shortcutInfo, iconDpi)//.assertNotAdaptiveIconDrawable(shortcutInfo) + return iconPackManager.getIcon(shortcutInfo, iconDpi).assertNotAdaptiveIconDrawable(shortcutInfo) } @RequiresApi(Build.VERSION_CODES.O) fun getDynamicIcon(launcherActivityInfo: LauncherActivityInfo?, iconDpi: Int, flattenDrawable: Boolean): Drawable { - return super.getIcon(launcherActivityInfo, iconDpi, flattenDrawable)//.assertNotAdaptiveIconDrawable(launcherActivityInfo) + return super.getIcon(launcherActivityInfo, iconDpi, flattenDrawable).assertNotAdaptiveIconDrawable(launcherActivityInfo) } private fun T.assertNotAdaptiveIconDrawable(info: Any?): T { diff --git a/Omega/src/com/saggitt/omega/qsb/AbstractQsbLayout.java b/Omega/src/com/saggitt/omega/qsb/AbstractQsbLayout.java index 79427d6daa..f5e3111171 100644 --- a/Omega/src/com/saggitt/omega/qsb/AbstractQsbLayout.java +++ b/Omega/src/com/saggitt/omega/qsb/AbstractQsbLayout.java @@ -520,7 +520,7 @@ protected final void setHintText(String str, TextView textView) { protected final boolean dE() { if (!Dh && !mUseTwoBubbles) { - return mUseTwoBubbles; + return false; } return true; } @@ -530,10 +530,10 @@ protected final int getRtlDimens() { } protected int getMicWidth() { - if (!mUseTwoBubbles || TextUtils.isEmpty(this.Dg)) { + if (!mUseTwoBubbles || TextUtils.isEmpty(Dg)) { return mSearchIconWidth; } - return (Math.round(qsbTextHintSize.measureText(this.Dg)) + qsbTextSpacing) + mSearchIconWidth; + return (Math.round(qsbTextHintSize.measureText(Dg)) + qsbTextSpacing) + mSearchIconWidth; } protected final void addOrUpdateSearchRipple() { diff --git a/Omega/src/com/saggitt/omega/qsb/AllAppsQsbLayout.java b/Omega/src/com/saggitt/omega/qsb/AllAppsQsbLayout.java index c5f7ae6939..eab8cf3049 100644 --- a/Omega/src/com/saggitt/omega/qsb/AllAppsQsbLayout.java +++ b/Omega/src/com/saggitt/omega/qsb/AllAppsQsbLayout.java @@ -22,7 +22,6 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -70,7 +69,6 @@ public class AllAppsQsbLayout extends AbstractQsbLayout implements SearchUiManag public boolean mDoNotRemoveFallback; private final boolean mLowPerformanceMode; private int mShadowAlpha; - private Bitmap mShadowBitmap; private boolean mUseFallbackSearch; private FallbackAppsSearchView mFallback; private TextView mHint; diff --git a/Omega/src/com/saggitt/omega/search/SearchThread.java b/Omega/src/com/saggitt/omega/search/SearchThread.java index 6b8853e8b7..41474c27c0 100644 --- a/Omega/src/com/saggitt/omega/search/SearchThread.java +++ b/Omega/src/com/saggitt/omega/search/SearchThread.java @@ -51,23 +51,28 @@ public SearchThread(Context context) { mHandler = new Handler(SearchThread.handlerThread.getLooper(), this); } - private void dj(SearchResult componentList) { + private void dj(SearchResult result) { Uri uri = new Uri.Builder() .scheme("content") .authority(BuildConfig.APPLICATION_ID + ".appssearch") - .appendPath(componentList.mQuery) + .appendPath(result.mQuery) .build(); - - try (Cursor cursor = mContext.getContentResolver().query(uri, null, null, null, null)) { + Cursor cursor = null; + try { + cursor = mContext.getContentResolver().query(uri, null, null, null, null); int suggestIntentData = cursor.getColumnIndex("suggest_intent_data"); while (cursor.moveToNext()) { - componentList.mApps.add(AppSearchProvider.uriToComponent(Uri.parse(cursor.getString(suggestIntentData)), mContext)); + result.mApps.add(AppSearchProvider.uriToComponent(Uri.parse(cursor.getString(suggestIntentData)), mContext)); } } catch (NullPointerException ignored) { + } finally { + if (cursor != null) { + cursor.close(); + } } - componentList.mSuggestions.addAll(getSuggestions(componentList.mQuery)); - Message.obtain(mUiHandler, 200, componentList).sendToTarget(); + result.mSuggestions.addAll(getSuggestions(result.mQuery)); + Message.obtain(mUiHandler, 200, result).sendToTarget(); } public void cancel(boolean interruptActiveRequests) { diff --git a/Omega/src/com/saggitt/omega/search/providers/GoogleSearchProvider.kt b/Omega/src/com/saggitt/omega/search/providers/GoogleSearchProvider.kt index ac4b3fab93..fed1862bb7 100644 --- a/Omega/src/com/saggitt/omega/search/providers/GoogleSearchProvider.kt +++ b/Omega/src/com/saggitt/omega/search/providers/GoogleSearchProvider.kt @@ -22,6 +22,7 @@ import android.content.Intent import android.graphics.drawable.Drawable import androidx.annotation.Keep import com.android.launcher3.R +import com.android.launcher3.util.PackageManagerHelper import com.saggitt.omega.OmegaLauncher import com.saggitt.omega.search.SearchProvider import com.saggitt.omega.util.Config @@ -32,6 +33,8 @@ class GoogleSearchProvider(context: Context) : SearchProvider(context) { override val name = context.getString(R.string.google_app) override val supportsVoiceSearch = true override val supportsAssistant = true + override val isAvailable: Boolean + get() = PackageManagerHelper.isAppEnabled(context.packageManager, Config.GOOGLE_QSB, 0) override val supportsFeed = true override val settingsIntent: Intent get() = Intent("com.google.android.apps.gsa.nowoverlayservice.PIXEL_DOODLE_QSB_SETTINGS") @@ -39,7 +42,6 @@ class GoogleSearchProvider(context: Context) : SearchProvider(context) { override val isBroadcast: Boolean get() = true - override fun startSearch(callback: (intent: Intent) -> Unit) = callback(Intent().setClassName(Config.GOOGLE_QSB, "${Config.GOOGLE_QSB}.SearchActivity")) diff --git a/assets/changelog.htm b/assets/changelog.htm index eeaab4f031..ddc5f5e302 100644 --- a/assets/changelog.htm +++ b/assets/changelog.htm @@ -9,8 +9,8 @@
-

v0.8.0 (Build 200)

-

Release date: 02-28-2021

+

v0.7.1 (Build 118)

+

Release date: 02-07-2021

  • Add: Save scroll position
  • Fix: Empty space when drawer search bar is disabled
  • diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 46a8609caa..b981c77f21 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -640,6 +640,10 @@ public static Drawable getBadge(Launcher launcher, ItemInfo info, Object obj) { return new InsetDrawable(new FastBitmapDrawable(badge), insetFraction, insetFraction, 0, 0); } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) { + FolderInfo folderInfo = (FolderInfo) info; + if (folderInfo.isCoverMode()) { + return getBadge(launcher, folderInfo.getCoverInfo(), obj); + } return ((FolderAdaptiveIcon) obj).getBadge(); } else { return launcher.getPackageManager() diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index e9566001ef..ef0c980122 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1566,8 +1566,8 @@ public DragView beginDragShared(View child, DragSource source, ItemInfo dragObje Rect dragRect = null; if (child instanceof BubbleTextView) { dragRect = new Rect(); - //BubbleTextView.getIconBounds(child, dragRect, grid.iconSizePx); - ((BubbleTextView) child).getIconBounds(dragRect); + BubbleTextView.getIconBounds(child, dragRect, grid.iconSizePx); + //((BubbleTextView) child).getIconBounds(dragRect); dragLayerY += dragRect.top; // Note: The dragRect is used to calculate drag layer offsets, but the // dragVisualizeOffset in addition to the dragRect (the size) to position the outline. @@ -3160,6 +3160,7 @@ public void removeItemsByMatcher(final ItemInfoMatcher matcher) { View parent = idToViewMap.get(itemToRemove.container); if (parent instanceof FolderIcon) { FolderInfo folderInfo = (FolderInfo) parent.getTag(); + folderInfo.prepareAutoUpdate(); folderInfo.remove((WorkspaceItemInfo) itemToRemove, false); if (((FolderIcon) parent).getFolder().isOpen()) { ((FolderIcon) parent).getFolder().close(false /* animate */); diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index c8d1b8ef78..29f28c7cda 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -594,7 +594,8 @@ private void animateOpen(List items, int pageNo) { anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { - mFolderIcon.setIconVisible(false); + //mFolderIcon.setIconVisible(false); + mFolderIcon.setBackgroundVisible(false); mFolderIcon.drawLeaveBehindIfExists(); } @Override @@ -721,7 +722,8 @@ private void closeComplete(boolean wasAnimated) { if (mFolderIcon != null) { mFolderIcon.setVisibility(View.VISIBLE); mFolderIcon.setIconVisible(true); - mFolderIcon.mFolderName.setTextVisibility(true); + mFolderIcon.setBackgroundVisible(true); + mFolderIcon.mFolderName.setTextVisibility(mFolderIcon.mFolderName.shouldTextBeVisible()); if (wasAnimated) { mFolderIcon.animateBgShadowAndStroke(); mFolderIcon.onFolderClose(mContent.getCurrentPage()); @@ -1354,6 +1356,11 @@ public static String getDefaultFolderName() { return sDefaultFolderName; } + @Override + public void prepareAutoUpdate() { + close(false); + } + public void onTitleChanged(CharSequence title) { } @@ -1578,11 +1585,6 @@ public void draw(Canvas canvas) { } } - @Override - public void prepareAutoUpdate() { - close(false); - } - public boolean isInAppDrawer() { return mInfo.container == ItemInfo.NO_ID; } diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index 17edb1f6b6..28136b43d0 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -138,6 +138,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel private GestureHandler mSwipeUpHandler; public boolean isCustomIcon = false; + private boolean mIsTextVisible = true; private static final Property DOT_SCALE_PROPERTY = new Property(Float.TYPE, "dotScale") { @@ -619,13 +620,13 @@ protected void dispatchDraw(Canvas canvas) { if (mFolder == null) return; if (mFolder.getItemCount() == 0 && !mAnimating) return; - //mPreviewItemManager.recomputePreviewDrawingParams(); + mPreviewItemManager.recomputePreviewDrawingParams(); - //if (!mBackground.drawingDelegated()) { - // mBackground.drawBackground(canvas); - //} + if (!mBackground.drawingDelegated()) { + mBackground.drawBackground(canvas); + } - //if (mCurrentPreviewItems.isEmpty() && !mAnimating) return; + if (mCurrentPreviewItems.isEmpty() && !mAnimating) return; final int saveCount = canvas.save(); canvas.clipPath(mBackground.getClipPath()); @@ -699,6 +700,11 @@ public void verifyHighRes() { } } + public void setBackgroundVisible(boolean visible) { + mBackgroundIsVisible = visible; + invalidate(); + } + @Override protected boolean verifyDrawable(@NonNull Drawable who) { return mPreviewItemManager.verifyDrawable(who) || super.verifyDrawable(who); diff --git a/src/com/android/launcher3/folder/PreviewBackground.java b/src/com/android/launcher3/folder/PreviewBackground.java index 95bb295800..d0c88c7cdd 100644 --- a/src/com/android/launcher3/folder/PreviewBackground.java +++ b/src/com/android/launcher3/folder/PreviewBackground.java @@ -141,6 +141,7 @@ public void setup(Context context, ActivityContext activity, View invalidateDele TypedArray ta = context.getTheme().obtainStyledAttributes(R.styleable.FolderIconPreview); mDotColor = ta.getColor(R.styleable.FolderIconPreview_folderDotColor, 0); mStrokeColor = ta.getColor(R.styleable.FolderIconPreview_folderIconBorderColor, 0); + //TODO: CREAR COLOR PERSONALIZADO DE FOLDER ICON mBgColor = ta.getColor(R.styleable.FolderIconPreview_folderFillColor, 0); ta.recycle(); diff --git a/src/com/android/launcher3/folder/PreviewItemManager.java b/src/com/android/launcher3/folder/PreviewItemManager.java index 2d817e6d2d..82392245a2 100644 --- a/src/com/android/launcher3/folder/PreviewItemManager.java +++ b/src/com/android/launcher3/folder/PreviewItemManager.java @@ -16,11 +16,6 @@ package com.android.launcher3.folder; -import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.ENTER_INDEX; -import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.EXIT_INDEX; -import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW; -import static com.android.launcher3.folder.FolderIcon.DROP_IN_ANIMATION_DURATION; - import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; @@ -45,6 +40,11 @@ import java.util.List; import java.util.function.Predicate; +import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.ENTER_INDEX; +import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.EXIT_INDEX; +import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW; +import static com.android.launcher3.folder.FolderIcon.DROP_IN_ANIMATION_DURATION; + /** * Manages the drawing and animations of {@link PreviewItemDrawingParams} for a {@link FolderIcon}. */ @@ -275,6 +275,13 @@ void onFolderClose(int currentPage) { ValueAnimator slideAnimator = ObjectAnimator .ofFloat(this, CURRENT_PAGE_ITEMS_TRANS_X, 0, ITEM_SLIDE_IN_OUT_DISTANCE_PX); + slideAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator valueAnimator) { + mCurrentPageItemsTransX = (float) valueAnimator.getAnimatedValue(); + onParamsChanged(); + } + }); slideAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java index 64e6cc91dc..aa5997e18a 100644 --- a/src/com/android/launcher3/views/FloatingIconView.java +++ b/src/com/android/launcher3/views/FloatingIconView.java @@ -396,7 +396,7 @@ private static float getLocationBoundsForView(Launcher launcher, View v, boolean @SuppressWarnings("WrongThread") private static void getIconResult(Launcher l, View originalView, ItemInfo info, RectF pos, IconLoadResult iconLoadResult) { - Drawable drawable = null; + Drawable drawable; Drawable badge = null; boolean supportsAdaptiveIcons = ADAPTIVE_ICON_WINDOW_ANIM.get() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;