Java Code Examples for android.os.Bundle#getCharSequenceArray()

The following examples show how to use android.os.Bundle#getCharSequenceArray() . These examples are extracted from open source projects. 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
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
        final MultiSelectListPreference preference = getListPreference();

        if (preference.getEntries() == null || preference.getEntryValues() == null) {
            throw new IllegalStateException(
                    "MultiSelectListPreference requires an entries array and " +
                            "an entryValues array.");
        }

        mNewValues.clear();
        mNewValues.addAll(preference.getValues());
        mPreferenceChanged = false;
        mEntries = preference.getEntries();
        mEntryValues = preference.getEntryValues();
    } else {
        mNewValues.clear();
        mNewValues.addAll(savedInstanceState.getStringArrayList(SAVE_STATE_VALUES));
        mPreferenceChanged = savedInstanceState.getBoolean(SAVE_STATE_CHANGED, false);
        mEntries = savedInstanceState.getCharSequenceArray(SAVE_STATE_ENTRIES);
        mEntryValues = savedInstanceState.getCharSequenceArray(SAVE_STATE_ENTRY_VALUES);
    }
}
 
Example 2
@TargetApi(value = Build.VERSION_CODES.JELLY_BEAN)
private boolean parseInboxNotification(Bundle extras)
{
    CharSequence summaryTextSequence = extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT);
    CharSequence subTextSequence = extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT);
    CharSequence titleSequence = extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT);

    if (summaryTextSequence != null)
        summary = summaryTextSequence.toString();
    else if (subTextSequence != null)
        summary = subTextSequence.toString();
    else if (titleSequence != null)
        summary = titleSequence.toString();
    else
        return false;

    CharSequence[] lines = extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);

    StringBuilder sb = new StringBuilder();
    sb.append(body);
    if(lines != null) {
        for (CharSequence line : lines) {
            sb.append(formatCharSequence(line));
            sb.append("\n\n");
        }
    }

    body = sb.toString().trim();

    return true;
}
 
Example 3
@TargetApi(Build.VERSION_CODES.FROYO)
private void setItems(Bundle args, final SimpleAlertDialog dialog, final int requestCode) {
    if (!hasItemClickListener()) {
        return;
    }
    CharSequence[] items;
    if (has(args, SimpleAlertDialog.ARG_ITEMS) && Build.VERSION_CODES.ECLAIR <= Build.VERSION.SDK_INT) {
        items = args.getCharSequenceArray(SimpleAlertDialog.ARG_ITEMS);
    } else if (has(args, SimpleAlertDialog.ARG_ITEMS_RES_ID)) {
        items = getActivity().getResources().getTextArray(args.getInt(SimpleAlertDialog.ARG_ITEMS_RES_ID));
    } else {
        return;
    }
    int[] icons = null;
    if (has(args, SimpleAlertDialog.ARG_ICONS)) {
        icons = args.getIntArray(SimpleAlertDialog.ARG_ICONS);
    }
    if (fragmentImplements(SimpleAlertDialog.OnItemClickListener.class)
            || activityImplements(SimpleAlertDialog.OnItemClickListener.class)) {
        AdapterView.OnItemClickListener listener = new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (fragmentImplements(SimpleAlertDialog.OnItemClickListener.class)) {
                    ((SimpleAlertDialog.OnItemClickListener) getTargetFragment())
                            .onItemClick(dialog, requestCode, position);
                }
                if (activityImplements(SimpleAlertDialog.OnItemClickListener.class)) {
                    ((SimpleAlertDialog.OnItemClickListener) getActivity())
                            .onItemClick(dialog, requestCode, position);
                }
            }
        };
        if (icons == null) {
            dialog.setItems(items, listener);
        } else {
            dialog.setItems(items, icons, listener);
        }
    }
}
 
Example 4
/**
 * Loads all possible texts from given {@link Notification#extras extras}.
 *
 * @param extras extras to load from
 */
@SuppressLint("InlinedApi")
private void loadFromExtras(@NonNull OpenNotification n, @NonNull Bundle extras) {
    n.titleBigText = extras.getCharSequence(Notification.EXTRA_TITLE_BIG);
    n.titleText = extras.getCharSequence(Notification.EXTRA_TITLE);
    n.infoText = extras.getCharSequence(Notification.EXTRA_INFO_TEXT);
    n.subText = extras.getCharSequence(Notification.EXTRA_SUB_TEXT);
    n.summaryText = extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT);
    n.messageBigText = removeColorSpans(extras.getCharSequence(Notification.EXTRA_BIG_TEXT));
    n.messageText = removeColorSpans(extras.getCharSequence(Notification.EXTRA_TEXT));

    CharSequence[] lines = extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
    n.messageTextLines = doIt(lines);
}
 
Example 5
Source Project: HeadsUp   File: Extractor.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Loads all possible texts from given {@link Notification#extras extras}.
 *
 * @param extras extras to load from
 */
@SuppressLint("InlinedApi")
private void loadFromExtras(@NonNull OpenNotification n, @NonNull Bundle extras) {
    n.titleBigText = extras.getCharSequence(Notification.EXTRA_TITLE_BIG);
    n.titleText = extras.getCharSequence(Notification.EXTRA_TITLE);
    n.infoText = extras.getCharSequence(Notification.EXTRA_INFO_TEXT);
    n.subText = extras.getCharSequence(Notification.EXTRA_SUB_TEXT);
    n.summaryText = extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT);
    n.messageBigText = extras.getCharSequence(Notification.EXTRA_BIG_TEXT);
    n.messageText = extras.getCharSequence(Notification.EXTRA_TEXT);

    CharSequence[] lines = extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
    n.messageTextLines = doIt(lines);
}
 
