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

Commit 853c13d4 authored by Mario Bertschler's avatar Mario Bertschler
Browse files

Show recently used instant apps provided by the app discovery service

in the same section as installed apps.

Change-Id: I2efd41c69960c4982523c58893aacfc7a5d0bb2e
parent 77ff9a43
Loading
Loading
Loading
Loading

res/drawable/ic_instant_app.xml

deleted100644 → 0
+0 −43
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 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/badge_size"
    android:height="@dimen/badge_size"
    android:viewportWidth="18"
    android:viewportHeight="18">

    <path
        android:fillColor="@android:color/black"
        android:fillType="evenOdd"
        android:strokeWidth="1"
        android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" />
    <path
        android:fillColor="@android:color/white"
        android:fillType="evenOdd"
        android:strokeWidth="1"
        android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" />
    <path
        android:fillColor="@android:color/white"
        android:fillType="evenOdd"
        android:strokeWidth="1"
        android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" />
    <path
        android:fillColor="@android:color/black"
        android:fillAlpha="0.87"
        android:fillType="evenOdd"
        android:strokeWidth="1"
        android:pathData="M 6 10.4123279 L 8.63934949 10.4123279 L 8.63934949 15.6 L 12.5577168 7.84517705 L 9.94547194 7.84517705 L 9.94547194 2 Z" />
</vector>
+0 −12
Original line number Diff line number Diff line
@@ -27,18 +27,6 @@
        android:padding="8dp"
        android:scaleType="fitCenter"/>

    <ImageView
        android:id="@+id/badge"
        android:layout_width="16dp"
        android:layout_height="16dp"
        android:scaleType="fitCenter"
        android:src="@drawable/ic_instant_app"
        android:layout_marginRight="6dp"
        android:layout_marginBottom="6dp"
        android:layout_alignRight="@+id/image"
        android:layout_alignBottom="@+id/image"
        android:clickable="false"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
+16 −2
Original line number Diff line number Diff line
@@ -292,7 +292,7 @@ public class AlphabeticalAppsList {
                mDiscoveredApps.clear();
                break;
            case UPDATE:
                mDiscoveredApps.add(new AppDiscoveryAppInfo(app, mLauncher));
                mDiscoveredApps.add(new AppDiscoveryAppInfo(app));
                break;
        }
        updateAdapterItems();
@@ -494,10 +494,13 @@ public class AlphabeticalAppsList {
        if (hasFilter()) {
            if (isAppDiscoveryRunning() || mDiscoveredApps.size() > 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;
    }

+4 −21
Original line number Diff line number Diff line
@@ -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() {
+3 −0
Original line number Diff line number Diff line
@@ -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;
Loading