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

Commit 0e9853b1 authored by Himanshu Gupta's avatar Himanshu Gupta Committed by Android (Google) Code Review
Browse files

Merge "Adding Clone Profile Badges in iconLoader library" into tm-qpr-dev

parents a34d11db 51f8d975
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="@dimen/profile_badge_size"
    android:height="@dimen/profile_badge_size"
    android:viewportWidth="24"
    android:viewportHeight="24">

    <path
        android:fillColor="#11000000"
        android:pathData="M.5,12.25
        A11.5,11.5 0 1,1 23.5,12.25
        A11.5,11.5 0 1,1 .5,12.25" />

    <path
        android:fillColor="@android:color/white"
        android:pathData="M1,12
        A11,11 0 1,1 23,12
        A11,11 0 1,1 1,12" />

    <group android:scaleX=".6" android:scaleY=".6" android:pivotX="12" android:pivotY="12">
      <path
        android:pathData="M22,9.5C22,13.642 18.642,17 14.5,17C10.358,17 7,13.642 7,9.5C7,5.358 10.358,2 14.5,2C18.642,2 22,5.358 22,9.5Z"
        android:fillColor="#ff3C4043"/>
    <path
        android:pathData="M9.5,20.333C12.722,20.333 15.333,17.722 15.333,14.5C15.333,11.278 12.722,8.667 9.5,8.667C6.278,8.667 3.667,11.278 3.667,14.5C3.667,17.722 6.278,20.333 9.5,20.333ZM9.5,22C13.642,22 17,18.642 17,14.5C17,10.358 13.642,7 9.5,7C5.358,7 2,10.358 2,14.5C2,18.642 5.358,22 9.5,22Z"
        android:fillColor="#ff3C4043"
        android:fillType="evenOdd"/>
    </group>
</vector>
+16 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import static android.graphics.Paint.DITHER_FLAG;
import static android.graphics.Paint.FILTER_BITMAP_FLAG;
import static android.graphics.drawable.AdaptiveIconDrawable.getExtraInsetFraction;

import static com.android.launcher3.icons.BitmapInfo.FLAG_CLONE;
import static com.android.launcher3.icons.BitmapInfo.FLAG_INSTANT;
import static com.android.launcher3.icons.BitmapInfo.FLAG_WORK;
import static com.android.launcher3.icons.ShadowGenerator.BLUR_FACTOR;
@@ -266,7 +267,10 @@ public class BaseIconFactory implements AutoCloseable {
                    isBadged = (d != mPm.getUserBadgedIcon(d, options.mUserHandle));
                    mIsUserBadged.put(key, isBadged);
                }
                op = op.setFlag(FLAG_WORK, isBadged);
                // Set the clone profile badge flag in case it is present.
                op = op.setFlag(FLAG_CLONE, isBadged && options.mIsCloneProfile);
                // Set the Work profile badge for all other cases.
                op = op.setFlag(FLAG_WORK, isBadged && !options.mIsCloneProfile);
            }
        }
        return op;
@@ -464,6 +468,8 @@ public class BaseIconFactory implements AutoCloseable {

        boolean mIsInstantApp;

        boolean mIsCloneProfile;

        @BitmapGenerationMode
        int mGenerationMode = MODE_WITH_SHADOW;

@@ -517,6 +523,15 @@ public class BaseIconFactory implements AutoCloseable {
            mGenerationMode = generationMode;
            return this;
        }

        /**
         * Used to determine the badge type for this icon.
         */
        @NonNull
        public IconOptions setIsCloneProfile(boolean isCloneProfile) {
            mIsCloneProfile = isCloneProfile;
            return this;
        }
    }

    /**
+4 −0
Original line number Diff line number Diff line
@@ -30,9 +30,11 @@ public class BitmapInfo {

    static final int FLAG_WORK = 1 << 0;
    static final int FLAG_INSTANT = 1 << 1;
    static final int FLAG_CLONE = 1 << 2;
    @IntDef(flag = true, value = {
            FLAG_WORK,
            FLAG_INSTANT,
            FLAG_CLONE
    })
    @interface BitmapInfoFlags {}

@@ -155,6 +157,8 @@ public class BitmapInfo {
                drawable.setBadge(context.getDrawable(R.drawable.ic_instant_app_badge));
            } else if ((flags & FLAG_WORK) != 0) {
                drawable.setBadge(context.getDrawable(R.drawable.ic_work_app_badge));
            } else if ((flags & FLAG_CLONE) != 0) {
                drawable.setBadge(context.getDrawable(R.drawable.ic_clone_app_badge));
            }
        }
    }