List of usage examples for android.appwidget AppWidgetManager EXTRA_APPWIDGET_ID
String EXTRA_APPWIDGET_ID
To view the source code for android.appwidget AppWidgetManager EXTRA_APPWIDGET_ID.
Click Source Link
From source file:de.spiritcroc.modular_remote.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (requestCode == REQUEST_PICK_APPWIDGET) { configureWidget(data);//from w w w . java2 s .c o m } else if (requestCode == REQUEST_CREATE_APPWIDGET) { createWidgetContainerFragment(data); } } else if (resultCode == RESULT_CANCELED && data != null) { int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); if (appWidgetId != -1) { appWidgetHost.deleteAppWidgetId(appWidgetId); } } }
From source file:de.spiritcroc.modular_remote.MainActivity.java
private void configureWidget(Intent data) { Bundle extras = data.getExtras();/*w ww. j av a2 s . c o m*/ int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); AppWidgetProviderInfo appWidgetProviderInfo = appWidgetManager.getAppWidgetInfo(appWidgetId); if (appWidgetProviderInfo.configure != null) { Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE); intent.setComponent(appWidgetProviderInfo.configure); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); startActivityForResult(intent, REQUEST_CREATE_APPWIDGET); } else { createWidgetContainerFragment(data); } }
From source file:de.spiritcroc.modular_remote.MainActivity.java
private void createWidgetContainerFragment(Intent data) { Bundle extras = data.getExtras();//from w w w . j a v a 2 s . c o m int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); if (addWidgetContainer != null) { addWidgetContainer.addFragment(WidgetContainerFragment.newInstance(appWidgetId), false); if (addWidgetListener != null) { addWidgetListener.dismiss(); addWidgetListener = null; } } }
From source file:xyz.klinker.blur.launcher3.Launcher.java
private void handleActivityResult(final int requestCode, final int resultCode, final Intent data) { // Reset the startActivity waiting flag setWaitingForResult(false);/*from ww w .j a v a 2s. c o m*/ final int pendingAddWidgetId = mPendingAddWidgetId; mPendingAddWidgetId = -1; Runnable exitSpringLoaded = new Runnable() { @Override public void run() { exitSpringLoadedDragModeDelayed((resultCode != RESULT_CANCELED), EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null); } }; if (requestCode == REQUEST_BIND_APPWIDGET) { // This is called only if the user did not previously have permissions to bind widgets final int appWidgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (resultCode == RESULT_CANCELED) { completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId); 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); // When the user has granted permission to bind widgets, we should check to see if // we can inflate the default search bar widget. getOrCreateQsbBar(); } return; } else if (requestCode == REQUEST_PICK_WALLPAPER) { if (resultCode == RESULT_OK && mWorkspace.isInOverviewMode()) { // User could have free-scrolled between pages before picking a wallpaper; make sure // we move to the closest one now to avoid visual jump. mWorkspace.setCurrentPage(mWorkspace.getPageNearestToCenterOfScreen()); showWorkspace(false); } return; } 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; int widgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (widgetId < 0) { appWidgetId = pendingAddWidgetId; } else { appWidgetId = widgetId; } final int result; if (appWidgetId < 0 || resultCode == RESULT_CANCELED) { Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not " + "returned from the widget configuration activity."); result = RESULT_CANCELED; completeTwoStageWidgetDrop(result, appWidgetId); 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; } } return; } if (requestCode == REQUEST_RECONFIGURE_APPWIDGET) { if (resultCode == RESULT_OK) { // Update the widget view. PendingAddArguments args = preparePendingAddArgs(requestCode, data, pendingAddWidgetId, mPendingAddInfo); if (workspaceLocked) { sPendingAddItem = args; } else { completeAdd(args); } } // Leave the widget in the pending state if the user canceled the configure. return; } // The pattern used here is that a user PICKs a specific application, // which, depending on the target, might need to CREATE the actual target. // For example, the user would PICK_SHORTCUT for "Music playlist", and we // launch over to the Music app to actually 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); } } else if (resultCode == RESULT_CANCELED) { mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded, ON_ACTIVITY_RESULT_ANIMATION_DELAY, false); } mDragLayer.clearAnimatedView(); }
From source file:com.android.soma.Launcher.java
/** * 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. *//* www .ja va 2 s .com*/ private boolean completeAdd(PendingAddArguments args) { boolean result = false; switch (args.requestCode) { case REQUEST_PICK_APPLICATION: completeAddApplication(args.intent, args.container, args.screenId, args.cellX, args.cellY); break; case REQUEST_PICK_SHORTCUT: processShortcut(args.intent); break; case REQUEST_CREATE_SHORTCUT: completeAddShortcut(args.intent, args.container, args.screenId, args.cellX, args.cellY); result = true; break; case REQUEST_CREATE_APPWIDGET: int appWidgetId = args.intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); completeAddAppWidget(appWidgetId, args.container, args.screenId, null, null); result = true; 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 result; }
From source file:com.android.soma.Launcher.java
@Override protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { // Reset the startActivity waiting flag mWaitingForResult = false;/*from w w w . ja v a 2 s.com*/ if (requestCode == REQUEST_BIND_APPWIDGET) { int appWidgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (resultCode == RESULT_CANCELED) { completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId); } else if (resultCode == RESULT_OK) { addAppWidgetImpl(appWidgetId, mPendingAddInfo, null, mPendingAddWidgetInfo); } return; } else if (requestCode == REQUEST_PICK_WALLPAPER) { if (resultCode == RESULT_OK && mWorkspace.isInOverviewMode()) { mWorkspace.exitOverviewMode(false); } return; } boolean delayExitSpringLoadedMode = false; boolean isWidgetDrop = (requestCode == REQUEST_PICK_APPWIDGET || requestCode == REQUEST_CREATE_APPWIDGET); // We have special handling for widgets if (isWidgetDrop) { int appWidgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (appWidgetId < 0) { Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not returned from the \\" + "widget configuration activity."); completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId); mWorkspace.stripEmptyScreens(); } else { completeTwoStageWidgetDrop(resultCode, appWidgetId); } return; } // The pattern used here is that a user PICKs a specific application, // which, depending on the target, might need to CREATE the actual target. // For example, the user would PICK_SHORTCUT for "Music playlist", and we // launch over to the Music app to actually CREATE_SHORTCUT. if (resultCode == RESULT_OK && mPendingAddInfo.container != ItemInfo.NO_ID) { final PendingAddArguments args = new PendingAddArguments(); args.requestCode = requestCode; args.intent = data; args.container = mPendingAddInfo.container; args.screenId = mPendingAddInfo.screenId; args.cellX = mPendingAddInfo.cellX; args.cellY = mPendingAddInfo.cellY; if (isWorkspaceLocked()) { sPendingAddList.add(args); } else { delayExitSpringLoadedMode = completeAdd(args); } } else if (resultCode == RESULT_CANCELED) { mWorkspace.stripEmptyScreens(); } mDragLayer.clearAnimatedView(); // Exit spring loaded mode if necessary after cancelling the configuration of a widget exitSpringLoadedDragModeDelayed((resultCode != RESULT_CANCELED), delayExitSpringLoadedMode, null); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { mWaitingForResult = false;//from ww w. j a va 2 s . com // The pattern used here is that a user PICKs a specific application, // which, depending on the target, might need to CREATE the actual // target. // For example, the user would PICK_SHORTCUT for "Music playlist", and // we // launch over to the Music app to actually CREATE_SHORTCUT. if (resultCode == RESULT_OK && mAddItemCellInfo != null) { switch (requestCode) { case REQUEST_PICK_APPLICATION: completeAddApplication(this, data, mAddItemCellInfo, !mDesktopLocked); break; case REQUEST_PICK_SHORTCUT: PersonaLog.e("data: ", "" + data); processShortcut(data, REQUEST_PICK_APPLICATION, REQUEST_CREATE_SHORTCUT); break; case REQUEST_CREATE_SHORTCUT: completeAddShortcut(data, mAddItemCellInfo, !mDesktopLocked); break; case REQUEST_PICK_LIVE_FOLDER: addLiveFolder(data); break; case REQUEST_CREATE_LIVE_FOLDER: completeAddLiveFolder(data, mAddItemCellInfo, !mDesktopLocked); break; case REQUEST_PICK_APPWIDGET: addAppWidget(data); break; case REQUEST_CREATE_APPWIDGET: completeAddAppWidget(data, mAddItemCellInfo, !mDesktopLocked); break; case REQUEST_PICK_ANYCUT: completeAddShortcut(data, mAddItemCellInfo, !mDesktopLocked); break; case REQUEST_EDIT_SHIRTCUT: completeEditShirtcut(data); break; // Trumobi changes for custom widget picker 290661 case REQUEST_BIND_APPWIDGET: addAppWidget(data); break; } } else if (resultCode == RESULT_OK) { switch (requestCode) { case REQUEST_SHOW_APP_LIST: { mAllAppsGrid.updateAppGrp(); showAllApps(true, null); } break; case REQUEST_EDIT_SHIRTCUT: completeEditShirtcut(data); break; } } else if ((requestCode == REQUEST_PICK_APPWIDGET || requestCode == REQUEST_CREATE_APPWIDGET) && resultCode == RESULT_CANCELED && data != null) { // Clean up the appWidgetId if we canceled int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); if (appWidgetId != -1) { mAppWidgetHost.deleteAppWidgetId(appWidgetId); } } }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
private void handleActivityResult(final int requestCode, final int resultCode, final Intent data) { // Reset the startActivity waiting flag setWaitingForResult(false);//from w w w. j a v a 2s . c om final int pendingAddWidgetId = mPendingAddWidgetId; mPendingAddWidgetId = -1; Runnable exitSpringLoaded = new Runnable() { @Override public void run() { exitSpringLoadedDragModeDelayed((resultCode != RESULT_CANCELED), EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null); } }; if (requestCode == REQUEST_BIND_APPWIDGET) { final int appWidgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (resultCode == RESULT_CANCELED) { completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId); 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); } return; } else if (requestCode == REQUEST_PICK_WALLPAPER) { if (resultCode == RESULT_OK && mWorkspace.isInOverviewMode()) { showWorkspace(false); } return; } 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; int widgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (widgetId < 0) { appWidgetId = pendingAddWidgetId; } else { appWidgetId = widgetId; } final int result; if (appWidgetId < 0 || resultCode == RESULT_CANCELED) { Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not " + "returned from the widget configuration activity."); result = RESULT_CANCELED; completeTwoStageWidgetDrop(result, appWidgetId); 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; } } return; } if (requestCode == REQUEST_RECONFIGURE_APPWIDGET) { if (resultCode == RESULT_OK) { // Update the widget view. PendingAddArguments args = preparePendingAddArgs(requestCode, data, pendingAddWidgetId, mPendingAddInfo); if (workspaceLocked) { sPendingAddItem = args; } else { completeAdd(args); } } // Leave the widget in the pending state if the user canceled the configure. return; } // The pattern used here is that a user PICKs a specific application, // which, depending on the target, might need to CREATE the actual target. // For example, the user would PICK_SHORTCUT for "Music playlist", and we // launch over to the Music app to actually 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); } } else if (resultCode == RESULT_CANCELED) { mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded, ON_ACTIVITY_RESULT_ANIMATION_DELAY, false); } mDragLayer.clearAnimatedView(); }
From source file:com.android.launcher3.Launcher.java
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;//from w w w. j a v a 2 s. c o m } mPendingActivityResult = null; // Reset the startActivity waiting flag final PendingRequestArgs requestArgs = mPendingRequestArgs; setWaitingForResult(null); if (requestArgs == null) { return; } final int pendingAddWidgetId = requestArgs.getWidgetId(); Runnable exitSpringLoaded = new Runnable() { @Override public void run() { exitSpringLoadedDragModeDelayed((resultCode != RESULT_CANCELED), EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null); } }; if (requestCode == REQUEST_BIND_APPWIDGET) { // This is called only if the user did not previously have permissions to bind widgets final int appWidgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (resultCode == RESULT_CANCELED) { completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId, requestArgs); mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded, ON_ACTIVITY_RESULT_ANIMATION_DELAY, false); } else if (resultCode == RESULT_OK) { addAppWidgetImpl(appWidgetId, requestArgs, null, requestArgs.getWidgetProvider(), ON_ACTIVITY_RESULT_ANIMATION_DELAY); } return; } else if (requestCode == REQUEST_PICK_WALLPAPER) { if (resultCode == RESULT_OK && mWorkspace.isInOverviewMode()) { // User could have free-scrolled between pages before picking a wallpaper; make sure // we move to the closest one now. mWorkspace.setCurrentPage(mWorkspace.getPageNearestToCenterOfScreen()); showWorkspace(false); } return; } boolean isWidgetDrop = (requestCode == REQUEST_PICK_APPWIDGET || requestCode == REQUEST_CREATE_APPWIDGET); // We have special handling for widgets if (isWidgetDrop) { final int appWidgetId; int widgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (widgetId < 0) { appWidgetId = pendingAddWidgetId; } else { appWidgetId = widgetId; } final int result; if (appWidgetId < 0 || resultCode == RESULT_CANCELED) { Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not " + "returned from the widget configuration activity."); result = RESULT_CANCELED; completeTwoStageWidgetDrop(result, appWidgetId, requestArgs); final Runnable onComplete = new Runnable() { @Override public void run() { exitSpringLoadedDragModeDelayed(false, 0, null); } }; 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; } if (requestCode == REQUEST_RECONFIGURE_APPWIDGET || requestCode == REQUEST_BIND_PENDING_APPWIDGET) { if (resultCode == RESULT_OK) { // Update the widget view. completeAdd(requestCode, data, pendingAddWidgetId, requestArgs); } // Leave the widget in the pending state if the user canceled the configure. return; } if (requestCode == REQUEST_CREATE_SHORTCUT) { // Handle custom shortcuts created using ACTION_CREATE_SHORTCUT. 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(); }
From source file:g7.bluesky.launcher3.Launcher.java
private void handleActivityResult(final int requestCode, final int resultCode, final Intent data) { // Reset the startActivity waiting flag setWaitingForResult(false);//w w w.j a v a 2 s . c o m if (requestCode == REQUEST_APP_LIST_VIEW) { String themeOpacity = defaultSharedPref.getString(SettingConstants.THEME_OPACITY_PREF_KEY, "255"); // if theme is not opaque => workspace is shown => no need to show again if (mWorkspace != null && !themeOpacity.equals("255")) { showWorkspaceSearchAndHotseat(); } return; } final int pendingAddWidgetId = mPendingAddWidgetId; mPendingAddWidgetId = -1; Runnable exitSpringLoaded = new Runnable() { @Override public void run() { exitSpringLoadedDragModeDelayed((resultCode != RESULT_CANCELED), EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null); } }; if (requestCode == REQUEST_BIND_APPWIDGET) { final int appWidgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (resultCode == RESULT_CANCELED) { completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId); 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); } return; } else if (requestCode == REQUEST_PICK_WALLPAPER) { if (resultCode == RESULT_OK && mWorkspace.isInOverviewMode()) { mWorkspace.exitOverviewMode(false); } return; } 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; int widgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1; if (widgetId < 0) { appWidgetId = pendingAddWidgetId; } else { appWidgetId = widgetId; } final int result; if (appWidgetId < 0 || resultCode == RESULT_CANCELED) { Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not " + "returned from the widget configuration activity."); result = RESULT_CANCELED; completeTwoStageWidgetDrop(result, appWidgetId); 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; } } return; } if (requestCode == REQUEST_RECONFIGURE_APPWIDGET) { if (resultCode == RESULT_OK) { // Update the widget view. PendingAddArguments args = preparePendingAddArgs(requestCode, data, pendingAddWidgetId, mPendingAddInfo); if (workspaceLocked) { sPendingAddItem = args; } else { completeAdd(args); } } // Leave the widget in the pending state if the user canceled the configure. return; } // The pattern used here is that a user PICKs a specific application, // which, depending on the target, might need to CREATE the actual target. // For example, the user would PICK_SHORTCUT for "Music playlist", and we // launch over to the Music app to actually 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); } } else if (resultCode == RESULT_CANCELED) { mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded, ON_ACTIVITY_RESULT_ANIMATION_DELAY, false); } mDragLayer.clearAnimatedView(); }