mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 01:16:49 +00:00
Add UI updates for incremental app installs.
1. Changed Preload Icon UI to be grayscale while the app is not startable. 2. Added progress bar for when app is installed but still ownloading. 3. Updated Preload Icon progress and click handling to use new incremental api. Progress bar color updates will follow in a separate CL. Demo: https://drive.google.com/file/d/1H1EvtTorLeJwC1eiq10tm-TT81YZ6osk/view?usp=sharing Bug: 171008815 Test: manual Change-Id: I5874a5146d79a8c91d7d90ff0b9c1c427a3c95dd
This commit is contained in:
@@ -28,10 +28,13 @@ import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
|
||||
@@ -104,13 +107,37 @@ public class AppInfo extends ItemInfoWithIcon {
|
||||
this.intent = intent;
|
||||
}
|
||||
|
||||
public AppInfo(@NonNull PackageInstallInfo installInfo) {
|
||||
componentName = installInfo.componentName;
|
||||
intent = new Intent(Intent.ACTION_MAIN)
|
||||
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
.setComponent(componentName)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||
user = installInfo.user;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String dumpProperties() {
|
||||
return super.dumpProperties() + " componentName=" + componentName;
|
||||
}
|
||||
|
||||
public WorkspaceItemInfo makeWorkspaceItem() {
|
||||
return new WorkspaceItemInfo(this);
|
||||
WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo(this);
|
||||
|
||||
if ((runtimeStatusFlags & FLAG_INSTALL_SESSION_ACTIVE) != 0) {
|
||||
// We need to update the component name when the apk is installed
|
||||
workspaceItemInfo.status |= WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON;
|
||||
// Since the user is manually placing it on homescreen, it should not be auto-removed
|
||||
// later
|
||||
workspaceItemInfo.status |= WorkspaceItemInfo.FLAG_RESTORE_STARTED;
|
||||
workspaceItemInfo.status |= FLAG_INSTALL_SESSION_ACTIVE;
|
||||
}
|
||||
if ((runtimeStatusFlags & FLAG_INCREMENTAL_DOWNLOAD_ACTIVE) != 0) {
|
||||
workspaceItemInfo.runtimeStatusFlags |= FLAG_INCREMENTAL_DOWNLOAD_ACTIVE;
|
||||
}
|
||||
|
||||
return workspaceItemInfo;
|
||||
}
|
||||
|
||||
public ComponentKey toComponentKey() {
|
||||
@@ -129,6 +156,12 @@ public class AppInfo extends ItemInfoWithIcon {
|
||||
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ComponentName getTargetComponent() {
|
||||
return componentName;
|
||||
}
|
||||
|
||||
public static void updateRuntimeFlagsForActivityTarget(
|
||||
ItemInfoWithIcon info, LauncherActivityInfo lai) {
|
||||
ApplicationInfo appInfo = lai.getApplicationInfo();
|
||||
@@ -143,6 +176,11 @@ public class AppInfo extends ItemInfoWithIcon {
|
||||
// The icon for a non-primary user is badged, hence it's not exactly an adaptive icon.
|
||||
info.runtimeStatusFlags |= FLAG_ADAPTIVE_ICON;
|
||||
}
|
||||
|
||||
// Sets the progress level, installation and incremental download flags.
|
||||
info.setProgressLevel(
|
||||
PackageManagerHelper.getLoadingProgress(lai),
|
||||
PackageInstallInfo.STATUS_INSTALLED);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user