use of android.graphics.drawable.ColorDrawable in project Xposed-Tinted-Status-Bar by MohammadAG.
the class ColorPickerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
String prefTitle = bundle.getString("title");
prefKey = bundle.getString("key");
prefColor = bundle.getString("color");
prefEnabled = bundle.getBoolean("enabled");
setTitle(prefTitle);
if (Utils.hasActionBar())
getActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_color_picker);
final ColorPicker picker = (ColorPicker) findViewById(R.id.picker);
OpacityBar opacityBar = (OpacityBar) findViewById(R.id.opacitybar);
SaturationBar saturationBar = (SaturationBar) findViewById(R.id.saturationbar);
ValueBar valueBar = (ValueBar) findViewById(R.id.valuebar);
picker.addOpacityBar(opacityBar);
picker.addSaturationBar(saturationBar);
picker.addValueBar(valueBar);
editText = (EditText) findViewById(R.id.edittext);
picker.setOldCenterColor(Color.parseColor("#ff33b5e5"));
picker.setOnColorChangedListener(this);
picker.setColor(Color.parseColor(Utils.addHashIfNeeded(prefColor)));
Button bPreview = (Button) findViewById(R.id.bPreviewColor);
bPreview.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
String textEditString = editText.getText().toString();
int colourHex;
if (isFullyTransparent(textEditString)) {
colourHex = Color.parseColor("#00000000");
} else {
colourHex = Color.parseColor(Utils.addHashIfNeeded(textEditString));
picker.setColor(colourHex);
}
ColorDrawable previewDrawable = new ColorDrawable(colourHex);
if (SettingsKeys.STATUS_BAR_TINT.equals(prefKey) && Utils.hasActionBar()) {
getActionBar().setBackgroundDrawable(previewDrawable);
/* Workaround, there's no invalidate() method that would redraw the
* action bar, and setting the drawable at runtime simply does nothing.
*/
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setDisplayShowTitleEnabled(true);
}
String previewKey;
Intent intent = new Intent(StatusBarTintApi.INTENT_CHANGE_COLOR_NAME);
if (SettingsKeys.DEFAULT_NAV_BAR_IM_TINT.equals(prefKey) || SettingsKeys.DEFAULT_NAV_BAR_TINT.equals(prefKey)) {
previewKey = SettingsKeys.NAVIGATION_BAR_TINT;
} else if (SettingsKeys.DEFAULT_STATUS_BAR_TINT.equals(prefKey)) {
previewKey = SettingsKeys.STATUS_BAR_TINT;
} else if (SettingsKeys.DEFAULT_NAV_BAR_ICON_TINT.equals(prefKey) || SettingsKeys.DEFAULT_NAV_BAR_ICON_IM_TINT.equals(prefKey)) {
previewKey = SettingsKeys.NAVIGATION_BAR_ICON_TINT;
} else if (SettingsKeys.DEFAULT_STATUS_BAR_ICON_TINT.equals(prefKey) || SettingsKeys.DEFAULT_STATUS_BAR_INVERTED_ICON_TINT.equals(prefKey)) {
if (SettingsKeys.DEFAULT_STATUS_BAR_INVERTED_ICON_TINT.equals(prefKey))
intent.putExtra(SettingsKeys.STATUS_BAR_TINT, Color.WHITE);
previewKey = SettingsKeys.STATUS_BAR_ICON_TINT;
} else {
previewKey = prefKey;
}
intent.putExtra(previewKey, colourHex);
sendOrderedBroadcast(intent, null);
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), R.string.invalid_color, Toast.LENGTH_SHORT).show();
}
}
});
Button bApply = (Button) findViewById(R.id.bApplyColor);
bApply.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
Color.parseColor(Utils.addHashIfNeeded(editText.getText().toString()));
returnResults();
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), R.string.invalid_color, Toast.LENGTH_SHORT).show();
}
}
});
}
use of android.graphics.drawable.ColorDrawable in project Fragmentation by YoKeyword.
the class SwipeBackActivity method onActivityCreate.
void onActivityCreate() {
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
getWindow().getDecorView().setBackgroundDrawable(null);
mSwipeBackLayout = new SwipeBackLayout(this);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mSwipeBackLayout.setLayoutParams(params);
}
use of android.graphics.drawable.ColorDrawable in project Carbon by ZieIony.
the class CarbonResources method loadDrawable.
public Drawable loadDrawable(TypedValue value, Resources.Theme theme) throws Resources.NotFoundException {
if (value == null || value.resourceId == 0) {
return null;
}
final boolean isColorDrawable;
final LongSparseArray<WeakReference<Drawable.ConstantState>> cache;
final long key;
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
isColorDrawable = true;
cache = sColorDrawableCache;
key = value.data;
} else {
isColorDrawable = false;
cache = sDrawableCache;
key = (long) value.assetCookie << 32 | value.data;
}
Drawable dr = getCachedDrawable(cache, key);
if (dr != null) {
return dr;
}
Drawable.ConstantState cs = null;
if (cs != null) {
final Drawable cloneDr = cs.newDrawable(this);
if (theme != null) {
dr = cloneDr.mutate();
applyTheme(dr, theme);
} else {
dr = cloneDr;
}
} else if (isColorDrawable) {
dr = new ColorDrawable(value.data);
} else {
dr = loadDrawableForCookie(value, value.resourceId, theme);
}
if (dr != null) {
dr.setChangingConfigurations(value.changingConfigurations);
cacheDrawable(value, theme, isColorDrawable, key, dr, cache);
}
return dr;
}
use of android.graphics.drawable.ColorDrawable in project Carbon by ZieIony.
the class DebugOverlay method show.
public void show() {
View anchor = context.getWindow().getDecorView().getRootView();
setContentView(new DebugLayout(context, anchor));
getContentView().setLayoutParams(new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
setBackgroundDrawable(new ColorDrawable(context.getResources().getColor(android.R.color.transparent)));
setTouchable(false);
setFocusable(false);
setOutsideTouchable(false);
setAnimationStyle(0);
super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
update(anchor.getWidth(), anchor.getHeight());
anchor.getViewTreeObserver().addOnPreDrawListener(listener);
}
use of android.graphics.drawable.ColorDrawable in project Carbon by ZieIony.
the class IconTextListItemActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listcomponent);
Samples.initToolbar(this, getString(R.string.iconTextListItemActivity_title));
RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
recycler.setLayoutManager(new LinearLayoutManager(this));
RowListAdapter adapter = new RowListAdapter<>(DefaultIconTextItem.class, IconTextRow::new);
adapter.addFactory(DefaultIconSearchItem.class, parent -> new IconSearchRow(parent, new ArraySearchDataProvider(new String[] {}), filterResults -> {
}));
recycler.setAdapter(adapter);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(new ColorDrawable(Carbon.getThemeColor(this, R.attr.carbon_dividerColor)), getResources().getDimensionPixelSize(R.dimen.carbon_1dip));
dividerItemDecoration.setDrawRules(position -> position == 0);
recycler.addItemDecoration(dividerItemDecoration);
VectorDrawable drawable = new VectorDrawable(getResources(), R.raw.ic_face_24px);
adapter.setItems(Arrays.asList(new DefaultIconSearchItem(this), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text")));
}
Aggregations