Search in sources :

Example 21 with ColorDrawable

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();
            }
        }
    });
}
Also used : ColorPicker(com.larswerkman.holocolorpicker.ColorPicker) Bundle(android.os.Bundle) Intent(android.content.Intent) View(android.view.View) ValueBar(com.larswerkman.holocolorpicker.ValueBar) OpacityBar(com.larswerkman.holocolorpicker.OpacityBar) ColorDrawable(android.graphics.drawable.ColorDrawable) Button(android.widget.Button) SaturationBar(com.larswerkman.holocolorpicker.SaturationBar) OnClickListener(android.view.View.OnClickListener)

Example 22 with ColorDrawable

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);
}
Also used : SwipeBackLayout(me.yokeyword.fragmentation.SwipeBackLayout) ColorDrawable(android.graphics.drawable.ColorDrawable) ViewGroup(android.view.ViewGroup)

Example 23 with ColorDrawable

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;
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) WeakReference(java.lang.ref.WeakReference) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) VectorDrawable(carbon.drawable.VectorDrawable) LollipopDrawable(carbon.drawable.ripple.LollipopDrawable)

Example 24 with ColorDrawable

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);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ViewGroup(android.view.ViewGroup) View(android.view.View)

Example 25 with ColorDrawable

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")));
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) IconSearchRow(carbon.component.IconSearchRow) DividerItemDecoration(carbon.recycler.DividerItemDecoration) IconTextRow(carbon.component.IconTextRow) ColorDrawable(android.graphics.drawable.ColorDrawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultIconTextItem(carbon.component.DefaultIconTextItem) DefaultIconSearchItem(carbon.component.DefaultIconSearchItem) Carbon(carbon.Carbon) RecyclerView(carbon.widget.RecyclerView) SamplesActivity(tk.zielony.carbonsamples.SamplesActivity) VectorDrawable(carbon.drawable.VectorDrawable) R(tk.zielony.carbonsamples.R) RowListAdapter(carbon.recycler.RowListAdapter) Nullable(android.support.annotation.Nullable) ArraySearchDataProvider(carbon.widget.ArraySearchDataProvider) Samples(tk.zielony.carbonsamples.Samples) DefaultIconSearchItem(carbon.component.DefaultIconSearchItem) ColorDrawable(android.graphics.drawable.ColorDrawable) IconTextRow(carbon.component.IconTextRow) RowListAdapter(carbon.recycler.RowListAdapter) RecyclerView(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(carbon.recycler.DividerItemDecoration) DefaultIconTextItem(carbon.component.DefaultIconTextItem) IconSearchRow(carbon.component.IconSearchRow) VectorDrawable(carbon.drawable.VectorDrawable) ArraySearchDataProvider(carbon.widget.ArraySearchDataProvider)

Aggregations

ColorDrawable (android.graphics.drawable.ColorDrawable)519 View (android.view.View)112 Drawable (android.graphics.drawable.Drawable)102 BitmapDrawable (android.graphics.drawable.BitmapDrawable)67 ImageView (android.widget.ImageView)62 TextView (android.widget.TextView)55 Bitmap (android.graphics.Bitmap)51 AdapterView (android.widget.AdapterView)32 LinearLayout (android.widget.LinearLayout)32 Test (org.junit.Test)31 Canvas (android.graphics.Canvas)29 ListView (android.widget.ListView)27 FrameLayout (android.widget.FrameLayout)23 ViewGroup (android.view.ViewGroup)22 Handler (android.os.Handler)20 TransitionDrawable (android.graphics.drawable.TransitionDrawable)19 Paint (android.graphics.Paint)18 StateListDrawable (android.graphics.drawable.StateListDrawable)17 WindowManager (android.view.WindowManager)17 Point (android.graphics.Point)16