2018-11-05 17:05:35 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2018 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.
|
2021-04-24 09:48:35 +02:00
|
|
|
*
|
|
|
|
|
* Modifications copyright 2021, Lawnchair
|
2018-11-05 17:05:35 -08:00
|
|
|
*/
|
|
|
|
|
package com.android.launcher3.icons;
|
|
|
|
|
|
|
|
|
|
import android.content.ComponentName;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.pm.LauncherActivityInfo;
|
2021-03-01 22:35:06 +05:30
|
|
|
import android.graphics.drawable.Drawable;
|
2018-11-05 17:05:35 -08:00
|
|
|
import android.os.UserHandle;
|
|
|
|
|
|
2022-08-19 10:53:40 -07:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
2021-04-23 11:40:58 -07:00
|
|
|
import com.android.launcher3.LauncherAppState;
|
2019-08-06 09:48:36 -07:00
|
|
|
import com.android.launcher3.R;
|
2018-11-08 10:51:05 -08:00
|
|
|
import com.android.launcher3.icons.cache.CachingLogic;
|
2019-08-06 09:48:36 -07:00
|
|
|
import com.android.launcher3.util.ResourceBasedOverride;
|
2018-11-08 10:51:05 -08:00
|
|
|
|
2019-08-06 09:48:36 -07:00
|
|
|
/**
|
|
|
|
|
* Caching logic for LauncherActivityInfo.
|
|
|
|
|
*/
|
|
|
|
|
public class LauncherActivityCachingLogic
|
|
|
|
|
implements CachingLogic<LauncherActivityInfo>, ResourceBasedOverride {
|
2018-11-05 17:05:35 -08:00
|
|
|
|
2019-08-06 09:48:36 -07:00
|
|
|
/**
|
|
|
|
|
* Creates and returns a new instance
|
|
|
|
|
*/
|
|
|
|
|
public static LauncherActivityCachingLogic newInstance(Context context) {
|
|
|
|
|
return Overrides.getObject(LauncherActivityCachingLogic.class, context,
|
|
|
|
|
R.string.launcher_activity_logic_class);
|
2018-11-05 17:05:35 -08:00
|
|
|
}
|
|
|
|
|
|
2022-08-19 10:53:40 -07:00
|
|
|
@NonNull
|
2018-11-05 17:05:35 -08:00
|
|
|
@Override
|
2022-08-19 10:53:40 -07:00
|
|
|
public ComponentName getComponent(@NonNull LauncherActivityInfo object) {
|
2018-11-05 17:05:35 -08:00
|
|
|
return object.getComponentName();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-19 10:53:40 -07:00
|
|
|
@NonNull
|
2018-11-05 17:05:35 -08:00
|
|
|
@Override
|
2022-08-19 10:53:40 -07:00
|
|
|
public UserHandle getUser(@NonNull LauncherActivityInfo object) {
|
2018-11-05 17:05:35 -08:00
|
|
|
return object.getUser();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-19 10:53:40 -07:00
|
|
|
@NonNull
|
2018-11-05 17:05:35 -08:00
|
|
|
@Override
|
2022-08-19 10:53:40 -07:00
|
|
|
public CharSequence getLabel(@NonNull LauncherActivityInfo object) {
|
2018-11-05 17:05:35 -08:00
|
|
|
return object.getLabel();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-19 10:53:40 -07:00
|
|
|
@NonNull
|
2018-11-05 17:05:35 -08:00
|
|
|
@Override
|
2022-08-19 10:53:40 -07:00
|
|
|
public BitmapInfo loadIcon(@NonNull Context context, @NonNull LauncherActivityInfo object) {
|
2019-10-25 13:41:28 -07:00
|
|
|
try (LauncherIcons li = LauncherIcons.obtain(context)) {
|
2021-04-23 11:40:58 -07:00
|
|
|
return li.createBadgedIconBitmap(LauncherAppState.getInstance(context)
|
2025-01-01 09:56:15 +08:00
|
|
|
.getIconProvider().getIcon(object, li.mFillResIconDpi),
|
|
|
|
|
new BaseIconFactory.IconOptions().setUser(object.getUser()));
|
2019-10-25 13:41:28 -07:00
|
|
|
}
|
2018-11-05 17:05:35 -08:00
|
|
|
}
|
2019-08-06 09:48:36 -07:00
|
|
|
}
|