Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6077811 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Making LauncherIcons thread safe" into ub-launcher3-master

parents 33be6a13 18a4e5ae
Loading
Loading
Loading
Loading

res/layout/user_folder.xml

deleted100644 → 0
+0 −74
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2015 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.folder.Folder xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/round_rect_primary"
    android:elevation="5dp"
    android:orientation="vertical" >

    <com.android.launcher3.folder.FolderPagedView
        android:id="@+id/folder_content"
        android:clipToPadding="false"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:paddingTop="16dp"
        launcher:pageIndicator="@+id/folder_page_indicator" />

    <LinearLayout
        android:id="@+id/folder_footer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipChildren="false"
        android:orientation="horizontal"
        android:paddingLeft="12dp"
        android:paddingRight="12dp" >

        <com.android.launcher3.ExtendedEditText
            android:id="@+id/folder_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:background="@android:color/transparent"
            android:fontFamily="sans-serif-condensed"
            android:gravity="center_horizontal"
            android:hint="@string/folder_hint_text"
            android:imeOptions="flagNoExtractUi"
            android:paddingBottom="@dimen/folder_label_padding_bottom"
            android:paddingTop="@dimen/folder_label_padding_top"
            android:singleLine="true"
            android:textColor="?android:attr/textColorTertiary"
            android:includeFontPadding="false"
            android:textColorHighlight="?android:attr/colorControlHighlight"
            android:textColorHint="?android:attr/textColorHint"
            android:textSize="@dimen/folder_label_text_size" />

        <com.android.launcher3.pageindicators.PageIndicatorDots
            android:id="@+id/folder_page_indicator"
            android:layout_gravity="center_vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:elevation="1dp"
            />

    </LinearLayout>

