Queueing up items for adding later if Launcher is unavailable. (Bug 6457412)
Change-Id: Ia66a6411a54397543db4122a80ebca6a50b6360c
This commit is contained in:
@@ -22,6 +22,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Debug;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.launcher.R;
|
import com.android.launcher.R;
|
||||||
@@ -90,9 +91,12 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Queue the item up for adding if launcher has not loaded properly yet
|
||||||
|
boolean launcherNotLoaded = LauncherModel.getCellCountX() <= 0 ||
|
||||||
|
LauncherModel.getCellCountY() <= 0;
|
||||||
|
|
||||||
PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent);
|
PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent);
|
||||||
if (mUseInstallQueue) {
|
if (mUseInstallQueue || launcherNotLoaded) {
|
||||||
mInstallQueue.add(info);
|
mInstallQueue.add(info);
|
||||||
} else {
|
} else {
|
||||||
processInstallShortcut(context, info);
|
processInstallShortcut(context, info);
|
||||||
@@ -102,9 +106,11 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
|
|||||||
static void enableInstallQueue() {
|
static void enableInstallQueue() {
|
||||||
mUseInstallQueue = true;
|
mUseInstallQueue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void disableAndFlushInstallQueue(Context context) {
|
static void disableAndFlushInstallQueue(Context context) {
|
||||||
mUseInstallQueue = false;
|
mUseInstallQueue = false;
|
||||||
|
flushInstallQueue(context);
|
||||||
|
}
|
||||||
|
static void flushInstallQueue(Context context) {
|
||||||
Iterator<PendingInstallShortcutInfo> iter = mInstallQueue.iterator();
|
Iterator<PendingInstallShortcutInfo> iter = mInstallQueue.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
processInstallShortcut(context, iter.next());
|
processInstallShortcut(context, iter.next());
|
||||||
|
|||||||
@@ -649,6 +649,9 @@ public final class Launcher extends Activity
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
// Process any items that were added while Launcher was away
|
||||||
|
InstallShortcutReceiver.flushInstallQueue(this);
|
||||||
|
|
||||||
mPaused = false;
|
mPaused = false;
|
||||||
if (mRestoring || mOnResumeNeedsLoad) {
|
if (mRestoring || mOnResumeNeedsLoad) {
|
||||||
mWorkspaceLoading = true;
|
mWorkspaceLoading = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user