Java Code Examples for android.graphics.Color#WHITE

The following examples show how to use android.graphics.Color#WHITE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SvgHelper.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private static Integer getColorByName(String name) {
    switch (name.toLowerCase()) {
        case "black":
            return Color.BLACK;
        case "gray":
            return Color.GRAY;
        case "red":
            return Color.RED;
        case "green":
            return Color.GREEN;
        case "blue":
            return Color.BLUE;
        case "yellow":
            return Color.YELLOW;
        case "cyan":
            return Color.CYAN;
        case "magenta":
            return Color.MAGENTA;
        case "white":
            return Color.WHITE;
    }
    return null;
}
 
Example 2
Source File: SVBar.java    From PhotoEdit with Apache License 2.0 6 votes vote down vote up
/**
 * Calculate the color selected by the pointer on the bar.
 *
 * @param coord
 *            Coordinate of the pointer.
 */
private void calculateColor(int coord) {
    coord = coord - mBarPointerHaloRadius;
    if (coord > (mBarLength / 2) && (coord < mBarLength)) {
        mColor = Color
                .HSVToColor(new float[] {
                        mHSVColor[0], 1f, 1 - (mPosToSVFactor * (coord - (mBarLength / 2)))
                });
    } else if (coord > 0 && coord < mBarLength) {
        mColor = Color.HSVToColor(new float[]{
                mHSVColor[0], (mPosToSVFactor * coord), 1f
        });
    } else if(coord == (mBarLength / 2)){
        mColor = Color.HSVToColor(new float[]{
                mHSVColor[0], 1f, 1f
        });
    } else if (coord <= 0) {
        mColor = Color.WHITE;
    } else if (coord >= mBarLength) {
        mColor = Color.BLACK;
    }
}
 