</com.android.launcher3.folder.Folder>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ public class AppInfo extends ItemInfoWithIcon {
        info.runtimeStatusFlags |= (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0
                ? FLAG_SYSTEM_NO : FLAG_SYSTEM_YES;

        if (FeatureFlags.LEGACY_ICON_TREATMENT && Utilities.ATLEAST_OREO
        if (Utilities.ATLEAST_OREO
                && appInfo.targetSdkVersion >= Build.VERSION_CODES.O
                && Process.myUserHandle().equals(lai.getUser())) {
            // The icon for a non-primary user is badged, hence it's not exactly an adaptive icon.
+4 −2
Original line number Diff line number Diff line
@@ -437,9 +437,11 @@ public class AutoInstallsLayout {
            }

            // Auto installs should always support the current platform version.
            LauncherIcons li = LauncherIcons.obtain(mContext);
            mValues.put(LauncherSettings.Favorites.ICON, Utilities.flattenBitmap(
                    LauncherIcons.createBadgedIconBitmap(
                            icon, Process.myUserHandle(), mContext, VERSION.SDK_INT).icon));
                    li.createBadgedIconBitmap(icon, Process.myUserHandle(), VERSION.SDK_INT).icon));
            li.recycle();

            mValues.put(Favorites.ICON_PACKAGE, mIconRes.getResourcePackageName(iconId));
            mValues.put(Favorites.ICON_RESOURCE, mIconRes.getResourceName(iconId));

+22 −15
Original line number Diff line number Diff line
@@ -193,8 +193,10 @@ public class IconCache {
    }

    protected BitmapInfo makeDefaultIcon(UserHandle user) {
        Drawable unbadged = getFullResDefaultActivityIcon();
        return LauncherIcons.createBadgedIconBitmap(unbadged, user, mContext, VERSION.SDK_INT);
        try (LauncherIcons li = LauncherIcons.obtain(mContext)) {
            return li.createBadgedIconBitmap(
                    getFullResDefaultActivityIcon(), user, VERSION.SDK_INT);
        }
    }

    /**
@@ -378,8 +380,10 @@ public class IconCache {
        }
        if (entry == null) {
            entry = new CacheEntry();
            LauncherIcons.createBadgedIconBitmap(getFullResIcon(app), app.getUser(),
                    mContext,  app.getApplicationInfo().targetSdkVersion).applyTo(entry);
            LauncherIcons li = LauncherIcons.obtain(mContext);
            li.createBadgedIconBitmap(getFullResIcon(app), app.getUser(),
                    app.getApplicationInfo().targetSdkVersion).applyTo(entry);
            li.recycle();
        }
        entry.title = app.getLabel();
        entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser());
@@ -535,9 +539,10 @@ public class IconCache {
                providerFetchedOnce = true;

                if (info != null) {
                    LauncherIcons.createBadgedIconBitmap(
                            getFullResIcon(info), info.getUser(), mContext,
                    LauncherIcons li = LauncherIcons.obtain(mContext);
                    li.createBadgedIconBitmap(getFullResIcon(info), info.getUser(),
                            info.getApplicationInfo().targetSdkVersion).applyTo(entry);
                    li.recycle();
                } else {
                    if (usePackageIcon) {
                        CacheEntry packageEntry = getEntryForPackageLocked(
@@ -596,7 +601,9 @@ public class IconCache {
            entry.title = title;
        }
        if (icon != null) {
            LauncherIcons.createIconBitmap(icon, mContext).applyTo(entry);
            LauncherIcons li = LauncherIcons.obtain(mContext);
            li.createIconBitmap(icon).applyTo(entry);
            li.recycle();
        }
        if (!TextUtils.isEmpty(title) && entry.icon != null) {
            mCache.put(cacheKey, entry);
@@ -633,14 +640,17 @@ public class IconCache {
                        throw new NameNotFoundException("ApplicationInfo is null");
                    }

                    LauncherIcons li = LauncherIcons.obtain(mContext);
                    // Load the full res icon for the application, but if useLowResIcon is set, then
                    // only keep the low resolution icon instead of the larger full-sized icon
                    BitmapInfo iconInfo = LauncherIcons.createBadgedIconBitmap(
                            appInfo.loadIcon(mPackageManager), user, mContext, appInfo.targetSdkVersion);
                    BitmapInfo iconInfo = li.createBadgedIconBitmap(
                            appInfo.loadIcon(mPackageManager), user, appInfo.targetSdkVersion);
                    if (mInstantAppResolver.isInstantApp(appInfo)) {
                        LauncherIcons.badgeWithDrawable(iconInfo.icon,
                                mContext.getDrawable(R.drawable.ic_instant_app_badge), mContext);
                        li.badgeWithDrawable(iconInfo.icon,
                                mContext.getDrawable(R.drawable.ic_instant_app_badge));
                    }
                    li.recycle();

                    Bitmap lowResIcon =  generateLowResIcon(iconInfo.icon);
                    entry.title = appInfo.loadLabel(mPackageManager);
                    entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);
@@ -776,10 +786,7 @@ public class IconCache {
    }

    private static final class IconDB extends SQLiteCacheHelper {
        private final static int DB_VERSION = 18;

        private final static int RELEASE_VERSION = DB_VERSION +
                (FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION ? 0 : 1);
        private final static int RELEASE_VERSION = 20;

        private final static String TABLE_NAME = "icons";
        private final static String COLUMN_ROWID = "rowid";
+8 −3
Original line number Diff line number Diff line
@@ -498,7 +498,9 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
                return Pair.create((ItemInfo) si, (Object) activityInfo);
            } else if (shortcutInfo != null) {
                ShortcutInfo si = new ShortcutInfo(shortcutInfo, mContext);
                LauncherIcons.createShortcutIcon(shortcutInfo, mContext).applyTo(si);
                LauncherIcons li = LauncherIcons.obtain(mContext);
                li.createShortcutIcon(shortcutInfo).applyTo(si);
                li.recycle();
                return Pair.create((ItemInfo) si, (Object) shortcutInfo);
            } else if (providerInfo != null) {
                LauncherAppWidgetProviderInfo info = LauncherAppWidgetProviderInfo
@@ -643,15 +645,18 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
        info.user = Process.myUserHandle();

        BitmapInfo iconInfo = null;
        LauncherIcons li = LauncherIcons.obtain(app.getContext());
        if (bitmap instanceof Bitmap) {
            iconInfo = LauncherIcons.createIconBitmap((Bitmap) bitmap, app.getContext());
            iconInfo = li.createIconBitmap((Bitmap) bitmap);
        } else {
            Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
            if (extra instanceof Intent.ShortcutIconResource) {
                info.iconResource = (Intent.ShortcutIconResource) extra;
                iconInfo = LauncherIcons.createIconBitmap(info.iconResource, app.getContext());
                iconInfo = li.createIconBitmap(info.iconResource);
            }
        }
        li.recycle();

        if (iconInfo == null) {
            iconInfo = app.getIconCache().getDefaultIcon(info.user);
        }
Loading