Example usage for android.graphics Color BLACK

List of usage examples for android.graphics Color BLACK

Introduction

In this page you can find the example usage for android.graphics Color BLACK.

Prototype

int BLACK

To view the source code for android.graphics Color BLACK.

Click Source Link

Usage

From source file:com.bonsai.btcreceive.ReceiveFragment.java

private Bitmap createBitmap(String content, final int size) {
    final Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
    hints.put(EncodeHintType.MARGIN, 0);
    hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
    BitMatrix result;/*  ww w .j  a  va  2s  .  c  o  m*/
    try {
        result = sQRCodeWriter.encode(content, BarcodeFormat.QR_CODE, size, size, hints);
    } catch (WriterException ex) {
        mLogger.warn("qr encoder failed: " + ex.toString());
        return null;
    }

    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.TRANSPARENT;
        }
    }

    final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, width, 0, 0, width, height);

    return bitmap;
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

private void init(AttributeSet attrs) {

    mHostActivity = Util.getHostActivity(getContext());

    LayoutInflater layoutInflater = (LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mMainLayout = inflate(getContext(), R.layout.floating_search_layout, this);
    mBackgroundDrawable = new ColorDrawable(Color.BLACK);

    mQuerySection = (CardView) findViewById(R.id.search_query_section);
    mClearButton = (ImageView) findViewById(R.id.clear_btn);
    mSearchInput = (SearchInputView) findViewById(R.id.search_bar_text);
    mSearchInputParent = findViewById(R.id.search_input_parent);
    mLeftAction = (ImageView) findViewById(R.id.left_action);
    mSearchProgress = (ProgressBar) findViewById(R.id.search_bar_search_progress);
    initDrawables();// w  w  w .ja v a 2s  .  c o  m
    mClearButton.setImageDrawable(mIconClear);
    mMenuView = (MenuView) findViewById(R.id.menu_view);

    mDivider = findViewById(R.id.divider);

    mSuggestionsSection = (RelativeLayout) findViewById(R.id.search_suggestions_section);
    mSuggestionListContainer = findViewById(R.id.suggestions_list_container);
    mSuggestionsList = (RecyclerView) findViewById(R.id.suggestions_list);

    setupViews(attrs);
}

From source file:ch.ethz.dcg.jukefox.manager.libraryimport.AndroidAlbumCoverFetcherThread.java

private void drawTextOnBitmap(CompleteAlbum album, Bitmap bitmapHigh, int bitmapSize, float textHeight) {
    Canvas canvas = new Canvas(bitmapHigh);
    canvas.drawARGB(0, 125, 125, 125);//w  ww.  ja  va  2  s . c  om
    Paint paint = new Paint();
    paint.setColor(Color.BLACK);
    paint.setTypeface(Typeface.SERIF);
    paint.setSubpixelText(true);
    paint.setTextSize(textHeight);
    paint.setAntiAlias(true);
    String artist = album.getArtists().get(0).getName();
    String shortenedText = new String(artist);

    int textLength = artist.length();
    if (textLength > 18) {
        shortenedText = artist.substring(0, 15) + "...";
        textLength = 18;
    } else if (textLength < 8) {
        while (shortenedText.length() < 8) {
            shortenedText = " " + shortenedText + " ";
        }
    }
    float pixelLength = paint.measureText(shortenedText);
    paint.setTextSize(textHeight * (bitmapSize * 2 / 3) / pixelLength);

    canvas.drawText(shortenedText, bitmapSize / 6, bitmapSize / 3, paint);

    shortenedText = album.getName();
    textLength = album.getName().length();
    if (textLength > 18) {
        shortenedText = album.getName().substring(0, 15) + "...";
        textLength = 18;
    } else if (textLength < 8) {
        while (shortenedText.length() < 8) {
            shortenedText = " " + shortenedText + " ";
        }
    }
    paint.setTextSize(bitmapSize / 10f);
    pixelLength = paint.measureText(shortenedText);
    textHeight = textHeight * bitmapSize * 2f / 3f / pixelLength;
    paint.setTextSize(textHeight);

    canvas.drawText(shortenedText, bitmapSize / 6f, bitmapSize * 2 / 3f + textHeight, paint);
}

From source file:co.dilaver.quoter.activities.ShareActivity.java

private int getContrastColor(int color) {
    double y = (299 * Color.red(color) + 587 * Color.green(color) + 114 * Color.blue(color)) / 1000;
    return y >= 128 ? Color.BLACK : Color.WHITE;
}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardView.java

@Override
public void onDraw(Canvas canvas) {
    final boolean keyboardChanged = mKeyboardChanged;
    super.onDraw(canvas);
    // switching animation
    if (mAnimationLevel != AnimationsLevel.None && keyboardChanged && (mInAnimation != null)) {
        startAnimation(mInAnimation);//from w  w w  .j a v  a2 s .  c o  m
        mInAnimation = null;
    }
    // text pop out animation
    if (mPopOutText != null && mAnimationLevel != AnimationsLevel.None) {
        final int maxVerticalTravel = getHeight() / 2;
        final long currentAnimationTime = SystemClock.elapsedRealtime() - mPopOutTime;
        if (currentAnimationTime > TEXT_POP_OUT_ANIMATION_DURATION) {
            mPopOutText = null;
        } else {
            final float popOutPositionProgress = ((float) currentAnimationTime)
                    / ((float) TEXT_POP_OUT_ANIMATION_DURATION);
            final float animationProgress = mPopOutTextReverting ? 1f - popOutPositionProgress
                    : popOutPositionProgress;
            final float animationInterpolatorPosition = getPopOutAnimationInterpolator(false,
                    animationProgress);
            final int y = mPopOutStartPoint.y - (int) (maxVerticalTravel * animationInterpolatorPosition);
            final int x = mPopOutStartPoint.x;
            final int alpha = mPopOutTextReverting ? (int) (255 * animationProgress)
                    : 255 - (int) (255 * animationProgress);
            // drawing
            setPaintToKeyText(mPaint);
            // will disappear over time
            mPaint.setAlpha(alpha);
            mPaint.setShadowLayer(5, 0, 0, Color.BLACK);
            // will grow over time
            mPaint.setTextSize(mPaint.getTextSize() * (1.0f + animationInterpolatorPosition));
            canvas.translate(x, y);
            canvas.drawText(mPopOutText, 0, mPopOutText.length(), 0, 0, mPaint);
            canvas.translate(-x, -y);
            //we're doing reverting twice much faster
            if (mPopOutTextReverting) {
                mPopOutTime = mPopOutTime - (int) (60 * popOutPositionProgress);
            }
            // next frame
            postInvalidateDelayed(1000 / 60);// doing 60 frames per second;
        }
    }
    //showing alpha/beta icon if needed
    if (BuildConfig.TESTING_BUILD) {
        final float textSizeForBuildSign = mPaint.getTextSize() / 2f;
        final float x = getWidth() - (mBuildTypeSignText.length() * textSizeForBuildSign);
        final float y = getHeight() - textSizeForBuildSign - getPaddingBottom();
        canvas.translate(x, y);
        canvas.drawText(mBuildTypeSignText, 0, mBuildTypeSignText.length(), 0, 0, mBuildTypeSignPaint);
        canvas.translate(-x, -y);
    }
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private LinearLayout ActivateColorize(LinearLayout ll, String text, Drawable dr) {

    // text//from   ww  w . j  a v  a2 s  .co  m
    TextView v = (TextView) ll.findViewWithTag("tv");
    v.setText(text);
    v.setTextSize(10);
    v.setTextColor(Color.BLACK); //v.setTextColor(Color.WHITE);
    v.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);

    //dr.setColorFilter(0xFF888888, android.graphics.PorterDuff.Mode.MULTIPLY);
    dr.setColorFilter(resources.getColor(R.color.orange), android.graphics.PorterDuff.Mode.SRC_ATOP);

    v.setCompoundDrawablesWithIntrinsicBounds(null, dr, null, null);
    v.setPadding(0, 5, 0, 2);

    v.setBackgroundDrawable(resources.getDrawable(R.drawable.gradient_tabs_focused));

    // hbar
    View hbar = ll.findViewWithTag("hbar");
    //hbar.setBackgroundColor(resources.getColor(R.color.orange));
    hbar.setBackgroundDrawable(resources.getDrawable(R.drawable.gradient_orange));

    return ll;
}

From source file:com.agenmate.lollipop.addedit.AddEditFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        getActivity().onBackPressed();//from w w  w .  j a v a 2  s .  c  o  m
        return true;
    case R.id.action_save:
        String title = emptyStringChecker(titleEdit.getText().toString());
        if (title == null) {
            Snackbar.make(background, "Title can't be Empty", Snackbar.LENGTH_LONG).show();
            return true;
        }
        String description = emptyStringChecker(descEdit.getText().toString());
        int priority = getPriority();

        long dueAt = getDueDate();
        if (dueAt < 0) {
            Snackbar.make(background, "Not enough time to complete task at due date", Snackbar.LENGTH_LONG)
                    .show();
            return true;
        }

        presenter.saveTask(title, description, priority, selectedColor, dueAt, hasAlarm, isCompleted);

        return true;
    case R.id.action_alarm:
        if (!hasAlarm) {
            if (getDueDate() < 0) {
                Snackbar.make(background, "Not enough time to complete task at due date", Snackbar.LENGTH_LONG)
                        .show();
                return true;
            }
        }
        boolean setWhite = selectedColor == 0 || selectedColor == 5 || selectedColor == 6;
        item.setIcon(hasAlarm ? R.drawable.ic_alarm_off : R.drawable.ic_alarm_on);
        Drawable drawable = item.getIcon();
        drawable.mutate();
        drawable.setColorFilter(setWhite ? Color.WHITE : Color.BLACK, PorterDuff.Mode.SRC_ATOP);
        hasAlarm = !hasAlarm;
        return true;

    case R.id.action_delete:
        presenter.deleteTask();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.exclaimindustries.geohashdroid.util.KnownLocation.java

@NonNull
private Bitmap buildMarkerBitmap(@NonNull Context c) {
    // Oh, this is going to be FUN.
    int dim = c.getResources().getDimensionPixelSize(R.dimen.known_location_marker_canvas_size);
    float radius = c.getResources().getDimension(R.dimen.known_location_pin_head_radius);

    Bitmap bitmap = Bitmap.createBitmap(dim, dim, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    Paint paint = new Paint();
    paint.setAntiAlias(true);/*from  w w  w  . j  av  a  2  s .com*/

    KnownLocationPinData pinData = new KnownLocationPinData(c, mLocation);

    // Draw the pin line first.  That goes from the bottom-center up to
    // wherever the radius and length take us.
    float topX = Double.valueOf((dim / 2) + (pinData.getLength() * Math.cos(pinData.getAngle()))).floatValue();
    float topY = Double.valueOf(dim - (pinData.getLength() * Math.sin(pinData.getAngle()))).floatValue();
    paint.setStrokeWidth(c.getResources().getDimension(R.dimen.known_location_stroke));
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.BLACK);

    canvas.drawLine(dim / 2, dim, topX, topY, paint);

    // On the top of that line, fill in a circle.
    paint.setColor(pinData.getColor());
    paint.setStyle(Paint.Style.FILL);
    canvas.drawCircle(topX, topY, radius, paint);

    // And outline it.
    paint.setColor(Color.BLACK);
    paint.setStyle(Paint.Style.STROKE);
    canvas.drawCircle(topX, topY, radius, paint);

    return bitmap;
}

From source file:com.kunze.androidlocaltodo.TaskActivityFragment.java

private static void SetFriendlyDueDateText(TextView dueDateView, Calendar dueDate) {
    SimpleDateFormat dateFormatDisplay = new SimpleDateFormat("MM-dd-yyyy", Locale.US);
    Calendar now = Calendar.getInstance();
    int nowDay = TaskDatabase.ConvertDateToInt(now);
    int dueDay = TaskDatabase.ConvertDateToInt(dueDate);
    int dayDiff = nowDay - dueDay;
    if (dayDiff == 0) {
        dueDateView.setText("Today");
        dueDateView.setTextColor(Color.RED);
    } else if (dueDate.before(now)) {
        dueDateView.setText("+ " + dayDiff + " days!");
        dueDateView.setTextColor(Color.RED);
    } else if (dayDiff > -7) {
        dueDateView.setText(dueDate.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US));
        dueDateView.setTextColor(Color.BLACK);
    } else if (dayDiff > -14) {
        dueDateView.setText("Next " + dueDate.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US));
        dueDateView.setTextColor(Color.BLACK);
    } else {//from  w  w w.j  a  v a 2  s .com
        dueDateView.setText(dateFormatDisplay.format(dueDate.getTime()));
        dueDateView.setTextColor(Color.BLACK);
    }
}

From source file:bikebadger.RideFragment.java

public void OpenGPXFileOnNewThreadWithDialog(final String path) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    final File gpxFile = new File(path);
    pd.setMessage("Loading \"" + gpxFile.getName() + "\"");
    pd.setIndeterminate(true);/*from   ww w . ja v  a2s .  c om*/
    pd.setCancelable(false);
    pd.show();
    Thread mThread = new Thread() {
        @Override
        public void run() {
            mRideManager.OpenGPXFile(path);
            pd.dismiss();
            if (mRideManager.mWaypoints != null) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        //Toast.makeText(getActivity(), "Hello", Toast.LENGTH_SHORT).show();
                        MyToast.Show(getActivity(),
                                "\"" + gpxFile.getName() + "\" loaded (" + mRideManager.mWaypoints.size() + ")",
                                Color.BLACK);
                    }
                });
            }
        }
    };
    mThread.start();
}