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;
}
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");
}
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);
}
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();
}
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;
}
Aggregations