summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Launcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/Launcher.java')
-rw-r--r--src/com/android/launcher3/Launcher.java677
1 files changed, 221 insertions, 456 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 1caec339b..b6474e6ef 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -25,7 +25,6 @@ import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
-import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.AlertDialog;
import android.app.SearchManager;
@@ -36,7 +35,6 @@ import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentCallbacks2;
import android.content.ComponentName;
-import android.content.ContentValues;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.DialogInterface;
@@ -51,10 +49,8 @@ import android.content.res.Configuration;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Rect;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
@@ -81,7 +77,6 @@ import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
-import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.OvershootInterpolator;
@@ -106,6 +101,7 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.dynamicui.ExtractedColors;
import com.android.launcher3.folder.Folder;
@@ -119,10 +115,12 @@ import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.DeepShortcutsContainer;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.util.ActivityResultInfo;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.PackageManagerHelper;
+import com.android.launcher3.util.PendingRequestArgs;
import com.android.launcher3.util.TestingUtils;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.ViewOnDrawExecutor;
@@ -164,10 +162,6 @@ public class Launcher extends Activity
private static final int REQUEST_PERMISSION_CALL_PHONE = 13;
- private static final int WORKSPACE_BACKGROUND_GRADIENT = 0;
- private static final int WORKSPACE_BACKGROUND_TRANSPARENT = 1;
- private static final int WORKSPACE_BACKGROUND_BLACK = 2;
-
private static final float BOUNCE_ANIMATION_TENSION = 1.3f;
/**
@@ -191,15 +185,11 @@ public class Launcher extends Activity
private static final String RUNTIME_STATE_CURRENT_SCREEN = "launcher.current_screen";
// Type: int
private static final String RUNTIME_STATE = "launcher.state";
- // Type: Content Values / parcelable
- private static final String RUNTIME_STATE_PENDING_ADD_ITEM = "launcher.add_item";
- // Type: parcelable
- private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_INFO = "launcher.add_widget_info";
- // Type: parcelable
- private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_ID = "launcher.add_widget_id";
-
- static final String INTRO_SCREEN_DISMISSED = "launcher.intro_screen_dismissed";
- static final String FIRST_RUN_ACTIVITY_DISPLAYED = "launcher.first_run_activity_displayed";
+ // Type: PendingRequestArgs
+ private static final String RUNTIME_STATE_PENDING_REQUEST_ARGS = "launcher.request_args";
+ // Type: ActivityResultInfo
+ private static final String RUNTIME_STATE_PENDING_ACTIVITY_RESULT = "launcher.activity_result";
+
static final String APPS_VIEW_SHOWN = "launcher.apps_view_shown";
/** The different states that Launcher can be in. */
@@ -246,10 +236,6 @@ public class Launcher extends Activity
private AppWidgetManagerCompat mAppWidgetManager;
private LauncherAppWidgetHost mAppWidgetHost;
- @Thunk final ItemInfo mPendingAddInfo = new ItemInfo();
- private LauncherAppWidgetProviderInfo mPendingAddWidgetInfo;
- private int mPendingAddWidgetId = -1;
-
private int[] mTmpAddItemCellCoordinates = new int[2];
@Thunk Hotseat mHotseat;
@@ -279,8 +265,6 @@ public class Launcher extends Activity
@Thunk boolean mWorkspaceLoading = true;
private boolean mPaused = true;
- private boolean mRestoring;
- private boolean mWaitingForResult;
private boolean mOnResumeNeedsLoad;
private ArrayList<Runnable> mBindOnResumeCallbacks = new ArrayList<Runnable>();
@@ -316,10 +300,7 @@ public class Launcher extends Activity
// match the sensor state.
private static final int RESTORE_SCREEN_ORIENTATION_DELAY = 500;
- @Thunk Drawable mWorkspaceBackgroundDrawable;
-
private final ArrayList<Integer> mSynchronouslyBoundPages = new ArrayList<Integer>();
- private static final boolean DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE = false;
// We only want to get the SharedPreferences once since it does an FS stat each time we get
// it from the context.
@@ -363,17 +344,13 @@ public class Launcher extends Activity
}
};
- private static PendingAddArguments sPendingAddItem;
-
- @Thunk static class PendingAddArguments {
- int requestCode;
- Intent intent;
- long container;
- long screenId;
- int cellX;
- int cellY;
- int appWidgetId;
- }
+ // Activity result which needs to be processed after workspace has loaded.
+ private ActivityResultInfo mPendingActivityResult;
+ /**
+ * Holds extra information required to handle a result from an external call, like
+ * {@link #startActivityForResult(Intent, int)} or {@link #requestPermissions(String[], int)}
+ */
+ private PendingRequestArgs mPendingRequestArgs;
private UserEventDispatcher mUserEventDispatcher;
@@ -464,20 +441,14 @@ public class Launcher extends Activity
Trace.endSection();
}
- if (!mRestoring) {
- if (DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE) {
- // If the user leaves launcher, then we should just load items asynchronously when
- // they return.
- mModel.startLoader(PagedView.INVALID_RESTORE_PAGE);
- } else {
- // We only load the page synchronously if the user rotates (or triggers a
- // configuration change) while launcher is in the foreground
- if (!mModel.startLoader(mWorkspace.getRestorePage())) {
- // If we are not binding synchronously, show a fade in animation when
- // the first page bind completes.
- mDragLayer.setAlpha(0);
- }
- }
+ // We only load the page synchronously if the user rotates (or triggers a
+ // configuration change) while launcher is in the foreground
+ if (!mModel.startLoader(mWorkspace.getRestorePage())) {
+ // If we are not binding synchronously, show a fade in animation when
+ // the first page bind completes.
+ mDragLayer.setAlpha(0);
+ } else {
+ setWorkspaceLoading(true);
}
// For handling default keys
@@ -504,12 +475,6 @@ public class Launcher extends Activity
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onCreate(savedInstanceState);
}
-
- if (shouldShowIntroScreen()) {
- showIntroScreen();
- } else {
- showFirstRunActivity();
- }
}
@Override
@@ -676,53 +641,61 @@ public class Launcher extends Activity
* Returns whether we should delay spring loaded mode -- for shortcuts and widgets that have
* a configuration step, this allows the proper animations to run after other transitions.
*/
- private long completeAdd(PendingAddArguments args) {
- long screenId = args.screenId;
- if (args.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
+ private long completeAdd(
+ int requestCode, Intent intent, int appWidgetId, PendingRequestArgs info) {
+ long screenId = info.screenId;
+ if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
// When the screen id represents an actual screen (as opposed to a rank) we make sure
// that the drop page actually exists.
- screenId = ensurePendingDropLayoutExists(args.screenId);
+ screenId = ensurePendingDropLayoutExists(info.screenId);
}
- switch (args.requestCode) {
+ switch (requestCode) {
case REQUEST_CREATE_SHORTCUT:
- completeAddShortcut(args.intent, args.container, screenId, args.cellX,
- args.cellY);
+ completeAddShortcut(intent, info.container, screenId, info.cellX, info.cellY, info);
break;
case REQUEST_CREATE_APPWIDGET:
- completeAddAppWidget(args.appWidgetId, args.container, screenId, null, null);
+ completeAddAppWidget(appWidgetId, info, null, null);
break;
case REQUEST_RECONFIGURE_APPWIDGET:
- completeRestoreAppWidget(args.appWidgetId, LauncherAppWidgetInfo.RESTORE_COMPLETED);
+ completeRestoreAppWidget(appWidgetId, LauncherAppWidgetInfo.RESTORE_COMPLETED);
break;
case REQUEST_BIND_PENDING_APPWIDGET: {
- int widgetId = args.appWidgetId;
- LauncherAppWidgetInfo info =
+ int widgetId = appWidgetId;
+ LauncherAppWidgetInfo widgetInfo =
completeRestoreAppWidget(widgetId, LauncherAppWidgetInfo.FLAG_UI_NOT_READY);
- if (info != null) {
+ if (widgetInfo != null) {
// Since the view was just bound, also launch the configure activity if needed
LauncherAppWidgetProviderInfo provider = mAppWidgetManager
.getLauncherAppWidgetInfo(widgetId);
if (provider != null && provider.configure != null) {
- startRestoredWidgetReconfigActivity(provider, info);
+ startRestoredWidgetReconfigActivity(provider, widgetInfo);
}
}
break;
}
}
- // Before adding this resetAddInfo(), after a shortcut was added to a workspace screen,
- // if you turned the screen off and then back while in All Apps, Launcher would not
- // return to the workspace. Clearing mAddInfo.container here fixes this issue
- resetAddInfo();
+
return screenId;
}
private void handleActivityResult(
final int requestCode, final int resultCode, final Intent data) {
+ if (isWorkspaceLoading()) {
+ // process the result once the workspace has loaded.
+ mPendingActivityResult = new ActivityResultInfo(requestCode, resultCode, data);
+ return;
+ }
+ mPendingActivityResult = null;
+
// Reset the startActivity waiting flag
- setWaitingForResult(false);
- final int pendingAddWidgetId = mPendingAddWidgetId;
- mPendingAddWidgetId = -1;
+ final PendingRequestArgs requestArgs = mPendingRequestArgs;
+ setWaitingForResult(null);
+ if (requestArgs == null) {
+ return;
+ }
+
+ final int pendingAddWidgetId = requestArgs.getWidgetId();
Runnable exitSpringLoaded = new Runnable() {
@Override
@@ -737,12 +710,14 @@ public class Launcher extends Activity
final int appWidgetId = data != null ?
data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1;
if (resultCode == RESULT_CANCELED) {
- completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId);
+ completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId, requestArgs);
mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
} else if (resultCode == RESULT_OK) {
- addAppWidgetImpl(appWidgetId, mPendingAddInfo, null,
- mPendingAddWidgetInfo, ON_ACTIVITY_RESULT_ANIMATION_DELAY);
+ addAppWidgetImpl(
+ appWidgetId, requestArgs, null,
+ requestArgs.getWidgetProvider(),
+ ON_ACTIVITY_RESULT_ANIMATION_DELAY);
}
return;
} else if (requestCode == REQUEST_PICK_WALLPAPER) {
@@ -758,7 +733,6 @@ public class Launcher extends Activity
boolean isWidgetDrop = (requestCode == REQUEST_PICK_APPWIDGET ||
requestCode == REQUEST_CREATE_APPWIDGET);
- final boolean workspaceLocked = isWorkspaceLocked();
// We have special handling for widgets
if (isWidgetDrop) {
final int appWidgetId;
@@ -775,46 +749,36 @@ public class Launcher extends Activity
Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not " +
"returned from the widget configuration activity.");
result = RESULT_CANCELED;
- completeTwoStageWidgetDrop(result, appWidgetId);
+ completeTwoStageWidgetDrop(result, appWidgetId, requestArgs);
final Runnable onComplete = new Runnable() {
@Override
public void run() {
exitSpringLoadedDragModeDelayed(false, 0, null);
}
};
- if (workspaceLocked) {
- // No need to remove the empty screen if we're mid-binding, as the
- // the bind will not add the empty screen.
- mWorkspace.postDelayed(onComplete, ON_ACTIVITY_RESULT_ANIMATION_DELAY);
- } else {
- mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete,
- ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
- }
- } else {
- if (!workspaceLocked) {
- if (mPendingAddInfo.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
- // When the screen id represents an actual screen (as opposed to a rank)
- // we make sure that the drop page actually exists.
- mPendingAddInfo.screenId =
- ensurePendingDropLayoutExists(mPendingAddInfo.screenId);
- }
- final CellLayout dropLayout = mWorkspace.getScreenWithId(mPendingAddInfo.screenId);
- dropLayout.setDropPending(true);
- final Runnable onComplete = new Runnable() {
- @Override
- public void run() {
- completeTwoStageWidgetDrop(resultCode, appWidgetId);
- dropLayout.setDropPending(false);
- }
- };
- mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete,
- ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
- } else {
- PendingAddArguments args = preparePendingAddArgs(requestCode, data, appWidgetId,
- mPendingAddInfo);
- sPendingAddItem = args;
+ mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete,
+ ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
+ } else {
+ if (requestArgs.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
+ // When the screen id represents an actual screen (as opposed to a rank)
+ // we make sure that the drop page actually exists.
+ requestArgs.screenId =
+ ensurePendingDropLayoutExists(requestArgs.screenId);
}
+ final CellLayout dropLayout =
+ mWorkspace.getScreenWithId(requestArgs.screenId);
+
+ dropLayout.setDropPending(true);
+ final Runnable onComplete = new Runnable() {
+ @Override
+ public void run() {
+ completeTwoStageWidgetDrop(resultCode, appWidgetId, requestArgs);
+ dropLayout.setDropPending(false);
+ }
+ };
+ mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete,
+ ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
}
return;
}
@@ -823,13 +787,7 @@ public class Launcher extends Activity
|| requestCode == REQUEST_BIND_PENDING_APPWIDGET) {
if (resultCode == RESULT_OK) {
// Update the widget view.
- PendingAddArguments args = preparePendingAddArgs(requestCode, data,
- pendingAddWidgetId, mPendingAddInfo);
- if (workspaceLocked) {
- sPendingAddItem = args;
- } else {
- completeAdd(args);
- }
+ completeAdd(requestCode, data, pendingAddWidgetId, requestArgs);
}
// Leave the widget in the pending state if the user canceled the configure.
return;
@@ -837,23 +795,17 @@ public class Launcher extends Activity
if (requestCode == REQUEST_CREATE_SHORTCUT) {
// Handle custom shortcuts created using ACTION_CREATE_SHORTCUT.
- if (resultCode == RESULT_OK && mPendingAddInfo.container != ItemInfo.NO_ID) {
- final PendingAddArguments args = preparePendingAddArgs(requestCode, data, -1,
- mPendingAddInfo);
- if (isWorkspaceLocked()) {
- sPendingAddItem = args;
- } else {
- completeAdd(args);
- mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
- ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
- }
+ if (resultCode == RESULT_OK && requestArgs.container != ItemInfo.NO_ID) {
+ completeAdd(requestCode, data, -1, requestArgs);
+ mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
+ ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
+
} else if (resultCode == RESULT_CANCELED) {
mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
}
}
mDragLayer.clearAnimatedView();
-
}
@Override
@@ -868,22 +820,25 @@ public class Launcher extends Activity
/** @Override for MNC */
public void onRequestPermissionsResult(int requestCode, String[] permissions,
int[] grantResults) {
- if (requestCode == REQUEST_PERMISSION_CALL_PHONE && sPendingAddItem != null
- && sPendingAddItem.requestCode == REQUEST_PERMISSION_CALL_PHONE) {
+ PendingRequestArgs pendingArgs = mPendingRequestArgs;
+ if (requestCode == REQUEST_PERMISSION_CALL_PHONE && pendingArgs != null
+ && pendingArgs.getRequestCode() == REQUEST_PERMISSION_CALL_PHONE) {
+ setWaitingForResult(null);
+
View v = null;
- CellLayout layout = getCellLayout(sPendingAddItem.container, sPendingAddItem.screenId);
+ CellLayout layout = getCellLayout(pendingArgs.container, pendingArgs.screenId);
if (layout != null) {
- v = layout.getChildAt(sPendingAddItem.cellX, sPendingAddItem.cellY);
+ v = layout.getChildAt(pendingArgs.cellX, pendingArgs.cellY);
}
- Intent intent = sPendingAddItem.intent;
- sPendingAddItem = null;
+ Intent intent = pendingArgs.getPendingIntent();
+
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startActivitySafely(v, intent, null);
} else {
// TODO: Show a snack bar with link to settings
Toast.makeText(this, getString(R.string.msg_no_phone_permission,
- getString(R.string.app_name)), Toast.LENGTH_SHORT).show();
+ getString(R.string.derived_app_name)), Toast.LENGTH_SHORT).show();
}
}
if (mLauncherCallbacks != null) {
@@ -892,19 +847,6 @@ public class Launcher extends Activity
}
}
- private PendingAddArguments preparePendingAddArgs(int requestCode, Intent data, int
- appWidgetId, ItemInfo info) {
- PendingAddArguments args = new PendingAddArguments();
- args.requestCode = requestCode;
- args.intent = data;
- args.container = info.container;
- args.screenId = info.screenId;
- args.cellX = info.cellX;
- args.cellY = info.cellY;
- args.appWidgetId = appWidgetId;
- return args;
- }
-
/**
* Check to see if a given screen id exists. If not, create it at the end, return the new id.
*
@@ -923,8 +865,9 @@ public class Launcher extends Activity
}
}
- @Thunk void completeTwoStageWidgetDrop(final int resultCode, final int appWidgetId) {
- CellLayout cellLayout = mWorkspace.getScreenWithId(mPendingAddInfo.screenId);
+ @Thunk void completeTwoStageWidgetDrop(
+ final int resultCode, final int appWidgetId, final PendingRequestArgs requestArgs) {
+ CellLayout cellLayout = mWorkspace.getScreenWithId(requestArgs.screenId);
Runnable onCompleteRunnable = null;
int animationType = 0;
@@ -932,13 +875,12 @@ public class Launcher extends Activity
if (resultCode == RESULT_OK) {
animationType = Workspace.COMPLETE_TWO_STAGE_WIDGET_DROP_ANIMATION;
final AppWidgetHostView layout = mAppWidgetHost.createView(this, appWidgetId,
- mPendingAddWidgetInfo);
+ requestArgs.getWidgetProvider());
boundWidget = layout;
onCompleteRunnable = new Runnable() {
@Override
public void run() {
- completeAddAppWidget(appWidgetId, mPendingAddInfo.container,
- mPendingAddInfo.screenId, layout, null);
+ completeAddAppWidget(appWidgetId, requestArgs, layout, null);
exitSpringLoadedDragModeDelayed((resultCode != RESULT_CANCELED),
EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null);
}
@@ -948,7 +890,7 @@ public class Launcher extends Activity
animationType = Workspace.CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION;
}
if (mDragLayer.getAnimatedView() != null) {
- mWorkspace.animateWidgetDrop(mPendingAddInfo, cellLayout,
+ mWorkspace.animateWidgetDrop(requestArgs, cellLayout,
(DragView) mDragLayer.getAnimatedView(), onCompleteRunnable,
animationType, boundWidget, true);
} else if (onCompleteRunnable != null) {
@@ -1009,21 +951,16 @@ public class Launcher extends Activity
// view after launching an app, as they may be depending on the UI to be static to
// switch to another app, otherwise, if it was
showAppsView(false /* animated */, !launchedFromApp /* updatePredictedApps */,
- false /* focusSearchBar */);
+ mAppsView.shouldRestoreImeState() /* focusSearchBar */);
} else if (mOnResumeState == State.WIDGETS) {
showWidgetsView(false, false);
}
mOnResumeState = State.NONE;
- // Background was set to gradient in onPause(), restore to transparent if in all apps.
- setWorkspaceBackground(mState == State.WORKSPACE ? WORKSPACE_BACKGROUND_GRADIENT
- : WORKSPACE_BACKGROUND_TRANSPARENT);
-
mPaused = false;
- if (mRestoring || mOnResumeNeedsLoad) {
+ if (mOnResumeNeedsLoad) {
setWorkspaceLoading(true);
mModel.startLoader(getCurrentWorkspaceScreen());
- mRestoring = false;
mOnResumeNeedsLoad = false;
}
if (mBindOnResumeCallbacks.size() > 0) {
@@ -1295,7 +1232,8 @@ public class Launcher extends Activity
return mDefaultKeySsb.toString();
}
- private void clearTypedText() {
+ @Override
+ public void clearTypedText() {
mDefaultKeySsb.clear();
mDefaultKeySsb.clearSpans();
Selection.setSelection(mDefaultKeySsb, 0);
@@ -1338,18 +1276,12 @@ public class Launcher extends Activity
mWorkspace.setRestorePage(currentScreen);
}
- ContentValues itemValues = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_ITEM);
- if (itemValues != null) {
- mPendingAddInfo.readFromValues(itemValues);
- AppWidgetProviderInfo info = savedState.getParcelable(
- RUNTIME_STATE_PENDING_ADD_WIDGET_INFO);
- mPendingAddWidgetInfo = info == null ?
- null : LauncherAppWidgetProviderInfo.fromProviderInfo(this, info);
-
- mPendingAddWidgetId = savedState.getInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID);
- setWaitingForResult(true);
- mRestoring = true;
+ PendingRequestArgs requestArgs = savedState.getParcelable(RUNTIME_STATE_PENDING_REQUEST_ARGS);
+ if (requestArgs != null) {
+ setWaitingForResult(requestArgs);
}
+
+ mPendingActivityResult = savedState.getParcelable(RUNTIME_STATE_PENDING_ACTIVITY_RESULT);
}
/**
@@ -1367,10 +1299,8 @@ public class Launcher extends Activity
mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
- mWorkspaceBackgroundDrawable = getResources().getDrawable(R.drawable.workspace_bg);
// Setup the drag layer
-
mDragLayer.setup(this, mDragController, mAllAppsController);
// Setup the hotseat
@@ -1527,12 +1457,19 @@ public class Launcher extends Activity
* @param data The intent describing the shortcut.
*/
private void completeAddShortcut(Intent data, long container, long screenId, int cellX,
- int cellY) {
+ int cellY, PendingRequestArgs args) {
int[] cellXY = mTmpAddItemCellCoordinates;
CellLayout layout = getCellLayout(container, screenId);
ShortcutInfo info = InstallShortcutReceiver.fromShortcutIntent(this, data);
- if (info == null) {
+ if (info == null || args.getRequestCode() != REQUEST_CREATE_SHORTCUT ||
+ args.getPendingIntent().getComponent() == null) {
+ return;
+ }
+ if (!PackageManagerHelper.hasPermissionForActivity(
+ this, info.intent, args.getPendingIntent().getComponent().getPackageName())) {
+ // The app is trying to add a shortcut without sufficient permissions
+ Log.e(TAG, "Ignoring malicious intent " + info.intent.toUri(0));
return;
}
final View view = createShortcut(info);
@@ -1566,10 +1503,8 @@ public class Launcher extends Activity
LauncherModel.addItemToDatabase(this, info, container, screenId, cellXY[0], cellXY[1]);
- if (!mRestoring) {
- mWorkspace.addInScreen(view, container, screenId, cellXY[0], cellXY[1], 1, 1,
- isWorkspaceLocked());
- }
+ mWorkspace.addInScreen(view, container, screenId, cellXY[0], cellXY[1], 1, 1,
+ isWorkspaceLocked());
}
/**
@@ -1577,10 +1512,9 @@ public class Launcher extends Activity
*
* @param appWidgetId The app widget id
*/
- @Thunk void completeAddAppWidget(int appWidgetId, long container, long screenId,
+ @Thunk void completeAddAppWidget(int appWidgetId, ItemInfo itemInfo,
AppWidgetHostView hostView, LauncherAppWidgetProviderInfo appWidgetInfo) {
- ItemInfo info = mPendingAddInfo;
if (appWidgetInfo == null) {
appWidgetInfo = mAppWidgetManager.getLauncherAppWidgetInfo(appWidgetId);
}
@@ -1591,24 +1525,21 @@ public class Launcher extends Activity
LauncherAppWidgetInfo launcherInfo;
launcherInfo = new LauncherAppWidgetInfo(appWidgetId, appWidgetInfo.provider);
- launcherInfo.spanX = info.spanX;
- launcherInfo.spanY = info.spanY;
- launcherInfo.minSpanX = info.minSpanX;
- launcherInfo.minSpanY = info.minSpanY;
+ launcherInfo.spanX = itemInfo.spanX;
+ launcherInfo.spanY = itemInfo.spanY;
+ launcherInfo.minSpanX = itemInfo.minSpanX;
+ launcherInfo.minSpanY = itemInfo.minSpanY;
launcherInfo.user = mAppWidgetManager.getUser(appWidgetInfo);
LauncherModel.addItemToDatabase(this, launcherInfo,
- container, screenId, info.cellX, info.cellY);
+ itemInfo.container, itemInfo.screenId, itemInfo.cellX, itemInfo.cellY);
- if (!mRestoring) {
- if (hostView == null) {
- // Perform actual inflation because we're live
- hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
- }
- hostView.setVisibility(View.VISIBLE);
- addAppWidgetToWorkspace(hostView, launcherInfo, appWidgetInfo, isWorkspaceLocked());
+ if (hostView == null) {
+ // Perform actual inflation because we're live
+ hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
}
- resetAddInfo();
+ hostView.setVisibility(View.VISIBLE);
+ addAppWidgetToWorkspace(hostView, launcherInfo, appWidgetInfo, isWorkspaceLocked());
}
private void addAppWidgetToWorkspace(
@@ -1639,8 +1570,7 @@ public class Launcher extends Activity
// Reset AllApps to its initial state only if we are not in the middle of
// processing a multi-step drop
- if (mAppsView != null && mWidgetsView != null &&
- mPendingAddInfo.container == ItemInfo.NO_ID) {
+ if (mAppsView != null && mWidgetsView != null && mPendingRequestArgs == null) {
if (!showWorkspace(false)) {
// If we are already on the workspace, then manually reset all apps
mAppsView.reset();
@@ -1852,7 +1782,7 @@ public class Launcher extends Activity
getWindow().closeAllPanels();
// Whatever we were doing is hereby canceled.
- setWaitingForResult(false);
+ setWaitingForResult(null);
}
@Override
@@ -1970,13 +1900,11 @@ public class Launcher extends Activity
closeFolder(false);
closeShortcutsContainer(false);
- if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screenId > -1 &&
- mWaitingForResult) {
- ContentValues itemValues = new ContentValues();
- mPendingAddInfo.writeToValues(itemValues);
- outState.putParcelable(RUNTIME_STATE_PENDING_ADD_ITEM, itemValues);
- outState.putParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO, mPendingAddWidgetInfo);
- outState.putInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID, mPendingAddWidgetId);
+ if (mPendingRequestArgs != null) {
+ outState.putParcelable(RUNTIME_STATE_PENDING_REQUEST_ARGS, mPendingRequestArgs);
+ }
+ if (mPendingActivityResult != null) {
+ outState.putParcelable(RUNTIME_STATE_PENDING_ACTIVITY_RESULT, mPendingActivityResult);
}
if (mLauncherCallbacks != null) {
@@ -2039,14 +1967,12 @@ public class Launcher extends Activity
@Override
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
- onStartForResult(requestCode);
super.startActivityForResult(intent, requestCode, options);
}
@Override
public void startIntentSenderForResult (IntentSender intent, int requestCode,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options) {
- onStartForResult(requestCode);
try {
super.startIntentSenderForResult(intent, requestCode,
fillInIntent, flagsMask, flagsValues, extraFlags, options);
@@ -2055,12 +1981,6 @@ public class Launcher extends Activity
}
}
- private void onStartForResult(int requestCode) {
- if (requestCode >= 0) {
- setWaitingForResult(true);
- }
- }
-
/**
* Indicates that we want global search for this activity by setting the globalSearch
* argument for {@link #startSearch} to true.
@@ -2078,13 +1998,10 @@ public class Launcher extends Activity
appSearchData.putString("source", "launcher-search");
}
- // TODO send proper bounds.
- Rect sourceBounds = null;
-
- boolean clearTextImmediately = startSearch(initialQuery, selectInitialQuery,
- appSearchData, sourceBounds);
- if (clearTextImmediately) {
- clearTypedText();
+ if (mLauncherCallbacks == null ||
+ !mLauncherCallbacks.startSearch(initialQuery, selectInitialQuery, appSearchData)) {
+ // Starting search from the callbacks failed. Start the default global search.
+ startGlobalSearch(initialQuery, selectInitialQuery, appSearchData, null);
}
// We need to show the workspace after starting the search
@@ -2092,28 +2009,9 @@ public class Launcher extends Activity
}
/**
- * Start a text search.
- *
- * @return {@code true} if the search will start immediately, so any further keypresses
- * will be handled directly by the search UI. {@code false} if {@link Launcher} should continue
- * to buffer keypresses.
- */
- public boolean startSearch(String initialQuery,
- boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds) {
- if (mLauncherCallbacks != null && mLauncherCallbacks.providesSearch()) {
- return mLauncherCallbacks.startSearch(initialQuery, selectInitialQuery, appSearchData,
- sourceBounds);
- }
-
- startGlobalSearch(initialQuery, selectInitialQuery,
- appSearchData, sourceBounds);
- return false;
- }
-
- /**
* Starts the global search activity. This code is a copied from SearchManager
*/
- private void startGlobalSearch(String initialQuery,
+ public void startGlobalSearch(String initialQuery,
boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds) {
final SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
@@ -2171,7 +2069,7 @@ public class Launcher extends Activity
}
public boolean isWorkspaceLocked() {
- return mWorkspaceLoading || mWaitingForResult;
+ return mWorkspaceLoading || mPendingRequestArgs != null;
}
public boolean isWorkspaceLoading() {
@@ -2186,9 +2084,9 @@ public class Launcher extends Activity
}
}
- private void setWaitingForResult(boolean value) {
+ private void setWaitingForResult(PendingRequestArgs args) {
boolean isLocked = isWorkspaceLocked();
- mWaitingForResult = value;
+ mPendingRequestArgs = args;
if (isLocked != isWorkspaceLocked()) {
onWorkspaceLockedChanged();
}
@@ -2200,33 +2098,23 @@ public class Launcher extends Activity
}
}
- private void resetAddInfo() {
- mPendingAddInfo.container = ItemInfo.NO_ID;
- mPendingAddInfo.screenId = -1;
- mPendingAddInfo.cellX = mPendingAddInfo.cellY = -1;
- mPendingAddInfo.spanX = mPendingAddInfo.spanY = -1;
- mPendingAddInfo.minSpanX = mPendingAddInfo.minSpanY = 1;
- }
-
- void addAppWidgetFromDropImpl(final int appWidgetId, final ItemInfo info, final
- AppWidgetHostView boundWidget, final LauncherAppWidgetProviderInfo appWidgetInfo) {
+ void addAppWidgetFromDropImpl(int appWidgetId, ItemInfo info, AppWidgetHostView boundWidget,
+ LauncherAppWidgetProviderInfo appWidgetInfo) {
if (LOGD) {
Log.d(TAG, "Adding widget from drop");
}
addAppWidgetImpl(appWidgetId, info, boundWidget, appWidgetInfo, 0);
}
- void addAppWidgetImpl(final int appWidgetId, final ItemInfo info,
- final AppWidgetHostView boundWidget, final LauncherAppWidgetProviderInfo appWidgetInfo,
+ void addAppWidgetImpl(int appWidgetId, ItemInfo info,
+ AppWidgetHostView boundWidget, LauncherAppWidgetProviderInfo appWidgetInfo,
int delay) {
if (appWidgetInfo.configure != null) {
- mPendingAddWidgetInfo = appWidgetInfo;
- mPendingAddWidgetId = appWidgetId;
+ setWaitingForResult(PendingRequestArgs.forWidgetInfo(appWidgetId, appWidgetInfo, info));
// Launch over to configure widget, if needed
mAppWidgetManager.startConfigActivity(appWidgetInfo, appWidgetId, this,
mAppWidgetHost, REQUEST_CREATE_APPWIDGET);
-
} else {
// Otherwise just add it
Runnable onComplete = new Runnable() {
@@ -2237,8 +2125,7 @@ public class Launcher extends Activity
null);
}
};
- completeAddAppWidget(appWidgetId, info.container, info.screenId, boundWidget,
- appWidgetInfo);
+ completeAddAppWidget(appWidgetId, info, boundWidget, appWidgetInfo);
mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete, delay, false);
}
}
@@ -2251,17 +2138,22 @@ public class Launcher extends Activity
public void addPendingItem(PendingAddItemInfo info, long container, long screenId,
int[] cell, int spanX, int spanY) {
+ info.container = container;
+ info.screenId = screenId;
+ if (cell != null) {
+ info.cellX = cell[0];
+ info.cellY = cell[1];
+ }
+ info.spanX = spanX;
+ info.spanY = spanY;
+
switch (info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET:
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
- int span[] = new int[2];
- span[0] = spanX;
- span[1] = spanY;
- addAppWidgetFromDrop((PendingAddWidgetInfo) info,
- container, screenId, cell, span);
+ addAppWidgetFromDrop((PendingAddWidgetInfo) info);
break;
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
- processShortcutFromDrop(info.componentName, container, screenId, cell);
+ processShortcutFromDrop(info);
break;
default:
throw new IllegalStateException("Unknown item type: " + info.itemType);
@@ -2270,51 +2162,17 @@ public class Launcher extends Activity
/**
* Process a shortcut drop.
- *
- * @param componentName The name of the component
- * @param screenId The ID of the screen where it should be added
- * @param cell The cell it should be added to, optional
*/
- private void processShortcutFromDrop(ComponentName componentName, long container, long screenId,
- int[] cell) {
- resetAddInfo();
- mPendingAddInfo.container = container;
- mPendingAddInfo.screenId = screenId;
-
- if (cell != null) {
- mPendingAddInfo.cellX = cell[0];
- mPendingAddInfo.cellY = cell[1];
- }
-
- Intent createShortcutIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
- createShortcutIntent.setComponent(componentName);
- Utilities.startActivityForResultSafely(this, createShortcutIntent, REQUEST_CREATE_SHORTCUT);
+ private void processShortcutFromDrop(PendingAddItemInfo info) {
+ Intent intent = new Intent(Intent.ACTION_CREATE_SHORTCUT).setComponent(info.componentName);
+ setWaitingForResult(PendingRequestArgs.forIntent(REQUEST_CREATE_SHORTCUT, intent, info));
+ Utilities.startActivityForResultSafely(this, intent, REQUEST_CREATE_SHORTCUT);
}
/**
* Process a widget drop.
- *
- * @param info The PendingAppWidgetInfo of the widget being added.
- * @param screenId The ID of the screen where it should be added
- * @param cell The cell it should be added to, optional
*/
- private void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId,
- int[] cell, int[] span) {
- resetAddInfo();
- mPendingAddInfo.container = info.container = container;
- mPendingAddInfo.screenId = info.screenId = screenId;
- mPendingAddInfo.minSpanX = info.minSpanX;
- mPendingAddInfo.minSpanY = info.minSpanY;
-
- if (cell != null) {
- mPendingAddInfo.cellX = cell[0];
- mPendingAddInfo.cellY = cell[1];
- }
- if (span != null) {
- mPendingAddInfo.spanX = span[0];
- mPendingAddInfo.spanY = span[1];
- }
-
+ private void addAppWidgetFromDrop(PendingAddWidgetInfo info) {
AppWidgetHostView hostView = info.boundWidget;
int appWidgetId;
if (hostView != null) {
@@ -2340,11 +2198,11 @@ public class Launcher extends Activity
if (success) {
addAppWidgetFromDropImpl(appWidgetId, info, null, info.info);
} else {
- mPendingAddWidgetInfo = info.info;
+ setWaitingForResult(PendingRequestArgs.forWidgetInfo(appWidgetId, info.info, info));
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
- mAppWidgetManager.getUser(mPendingAddWidgetInfo)
+ mAppWidgetManager.getUser(info.info)
.addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
// TODO: we need to make sure that this accounts for the options bundle.
// intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
@@ -2563,14 +2421,13 @@ public class Launcher extends Activity
LauncherAppWidgetProviderInfo appWidgetInfo =
mAppWidgetManager.findProvider(info.providerName, info.user);
if (appWidgetInfo != null) {
- mPendingAddWidgetId = info.appWidgetId;
- mPendingAddInfo.copyFrom(info);
- mPendingAddWidgetInfo = appWidgetInfo;
+ setWaitingForResult(PendingRequestArgs
+ .forWidgetInfo(info.appWidgetId, appWidgetInfo, info));
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mPendingAddWidgetId);
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, info.appWidgetId);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, appWidgetInfo.provider);
- mAppWidgetManager.getUser(mPendingAddWidgetInfo)
+ mAppWidgetManager.getUser(appWidgetInfo)
.addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
startActivityForResult(intent, REQUEST_BIND_PENDING_APPWIDGET);
}
@@ -2599,9 +2456,7 @@ public class Launcher extends Activity
private void startRestoredWidgetReconfigActivity(
LauncherAppWidgetProviderInfo provider, LauncherAppWidgetInfo info) {
- mPendingAddWidgetInfo = provider;
- mPendingAddInfo.copyFrom(info);
- mPendingAddWidgetId = info.appWidgetId;
+ setWaitingForResult(PendingRequestArgs.forWidgetInfo(info.appWidgetId, provider, info));
mAppWidgetManager.startConfigActivity(provider,
info.appWidgetId, this, mAppWidgetHost, REQUEST_RECONFIGURE_APPWIDGET);
}
@@ -2771,6 +2626,7 @@ public class Launcher extends Activity
int pageScroll = mWorkspace.getScrollForPage(mWorkspace.getPageNearestToCenterOfScreen());
float offset = mWorkspace.mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);
+ setWaitingForResult(new PendingRequestArgs(new ItemInfo()));
Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER)
.setPackage(pickerPackage)
.putExtra(Utilities.EXTRA_WALLPAPER_OFFSET, offset);
@@ -2784,8 +2640,10 @@ public class Launcher extends Activity
*/
public void onClickSettingsButton(View v) {
if (LOGD) Log.d(TAG, "onClickSettingsButton");
- startActivity(new Intent(Utilities.ACTION_APPLICATION_PREFERENCES)
- .setPackage(getPackageName()));
+ Intent intent = new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
+ .setPackage(getPackageName());
+ intent.setSourceBounds(getViewBounds(v));
+ startActivity(intent, getActivityLaunchOptions(v));
}
public View.OnTouchListener getHapticFeedbackTouchListener() {
@@ -2809,7 +2667,7 @@ public class Launcher extends Activity
mDragLayer.onAccessibilityStateChanged(enabled);
}
- public void onDragStarted(View view) {
+ public void onDragStarted() {
if (isOnCustomContent()) {
// Custom content screen doesn't participate in drag and drop. If on custom
// content screen, move to default.
@@ -2885,9 +2743,9 @@ public class Launcher extends Activity
&& Intent.ACTION_CALL.equals(intent.getAction())
&& checkSelfPermission(Manifest.permission.CALL_PHONE) !=
PackageManager.PERMISSION_GRANTED) {
- // TODO: Rename sPendingAddItem to a generic name.
- sPendingAddItem = preparePendingAddArgs(REQUEST_PERMISSION_CALL_PHONE, intent,
- 0, info);
+
+ setWaitingForResult(PendingRequestArgs
+ .forIntent(REQUEST_PERMISSION_CALL_PHONE, intent, info));
requestPermissions(new String[]{Manifest.permission.CALL_PHONE},
REQUEST_PERMISSION_CALL_PHONE);
} else {
@@ -3172,6 +3030,14 @@ public class Launcher extends Activity
}
}
+ public View getTopFloatingView() {
+ View topView = getOpenShortcutsContainer();
+ if (topView == null) {
+ topView = getWorkspace().getOpenFolder();
+ }
+ return topView;
+ }
+
/**
* @return The open shortcuts container, or null if there is none
*/
@@ -3221,7 +3087,7 @@ public class Launcher extends Activity
ItemInfo info = (ItemInfo) v.getTag();
longClickCellInfo = new CellLayout.CellInfo(v, info);
itemUnderLongClick = longClickCellInfo.cell;
- resetAddInfo();
+ mPendingRequestArgs = null;
}
// The hotseat touch handling does not go through Workspace, and we always allow long press
@@ -3243,7 +3109,7 @@ public class Launcher extends Activity
longClickCellInfo.cellX, longClickCellInfo.cellY));
if (!(itemUnderLongClick instanceof Folder || isAllAppsButton)) {
// User long pressed on an item
- mWorkspace.startDrag(longClickCellInfo);
+ mWorkspace.startDrag(longClickCellInfo, new DragOptions());
}
}
}
@@ -3285,29 +3151,6 @@ public class Launcher extends Activity
return (mState == State.WIDGETS) || (mOnResumeState == State.WIDGETS);
}
- private void setWorkspaceBackground(int background) {
- switch (background) {
- case WORKSPACE_BACKGROUND_TRANSPARENT:
- getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
- break;
- case WORKSPACE_BACKGROUND_BLACK:
- getWindow().setBackgroundDrawable(null);
- break;
- default:
- getWindow().setBackgroundDrawable(mWorkspaceBackgroundDrawable);
- }
- }
-
- protected void changeWallpaperVisiblity(boolean visible) {
- int wpflags = visible ? WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER : 0;
- int curflags = getWindow().getAttributes().flags
- & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
- if (wpflags != curflags) {
- getWindow().setFlags(wpflags, WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
- }
- setWorkspaceBackground(visible ? WORKSPACE_BACKGROUND_GRADIENT : WORKSPACE_BACKGROUND_BLACK);
- }
-
@Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
@@ -3564,10 +3407,6 @@ public class Launcher extends Activity
// TODO
}
- public boolean launcherCallbacksProvidesSearch() {
- return (mLauncherCallbacks != null && mLauncherCallbacks.providesSearch());
- }
-
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
final boolean result = super.dispatchPopulateAccessibilityEvent(event);
@@ -3955,14 +3794,30 @@ public class Launcher extends Activity
pendingInfo.minSpanX = item.minSpanX;
pendingInfo.minSpanY = item.minSpanY;
Bundle options = WidgetHostViewLoader.getDefaultOptionsForWidget(this, pendingInfo);
+
+ boolean isDirectConfig =
+ item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG);
+ if (isDirectConfig && item.bindOptions != null) {
+ Bundle newOptions = item.bindOptions.getExtras();
+ if (options != null) {
+ newOptions.putAll(options);
+ }
+ options = newOptions;
+ }
boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
item.appWidgetId, appWidgetInfo, options);
+ // We tried to bind once. If we were not able to bind, we would need to
+ // go through the permission dialog, which means we cannot skip the config
+ // activity.
+ item.bindOptions = null;
+ item.restoreStatus &= ~LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG;
+
// Bind succeeded
if (success) {
// If the widget has a configure activity, it is still needs to set it up,
// otherwise the widget is ready to go.
- item.restoreStatus = (appWidgetInfo.configure == null)
+ item.restoreStatus = (appWidgetInfo.configure == null) || isDirectConfig
? LauncherAppWidgetInfo.RESTORE_COMPLETED
: LauncherAppWidgetInfo.FLAG_UI_NOT_READY;
}
@@ -4105,21 +3960,10 @@ public class Launcher extends Activity
setWorkspaceLoading(false);
- // If we received the result of any pending adds while the loader was running (e.g. the
- // widget configuration forced an orientation change), process them now.
- if (sPendingAddItem != null) {
- final long screenId = completeAdd(sPendingAddItem);
-
- // TODO: this moves the user to the page where the pending item was added. Ideally,
- // the screen would be guaranteed to exist after bind, and the page would be set through
- // the workspace restore process.
- mWorkspace.post(new Runnable() {
- @Override
- public void run() {
- mWorkspace.snapToScreenId(screenId);
- }
- });
- sPendingAddItem = null;
+ if (mPendingActivityResult != null) {
+ handleActivityResult(mPendingActivityResult.requestCode,
+ mPendingActivityResult.resultCode, mPendingActivityResult.data);
+ mPendingActivityResult = null;
}
InstallShortcutReceiver.disableAndFlushInstallQueue(this);
@@ -4202,6 +4046,10 @@ public class Launcher extends Activity
return Collections.EMPTY_LIST;
}
ComponentName component = info.getTargetComponent();
+ if (component == null) {
+ return Collections.EMPTY_LIST;
+ }
+
List<String> ids = mDeepShortcutMap.get(new ComponentKey(component, info.user));
return ids == null ? Collections.EMPTY_LIST : ids;
}
@@ -4442,51 +4290,6 @@ public class Launcher extends Activity
}
}
- /**
- * To be overridden by subclasses to indicate that there is an activity to launch
- * before showing the standard launcher experience.
- */
- protected boolean hasFirstRunActivity() {
- if (mLauncherCallbacks != null) {
- return mLauncherCallbacks.hasFirstRunActivity();
- }
- return false;
- }
-
- /**
- * To be overridden by subclasses to launch any first run activity
- */
- protected Intent getFirstRunActivity() {
- if (mLauncherCallbacks != null) {
- return mLauncherCallbacks.getFirstRunActivity();
- }
- return null;
- }
-
- private boolean shouldRunFirstRunActivity() {
- return !ActivityManager.isRunningInTestHarness() &&
- !mSharedPrefs.getBoolean(FIRST_RUN_ACTIVITY_DISPLAYED, false);
- }
-
- public boolean showFirstRunActivity() {
- if (shouldRunFirstRunActivity() &&
- hasFirstRunActivity()) {
- Intent firstRunIntent = getFirstRunActivity();
- if (firstRunIntent != null) {
- startActivity(firstRunIntent);
- markFirstRunActivityShown();
- return true;
- }
- }
- return false;
- }
-
- private void markFirstRunActivityShown() {
- SharedPreferences.Editor editor = mSharedPrefs.edit();
- editor.putBoolean(FIRST_RUN_ACTIVITY_DISPLAYED, true);
- editor.apply();
- }
-
private void markAppsViewShown() {
if (mSharedPrefs.getBoolean(APPS_VIEW_SHOWN, false)) {
return;
@@ -4510,44 +4313,6 @@ public class Launcher extends Activity
return true;
}
- /**
- * To be overridden by subclasses to indicate that there is an in-activity full-screen intro
- * screen that must be displayed and dismissed.
- */
- protected boolean hasDismissableIntroScreen() {
- if (mLauncherCallbacks != null) {
- return mLauncherCallbacks.hasDismissableIntroScreen();
- }
- return false;
- }
-
- /**
- * Full screen intro screen to be shown and dismissed before the launcher can be used.
- */
- protected View getIntroScreen() {
- if (mLauncherCallbacks != null) {
- return mLauncherCallbacks.getIntroScreen();
- }
- return null;
- }
-
- /**
- * To be overriden by subclasses to indicate whether the in-activity intro screen has been
- * dismissed. This method is ignored if #hasDismissableIntroScreen returns false.
- */
- private boolean shouldShowIntroScreen() {
- return hasDismissableIntroScreen() &&
- !mSharedPrefs.getBoolean(INTRO_SCREEN_DISMISSED, false);
- }
-
- protected void showIntroScreen() {
- View introScreen = getIntroScreen();
- changeWallpaperVisiblity(false);
- if (introScreen != null) {
- mDragLayer.showOverlayView(introScreen);
- }
- }
-
// TODO: These method should be a part of LauncherSearchCallback
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ItemInfo createAppDragInfo(Intent appLaunchIntent) {
@@ -4614,8 +4379,8 @@ public class Launcher extends Activity
Log.d(TAG, "BEGIN launcher3 dump state for launcher " + this);
Log.d(TAG, "mSavedState=" + mSavedState);
Log.d(TAG, "mWorkspaceLoading=" + mWorkspaceLoading);
- Log.d(TAG, "mRestoring=" + mRestoring);
- Log.d(TAG, "mWaitingForResult=" + mWaitingForResult);
+ Log.d(TAG, "mPendingRequestArgs=" + mPendingRequestArgs);
+ Log.d(TAG, "mPendingActivityResult=" + mPendingActivityResult);
mModel.dumpState();
// TODO(hyunyoungs): add mWidgetsView.dumpState(); or mWidgetsModel.dumpState();