diff --git a/res/drawable/ic_instant_app.xml b/res/drawable/ic_instant_app.xml deleted file mode 100644 index be5a3e049e..0000000000 --- a/res/drawable/ic_instant_app.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - diff --git a/res/layout/all_apps_discovery_item.xml b/res/layout/all_apps_discovery_item.xml index 2b21ef5707..1a7eaa72de 100644 --- a/res/layout/all_apps_discovery_item.xml +++ b/res/layout/all_apps_discovery_item.xml @@ -27,18 +27,6 @@ android:padding="8dp" android:scaleType="fitCenter"/> - - 0) { mAdapterItems.add(AdapterItem.asLoadingDivider(position++)); - // Append all app discovery results for (int i = 0; i < mDiscoveredApps.size(); i++) { AppDiscoveryAppInfo appDiscoveryAppInfo = mDiscoveredApps.get(i); + if (appDiscoveryAppInfo.isRecent) { + // already handled in getFilteredAppInfos() + continue; + } AdapterItem item = AdapterItem.asDiscoveryItem(position++, "", appDiscoveryAppInfo, appIndex++); mAdapterItems.add(item); @@ -589,6 +592,17 @@ public class AlphabeticalAppsList { result.add(match); } } + + // adding recently used instant apps + if (mDiscoveredApps.size() > 0) { + for (int i = 0; i < mDiscoveredApps.size(); i++) { + AppDiscoveryAppInfo discoveryAppInfo = mDiscoveredApps.get(i); + if (discoveryAppInfo.isRecent) { + result.add(discoveryAppInfo); + } + } + Collections.sort(result, mAppNameComparator); + } return result; } diff --git a/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java b/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java index 50e979aac6..06493b2b17 100644 --- a/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java +++ b/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java @@ -18,24 +18,18 @@ package com.android.launcher3.discovery; import android.content.ComponentName; import android.content.Intent; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.android.launcher3.AppInfo; -import com.android.launcher3.Launcher; import com.android.launcher3.LauncherSettings; -import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; public class AppDiscoveryAppInfo extends AppInfo { - private final @NonNull Launcher mLauncher; - public final boolean showAsDiscoveryItem; public final boolean isInstantApp; + public final boolean isRecent; public final float rating; public final long reviewCount; public final @NonNull String publisher; @@ -43,14 +37,14 @@ public class AppDiscoveryAppInfo extends AppInfo { public final @NonNull Intent launchIntent; public final @Nullable String priceFormatted; - public AppDiscoveryAppInfo(AppDiscoveryItem item, Launcher launcher) { - this.mLauncher = launcher; + public AppDiscoveryAppInfo(AppDiscoveryItem item) { this.intent = item.isInstantApp ? item.launchIntent : item.installIntent; this.title = item.title; this.iconBitmap = item.bitmap; this.isDisabled = ShortcutInfo.DEFAULT; this.usingLowResIcon = false; this.isInstantApp = item.isInstantApp; + this.isRecent = item.isRecent; this.rating = item.starRating; this.showAsDiscoveryItem = true; this.publisher = item.publisher != null ? item.publisher : ""; @@ -67,18 +61,7 @@ public class AppDiscoveryAppInfo extends AppInfo { if (!isDragAndDropSupported()) { throw new RuntimeException("DnD is currently not supported for discovered store apps"); } - ShortcutInfo shortcutInfo = super.makeShortcut(); - if (isInstantApp) { - int iconSize = iconBitmap.getWidth(); - int badgeSize = mLauncher.getResources().getDimensionPixelOffset(R.dimen.badge_size); - Bitmap icon = Bitmap.createBitmap(iconBitmap); - Drawable badgeDrawable = mLauncher.getDrawable(R.drawable.ic_instant_app); - badgeDrawable.setBounds(iconSize - badgeSize, iconSize - badgeSize, iconSize, iconSize); - Canvas canvas = new Canvas(icon); - badgeDrawable.draw(canvas); - shortcutInfo.iconBitmap = icon; - } - return shortcutInfo; + return super.makeShortcut(); } public boolean isDragAndDropSupported() { diff --git a/src/com/android/launcher3/discovery/AppDiscoveryItem.java b/src/com/android/launcher3/discovery/AppDiscoveryItem.java index 7c10371d0b..09c91acc6d 100644 --- a/src/com/android/launcher3/discovery/AppDiscoveryItem.java +++ b/src/com/android/launcher3/discovery/AppDiscoveryItem.java @@ -28,6 +28,7 @@ public class AppDiscoveryItem { public final String packageName; public final boolean isInstantApp; + public final boolean isRecent; public final float starRating; public final long reviewCount; public final Intent launchIntent; @@ -39,6 +40,7 @@ public class AppDiscoveryItem { public AppDiscoveryItem(String packageName, boolean isInstantApp, + boolean isRecent, float starRating, long reviewCount, CharSequence title, @@ -49,6 +51,7 @@ public class AppDiscoveryItem { Intent installIntent) { this.packageName = packageName; this.isInstantApp = isInstantApp; + this.isRecent = isRecent; this.starRating = starRating; this.reviewCount = reviewCount; this.launchIntent = launchIntent; diff --git a/src/com/android/launcher3/discovery/AppDiscoveryItemView.java b/src/com/android/launcher3/discovery/AppDiscoveryItemView.java index 6faad87abd..9bb3b100e1 100644 --- a/src/com/android/launcher3/discovery/AppDiscoveryItemView.java +++ b/src/com/android/launcher3/discovery/AppDiscoveryItemView.java @@ -34,7 +34,6 @@ public class AppDiscoveryItemView extends RelativeLayout { private static boolean SHOW_REVIEW_COUNT = false; private ImageView mImage; - private ImageView mBadge; private TextView mTitle; private TextView mRatingText; private RatingView mRatingView; @@ -58,7 +57,6 @@ public class AppDiscoveryItemView extends RelativeLayout { protected void onFinishInflate() { super.onFinishInflate(); this.mImage = (ImageView) findViewById(R.id.image); - this.mBadge = (ImageView) findViewById(R.id.badge); this.mTitle = (TextView) findViewById(R.id.title); this.mRatingText = (TextView) findViewById(R.id.rating); this.mRatingView = (RatingView) findViewById(R.id.rating_view); @@ -80,7 +78,6 @@ public class AppDiscoveryItemView extends RelativeLayout { mImage.setTag(info); mImage.setImageBitmap(info.iconBitmap); mImage.setOnLongClickListener(info.isDragAndDropSupported() ? mOnLongClickListener : null); - mBadge.setVisibility(info.isInstantApp ? View.VISIBLE : View.GONE); mTitle.setText(info.title); mPrice.setText(info.priceFormatted != null ? info.priceFormatted : ""); mReviewCount.setVisibility(SHOW_REVIEW_COUNT ? View.VISIBLE : View.GONE);