Search in sources :

Example 61 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by ResurrectionRemix.

the class TaskStackBuilder method getIntents.

/**
     * Return an array containing the intents added to this builder. The intent at the
     * root of the task stack will appear as the first item in the array and the
     * intent at the top of the stack will appear as the last item.
     *
     * @return An array containing the intents added to this builder.
     */
@NonNull
public Intent[] getIntents() {
    Intent[] intents = new Intent[mIntents.size()];
    if (intents.length == 0)
        return intents;
    intents[0] = new Intent(mIntents.get(0)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
    for (int i = 1; i < intents.length; i++) {
        intents[i] = new Intent(mIntents.get(i));
    }
    return intents;
}
Also used : Intent(android.content.Intent) NonNull(android.annotation.NonNull)

Example 62 with NonNull

use of android.annotation.NonNull in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndSubtypeUtil method getSubtypeLocaleNameListAsSentence.

@NonNull
static String getSubtypeLocaleNameListAsSentence(@NonNull final List<InputMethodSubtype> subtypes, @NonNull final Context context, @NonNull final InputMethodInfo inputMethodInfo) {
    if (subtypes.isEmpty()) {
        return "";
    }
    final Locale locale = getDisplayLocale(context);
    final int subtypeCount = subtypes.size();
    final CharSequence[] subtypeNames = new CharSequence[subtypeCount];
    for (int i = 0; i < subtypeCount; i++) {
        subtypeNames[i] = subtypes.get(i).getDisplayName(context, inputMethodInfo.getPackageName(), inputMethodInfo.getServiceInfo().applicationInfo);
    }
    return LocaleHelper.toSentenceCase(ListFormatter.getInstance(locale).format(subtypeNames), locale);
}
Also used : Locale(java.util.Locale) NonNull(android.annotation.NonNull)

Example 63 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by ResurrectionRemix.

the class ColorStateList method createFromXml.

/**
     * Creates a ColorStateList from an XML document using given a set of
     * {@link Resources} and a {@link Theme}.
     *
     * @param r Resources against which the ColorStateList should be inflated.
     * @param parser Parser for the XML document defining the ColorStateList.
     * @param theme Optional theme to apply to the color state list, may be
     *              {@code null}.
     * @return A new color state list.
     */
@NonNull
public static ColorStateList createFromXml(@NonNull Resources r, @NonNull XmlPullParser parser, @Nullable Theme theme) throws XmlPullParserException, IOException {
    final AttributeSet attrs = Xml.asAttributeSet(parser);
    int type;
    while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) {
    // Seek parser to start tag.
    }
    if (type != XmlPullParser.START_TAG) {
        throw new XmlPullParserException("No start tag found");
    }
    return createFromXmlInner(r, parser, attrs, theme);
}
Also used : AttributeSet(android.util.AttributeSet) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) NonNull(android.annotation.NonNull)

Example 64 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by ResurrectionRemix.

the class DngCreator method setThumbnail.

/**
     * Set the thumbnail image.
     *
     * <p>
     * Pixel data is interpreted as a {@link android.graphics.ImageFormat#YUV_420_888} image.
     * Thumbnail images with a dimension larger than {@link #MAX_THUMBNAIL_DIMENSION} will be
     * rejected.
     * </p>
     *
     * @param pixels an {@link android.media.Image} object with the format
     *               {@link android.graphics.ImageFormat#YUV_420_888}.
     * @return this {@link #DngCreator} object.
     * @throws java.lang.IllegalArgumentException if the given thumbnail image has a dimension
     *      larger than {@link #MAX_THUMBNAIL_DIMENSION}.
     */
