Search in sources :

Example 66 with TypedArray

use of android.content.res.TypedArray in project platform_frameworks_base by android.

the class ShapeDrawable method inflateTag.

/**
     * Subclasses override this to parse custom subelements. If you handle it,
     * return true, else return <em>super.inflateTag(...)</em>.
     */
protected boolean inflateTag(String name, Resources r, XmlPullParser parser, AttributeSet attrs) {
    if ("padding".equals(name)) {
        TypedArray a = r.obtainAttributes(attrs, com.android.internal.R.styleable.ShapeDrawablePadding);
        setPadding(a.getDimensionPixelOffset(com.android.internal.R.styleable.ShapeDrawablePadding_left, 0), a.getDimensionPixelOffset(com.android.internal.R.styleable.ShapeDrawablePadding_top, 0), a.getDimensionPixelOffset(com.android.internal.R.styleable.ShapeDrawablePadding_right, 0), a.getDimensionPixelOffset(com.android.internal.R.styleable.ShapeDrawablePadding_bottom, 0));
        a.recycle();
        return true;
    }
    return false;
}
Also used : TypedArray(android.content.res.TypedArray)

Example 67 with TypedArray

use of android.content.res.TypedArray in project platform_frameworks_base by android.

the class SettingsDrawerActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    long startTime = System.currentTimeMillis();
    TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
    if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
        getWindow().addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    super.setContentView(R.layout.settings_with_drawer);
    mContentHeaderContainer = (FrameLayout) findViewById(R.id.content_header_container);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
    if (theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
        toolbar.setVisibility(View.GONE);
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        mDrawerLayout = null;
        return;
    }
    getDashboardCategories();
    setActionBar(toolbar);
    mDrawerAdapter = new SettingsDrawerAdapter(this);
    ListView listView = (ListView) findViewById(R.id.left_drawer);
    listView.setAdapter(mDrawerAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(android.widget.AdapterView<?> parent, View view, int position, long id) {
            onTileClicked(mDrawerAdapter.getTile(position));
        }
    });
    mUserManager = UserManager.get(this);
    if (DEBUG_TIMING)
        Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms");
}
Also used : ListView(android.widget.ListView) TypedArray(android.content.res.TypedArray) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Toolbar(android.widget.Toolbar)

Example 68 with TypedArray

use of android.content.res.TypedArray in project platform_frameworks_base by android.

the class DreamBackend method getSettingsComponentName.

private static ComponentName getSettingsComponentName(PackageManager pm, ResolveInfo resolveInfo) {
    if (resolveInfo == null || resolveInfo.serviceInfo == null || resolveInfo.serviceInfo.metaData == null)
        return null;
    String cn = null;
    XmlResourceParser parser = null;
    Exception caughtException = null;
    try {
        parser = resolveInfo.serviceInfo.loadXmlMetaData(pm, DreamService.DREAM_META_DATA);
        if (parser == null) {
            Log.w(TAG, "No " + DreamService.DREAM_META_DATA + " meta-data");
            return null;
        }
        Resources res = pm.getResourcesForApplication(resolveInfo.serviceInfo.applicationInfo);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        int type;
        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
        }
        String nodeName = parser.getName();
        if (!"dream".equals(nodeName)) {
            Log.w(TAG, "Meta-data does not start with dream tag");
            return null;
        }
        TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.Dream);
        cn = sa.getString(com.android.internal.R.styleable.Dream_settingsActivity);
        sa.recycle();
    } catch (PackageManager.NameNotFoundException | IOException | XmlPullParserException e) {
        caughtException = e;
    } finally {
        if (parser != null)
            parser.close();
    }
    if (caughtException != null) {
        Log.w(TAG, "Error parsing : " + resolveInfo.serviceInfo.packageName, caughtException);
        return null;
    }
    if (cn != null && cn.indexOf('/') < 0) {
        cn = resolveInfo.serviceInfo.packageName + "/" + cn;
    }
    return cn == null ? null : ComponentName.unflattenFromString(cn);
}
Also used : XmlResourceParser(android.content.res.XmlResourceParser) AttributeSet(android.util.AttributeSet) TypedArray(android.content.res.TypedArray) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) Resources(android.content.res.Resources) IOException(java.io.IOException) RemoteException(android.os.RemoteException) IOException(java.io.IOException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 69 with TypedArray

use of android.content.res.TypedArray in project platform_frameworks_base by android.

the class HelpUtils method addIntentParameters.

public static void addIntentParameters(Context context, Intent intent, String backupContext, boolean sendPackageName) {
    if (!intent.hasExtra(EXTRA_CONTEXT)) {
        // Insert some context if none exists.
        intent.putExtra(EXTRA_CONTEXT, backupContext);
    }
    Resources resources = context.getResources();
    boolean includePackageName = resources.getBoolean(R.bool.config_sendPackageName);
    if (sendPackageName && includePackageName) {
        String[] packageNameKey = { resources.getString(R.string.config_helpPackageNameKey) };
        String[] packageNameValue = { resources.getString(R.string.config_helpPackageNameValue) };
        String intentExtraKey = resources.getString(R.string.config_helpIntentExtraKey);
        String intentNameKey = resources.getString(R.string.config_helpIntentNameKey);
        intent.putExtra(intentExtraKey, packageNameKey);
        intent.putExtra(intentNameKey, packageNameValue);
    }
    intent.putExtra(EXTRA_THEME, 1);
    TypedArray array = context.obtainStyledAttributes(new int[] { android.R.attr.colorPrimary });
    intent.putExtra(EXTRA_PRIMARY_COLOR, array.getColor(0, 0));
    array.recycle();
}
Also used : TypedArray(android.content.res.TypedArray) Resources(android.content.res.Resources)

Example 70 with TypedArray

use of android.content.res.TypedArray in project platform_frameworks_base by android.

the class Utils method getColorAccent.

@ColorInt
public static int getColorAccent(Context context) {
    TypedArray ta = context.obtainStyledAttributes(new int[] { android.R.attr.colorAccent });
    @ColorInt int colorAccent = ta.getColor(0, 0);
    ta.recycle();
    return colorAccent;
}
Also used : ColorInt(android.annotation.ColorInt) TypedArray(android.content.res.TypedArray) ColorInt(android.annotation.ColorInt)

Aggregations

TypedArray (android.content.res.TypedArray)2031 Paint (android.graphics.Paint)193 TypedValue (android.util.TypedValue)190 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)162 Drawable (android.graphics.drawable.Drawable)119 Resources (android.content.res.Resources)118 View (android.view.View)117 Context (android.content.Context)80 XmlResourceParser (android.content.res.XmlResourceParser)80 ColorStateList (android.content.res.ColorStateList)78 AttributeSet (android.util.AttributeSet)78 IOException (java.io.IOException)77 SuppressLint (android.annotation.SuppressLint)66 TextPaint (android.text.TextPaint)63 TextView (android.widget.TextView)63 ViewGroup (android.view.ViewGroup)59 Bundle (android.os.Bundle)48 Point (android.graphics.Point)43 LayoutInflater (android.view.LayoutInflater)42 ImageView (android.widget.ImageView)40