Skip to content

Commit

Permalink
actualizar codigo para Folder Icon
Browse files Browse the repository at this point in the history
Signed-off-by: Saul Henriquez <[email protected]>
  • Loading branch information
saulhdev committed Feb 7, 2021
1 parent 0feb4e4 commit ab4fbfe
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 40 deletions.
10 changes: 5 additions & 5 deletions Omega/src/com/saggitt/omega/icons/CustomIconProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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> T.assertNotAdaptiveIconDrawable(info: Any?): T {
Expand Down
6 changes: 3 additions & 3 deletions Omega/src/com/saggitt/omega/qsb/AbstractQsbLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions Omega/src/com/saggitt/omega/qsb/AllAppsQsbLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 12 additions & 7 deletions Omega/src/com/saggitt/omega/search/SearchThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,14 +33,15 @@ 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")
.setPackage(Config.GOOGLE_QSB).addFlags(268435456)
override val isBroadcast: Boolean
get() = true


override fun startSearch(callback: (intent: Intent) -> Unit) =
callback(Intent().setClassName(Config.GOOGLE_QSB, "${Config.GOOGLE_QSB}.SearchActivity"))

Expand Down
4 changes: 2 additions & 2 deletions assets/changelog.htm
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<body id="top">

<div>
<h2>v0.8.0 (Build 200)</h2>
<h4>Release date: 02-28-2021</h4>
<h2>v0.7.1 (Build 118)</h2>
<h4>Release date: 02-07-2021</h4>
<ul class="changelog">
<li>Add: Save scroll position</li>
<li>Fix: Empty space when drawer search bar is disabled</li>
Expand Down
4 changes: 4 additions & 0 deletions src/com/android/launcher3/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions src/com/android/launcher3/Workspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 */);
Expand Down
16 changes: 9 additions & 7 deletions src/com/android/launcher3/folder/Folder.java
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,8 @@ private void animateOpen(List<WorkspaceItemInfo> 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
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -1354,6 +1356,11 @@ public static String getDefaultFolderName() {
return sDefaultFolderName;
}

@Override
public void prepareAutoUpdate() {
close(false);
}

public void onTitleChanged(CharSequence title) {
}

Expand Down Expand Up @@ -1578,11 +1585,6 @@ public void draw(Canvas canvas) {
}
}

@Override
public void prepareAutoUpdate() {
close(false);
}

public boolean isInAppDrawer() {
return mInfo.container == ItemInfo.NO_ID;
}
Expand Down
16 changes: 11 additions & 5 deletions src/com/android/launcher3/folder/FolderIcon.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<FolderIcon, Float> DOT_SCALE_PROPERTY
= new Property<FolderIcon, Float>(Float.TYPE, "dotScale") {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/com/android/launcher3/folder/PreviewBackground.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
17 changes: 12 additions & 5 deletions src/com/android/launcher3/folder/PreviewItemManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
*/
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/android/launcher3/views/FloatingIconView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ab4fbfe

Please sign in to comment.