summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/compat
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-07-27 17:32:34 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-07-29 16:06:36 -0700
commit79cf718fcdf39d0e60743b32c6611fbb971ff38c (patch)
tree03d926be58c5615ecc66e2bc23814e9ff9ad4502 /src/com/android/launcher3/compat
parenta2454ad2d8dcffa94f670853eb464726c73597f1 (diff)
downloadandroid_packages_apps_Trebuchet-79cf718fcdf39d0e60743b32c6611fbb971ff38c.tar.gz
android_packages_apps_Trebuchet-79cf718fcdf39d0e60743b32c6611fbb971ff38c.tar.bz2
android_packages_apps_Trebuchet-79cf718fcdf39d0e60743b32c6611fbb971ff38c.zip
Badging shortcuts with app icons
Change-Id: I3fa005ece20a54b31f823acb28c384ecdf1eafb1
Diffstat (limited to 'src/com/android/launcher3/compat')
-rw-r--r--src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java b/src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java
new file mode 100644
index 000000000..46d36d1b0
--- /dev/null
+++ b/src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+package com.android.launcher3.compat;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.graphics.drawable.Drawable;
+import android.util.Log;
+
+/**
+ * {@link LauncherActivityInfoCompat} which loads its data only when needed.
+ */
+public class DeferredLauncherActivityInfo extends LauncherActivityInfoCompat {
+
+ private final ComponentName mComponent;
+ private final UserHandleCompat mUser;
+ private final Context mContext;
+
+ private LauncherActivityInfoCompat mActualInfo;
+
+ public DeferredLauncherActivityInfo(
+ ComponentName component, UserHandleCompat user, Context context) {
+ mComponent = component;
+ mUser = user;
+ mContext = context;
+ }
+
+ @Override
+ public ComponentName getComponentName() {
+ return mComponent;
+ }
+
+ @Override
+ public UserHandleCompat getUser() {
+ return mUser;
+ }
+
+ private synchronized LauncherActivityInfoCompat getActualInfo() {
+ if (mActualInfo == null) {
+ Intent intent = new Intent(Intent.ACTION_MAIN)
+ .addCategory(Intent.CATEGORY_LAUNCHER)
+ .setComponent(mComponent);
+ mActualInfo = LauncherAppsCompat.getInstance(mContext).resolveActivity(intent, mUser);
+ }
+ return mActualInfo;
+ }
+
+ @Override
+ public CharSequence getLabel() {
+ return getActualInfo().getLabel();
+ }
+
+ @Override
+ public Drawable getIcon(int density) {
+ return getActualInfo().getIcon(density);
+ }
+
+ @Override
+ public ApplicationInfo getApplicationInfo() {
+ return getActualInfo().getApplicationInfo();
+ }
+
+ @Override
+ public long getFirstInstallTime() {
+ return getActualInfo().getFirstInstallTime();
+ }
+}