Java Code Examples for android.os.bundle#getCharSequence()
The following examples show how to use
android.os.bundle#getCharSequence() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlertPopup.java From arcusandroid with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle arguments = getArguments(); if (arguments != null) { mTitle = arguments.getString(TITLE_KEY, ""); mDescription = arguments.getCharSequence(DESC_KEY, ""); mTopButtonText = arguments.getString(TOP_TEXT_KEY, ""); mBottomButtonText = arguments.getString(BOTTOM_TEXT_KEY, ""); mErrorText = arguments.getString(ERROR_TEXT_KEY, ""); mStyle = (ColorStyle) arguments.getSerializable(STYLE_KEY); mTopButtonColor = (Version1ButtonColor) arguments.getSerializable(TOP_BUTTON_COLOR_KEY); if (mStyle == null) mStyle = ColorStyle.PINK; } }
Example 2
Source File: Notification.java From an2linuxclient with GNU General Public License v3.0 | 6 votes |
@RequiresApi(Build.VERSION_CODES.KITKAT) private void extractMessage(StatusBarNotification sbn) { Bundle extras = sbn.getNotification().extras; String contentText = ""; String subText = ""; CharSequence temp = extras.getCharSequence(android.app.Notification.EXTRA_TEXT); if (temp != null){ contentText = temp.toString(); } temp = extras.getCharSequence(android.app.Notification.EXTRA_SUB_TEXT); if (temp != null){ subText = temp.toString(); } message = ""; if (!contentText.equals("")) message += contentText; if (!subText.equals("")) message += "\n" + subText; message = message.replace("\n\n", "\n").trim(); if (message.length() > ns.getMessageMax()){ message = message.substring(0, ns.getMessageMax()) + "…"; } }
Example 3
Source File: WearReplyReceiver.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { ApplicationLoader.postInitApplication(); Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput == null) { return; } CharSequence text = remoteInput.getCharSequence(NotificationsController.EXTRA_VOICE_REPLY); if (text == null || text.length() == 0) { return; } long dialog_id = intent.getLongExtra("dialog_id", 0); int max_id = intent.getIntExtra("max_id", 0); int currentAccount = intent.getIntExtra("currentAccount", 0); if (dialog_id == 0 || max_id == 0) { return; } SendMessagesHelper.getInstance(currentAccount).sendMessage(text.toString(), dialog_id, null, null, true, null, null, null); MessagesController.getInstance(currentAccount).markDialogAsRead(dialog_id, max_id, max_id, 0, false, 0, true); }
Example 4
Source File: SubscribeDecoratorService.java From nevo-decorators-sms-captchas with GNU General Public License v3.0 | 6 votes |
@Override protected void apply(MutableStatusBarNotification evolving) { MutableNotification notification = evolving.getNotification(); Bundle extras = notification.extras; CharSequence message = extras.getCharSequence(Notification.EXTRA_TEXT); if (message == null || extras.getBoolean(Global.NOTIFICATION_EXTRA_APPLIED, false) || !message.toString().matches(mSettings.getSubscribeIdentifyPattern())) return; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) notification.setChannelId(NOTIFICATION_CHANNEL_SUBSCRIBE_DEFAULT); else notification.priority = mSettings.getSubscribePriority(); appendActions(notification ,evolving.getKey() ,new Notification.Action[0]); extras.putBoolean(Global.NOTIFICATION_EXTRA_APPLIED, true); Log.i(TAG, "Applied " + evolving.getKey()); }
Example 5
Source File: MessageReplyReceiver.java From MycroftCore-Android with Apache License 2.0 | 5 votes |
/** * Get the message text from the intent. * Note that you should call {@code RemoteInput#getResultsFromIntent(intent)} to process * the RemoteInput. */ private CharSequence getMessageText(Intent intent) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput != null) { return remoteInput.getCharSequence(MycroftMessagingService.EXTRA_VOICE_REPLY); } return null; }
Example 6
Source File: ResetEditPreferenceDialogFragCompat.java From XposedSmsCode with GNU General Public License v3.0 | 5 votes |
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { this.mText = this.getResetEditPreference().getText(); } else { this.mText = savedInstanceState.getCharSequence(SAVE_STATE_TEXT); } }
Example 7
Source File: DialerActivity.java From emerald-dialer with GNU General Public License v3.0 | 5 votes |
@Override protected void onRestoreInstanceState(Bundle bundle) { CharSequence savedNumber = bundle.getCharSequence(BUNDLE_KEY_NUMBER); if (savedNumber != null || !TextUtils.isEmpty(savedNumber)) { numberField.setText(savedNumber.toString()); numberField.setCursorVisible(true); numberField.setSelection(savedNumber.length()); } super.onSaveInstanceState(bundle); }
Example 8
Source File: ColorSelectDialog.java From SelectionDialogs with Apache License 2.0 | 5 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args != null && args.containsKey(ARG_TITLE)) { mTitle = args.getCharSequence(ARG_TITLE); } else { mTitle = getString(R.string.selectiondialogs_color_dialog_title); } if (args != null && args.containsKey(ARG_ITEMS)) { mSelectionDialogsItems = args.getParcelableArrayList(ARG_ITEMS); } else { Log.w(LOG_TAG, "No items provided! Creating default"); mSelectionDialogsItems = new ArrayList<>(); mSelectionDialogsItems.add(createDefaultItem()); } if (args != null && args.containsKey(ARG_SORT_BY_NAME)) { mSortByName = args.getBoolean(ARG_SORT_BY_NAME); if (mSortByName) { Collections.sort(mSelectionDialogsItems, new SelectableItemNameComparator<SelectableColor>()); } } else { mSortByName = false; } }
Example 9
Source File: BigPictureSocialIntentService.java From android-Notifications with Apache License 2.0 | 5 votes |
private CharSequence getMessage(Intent intent) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput != null) { return remoteInput.getCharSequence(EXTRA_COMMENT); } return null; }
Example 10
Source File: MainActivity.java From TextThing with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); final TextView textBox = (TextView) findViewById(R.id.editText); CharSequence userText = savedInstanceState.getCharSequence("savedText"); textBox.setText(userText); }
Example 11
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 5 votes |
@Override protected void onResume() { super.onResume(); if (getIntent() != null) { Bundle inputResults = RemoteInput.getResultsFromIntent(getIntent()); if (inputResults != null) { CharSequence replyText = inputResults.getCharSequence(KEY_REPLY); if (replyText != null) { Toast.makeText(this, TextUtils.concat(getString(R.string.reply_was), replyText), Toast.LENGTH_LONG).show(); } } } }
Example 12
Source File: ReplyBroadcastReceiver.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); CharSequence message = remoteInput != null ? remoteInput.getCharSequence(KEY_TEXT_REPLY) : null; // TODO Handle the reply sent from the notification. }
Example 13
Source File: NotificationPlatformBridge.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Nullable private static String getNotificationReply(Intent intent) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { // RemoteInput was added in KITKAT_WATCH. Bundle remoteInputResults = RemoteInput.getResultsFromIntent(intent); if (remoteInputResults != null) { CharSequence reply = remoteInputResults.getCharSequence(NotificationConstants.KEY_TEXT_REPLY); if (reply != null) { return reply.toString(); } } } return null; }
Example 14
Source File: MessagingIntentService.java From user-interface-samples with Apache License 2.0 | 5 votes |
private CharSequence getMessage(Intent intent) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput != null) { return remoteInput.getCharSequence(EXTRA_REPLY); } return null; }
Example 15
Source File: NotificationHelper.java From NotificationPeekPort with Apache License 2.0 | 5 votes |
/** * Get text from notification with specific field. * * @param n StatusBarNotification object. * @param field StatusBarNotification extra field. * @return Notification text. */ public static String getNotificationText(StatusBarNotification n, String field) { String text = null; if (n != null) { Notification notification = n.getNotification(); Bundle extras = notification.extras; CharSequence chars = extras.getCharSequence(field); text = chars != null ? chars.toString() : null; } return text; }
Example 16
Source File: KeyboardInputController.java From wearmouse with Apache License 2.0 | 5 votes |
/** * Should be called in the Activity's (or Fragment's) onActivityResult() method that was invoked * in response to the Intent returned by {@code getInputIntent}. */ public void onActivityResult(Intent data) { final Bundle result = RemoteInput.getResultsFromIntent(data); if (result != null) { CharSequence text = result.getCharSequence(Intent.EXTRA_TEXT); if (text != null) { for (int i = 0, n = text.length(); i < n; ++i) { keyboardHelper.sendChar(text.charAt(i)); } } } }
Example 17
Source File: SettingsActivity.java From HgLauncher with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { if (!PreferenceHelper.hasEditor()) { PreferenceHelper.initPreference(this); } PreferenceHelper.fetchPreference(); if (PreferenceHelper.getProviderList().isEmpty()) { Utils.setDefaultProviders(getResources()); } // Check the caller of this activity. // If it's coming from the launcher itself, it will always have a calling activity. checkCaller(); // Load the appropriate theme. switch (PreferenceHelper.appTheme()) { default: case "auto": if (Utils.atLeastQ()) { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); } else { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY); } break; case "light": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); break; case "dark": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.AppTheme_Dark); break; case "black": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); break; } super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); if (getRequestedOrientation() != PreferenceHelper.getOrientation()) { setRequestedOrientation(PreferenceHelper.getOrientation()); } if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } if (savedInstanceState == null) { ViewUtils.setFragment(getSupportFragmentManager(), new BasePreference(), "settings"); } else { fragmentTitle = savedInstanceState.getCharSequence("title"); if (getSupportActionBar() != null) { getSupportActionBar().setTitle(fragmentTitle); } } }
Example 18
Source File: TabSwitcherModel.java From ChromeLikeTabSwitcher with Apache License 2.0 | 4 votes |
@Override public final void restoreInstanceState(@Nullable final Bundle savedInstanceState) { if (savedInstanceState != null) { referenceTabIndex = savedInstanceState.getInt(REFERENCE_TAB_INDEX_EXTRA, -1); referenceTabPosition = savedInstanceState.getFloat(REFERENCE_TAB_POSITION_EXTRA, -1); logLevel = (LogLevel) savedInstanceState.getSerializable(LOG_LEVEL_EXTRA); tabs = savedInstanceState.getParcelableArrayList(TABS_EXTRA); switcherShown = savedInstanceState.getBoolean(SWITCHER_SHOWN_EXTRA); int selectedTabIndex = savedInstanceState.getInt(SELECTED_TAB_INDEX_EXTRA); selectedTab = selectedTabIndex != -1 ? tabs.get(selectedTabIndex) : null; padding = savedInstanceState.getIntArray(PADDING_EXTRA); applyPaddingToTabs = savedInstanceState.getBoolean(APPLY_PADDING_TO_TABS_EXTRA); tabIconId = savedInstanceState.getInt(TAB_ICON_ID_EXTRA); tabIconBitmap = savedInstanceState.getParcelable(TAB_ICON_BITMAP_EXTRA); tabIconTintList = savedInstanceState.getParcelable(TAB_ICON_TINT_LIST_EXTRA); tabIconTintMode = (PorterDuff.Mode) savedInstanceState.getSerializable(TAB_ICON_TINT_MODE_EXTRA); tabBackgroundColor = savedInstanceState.getParcelable(TAB_BACKGROUND_COLOR_EXTRA); tabContentBackgroundColor = savedInstanceState.getInt(TAB_CONTENT_BACKGROUND_COLOR_EXTRA); tabTitleTextColor = savedInstanceState.getParcelable(TAB_TITLE_TEXT_COLOR_EXTRA); tabCloseButtonIconId = savedInstanceState.getInt(TAB_CLOSE_BUTTON_ICON_ID_EXTRA); tabCloseButtonIconBitmap = savedInstanceState.getParcelable(TAB_CLOSE_BUTTON_ICON_BITMAP_EXTRA); tabCloseButtonIconTintList = savedInstanceState.getParcelable(TAB_CLOSE_BUTTON_ICON_TINT_LIST_EXTRA); tabCloseButtonIconTintMode = (PorterDuff.Mode) savedInstanceState .getSerializable(TAB_CLOSE_BUTTON_ICON_TINT_MODE_EXTRA); tabProgressBarColor = savedInstanceState.getInt(TAB_PROGRESS_BAR_COLOR_EXTRA, -1); showToolbars = savedInstanceState.getBoolean(SHOW_TOOLBARS_EXTRA); toolbarTitle = savedInstanceState.getCharSequence(TOOLBAR_TITLE_EXTRA); toolbarNavigationIconTintList = savedInstanceState.getParcelable(TOOLBAR_NAVIGATION_ICON_TINT_LIST_EXTRA); toolbarNavigationIconTintMode = (PorterDuff.Mode) savedInstanceState .getSerializable(TOOLBAR_NAVIGATION_ICON_TINT_MODE_EXTRA); tabPreviewFadeThreshold = savedInstanceState.getLong(TAB_PREVIEW_FADE_THRESHOLD_EXTRA); tabPreviewFadeDuration = savedInstanceState.getLong(TAB_PREVIEW_FADE_DURATION); clearSavedStatesWhenRemovingTabs = savedInstanceState.getBoolean(CLEAR_SAVED_STATES_WHEN_REMOVING_TABS_EXTRA); getContentRecyclerAdapter().restoreInstanceState(savedInstanceState); } }
Example 19
Source File: AlertController.java From HaoReader with GNU General Public License v3.0 | 4 votes |
AlertParams(@NonNull Context context, @NonNull Bundle bundle) { mTheme = bundle.getInt(ARG_THEME); mTitleText = bundle.getCharSequence(ARG_TITLE_TEXT); if (mTitleText == null) { int titleResId = bundle.getInt(ARG_TITLE_TEXT_ID, 0); if (titleResId != 0) { mTitleText = context.getText(titleResId); } } mMessageText = bundle.getCharSequence(ARG_MESSAGE_TEXT); if (mMessageText == null) { int messageResId = bundle.getInt(ARG_MESSAGE_TEXT_ID, 0); if (messageResId != 0) { mMessageText = context.getText(messageResId); } } mMessageTextAlignment = bundle.getInt(ARG_MESSAGE_TEXT_ALIGNMENT, View.TEXT_ALIGNMENT_TEXT_START); mPositiveText = bundle.getCharSequence(ARG_POSITIVE_TEXT); if (mPositiveText == null) { int positiveResId = bundle.getInt(ARG_POSITIVE_TEXT_ID, 0); if (positiveResId != 0) { mPositiveText = context.getText(positiveResId); } } mNegativeText = bundle.getCharSequence(ARG_NEGATIVE_TEXT); if (mNegativeText == null) { int negativeResId = bundle.getInt(ARG_NEGATIVE_TEXT_ID, 0); if (negativeResId != 0) { mNegativeText = context.getText(negativeResId); } } mViewLayoutResId = bundle.getInt(ARG_VIEW_LAYOUT_ID, 0); int viewWidth = bundle.getInt(ARG_VIEW_LAYOUT_WIDTH, 0); int viewHeight = bundle.getInt(ARG_VIEW_LAYOUT_HEIGHT, 0); if (viewWidth != 0 && viewHeight != 0) { mViewParams = new FrameLayout.LayoutParams(viewWidth, viewHeight); int gravity = bundle.getInt(ARG_VIEW_LAYOUT_GRAVITY, 0); if (gravity != 0) { mViewParams.gravity = gravity; } } }
Example 20
Source File: WizardDialogDecorator.java From AndroidMaterialDialog with Apache License 2.0 | 4 votes |
@Override public final void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) { setTabPosition(TabPosition.fromValue(savedInstanceState.getInt(TAB_POSITION_EXTRA))); enableTabLayout(savedInstanceState.getBoolean(TAB_LAYOUT_ENABLED_EXTRA)); showTabLayout(savedInstanceState.getBoolean(TAB_LAYOUT_SHOWN_EXTRA)); setTabIndicatorHeight(savedInstanceState.getInt(TAB_INDICATOR_HEIGHT_EXTRA)); setTabIndicatorColor(savedInstanceState.getInt(TAB_INDICATOR_COLOR_EXTRA)); setTabTextColor(savedInstanceState.getInt(TAB_TEXT_COLOR_EXTRA)); setTabSelectedTextColor(savedInstanceState.getInt(TAB_SELECTED_TEXT_COLOR_EXTRA)); enableSwipe(savedInstanceState.getBoolean(SWIPE_ENABLED_EXTRA)); showButtonBar(savedInstanceState.getBoolean(BUTTON_BAR_SHOWN_EXTRA)); setButtonTextColor(savedInstanceState.getInt(BUTTON_TEXT_COLOR_EXTRA)); showButtonBarDivider(savedInstanceState.getBoolean(SHOW_BUTTON_BAR_DIVIDER_EXTRA)); setButtonBarDividerColor(savedInstanceState.getInt(BUTTON_BAR_DIVIDER_COLOR_EXTRA)); setButtonBarDividerMargin(savedInstanceState.getInt(BUTTON_BAR_DIVIDER_MARGIN_EXTRA)); CharSequence backButtonText = savedInstanceState.getCharSequence(BACK_BUTTON_TEXT_EXTRA); CharSequence nextButtonText = savedInstanceState.getCharSequence(NEXT_BUTTON_TEXT_EXTRA); CharSequence finishButtonText = savedInstanceState.getCharSequence(FINISH_BUTTON_TEXT_EXTRA); if (!TextUtils.isEmpty(backButtonText)) { setBackButtonText(backButtonText); } if (!TextUtils.isEmpty(nextButtonText)) { setNextButtonText(nextButtonText); } if (!TextUtils.isEmpty(finishButtonText)) { setFinishButtonText(finishButtonText); } ArrayList<ViewPagerItem> viewPagerItems = savedInstanceState.getParcelableArrayList(VIEW_PAGER_ITEMS_EXTRA); if (viewPagerItems != null) { for (ViewPagerItem item : viewPagerItems) { addFragment(item.getTitle(), item.getFragmentClass(), item.getArguments()); } } }