Example 6
private void extract()  {
	// General
	when           = n.when;
	flags          = n.flags;
	defaults       = n.defaults;
	ledARGB        = n.ledARGB;
	ledOff         = n.ledOffMS;
	ledOn          = n.ledOnMS;

	if(Build.VERSION.SDK_INT < 24) { // as of 24, this number is not shown anymore
		number = n.number;
	} else {
		number = -1;
	}

	// Device
	ringerMode     = Util.getRingerMode(context);
	isScreenOn     = Util.isScreenOn(context);
	batteryLevel   = Util.getBatteryLevel(context);
	batteryStatus  = Util.getBatteryStatus(context);
	isConnected    = Util.isNetworkAvailable(context);
	connectionType = Util.getConnectivityType(context);

	// 16
	priority = n.priority;

	// 21
	if(Build.VERSION.SDK_INT >= 21) {
		visibility = n.visibility;
		color      = n.color;

		listenerHints = NotificationListener.getListenerHints();
		interruptionFilter = NotificationListener.getInterruptionFilter();
		NotificationListenerService.Ranking ranking = new NotificationListenerService.Ranking();
		NotificationListenerService.RankingMap rankingMap = NotificationListener.getRanking();
		if(rankingMap != null && rankingMap.getRanking(key, ranking)) {
			matchesInterruptionFilter = ranking.matchesInterruptionFilter();
		}
	}

	// Compat
	group          = NotificationCompat.getGroup(n);
	isGroupSummary = NotificationCompat.isGroupSummary(n);
	category       = NotificationCompat.getCategory(n);
	actionCount    = NotificationCompat.getActionCount(n);
	isLocalOnly    = NotificationCompat.getLocalOnly(n);

	Bundle extras = NotificationCompat.getExtras(n);
	if(extras != null) {
		String[] tmp = extras.getStringArray(NotificationCompat.EXTRA_PEOPLE);
		people = tmp != null ? Arrays.asList(tmp) : null;
		style  = extras.getString(NotificationCompat.EXTRA_TEMPLATE);
	}

	// Text
	if(LOG_TEXT) {
		appName    = Util.getAppNameFromPackage(context, packageName, false);
		tickerText = Util.nullToEmptyString(n.tickerText);

		if(extras != null) {
			title       = Util.nullToEmptyString(extras.getCharSequence(NotificationCompat.EXTRA_TITLE));
			titleBig    = Util.nullToEmptyString(extras.getCharSequence(NotificationCompat.EXTRA_TITLE_BIG));
			text        = Util.nullToEmptyString(extras.getCharSequence(NotificationCompat.EXTRA_TEXT));
			textBig     = Util.nullToEmptyString(extras.getCharSequence(NotificationCompat.EXTRA_BIG_TEXT));
			textInfo    = Util.nullToEmptyString(extras.getCharSequence(NotificationCompat.EXTRA_INFO_TEXT));
			textSub     = Util.nullToEmptyString(extras.getCharSequence(NotificationCompat.EXTRA_SUB_TEXT));
			textSummary = Util.nullToEmptyString(extras.getCharSequence(NotificationCompat.EXTRA_SUMMARY_TEXT));

			CharSequence[] lines = extras.getCharSequenceArray(NotificationCompat.EXTRA_TEXT_LINES);
			if(lines != null) {
				textLines = "";
				for(CharSequence line : lines) {
					textLines += line + "\n";
				}
				textLines = textLines.trim();
			}
		}
	}
}
 
Example 7
public CharSequence[] getCharSequenceArray(Bundle state, String key) {
    return state.getCharSequenceArray(key + mBaseKey);
}
 
Example 8
@TargetApi(value = Build.VERSION_CODES.JELLY_BEAN)
private boolean tryParseNatively(Notification notification)
{
    Bundle extras = notification.extras;
    if (extras == null)
        return false;

    if (parseMessageStyleNotification(notification, extras))
        return true;

    CharSequence[] textLinesSequence = extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
    if (textLinesSequence != null && textLinesSequence.length > 0)
    {
        if (parseInboxNotification(extras))
            return true;
    }

    if (extras.get(Notification.EXTRA_TEXT) == null && extras.get(Notification.EXTRA_TEXT_LINES) == null && extras.get(Notification.EXTRA_BIG_TEXT) == null)
        return false;

    CharSequence bigTitle = extras.getCharSequence(Notification.EXTRA_TITLE_BIG);
    CharSequence title = extras.getCharSequence(Notification.EXTRA_TITLE);

    if (bigTitle != null && (bigTitle.length() < 40 || extras.get(Notification.EXTRA_TITLE) == null))
        summary = bigTitle.toString();
    else if (title != null)
        summary = title.toString();

    if (extras.get(Notification.EXTRA_TEXT_LINES) != null)
    {
        CharSequence[] lines = extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);

        StringBuilder sb = new StringBuilder();
        sb.append(body);
        if(lines != null) {
            for (CharSequence line : lines) {
                sb.append(formatCharSequence(line));
                sb.append("\n\n");
            }
        }

        body = sb.toString().trim();
    }
    else if (extras.get(Notification.EXTRA_BIG_TEXT) != null)
        body = formatCharSequence(extras.getCharSequence(Notification.EXTRA_BIG_TEXT));
    else
        body = formatCharSequence(extras.getCharSequence(Notification.EXTRA_TEXT));

    return true;
}