Example 3
Source File: BarcodeProvider.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
public static Bitmap create2dBarcodeBitmap(String input, int size) {
    try {
        final QRCodeWriter barcodeWriter = new QRCodeWriter();
        final Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
        hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
        final BitMatrix result = barcodeWriter.encode(input, BarcodeFormat.QR_CODE, size, size, hints);
        final int width = result.getWidth();
        final int height = result.getHeight();
        final int[] pixels = new int[width * height];
        for (int y = 0; y < height; y++) {
            final int offset = y * width;
            for (int x = 0; x < width; x++) {
                pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.WHITE;
            }
        }
        final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
        return bitmap;
    } catch (final Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 4
Source File: GradientTextView.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    if (mWidth == 0) {
        Log.e(TAG, "*********************");
        mWidth = getMeasuredWidth();
        paint2 = getPaint();
        //颜色渐变器
        gradient = new LinearGradient(0, 0, mWidth, 0, new int[]{Color.GRAY, Color.WHITE, Color.GRAY}, new float[]{
                0.3f, 0.5f, 1.0f
        }, Shader.TileMode.CLAMP);
        paint2.setShader(gradient);

        matrix = new Matrix();
    }
}
 
Example 5
Source File: ProfileDataCache.java    From 365browser with Apache License 2.0 6 votes vote down vote up
public ProfileDataCache(Context context, Profile profile) {
    mContext = context;
    mProfile = profile;

    // There's no WindowAndroid present at this time, so get the default display.
    final DisplayAndroid displayAndroid = DisplayAndroid.getNonMultiDisplay(context);
    mImageSizePx = (int) Math.ceil(PROFILE_IMAGE_SIZE_DP * displayAndroid.getDipScale());
    mImageStrokePx = (int) Math.ceil(PROFILE_IMAGE_STROKE_DP * displayAndroid.getDipScale());
    mImageStrokeColor = Color.WHITE;

    Bitmap placeHolder = BitmapFactory.decodeResource(mContext.getResources(),
            R.drawable.fre_placeholder);
    mPlaceholderImage = getCroppedBitmap(placeHolder);

    ProfileDownloader.addObserver(this);
}
 
Example 6
Source File: CircleWatchface.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
public int getTextColor() {
    if (sharedPrefs.getBoolean("dark", true)) {
        return Color.WHITE;
    } else {
        return Color.BLACK;

    }
}
 
Example 7
Source File: PlusTextView.java    From douyin with Apache License 2.0 5 votes vote down vote up
public PlusBuilder(Context context) {
    this.context = context;
    this.text = "PlusTextView";
    this.textColor = Color.WHITE;
    this.backgroundColor = Color.parseColor("#417BC7");
    this.pressedColor = Color.parseColor("#aa417BC7");
    this.unencbleColor = Color.parseColor("#aaff0000"); //不可用颜色
    this.textView = new TextView(context);
}
 
Example 8
Source File: TransferEntriesActivity.java    From Aegis with GNU General Public License v3.0 5 votes vote down vote up
private void generateQR() {
    GoogleAuthInfo selectedEntry = _authInfos.get(_currentEntryCount - 1);
    _issuer.setText(selectedEntry.getIssuer());
    _accountName.setText(selectedEntry.getAccountName());
    _entriesCount.setText(String.format(getString(R.string.entries_count), _currentEntryCount, _authInfos.size()));

    QRCodeWriter writer = new QRCodeWriter();
    BitMatrix bitMatrix = null;
    try {
        bitMatrix = writer.encode(selectedEntry.getUri().toString(), BarcodeFormat.QR_CODE, 512, 512);
    } catch (WriterException e) {
        Dialogs.showErrorDialog(this, R.string.unable_to_generate_qrcode, e);
        return;
    }

    int width = bitMatrix.getWidth();
    int height = bitMatrix.getHeight();
    int[] pixels = new int[width * height];
    for (int y = 0; y < height; y++) {
        int offset = y * width;
        for (int x = 0; x < width; x++) {
            pixels[offset + x] = bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE;
        }
    }

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
    _qrImage.setImageBitmap(bitmap);
}
 
Example 9
Source File: BrowserActivity.java    From Xndroid with GNU General Public License v3.0 5 votes vote down vote up
private int getSearchBarColor(int requestedColor, int defaultColor) {
    if (requestedColor == defaultColor) {
        return mDarkTheme ? DrawableUtils.mixColor(0.25f, defaultColor, Color.WHITE) : Color.WHITE;
    } else {
        return DrawableUtils.mixColor(0.25f, requestedColor, Color.WHITE);
    }
}
 
Example 10
Source File: ColorUtils.java    From twitter-kit-android with Apache License 2.0 5 votes vote down vote up
public static int calculateCtaTextColor(final int ctaBackgroundColor) {
    if (isLightColor(ctaBackgroundColor)) {
        return calculateDarkerColor(ctaBackgroundColor, CTA_TEXT_LIGHTNESS_FACTOR);
    } else {
        return Color.WHITE;
    }
}
 
Example 11
Source File: BIGChart.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
protected void setColorDark() {
    mTime.setTextColor(Color.WHITE);
    mRelativeLayout.setBackgroundColor(Color.BLACK);
    if (sgvLevel == 1) {
        mSgv.setTextColor(Color.YELLOW);
        mDelta.setTextColor(Color.YELLOW);
    } else if (sgvLevel == 0) {
        mSgv.setTextColor(Color.WHITE);
        mDelta.setTextColor(Color.WHITE);
    } else if (sgvLevel == -1) {
        mSgv.setTextColor(Color.RED);
        mDelta.setTextColor(Color.RED);
    }


    if (ageLevel == 1) {
        mTimestamp.setTextColor(Color.WHITE);
    } else {
        mTimestamp.setTextColor(Color.RED);
    }

    if (batteryLevel == 1) {
    } else {
    }
    if (chart != null) {
        highColor = Color.YELLOW;
        lowColor = Color.RED;
        midColor = Color.WHITE;
        singleLine = false;
        pointSize = 2;
        setupCharts();
    }

}
 
Example 12
Source File: CircleWatchface.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public int getBackgroundColor() {
    if (sharedPrefs.getBoolean("dark", false)) {
        return Color.BLACK;
    } else {
        return Color.WHITE;

    }
}
 
Example 13
Source File: MeActivity.java    From Musicoco with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    String text = texts[position];
    Bitmap b = BitmapUtils.bitmapResizeFromResource(
            context.getResources(),
            images[position],
            holder.image.getMeasuredWidth(), holder.image.getMeasuredHeight());

    int dTC = Color.WHITE;
    int dBC = ColorUtils.getAccentColor(context);
    int[] colors = new int[4];
    ColorUtils.get4LightColorWithTextFormBitmap(b, dBC, dTC, colors);

    int l = colors[0];
    int lt = colors[1];
    int s = colors[2];
    int st = colors[3];

    l = l == dBC ? s : l;
    lt = l == s ? st : lt;

    holder.text.setText(text);
    holder.text.setTextColor(lt);
    holder.text.setBackgroundColor(l);

    holder.image.setImageBitmap(b);

    if (listener != null) {
        final int pos = position;
        holder.item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onItemClick(pos, url[pos], texts[pos]);
            }
        });
    }
}
 