@NonNull
public DngCreator setThumbnail(@NonNull Image pixels) {
    if (pixels == null) {
        throw new IllegalArgumentException("Null argument to setThumbnail");
    }
    int format = pixels.getFormat();
    if (format != ImageFormat.YUV_420_888) {
        throw new IllegalArgumentException("Unsupported Image format " + format);
    }
    int width = pixels.getWidth();
    int height = pixels.getHeight();
    if (width > MAX_THUMBNAIL_DIMENSION || height > MAX_THUMBNAIL_DIMENSION) {
        throw new IllegalArgumentException("Thumbnail dimensions width,height (" + width + "," + height + ") too large, dimensions must be smaller than " + MAX_THUMBNAIL_DIMENSION);
    }
    ByteBuffer rgbBuffer = convertToRGB(pixels);
    nativeSetThumbnail(rgbBuffer, width, height);
    return this;
}
Also used : ByteBuffer(java.nio.ByteBuffer) NonNull(android.annotation.NonNull)

Example 65 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by ResurrectionRemix.

the class InputMethodSubtype method getDisplayName.

/**
     * Returns a display name for this subtype.
     *
     * <p>If {@code subtypeNameResId} is specified (!= 0) text generated from that resource will
     * be returned. The localized string resource of the label should be capitalized for inclusion
     * in UI lists. The string resource may contain at most one {@code %s}. If present, the
     * {@code %s} will be replaced with the display name of the subtype locale in the user's locale.
     *
     * <p>If {@code subtypeNameResId} is not specified (== 0) the framework returns the display name
     * of the subtype locale, as capitalized for use in UI lists, in the user's locale.
     *
     * @param context {@link Context} will be used for getting {@link Locale} and
     * {@link android.content.pm.PackageManager}.
     * @param packageName The package name of the input method.
     * @param appInfo The {@link ApplicationInfo} of the input method.
     * @return a display name for this subtype.
     */
@NonNull
public CharSequence getDisplayName(Context context, String packageName, ApplicationInfo appInfo) {
    if (mSubtypeNameResId == 0) {
        return getLocaleDisplayName(getLocaleFromContext(context), getLocaleObject(), DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU);
    }
    final CharSequence subtypeName = context.getPackageManager().getText(packageName, mSubtypeNameResId, appInfo);
    if (TextUtils.isEmpty(subtypeName)) {
        return "";
    }
    final String subtypeNameString = subtypeName.toString();
    String replacementString;
    if (containsExtraValueKey(EXTRA_KEY_UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) {
        replacementString = getExtraValueOf(EXTRA_KEY_UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME);
    } else {
        final DisplayContext displayContext;
        if (TextUtils.equals(subtypeNameString, "%s")) {
            displayContext = DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU;
        } else if (subtypeNameString.startsWith("%s")) {
            displayContext = DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE;
        } else {
            displayContext = DisplayContext.CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE;
        }
        replacementString = getLocaleDisplayName(getLocaleFromContext(context), getLocaleObject(), displayContext);
    }
    if (replacementString == null) {
        replacementString = "";
    }
    try {
        return String.format(subtypeNameString, replacementString);
    } catch (IllegalFormatException e) {
        Slog.w(TAG, "Found illegal format in subtype name(" + subtypeName + "): " + e);
        return "";
    }
}
Also used : DisplayContext(android.icu.text.DisplayContext) IllegalFormatException(java.util.IllegalFormatException) NonNull(android.annotation.NonNull)

Aggregations

NonNull (android.annotation.NonNull)322 ArrayList (java.util.ArrayList)46 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)45 IOException (java.io.IOException)35 ComponentName (android.content.ComponentName)25 File (java.io.File)22 XmlPullParser (org.xmlpull.v1.XmlPullParser)20 Intent (android.content.Intent)18 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)16 ResolveInfo (android.content.pm.ResolveInfo)16 Bundle (android.os.Bundle)15 RemoteException (android.os.RemoteException)15 FileNotFoundException (java.io.FileNotFoundException)15 Paint (android.graphics.Paint)14 PackageParser (android.content.pm.PackageParser)12 ContentResolver (android.content.ContentResolver)10 UserInfo (android.content.pm.UserInfo)10 StorageManager (android.os.storage.StorageManager)10 VolumeInfo (android.os.storage.VolumeInfo)10 KeyCharacteristics (android.security.keymaster.KeyCharacteristics)10