List of usage examples for android.os Bundle putParcelable
public void putParcelable(@Nullable String key, @Nullable Parcelable value)
From source file:com.android.settings.accessibility.AccessibilitySettings.java
private void updateServicePreferences() { // Since services category is auto generated we have to do a pass // to generate it since services can come and go and then based on // the global accessibility state to decided whether it is enabled. // Generate.//from w w w. j a va 2s. c o m ArrayList<Preference> servicePreferences = new ArrayList<>( mServicePreferenceToPreferenceCategoryMap.keySet()); for (int i = 0; i < servicePreferences.size(); i++) { Preference service = servicePreferences.get(i); PreferenceCategory category = mServicePreferenceToPreferenceCategoryMap.get(service); category.removePreference(service); } initializePreBundledServicesMapFromArray(CATEGORY_SCREEN_READER, R.array.config_preinstalled_screen_reader_services); initializePreBundledServicesMapFromArray(CATEGORY_AUDIO_AND_CAPTIONS, R.array.config_preinstalled_audio_and_caption_services); initializePreBundledServicesMapFromArray(CATEGORY_DISPLAY, R.array.config_preinstalled_display_services); initializePreBundledServicesMapFromArray(CATEGORY_INTERACTION_CONTROL, R.array.config_preinstalled_interaction_control_services); AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(getActivity()); List<AccessibilityServiceInfo> installedServices = accessibilityManager .getInstalledAccessibilityServiceList(); Set<ComponentName> enabledServices = AccessibilityUtils.getEnabledServicesFromSettings(getActivity()); List<String> permittedServices = mDpm.getPermittedAccessibilityServices(UserHandle.myUserId()); final boolean accessibilityEnabled = Settings.Secure.getInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1; PreferenceCategory downloadedServicesCategory = mCategoryToPrefCategoryMap .get(CATEGORY_DOWNLOADED_SERVICES); // Temporarily add the downloaded services category back if it was previously removed. if (findPreference(CATEGORY_DOWNLOADED_SERVICES) == null) { getPreferenceScreen().addPreference(downloadedServicesCategory); } for (int i = 0, count = installedServices.size(); i < count; ++i) { AccessibilityServiceInfo info = installedServices.get(i); RestrictedPreference preference = new RestrictedPreference(downloadedServicesCategory.getContext()); String title = info.getResolveInfo().loadLabel(getPackageManager()).toString(); Drawable icon; if (info.getResolveInfo().getIconResource() == 0) { icon = ContextCompat.getDrawable(getContext(), R.mipmap.ic_accessibility_generic); } else { icon = info.getResolveInfo().loadIcon(getPackageManager()); } ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo; String packageName = serviceInfo.packageName; ComponentName componentName = new ComponentName(packageName, serviceInfo.name); String componentNameKey = componentName.flattenToString(); preference.setKey(componentName.flattenToString()); preference.setTitle(title); preference.setIcon(icon); final boolean serviceEnabled = accessibilityEnabled && enabledServices.contains(componentName); final String serviceState = serviceEnabled ? getString(R.string.accessibility_summary_state_enabled) : getString(R.string.accessibility_summary_state_disabled); final CharSequence serviceSummary = info.loadSummary(getPackageManager()); final String stateSummaryCombo = getString(R.string.accessibility_summary_default_combination, serviceState, serviceSummary); preference.setSummary((TextUtils.isEmpty(serviceSummary)) ? serviceState : stateSummaryCombo); // Disable all accessibility services that are not permitted. boolean serviceAllowed = permittedServices == null || permittedServices.contains(packageName); if (!serviceAllowed && !serviceEnabled) { EnforcedAdmin admin = RestrictedLockUtils.checkIfAccessibilityServiceDisallowed(getActivity(), packageName, UserHandle.myUserId()); if (admin != null) { preference.setDisabledByAdmin(admin); } else { preference.setEnabled(false); } } else { preference.setEnabled(true); } preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName()); preference.setPersistent(true); Bundle extras = preference.getExtras(); extras.putString(EXTRA_PREFERENCE_KEY, preference.getKey()); extras.putBoolean(EXTRA_CHECKED, serviceEnabled); extras.putString(EXTRA_TITLE, title); String description = info.loadDescription(getPackageManager()); if (TextUtils.isEmpty(description)) { description = getString(R.string.accessibility_service_default_description); } extras.putString(EXTRA_SUMMARY, description); String settingsClassName = info.getSettingsActivityName(); if (!TextUtils.isEmpty(settingsClassName)) { extras.putString(EXTRA_SETTINGS_TITLE, getString(R.string.accessibility_menu_item_settings)); extras.putString(EXTRA_SETTINGS_COMPONENT_NAME, new ComponentName(packageName, settingsClassName).flattenToString()); } extras.putParcelable(EXTRA_COMPONENT_NAME, componentName); PreferenceCategory prefCategory = downloadedServicesCategory; // Set the appropriate category if the service comes pre-installed. if (mPreBundledServiceComponentToCategoryMap.containsKey(componentName)) { prefCategory = mPreBundledServiceComponentToCategoryMap.get(componentName); } preference.setOrder(FIRST_PREFERENCE_IN_CATEGORY_INDEX); prefCategory.addPreference(preference); mServicePreferenceToPreferenceCategoryMap.put(preference, prefCategory); } // If the user has not installed any additional services, hide the category. if (downloadedServicesCategory.getPreferenceCount() == 0) { PreferenceScreen screen = getPreferenceScreen(); screen.removePreference(downloadedServicesCategory); } }
From source file:com.android.settings.HWSettings.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // Save the current fragment, if it is the same as originally launched if (mCurrentHeader != null) { outState.putParcelable(SAVE_KEY_CURRENT_HEADER, mCurrentHeader); }/*ww w. j av a2 s.c o m*/ if (mParentHeader != null) { outState.putParcelable(SAVE_KEY_PARENT_HEADER, mParentHeader); } if (HW_SETTINGS) { //wangkaifeng tab settings if (curTabIndex != -1) { outState.putInt(SAVE_KEY_CURRENT_TAB, curTabIndex); } } }
From source file:com.android.settings.HWSettings.java
@Override public Intent getIntent() { Intent superIntent = super.getIntent(); String startingFragment = getStartingFragmentClass(superIntent); // This is called from super.onCreate, isMultiPane() is not yet reliable // Do not use onIsHidingHeaders either, which relies itself on this method if (startingFragment != null && !onIsMultiPane()) { Intent modIntent = new Intent(superIntent); modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment); Bundle args = superIntent.getExtras(); if (args != null) { args = new Bundle(args); } else {/*from w w w. j a va 2s . co m*/ args = new Bundle(); } args.putParcelable("intent", superIntent); modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, superIntent.getExtras()); return modIntent; } return superIntent; }
From source file:com.cerema.cloud2.ui.activity.FileDisplayActivity.java
/** * Stars the preview of a text file {@link OCFile}. * * @param file Text {@link OCFile} to preview. *//* w w w. j a v a 2s .c om*/ public void startTextPreview(OCFile file) { Bundle args = new Bundle(); args.putParcelable(EXTRA_FILE, file); args.putParcelable(EXTRA_ACCOUNT, getAccount()); Fragment textPreviewFragment = Fragment.instantiate(getApplicationContext(), PreviewTextFragment.class.getName(), args); setSecondFragment(textPreviewFragment); updateFragmentsVisibility(true); //updateNavigationElementsInActionBar(file); setFile(file); }
From source file:androidx.media.MediaController2.java
/** * Request that the player start playback for a specific {@link Uri}. * * @param uri The URI of the requested media. * @param extras Optional extras that can include extra information about the media item * to be played.//w ww . j a v a 2s . c om */ public void playFromUri(@NonNull Uri uri, @Nullable Bundle extras) { synchronized (mLock) { if (!mConnected) { Log.w(TAG, "Session isn't active", new IllegalStateException()); return; } Bundle args = new Bundle(); args.putParcelable(ARGUMENT_URI, uri); args.putBundle(ARGUMENT_EXTRAS, extras); sendCommand(COMMAND_CODE_SESSION_PLAY_FROM_URI, args); } }
From source file:androidx.media.MediaController2.java
/** * Request that the player prepare playback for a specific {@link Uri}. In other words, * other sessions can continue to play during the preparation of this session. This method * can be used to speed up the start of the playback. Once the preparation is done, the * session will change its playback state to {@link MediaPlayerBase#PLAYER_STATE_PAUSED}. * Afterwards, {@link #play} can be called to start playback. If the preparation is not needed, * {@link #playFromUri} can be directly called without this method. * * @param uri The URI of the requested media. * @param extras Optional extras that can include extra information about the media item * to be prepared./* www . j a v a2 s . com*/ */ public void prepareFromUri(@NonNull Uri uri, @Nullable Bundle extras) { synchronized (mLock) { if (!mConnected) { Log.w(TAG, "Session isn't active", new IllegalStateException()); return; } Bundle args = new Bundle(); args.putParcelable(ARGUMENT_URI, uri); args.putBundle(ARGUMENT_EXTRAS, extras); sendCommand(COMMAND_CODE_SESSION_PREPARE_FROM_URI, args); } }
From source file:com.android.mail.ui.FolderListFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mListView != null) { outState.putParcelable(BUNDLE_LIST_STATE, mListView.onSaveInstanceState()); }/* www . j av a 2 s.c o m*/ if (mSelectedFolderUri != null) { outState.putString(BUNDLE_SELECTED_FOLDER, mSelectedFolderUri.toString()); } outState.putInt(BUNDLE_SELECTED_ITEM_TYPE, mSelectedDrawerItemCategory); outState.putInt(BUNDLE_SELECTED_TYPE, mSelectedFolderType); outState.putBoolean(BUNDLE_INBOX_PRESENT, mInboxPresent); }
From source file:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterActivityContent.java
@Override public void onSaveInstanceState(Bundle outState) { int index = messageCenterListView.getFirstVisiblePosition(); View v = messageCenterListView.getChildAt(0); int top = (v == null) ? 0 : (v.getTop() - messageCenterListView.getPaddingTop()); outState.putInt(LIST_TOP_INDEX, index); outState.putInt(LIST_TOP_OFFSET, top); outState.putParcelable(COMPOSING_EDITTEXT_STATE, saveEditTextInstanceState()); outState.putParcelable(WHO_CARD_NAME, messageCenterListAdapter.getWhoCardNameState()); outState.putParcelable(WHO_CARD_EMAIL, messageCenterListAdapter.getWhoCardEmailState()); outState.putString(WHO_CARD_AVATAR_FILE, messageCenterListAdapter.getWhoCardAvatarFileName()); outState.putInt(WHO_CARD_MODE, pendingWhoCardMode); if (contextualMessage == null) { interaction.clearContextualMessage(); }/*from ww w. j a va2s .co m*/ super.onSaveInstanceState(outState); }
From source file:com.chuhan.privatecalc.fragment.os.FragmentState.java
void performSaveInstanceState(Bundle outState) { onSaveInstanceState(outState);/*from w w w . jav a 2s.c om*/ if (mChildFragmentManager != null) { Parcelable p = mChildFragmentManager.saveAllState(); if (p != null) { outState.putParcelable(FragmentActivity.FRAGMENTS_TAG, p); } } }