Example 14
Source File: Utils.java    From droid-stealth with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a color from the resources of this app.
 *
 * @param resource the resource, for instance R.string.hello_world
 * @return the string value of the string resource
 */
public static int color(int resource) {
	if (getContext() == null) {
		return Color.WHITE;
	}
	return getContext().getResources().getColor(resource);
}
 
Example 15
Source File: ToastTintUse.java    From DevUtils with Apache License 2.0 4 votes vote down vote up
/**
 * 文本颜色
 * @return
 */
@Override
public int getTextColor() {
    return Color.WHITE;
}
 
Example 16
Source File: Nanrentu.java    From PicKing with Apache License 2.0 4 votes vote down vote up
@Override
public int getBackgroundColor() {
    return Color.WHITE;
}
 
Example 17
Source File: CompositorViewHolder.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public int getBrowserControlsBackgroundColor() {
    return mTabVisible == null ? Color.WHITE : mTabVisible.getThemeColor();
}
 
Example 18
Source File: SaturationBar.java    From PhotoEdit with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    getParent().requestDisallowInterceptTouchEvent(true);

    // Convert coordinates to our internal coordinate system
    float dimen;
    if (mOrientation == ORIENTATION_HORIZONTAL) {
        dimen = event.getX();
    }
    else {
        dimen = event.getY();
    }

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            mIsMovingPointer = true;
            // Check whether the user pressed on (or near) the pointer
            if (dimen >= (mBarPointerHaloRadius)
                    && dimen <= (mBarPointerHaloRadius + mBarLength)) {
                mBarPointerPosition = Math.round(dimen);
                calculateColor(Math.round(dimen));
                mBarPointerPaint.setColor(mColor);
                invalidate();
            }
            break;
        case MotionEvent.ACTION_MOVE:
            if (mIsMovingPointer) {
                // Move the the pointer on the bar.
                if (dimen >= mBarPointerHaloRadius
                        && dimen <= (mBarPointerHaloRadius + mBarLength)) {
                    mBarPointerPosition = Math.round(dimen);
                    calculateColor(Math.round(dimen));
                    mBarPointerPaint.setColor(mColor);
                    if (mPicker != null) {
                        mPicker.setNewCenterColor(mColor);
                        mPicker.changeValueBarColor(mColor);
                        mPicker.changeOpacityBarColor(mColor);
                    }
                    invalidate();
                } else if (dimen < mBarPointerHaloRadius) {
                    mBarPointerPosition = mBarPointerHaloRadius;
                    mColor = Color.WHITE;
                    mBarPointerPaint.setColor(mColor);
                    if (mPicker != null) {
                        mPicker.setNewCenterColor(mColor);
                        mPicker.changeValueBarColor(mColor);
                        mPicker.changeOpacityBarColor(mColor);
                    }
                    invalidate();
                } else if (dimen > (mBarPointerHaloRadius + mBarLength)) {
                    mBarPointerPosition = mBarPointerHaloRadius + mBarLength;
                    mColor = Color.HSVToColor(mHSVColor);
                    mBarPointerPaint.setColor(mColor);
                    if (mPicker != null) {
                        mPicker.setNewCenterColor(mColor);
                        mPicker.changeValueBarColor(mColor);
                        mPicker.changeOpacityBarColor(mColor);
                    }
                    invalidate();
                }
            }
            if(onSaturationChangedListener != null && oldChangedListenerSaturation != mColor){
                onSaturationChangedListener.onSaturationChanged(mColor);
                oldChangedListenerSaturation = mColor;
            }
            break;
        case MotionEvent.ACTION_UP:
            mIsMovingPointer = false;
            break;
    }
    return true;
}
 
Example 19
Source File: HomeIconActivity.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    materialMenu = new MaterialMenuIconCompat(this, Color.WHITE, Stroke.THIN);
    helper.init(getWindow().getDecorView(), materialMenu);
}
 
Example 20
Source File: ThemeUtils.java    From Xndroid with GNU General Public License v3.0 2 votes vote down vote up
/**
 * The text hint color for dark theme or light theme.
 *
 * @param dark true for a text color suitable for use with a dark theme,
 *             false for a text color suitable for use with a light theme.
 * @return a text color.
 */
@ColorInt
public static int getThemedTextHintColor(boolean dark) {
    return 0x80ffffff & (dark ? Color.WHITE : Color.BLACK);
}