List of usage examples for android.os Bundle putBoolean
public void putBoolean(@Nullable String key, boolean value)
From source file:com.eleybourn.bookcatalogue.utils.Utils.java
/** * If there is a '__thumbnails' key, pick the largest image, rename it * and delete the others. Finally, remove the key. * /*from www. ja va 2 s. co m*/ * @param result Book data */ static public void cleanupThumbnails(Bundle result) { if (result.containsKey("__thumbnail")) { long best = -1; int bestFile = -1; // Parse the list ArrayList<String> files = Utils.decodeList(result.getString("__thumbnail"), '|'); // Just read the image files to get file size BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inJustDecodeBounds = true; // Scan, finding biggest for (int i = 0; i < files.size(); i++) { String filespec = files.get(i); File file = new File(filespec); if (file.exists()) { BitmapFactory.decodeFile(filespec, opt); // If no size info, assume file bad and skip if (opt.outHeight > 0 && opt.outWidth > 0) { long size = opt.outHeight * opt.outWidth; if (size > best) { best = size; bestFile = i; } } } } // Delete all but the best one. Note there *may* be no best one, // so all would be deleted. We do this first in case the list // contains a file with the same name as the target of our // rename. for (int i = 0; i < files.size(); i++) { if (i != bestFile) { File file = new File(files.get(i)); file.delete(); } } // Get the best file (if present) and rename it. if (bestFile >= 0) { File file = new File(files.get(bestFile)); file.renameTo(CatalogueDBAdapter.getTempThumbnail()); } // Finally, cleanup the data result.remove("__thumbnail"); result.putBoolean(CatalogueDBAdapter.KEY_THUMBNAIL, true); } }
From source file:com.df.app.procedures.CarRecogniseLayout.java
/** * ??/* w ww. jav a2 s .co m*/ */ private void recogniseLicense() { // String selectPath = AppCommon.licensePhotoPath; boolean cutBoolean = cut; try { Intent intent = new Intent("wintone.idcard"); Bundle bundle = new Bundle(); int nSubID[] = null; bundle.putInt("nTypeInitIDCard", 0); //?0?? bundle.putString("lpFileName", selectPath);//? bundle.putInt("nTypeLoadImageToMemory", 0);//0???1??24 bundle.putInt("nMainID", nMainID); //?6?2????????ID????? bundle.putIntArray("nSubID", nSubID); //????ID????????nSubID[0]=nullnMainID? //sn File file = new File(AppCommon.licenseUtilPath); String snString = null; if (file.exists()) { String filePATH = AppCommon.licenseUtilPath + "/IdCard.sn"; File newFile = new File(filePATH); if (newFile.exists()) { BufferedReader bfReader = new BufferedReader(new FileReader(newFile)); snString = bfReader.readLine().toUpperCase(); bfReader.close(); } else { bundle.putString("sn", ""); } if (snString != null && !snString.equals("")) { bundle.putString("sn", snString); } else { bundle.putString("sn", ""); } } else { bundle.putString("sn", ""); } bundle.putString("authfile", ""); //? /mnt/sdcard/AndroidWT/357816040594713_zj.txt bundle.putString("logo", ""); //logologo?? bundle.putBoolean("isCut", cutBoolean); //?? bundle.putString("returntype", "withvalue");//?withvalue??? intent.putExtras(bundle); ((Activity) getContext()).startActivityForResult(intent, 8); } catch (Exception e) { Toast.makeText(getContext(), "?" + "wintone.idcard", Toast.LENGTH_SHORT).show(); } }
From source file:com.android.gallery3d.app.PhotoPage.java
private void switchToGrid() { /// M: [BUG.MODIFY] @{ // For case 1: AlbumSetPage >> AlbumPage >> AlbumSetPage >> (AlbumPage , PhotoPage) // For case 2: ContainerPage >> PhotoPage >> film mode >> grid mode /* if (mActivity.getStateManager().hasStateClass(AlbumPage.class)) { *//*w ww .j a v a 2 s . co m*/ if (mActivity.getStateManager().hasStateClassInNearPosition(AlbumPage.class) || mActivity.getStateManager().hasStateClassInNearPosition(ContainerPage.class)) { /// @} onUpPressed(); } else { if (mOriginalSetPathString == null) return; Bundle data = new Bundle(getData()); data.putString(AlbumPage.KEY_MEDIA_PATH, mOriginalSetPathString); data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH, mActivity.getDataManager().getTopSetPath(DataManager.INCLUDE_ALL)); // We only show cluster menu in the first AlbumPage in stack // TODO: Enable this when running from the camera app boolean inAlbum = mActivity.getStateManager().hasStateClass(AlbumPage.class); data.putBoolean(AlbumPage.KEY_SHOW_CLUSTER_MENU, !inAlbum && mAppBridge == null); data.putBoolean(PhotoPage.KEY_APP_BRIDGE, mAppBridge != null); // Account for live preview being first item mActivity.getTransitionStore().put(KEY_RETURN_INDEX_HINT, mAppBridge != null ? mCurrentIndex - 1 : mCurrentIndex); if (mHasCameraScreennailOrPlaceholder && mAppBridge != null) { mActivity.getStateManager().startState(AlbumPage.class, data); } else { mActivity.getStateManager().switchState(this, AlbumPage.class, data); } } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
public void showSMBDialog(String name, String path, boolean edit) { if (path.length() > 0 && name.length() == 0) { int i = dataUtils.containsServer(new String[] { name, path }); if (i != -1) name = dataUtils.getServers().get(i)[0]; }// w ww . j av a 2 s . c om SmbConnectDialog smbConnectDialog = new SmbConnectDialog(); Bundle bundle = new Bundle(); bundle.putString("name", name); bundle.putString("path", path); bundle.putBoolean("edit", edit); smbConnectDialog.setArguments(bundle); smbConnectDialog.show(getFragmentManager(), "smbdailog"); }
From source file:com.android.mail.compose.ComposeActivity.java
/** * Use the {@link ContentResolver#call} method to send or save the message. * * If this was successful, this method will return an non-null Bundle instance *//* ww w . ja va2s .c o m*/ private static Bundle callAccountSendSaveMethod(final ContentResolver resolver, final Account account, final String method, final SendOrSaveMessage sendOrSaveMessage) { // Copy all of the values from the content values to the bundle final Bundle methodExtras = new Bundle(sendOrSaveMessage.mValues.size()); final Set<Entry<String, Object>> valueSet = sendOrSaveMessage.mValues.valueSet(); for (Entry<String, Object> entry : valueSet) { final Object entryValue = entry.getValue(); final String key = entry.getKey(); if (entryValue instanceof String) { methodExtras.putString(key, (String) entryValue); } else if (entryValue instanceof Boolean) { methodExtras.putBoolean(key, (Boolean) entryValue); } else if (entryValue instanceof Integer) { methodExtras.putInt(key, (Integer) entryValue); } else if (entryValue instanceof Long) { methodExtras.putLong(key, (Long) entryValue); } else { LogUtils.wtf(LOG_TAG, "Unexpected object type: %s", entryValue.getClass().getName()); } } // If the SendOrSaveMessage has some opened fds, add them to the bundle final Bundle fdMap = sendOrSaveMessage.attachmentFds(); if (fdMap != null) { methodExtras.putParcelable(UIProvider.SendOrSaveMethodParamKeys.OPENED_FD_MAP, fdMap); } return resolver.call(account.uri, method, account.uri.toString(), methodExtras); }
From source file:com.kll.collect.android.activities.FormEntryActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString(KEY_FORMPATH, mFormPath); FormController formController = Collect.getInstance().getFormController(); if (formController != null) { outState.putString(KEY_INSTANCEPATH, formController.getInstancePath().getAbsolutePath()); outState.putString(KEY_XPATH, formController.getXPath(formController.getFormIndex())); FormIndex waiting = formController.getIndexWaitingForData(); if (waiting != null) { outState.putString(KEY_XPATH_WAITING_FOR_DATA, formController.getXPath(waiting)); }/* w w w . j av a 2s .c o m*/ // save the instance to a temp path... nonblockingCreateSavePointData(); } outState.putBoolean(NEWFORM, false); outState.putString(KEY_ERROR, mErrorMessage); }
From source file:com.android.gallery3d.app.PhotoPage.java
@Override protected boolean onItemSelected(MenuItem item) { if (mModel == null) return true; refreshHidingMessage();//from w w w .j a v a 2s. com MediaItem current = mModel.getMediaItem(0); // This is a shield for monkey when it clicks the action bar // menu when transitioning from filmstrip to camera if (current instanceof SnailItem) return true; // TODO: We should check the current photo against the MediaItem // that the menu was initially created for. We need to fix this // after PhotoPage being refactored. if (current == null) { // item is not ready, ignore return true; } int currentIndex = mModel.getCurrentIndex(); Path path = current.getPath(); DataManager manager = mActivity.getDataManager(); int action = item.getItemId(); /// M: [BUG.ADD] show toast before PhotoDataAdapter finishing loading to avoid JE @{ if (action != android.R.id.home && !mLoadingFinished && mSetPathString != null) { Toast.makeText(mActivity, mActivity.getString(R.string.please_wait), Toast.LENGTH_SHORT).show(); return true; } /// @} String confirmMsg = null; switch (action) { case android.R.id.home: { onUpPressed(); return true; } case R.id.action_slideshow: { Bundle data = new Bundle(); /// M: [BUG.MODIFY] fix bug: slideshow doesn't play again // when finish playing the last picture @{ String mediaSetPath = mMediaSet.getPath().toString(); if (mSnailSetPath != null) { mediaSetPath = mediaSetPath.replace(mSnailSetPath + ",", ""); Log.i(TAG, "<onItemSelected> action_slideshow | mediaSetPath: " + mediaSetPath); } /*data.putString(SlideshowPage.KEY_SET_PATH, mMediaSet.getPath().toString());*/ data.putString(SlideshowPage.KEY_SET_PATH, mediaSetPath); /// @} data.putString(SlideshowPage.KEY_ITEM_PATH, path.toString()); /// M: [BUG.ADD] currentIndex-- if it is in camera folder @{ if (mHasCameraScreennailOrPlaceholder) { currentIndex--; } /// @} data.putInt(SlideshowPage.KEY_PHOTO_INDEX, currentIndex); data.putBoolean(SlideshowPage.KEY_REPEAT, true); mActivity.getStateManager().startStateForResult(SlideshowPage.class, REQUEST_SLIDESHOW, data); return true; } case R.id.action_crop: { /// M: [BUG.ADD] disable cropping photo when file not exists or sdcard is full. @{ File srcFile = new File(current.getFilePath()); if (!srcFile.exists()) { Log.i(TAG, "<onItemSelected> abort cropping photo when not exists!"); return true; } if (!isSpaceEnough(srcFile)) { Log.i(TAG, "<onItemSelected> abort cropping photo when no enough space!"); Toast.makeText(mActivity, mActivity.getString(R.string.storage_not_enough), Toast.LENGTH_SHORT) .show(); return true; } /// @} Activity activity = mActivity; Intent intent = new Intent(CropActivity.CROP_ACTION); intent.setClass(activity, CropActivity.class); intent.setDataAndType(manager.getContentUri(path), current.getMimeType()) .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); activity.startActivityForResult(intent, PicasaSource.isPicasaImage(current) ? REQUEST_CROP_PICASA : REQUEST_CROP); return true; } case R.id.action_trim: { Intent intent = new Intent(mActivity, TrimVideo.class); intent.setData(manager.getContentUri(path)); // We need the file path to wrap this into a RandomAccessFile. intent.putExtra(KEY_MEDIA_ITEM_PATH, current.getFilePath()); /// M: [FEATURE.ADD] SlideVideo@{ if (FeatureConfig.SUPPORT_SLIDE_VIDEO_PLAY) { intent.putExtra(TrimVideo.KEY_COME_FROM_GALLERY, true); } /// @} mActivity.startActivityForResult(intent, REQUEST_TRIM); return true; } case R.id.action_mute: { /// M: [BUG.ADD] disable muting video when file not exists or sdcard is full. @{ File srcFile = new File(current.getFilePath()); if (!srcFile.exists()) { Log.i(TAG, "<onItemSelected> abort muting video when not exists!"); return true; } if (!isSpaceEnough(srcFile)) { Log.i(TAG, "<onItemSelected> abort muting video when no enough space!"); Toast.makeText(mActivity, mActivity.getString(R.string.storage_not_enough), Toast.LENGTH_SHORT) .show(); return true; } /// @} mMuteVideo = new MuteVideo(current.getFilePath(), manager.getContentUri(path), mActivity); mMuteVideo.muteInBackground(); /// M: [FEATURE.ADD] SlideVideo@{ mMuteVideo.setMuteDoneListener(new MuteDoneListener() { public void onMuteDone(Uri uri) { redirectCurrentMedia(uri, false); } }); /// @} return true; } case R.id.action_edit: { /// M: [BUG.ADD] disable editing photo when file not exists or sdcard is full. @{ File srcFile = new File(current.getFilePath()); if (!srcFile.exists()) { Log.i(TAG, "<onItemSelected> abort editing photo when not exists!"); return true; } if (!isSpaceEnough(srcFile)) { Log.i(TAG, "<onItemSelected> abort editing photo when no enough space!"); Toast.makeText(mActivity, mActivity.getString(R.string.storage_not_enough), Toast.LENGTH_SHORT) .show(); return true; } /// @} launchPhotoEditor(); return true; } /// M: [FEATURE.ADD] @{ case R.id.m_action_picture_quality: { Activity activity = (Activity) mActivity; Intent intent = new Intent(PictureQualityActivity.ACTION_PQ); intent.setClass(activity, PictureQualityActivity.class); intent.setData(manager.getContentUri(path)); Bundle pqBundle = new Bundle(); pqBundle.putString("PQUri", manager.getContentUri(path).toString()); pqBundle.putString("PQMineType", current.getMimeType()); pqBundle.putInt("PQViewWidth", mPhotoView.getWidth()); pqBundle.putInt("PQViewHeight", mPhotoView.getHeight()); intent.putExtras(pqBundle); Log.i(TAG, "<onItemSelected>startActivity PQ"); activity.startActivityForResult(intent, REQUEST_PQ); return true; } case R.id.m_action_image_dc: { ImageDC.resetStatus((Context) mActivity); ImageDC.setMenuItemTile(item); path.clearObject(); mActivity.getDataManager().forceRefreshAll(); Log.d(TAG, "< onStateResult > forceRefreshAll~~"); return true; } /// @} case R.id.action_simple_edit: { launchSimpleEditor(); return true; } case R.id.action_details: { if (mShowDetails) { hideDetails(); } else { showDetails(); } return true; } case R.id.print: { mActivity.printSelectedImage(manager.getContentUri(path)); return true; } case R.id.action_delete: confirmMsg = mActivity.getResources().getQuantityString(R.plurals.delete_selection, 1); case R.id.action_setas: case R.id.action_rotate_ccw: case R.id.action_rotate_cw: case R.id.action_show_on_map: mSelectionManager.deSelectAll(); mSelectionManager.toggle(path); mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener); return true; /// M: [FEATURE.ADD] DRM & HotKnot @{ case R.id.m_action_protect_info: Log.d(TAG, "<onItemSelected> ProtectionInfo: do action_protection_info"); DrmHelper.showProtectionInfoDialog((Activity) mActivity, manager.getContentUri(path)); return true; case R.id.action_hotknot: Log.d(TAG, "<onItemSelected> HotKnot: do action_hotknot"); // for continuous shot, may share a group image, so getContentUris() Uri[] uris = null; ExtItem extItem = mCurrentPhoto.getExtItem(); if (extItem != null) { uris = extItem.getContentUris(); } if (uris != null) { mActivity.getHotKnot().sendZip(uris); } else { extHotKnot(); } return true; /// @} /// M: [FEATURE.ADD] entry to export as video @{ case R.id.action_export: mAnimatedContentSharer.exportCurrentPhoto(); return true; /// @} /// M: [FEATURE.ADD] Support BlueTooth print feature.@{ case R.id.action_print: mSelectionManager.deSelectAll(); mSelectionManager.toggle(path); mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener); return true; /// @} default: /// M: [FEATURE.ADD] menu extension @{ // return false; return mPhotoView.onOptionsItemSelected(item); /// @} } }
From source file:com.android.mail.ui.AbstractActivityController.java
/** * Sets the current folder if it is different from the object provided here. This method does * NOT notify the folder observers that a change has happened. Observers are notified when we * get an updated folder from the loaders, which will happen as a consequence of this method * (since this method starts/restarts the loaders). * @param folder The folder to assign//from ww w .j a va 2s . co m */ private void updateFolder(Folder folder) { if (folder == null || !folder.isInitialized()) { LogUtils.e(LOG_TAG, new Error(), "AAC.setFolder(%s): Bad input", folder); return; } if (folder.equals(mFolder)) { LogUtils.d(LOG_TAG, "AAC.setFolder(%s): Input matches mFolder", folder); return; } final boolean wasNull = mFolder == null; LogUtils.d(LOG_TAG, "AbstractActivityController.setFolder(%s)", folder.name); final LoaderManager lm = mActivity.getLoaderManager(); // updateFolder is called from AAC.onLoadFinished() on folder changes. We need to // ensure that the folder is different from the previous folder before marking the // folder changed. setHasFolderChanged(folder); mFolder = folder; // We do not need to notify folder observers yet. Instead we start the loaders and // when the load finishes, we will get an updated folder. Then, we notify the // folderObservers in onLoadFinished. mActionBarController.setFolder(mFolder); // Only when we switch from one folder to another do we want to restart the // folder and conversation list loaders (to trigger onCreateLoader). // The first time this runs when the activity is [re-]initialized, we want to re-use the // previous loader's instance and data upon configuration change (e.g. rotation). // If there was not already an instance of the loader, init it. if (lm.getLoader(LOADER_FOLDER_CURSOR) == null) { lm.initLoader(LOADER_FOLDER_CURSOR, Bundle.EMPTY, mFolderCallbacks); } else { lm.restartLoader(LOADER_FOLDER_CURSOR, Bundle.EMPTY, mFolderCallbacks); } if (!wasNull && lm.getLoader(LOADER_CONVERSATION_LIST) != null) { // If there was an existing folder AND we have changed // folders, we want to restart the loader to get the information // for the newly selected folder lm.destroyLoader(LOADER_CONVERSATION_LIST); } final Bundle args = new Bundle(2); args.putParcelable(BUNDLE_ACCOUNT_KEY, mAccount); args.putParcelable(BUNDLE_FOLDER_KEY, mFolder); args.putBoolean(BUNDLE_IGNORE_INITIAL_CONVERSATION_LIMIT_KEY, mIgnoreInitialConversationLimit); mIgnoreInitialConversationLimit = false; lm.initLoader(LOADER_CONVERSATION_LIST, args, mListCursorCallbacks); }
From source file:com.android.launcher2.Launcher.java
@Override protected void onSaveInstanceState(Bundle outState) { outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getNextPage()); super.onSaveInstanceState(outState); outState.putInt(RUNTIME_STATE, mState.ordinal()); // We close any open folder since it will not be re-opened, and we need to make sure // this state is reflected. closeFolder();/* ww w . j a v a 2s. co m*/ if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screen > -1 && mWaitingForResult) { outState.putLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, mPendingAddInfo.container); outState.putInt(RUNTIME_STATE_PENDING_ADD_SCREEN, mPendingAddInfo.screen); outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_X, mPendingAddInfo.cellX); outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_Y, mPendingAddInfo.cellY); outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_X, mPendingAddInfo.spanX); outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y, mPendingAddInfo.spanY); outState.putParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO, mPendingAddWidgetInfo); } if (mFolderInfo != null && mWaitingForResult) { outState.putBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, true); outState.putLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID, mFolderInfo.id); } // Save the current AppsCustomize tab if (mAppsCustomizeTabHost != null) { String currentTabTag = mAppsCustomizeTabHost.getCurrentTabTag(); if (currentTabTag != null) { outState.putString("apps_customize_currentTab", currentTabTag); } int currentIndex = mAppsCustomizeContent.getSaveInstanceStateIndex(); outState.putInt("apps_customize_currentIndex", currentIndex); } }
From source file:com.irccloud.android.activity.MainActivity.java
@Override public void onMessageViewReady() { if (shouldFadeIn) { Crashlytics.log(Log.DEBUG, "IRCCloud", "Fade In"); MessageViewFragment mvf = (MessageViewFragment) getSupportFragmentManager() .findFragmentById(R.id.messageViewFragment); UsersListFragment ulf = (UsersListFragment) getSupportFragmentManager() .findFragmentById(R.id.usersListFragment); if (Build.VERSION.SDK_INT < 16) { AlphaAnimation anim = new AlphaAnimation(0, 1); anim.setDuration(150);// w w w .j av a 2 s . co m anim.setFillAfter(true); if (mvf != null && mvf.getListView() != null) mvf.getListView().startAnimation(anim); if (ulf != null && ulf.getListView() != null) ulf.getListView().startAnimation(anim); } else { if (mvf != null && mvf.getListView() != null) mvf.getListView().animate().alpha(1); if (ulf != null && ulf.getListView() != null) ulf.getListView().animate().alpha(1); } if (mvf != null && mvf.getListView() != null) { if (mvf.buffer != buffer && buffer != null && BuffersDataSource.getInstance().getBuffer(buffer.bid) != null) { Bundle b = new Bundle(); b.putInt("cid", buffer.cid); b.putInt("bid", buffer.bid); b.putBoolean("fade", false); mvf.setArguments(b); } mvf.showSpinner(false); } shouldFadeIn = false; } }