@Override protected void bindCommon(MessageWireframe message) { TLLocalContact contact = (TLLocalContact) message.message.getExtras(); if (contact.getLastName().trim().length() == 0) { title = contact.getFirstName().trim(); } else { title = contact.getFirstName().trim() + " " + contact.getLastName().trim(); } phone = contact.getPhoneNumber(); if (message.message.isOut()) { senderPaint.setColor(0xff739f53); } else { senderPaint.setColor(0xff4884cf); } this.date = org.telegram.android.ui.TextUtil.formatTime(message.message.getDate(), getContext()); this.showState = message.message.isOut(); this.basePlaceholder = getResources().getDrawable(R.drawable.st_user_placeholder_dialog); if (contact.getUserId() > 0) { placeHolderBgPaint.setColor(Placeholders.getBgColor(contact.getUserId())); } else { placeHolderBgPaint.setColor(Placeholders.GREY); } boolean isNotContact = (message.relatedUser != null) && (message.relatedUser.getLinkType() != LinkType.CONTACT); this.showAddButton = isNotContact && (contact.getUserId() != application.getCurrentUid()); requestLayout(); }
/** * Draws value and label layout. * * @param canvas the canvas for drawing */ private void drawValue(Canvas canvas) { valuePaint.setColor(valueTextColor); valuePaint.drawableState = getDrawableState(); labelPaint.setColor(labelTextColor); labelPaint.drawableState = getDrawableState(); Rect bounds = new Rect(); itemsLayout.getLineBounds(visibleItems / 2, bounds); // draw label if (labelLayout != null) { canvas.save(); canvas.translate(itemsLayout.getWidth() + LABEL_OFFSET, bounds.top); labelLayout.draw(canvas); canvas.restore(); } // draw current value if (valueLayout != null) { canvas.save(); canvas.translate(0, bounds.top + scrollingOffset); valueLayout.draw(canvas); canvas.restore(); } }
public void draw(@NonNull Canvas canvas) { if (!hasValue()) { return; } if (offset.x == 0 && offset.y == 0) { calculatePosition(); } if (highContrast) { paint.setColor(contrastColor); paint.setAlpha(255); } final int width = view.getWidth(); final int height = view.getHeight(); switch (direction) { case up: canvas.drawText(value, width + offset.x, offset.y, paint); break; case down: canvas.drawText(value, width + offset.x, height + offset.y, paint); break; case left: canvas.drawText(value, offset.x, height / 2 + offset.y, paint); break; case right: canvas.drawText(value, width + offset.x, height / 2 + offset.y, paint); break; } if (highContrast) { paint.setColor(color); paint.setAlpha(intAlpha()); } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (currentMessageObject == null) { return; } if (currentMessageObject.isOutOwner()) { timePaint.setColor(theme.ChatMusicCell_timePaint_color); } else { timePaint.setColor(theme.ChatMusicCell_timePaint_color_2); } radialProgress.draw(canvas); canvas.save(); canvas.translate(timeX + titleX, AndroidUtilities.dp(12) + namesOffset); titleLayout.draw(canvas); canvas.restore(); canvas.save(); if (MediaController.getInstance().isPlayingAudio(currentMessageObject)) { canvas.translate(seekBarX, seekBarY); seekBar.draw(canvas); } else { canvas.translate(timeX + authorX, AndroidUtilities.dp(32) + namesOffset); authorLayout.draw(canvas); } canvas.restore(); canvas.save(); canvas.translate(timeX, AndroidUtilities.dp(52) + namesOffset); timeLayout.draw(canvas); canvas.restore(); }
@Override public void updateDrawState(@NonNull final TextPaint tp) { if (isSelected()) { tp.setColor(config.SELECTED_TEXT_COLOR); tp.bgColor = config.SELECTED_TEXT_BACKGROUND_COLOR; } else { tp.setColor(config.NORMAL_TEXT_COLOR); tp.bgColor = config.NORMAL_TEXT_BACKGROUND_COLOR; } tp.setUnderlineText(false); }
@Override public void updateDrawState(TextPaint ds) { super.updateDrawState(ds); if (hideUrlStyle) { ds.setUnderlineText(false); ds.setColor(Color.BLACK); } if (getURL().startsWith("people://")) { int userId = Integer.parseInt(getURL().replace("people://", "")); ds.setColor(colors[Math.abs(userId) % colors.length]); } }
private void init() { if (namePaint == null) { namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); namePaint.setTextSize(AndroidUtilities.dp(18)); namePaint.setColor(0xff222222); } if (nameEncryptedPaint == null) { nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); nameEncryptedPaint.setTextSize(AndroidUtilities.dp(18)); nameEncryptedPaint.setColor(0xff00a60e); } if (onlinePaint == null) { onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); onlinePaint.setTextSize(AndroidUtilities.dp(15)); onlinePaint.setColor(0xff316f9f); } if (offlinePaint == null) { offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); offlinePaint.setTextSize(AndroidUtilities.dp(15)); offlinePaint.setColor(0xff999999); } if (lockDrawable == null) { lockDrawable = getResources().getDrawable(R.drawable.ic_lock_green); } if (linePaint == null) { linePaint = new Paint(); linePaint.setColor(0xffdcdcdc); } if (broadcastDrawable == null) { broadcastDrawable = getResources().getDrawable(R.drawable.broadcast); } if (groupDrawable == null) { groupDrawable = getResources().getDrawable(R.drawable.grouplist); } if (avatarImage == null) { avatarImage = new ImageReceiver(this); } if (cellLayout == null) { cellLayout = new ChatOrUserCellLayout(); } }
/** Initialize the view */ private final void init() { // Foreground text paint mTextPaint = new Paint(); mTextPaint.setAntiAlias(true); mTextPaint.setTextSize(16); mTextPaint.setColor(0xFF000000); // The shadow mTextPaintShadow = new TextPaint(); mTextPaintShadow.setAntiAlias(true); mTextPaintShadow.setTextSize(16); mTextPaintShadow.setColor(0x00000000); // Base padding // setPadding(3, 3, 3, 3); mMovement = new Vector2D(0, 0); mOldMovement = new Vector2D(0, 0); // Create our edge paint mCurlEdgePaint = new Paint(); mCurlEdgePaint.setAntiAlias(true); mCurlEdgePaint.setStyle(Paint.Style.STROKE); // mCurlEdgePaint.setColor(this.edgeColor); // mCurlEdgePaint.setShadowLayer(10, -5, 5, 0x99000000); // Set the default props, those come from an XML :D mCurlSpeed = 30; mInitialEdgeOffset = 20; }
public IconicLabelView setTextColor(int color) { if (color == -1) { return this; } mTextPaint.setColor(color); return this; }
private Bitmap drawTextToBitmap(String gText) { Bitmap bitmap = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888); bitmap.eraseColor(Color.TRANSPARENT); bitmap.setHasAlpha(true); // bitmap.setHasAlpha(true); Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.TRANSPARENT); TextPaint textPaint = new TextPaint(); textPaint.setColor(Color.GREEN); textPaint.setTextSize(35); RectF rect = new RectF(0, 0, 300, 300); StaticLayout sl = new StaticLayout( gText, textPaint, (int) rect.width(), Layout.Alignment.ALIGN_NORMAL, 1, 1, false); canvas.save(); sl.draw(canvas); canvas.restore(); // Flip the image. Matrix m = new Matrix(); m.preScale(-1, 1); Bitmap output = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, false); output.setDensity(DisplayMetrics.DENSITY_DEFAULT); return output; }
public void setTextColor(int textColor) { paint.setColor(textColor); /* There should be no need to update the StaticLayout here, * as it has a pointer to the same Paint object (and will thus * draw text in the new colour) and a colour change alone won't * affect any dimensions/measurements. */ }
public static void sendTextBitmap( LiveViewAdapter liveView, int pluginId, String text, int bitmapSizeX, int fontSize, int bitmapSize) { // Empty bitmap and link the canvas to it Bitmap bitmap = null; try { bitmap = Bitmap.createBitmap(bitmapSizeX, bitmapSize, Bitmap.Config.RGB_565); } catch (IllegalArgumentException e) { return; } Canvas canvas = new Canvas(bitmap); // Set the text properties in the canvas TextPaint textPaint = new TextPaint(); textPaint.setTextSize(fontSize); textPaint.setColor(Color.WHITE); // Create the text layout and draw it to the canvas StaticLayout textLayout = new StaticLayout(text, textPaint, bitmapSizeX, Layout.Alignment.ALIGN_CENTER, 1, 1, false); textLayout.draw(canvas); try { liveView.sendImageAsBitmap(pluginId, centerX(bitmap), centerY(bitmap), bitmap); } catch (Exception e) { Log.d(PluginConstants.LOG_TAG, "Failed to send bitmap", e); } }
@SuppressWarnings("NullableProblems") @Override protected void onDraw(Canvas canvas) { // Draw Title Text if (mAttributes.isShowTitle() && mTitlePaint != null && mCurTitleProperty != null && mCurTitleProperty.mAlpha != 0) { CharSequence buf = getHint(); if (buf != null) { mTitlePaint.setTextSize(mCurTitleProperty.mTextSize); int color = getCurrentTitleTextColor(); int alpha = GeniusUi.modulateAlpha(Color.alpha(color), mCurTitleProperty.mAlpha); mTitlePaint.setColor(color); mTitlePaint.setAlpha(alpha); canvas.drawText( buf, 0, buf.length(), mCurTitleProperty.mPaddingLeft, mCurTitleProperty.mPaddingTop + mCurTitleProperty.mTextSize, mTitlePaint); } } super.onDraw(canvas); }
@Override public void updateDrawState(TextPaint ds) { ds.setColor(_context.getResources().getColor(R.color.red)); // set // text // color ds.setUnderlineText(false); // set to false to remove underline }
@Override public void updateDrawState(TextPaint ds) { super.updateDrawState(ds); ds.setColor(mIsPressed ? mPressedTextColor : mNormalTextColor); ds.bgColor = mIsPressed ? mPressedBackgroundColor : mNormalBackgroundColor; ds.setUnderlineText(false); }
private void sendTextBitmap(LiveViewAdapter mLiveViewAdapter, int mPluginId, String txt) { // Empty bitmap and link the canvas to it Bitmap bitmap = null; try { bitmap = Bitmap.createBitmap(128, 128, Bitmap.Config.RGB_565); } catch (IllegalArgumentException e) { return; } Canvas canvas = new Canvas(bitmap); // Set the text properties in the canvas TextPaint textPaint = new TextPaint(); textPaint.setTextSize(18); textPaint.setColor(Color.WHITE); // Create the text layout and draw it to the canvas Layout textLayout = new StaticLayout(txt, textPaint, 128, Layout.Alignment.ALIGN_CENTER, 1, 1, false); textLayout.draw(canvas); try { mLiveViewAdapter.sendImageAsBitmap( mPluginId, PluginUtils.centerX(bitmap), PluginUtils.centerY(bitmap), bitmap); } catch (Exception e) { Log.d(PluginConstants.LOG_TAG, "Failed to send bitmap", e); } }
public void init(AttributeSet attrs) { TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.SlantedTextView); mTextSize = array.getDimension(R.styleable.SlantedTextView_slantedTextSize, mTextSize); mTextColor = array.getColor(R.styleable.SlantedTextView_slantedTextColor, mTextColor); mSlantedLength = array.getDimension(R.styleable.SlantedTextView_slantedLength, mSlantedLength); mSlantedBackgroundColor = array.getColor(R.styleable.SlantedTextView_slantedBackgroundColor, mSlantedBackgroundColor); if (array.hasValue(R.styleable.SlantedTextView_slantedText)) { mSlantedText = array.getString(R.styleable.SlantedTextView_slantedText); } if (array.hasValue(R.styleable.SlantedTextView_slantedMode)) { mMode = array.getInt(R.styleable.SlantedTextView_slantedMode, 0); } array.recycle(); mPaint = new Paint(); mPaint.setStyle(Paint.Style.FILL); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); mPaint.setAntiAlias(true); mPaint.setColor(mSlantedBackgroundColor); mTextPaint = new TextPaint(); mTextPaint.setAntiAlias(true); mTextPaint.setTextSize(mTextSize); mTextPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD)); mTextPaint.setColor(mTextColor); mTextPaint.setTextAlign(Paint.Align.CENTER); }
public final void updateDrawState(TextPaint paramTextPaint) { paramTextPaint.setColor(this.linkColor); if (asg()) { paramTextPaint.bgColor = this.bgColor; return; } paramTextPaint.bgColor = 0; }
protected void init() { this.setPivot(0, 0); tp = new TextPaint(); tp.setColor(Color.BLACK); tp.setTextSize(fontSize); setText(text); }
@Override public void updateDrawState(TextPaint textPaint) { super.updateDrawState(textPaint); textPaint.setUnderlineText(false); textPaint.setColor(activity.getResources().getColor(R.color.secondary_text)); textPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC)); }
private void invalidateTextPaintAndMeasurements() { mTextPaint.setTextSize(mExampleDimension); mTextPaint.setColor(mExampleColor); mTextWidth = mTextPaint.measureText(mExampleString); Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics(); mTextHeight = fontMetrics.bottom; }
protected void init() { super.init(); if (FontController.USE_SUBPIXEL) { senderPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); } else { senderPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); } senderPaint.setTypeface(FontController.loadTypeface(getContext(), "regular")); senderPaint.setTextSize(getSp(16)); senderPaint.setColor(0xff000000); if (FontController.USE_SUBPIXEL) { bodyPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); } else { bodyPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); } bodyPaint.setTypeface(FontController.loadTypeface(getContext(), "regular")); bodyPaint.setTextSize(getSp(16)); bodyPaint.setColor(0xff273e57); if (FontController.USE_SUBPIXEL) { clockOutPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); } else { clockOutPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); } clockOutPaint.setTypeface(FontController.loadTypeface(getContext(), "regular")); clockOutPaint.setTextSize(getSp(12f)); clockOutPaint.setColor(0xff70B15C); clockIconPaint = new Paint(); clockIconPaint.setStyle(Paint.Style.STROKE); clockIconPaint.setColor(0xff12C000); clockIconPaint.setStrokeWidth(getPx(1)); clockIconPaint.setAntiAlias(true); clockIconPaint.setFlags(Paint.ANTI_ALIAS_FLAG); addContactResource = getResources().getDrawable(R.drawable.st_bubble_ic_contact); placeHolderBgPaint = new Paint(); avatarPaint = new Paint(); loader = application.getUiKernel().getAvatarLoader(); }
public ProfileSearchCell(Context context) { super(context); if (namePaint == null) { namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); namePaint.setColor(0xff212121); namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); nameEncryptedPaint.setColor(0xff00a60e); nameEncryptedPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); onlinePaint.setColor(Theme.MSG_LINK_TEXT_COLOR); offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); offlinePaint.setColor(0xff999999); linePaint = new Paint(); linePaint.setColor(0xffdcdcdc); countPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); countPaint.setColor(0xffffffff); countPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); broadcastDrawable = getResources().getDrawable(R.drawable.list_broadcast); lockDrawable = getResources().getDrawable(R.drawable.list_secret); groupDrawable = getResources().getDrawable(R.drawable.list_group); countDrawable = getResources().getDrawable(R.drawable.dialogs_badge); countDrawableGrey = getResources().getDrawable(R.drawable.dialogs_badge2); checkDrawable = getResources().getDrawable(R.drawable.check_list); botDrawable = getResources().getDrawable(R.drawable.bot_list); } namePaint.setTextSize(AndroidUtilities.dp(17)); nameEncryptedPaint.setTextSize(AndroidUtilities.dp(17)); onlinePaint.setTextSize(AndroidUtilities.dp(16)); offlinePaint.setTextSize(AndroidUtilities.dp(16)); countPaint.setTextSize(AndroidUtilities.dp(13)); avatarImage = new ImageReceiver(this); avatarImage.setRoundRadius(AndroidUtilities.dp(26)); avatarDrawable = new AvatarDrawable(); }
private void init() { if (namePaint == null) { namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); namePaint.setTextSize(Utilities.dp(18)); namePaint.setColor(0xff222222); } if (nameEncryptedPaint == null) { nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); nameEncryptedPaint.setTextSize(Utilities.dp(18)); nameEncryptedPaint.setColor(0xff00a60e); } if (onlinePaint == null) { onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); onlinePaint.setTextSize(Utilities.dp(15)); onlinePaint.setColor(0xff316f9f); } if (offlinePaint == null) { offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); offlinePaint.setTextSize(Utilities.dp(15)); offlinePaint.setColor(0xff999999); } if (lockDrawable == null) { lockDrawable = getResources().getDrawable(R.drawable.ic_lock_green); } if (linePaint == null) { linePaint = new Paint(); linePaint.setColor(0xffdcdcdc); } if (avatarImage == null) { avatarImage = new ImageReceiver(); avatarImage.parentView = new WeakReference<View>(this); } if (cellLayout == null) { cellLayout = new ChatOrUserCellLayout(); } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (TextUtils.isEmpty(content)) { return; } TextPaint paint = mTextPaint; if (isPressed()) { paint.setColor(Color.WHITE); } else { paint.setColor(0xff8f8f8f); } float x = getWidth() >> 1; int n = getHeight() - cent1 >> 1; int i1 = getHeight() - n; int i2 = cent2; float y = i1 - i2; canvas.drawText(content, x, y, paint); }
private void setup() { if (!mReady) { mSetupPending = true; return; } if (mBitmap == null) { return; } mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); mBitmapPaint.setAntiAlias(true); mBitmapPaint.setShader(mBitmapShader); mBorderPaint.setStyle(Paint.Style.STROKE); mBorderPaint.setAntiAlias(true); mBorderPaint.setColor(mBorderColor); mBorderPaint.setStrokeWidth(mBorderWidth); mBitmapHeight = mBitmap.getHeight(); mBitmapWidth = mBitmap.getWidth(); mBorderRect.set(0, 0, getWidth(), getHeight()); mBorderRadius = Math.min( (mBorderRect.height() - mBorderWidth) / 2, (mBorderRect.width() - mBorderWidth) / 2); mDrawableRect.set( mBorderWidth, mBorderWidth, mBorderRect.width() - mBorderWidth, mBorderRect.height() - mBorderWidth); mDrawableRadius = Math.min(mDrawableRect.height() / 2, mDrawableRect.width() / 2); mFlagBackgroundPaint.setColor(Color.BLACK & 0x66FFFFFF); mFlagBackgroundPaint.setFlags(TextPaint.ANTI_ALIAS_FLAG); mFlagTextPaint.setFlags(TextPaint.ANTI_ALIAS_FLAG); mFlagTextPaint.setTextAlign(Align.CENTER); mFlagTextPaint.setColor(Color.WHITE); mFlagTextPaint.setTextSize(getResources().getDisplayMetrics().density * 18); mSweepGradient = new SweepGradient( getWidth() / 2, getHeight() / 2, new int[] {Color.rgb(255, 255, 255), Color.rgb(1, 209, 255)}, null); mBorderPaint.setShader(mSweepGradient); updateShaderMatrix(); invalidate(); }
private void init() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setLayerType(LAYER_TYPE_SOFTWARE, null); } else { setDrawingCacheEnabled(true); } boolean hasShot = getContext() .getSharedPreferences(PREFS_SHOWCASE_INTERNAL, Context.MODE_PRIVATE) .getBoolean("hasShot" + getConfigOptions().showcaseId, false); if (hasShot && mOptions.shotType == TYPE_ONE_SHOT) { // The showcase has already been shot once, so we don't need to do anything setVisibility(View.GONE); isRedundant = true; return; } showcase = getContext().getResources().getDrawable(R.drawable.cling); showcaseRadius = metricScale * INNER_CIRCLE_RADIUS; PorterDuffXfermode mBlender = new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY); setOnTouchListener(this); mPaintTitle = new Paint(); mPaintTitle.setColor(titleTextColor); mPaintTitle.setShadowLayer(2.0f, 0f, 2.0f, Color.DKGRAY); mPaintTitle.setTextSize(24 * metricScale); mPaintTitle.setAntiAlias(true); mPaintDetail = new TextPaint(); mPaintDetail.setColor(detailTextColor); mPaintDetail.setShadowLayer(2.0f, 0f, 2.0f, Color.DKGRAY); mPaintDetail.setTextSize(16 * metricScale); mPaintDetail.setAntiAlias(true); mEraser = new Paint(); mEraser.setColor(0xFFFFFF); mEraser.setAlpha(0); mEraser.setXfermode(mBlender); mEraser.setAntiAlias(true); if (!mOptions.noButton && mEndButton.getParent() == null) { RelativeLayout.LayoutParams lps = (LayoutParams) generateDefaultLayoutParams(); lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); int margin = ((Number) (metricScale * 12)).intValue(); lps.setMargins(margin, margin, margin, margin); lps.height = LayoutParams.WRAP_CONTENT; lps.width = LayoutParams.WRAP_CONTENT; mEndButton.setLayoutParams(lps); mEndButton.setText(buttonText != null ? buttonText : getResources().getString(R.string.ok)); if (!hasCustomClickListener) mEndButton.setOnClickListener(this); addView(mEndButton); } }
public PaperButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mPadding = getResources().getDimensionPixelSize(R.dimen.paper_padding); TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.PaperButton); mColor = attributes.getColor( R.styleable.PaperButton_paper_color, getResources().getColor(R.color.paper_button_color)); mShadowColor = attributes.getColor( R.styleable.PaperButton_paper_shadow_color, getResources().getColor(R.color.paper_button_shadow_color)); mCornerRadius = attributes.getDimensionPixelSize( R.styleable.PaperButton_paper_corner_radius, getResources().getDimensionPixelSize(R.dimen.paper_button_corner_radius)); mText = attributes.getText(R.styleable.PaperButton_paper_text); mTextSize = attributes.getDimensionPixelSize( R.styleable.PaperButton_paper_text_size, getResources().getDimensionPixelSize(R.dimen.paper_text_size)); mTextColor = attributes.getColor( R.styleable.PaperButton_paper_text_color, getResources().getColor(R.color.paper_text_color)); final String assetPath = attributes.getString(R.styleable.PaperButton_paper_font); if (assetPath != null) { AssetManager assets = context.getAssets(); Typeface typeface = Typeface.createFromAsset(assets, assetPath); textPaint.setTypeface(typeface); } mShadowRadius = attributes.getFloat(R.styleable.PaperButton_paper_shadow_radius, SHADOW_RADIUS); mShadowOffsetX = attributes.getFloat(R.styleable.PaperButton_paper_shadow_offset_x, SHADOW_OFFSET_X); mShadowOffsetY = attributes.getFloat(R.styleable.PaperButton_paper_shadow_offset_y, SHADOW_OFFSET_Y); attributes.recycle(); backgroundPaint.setColor(mColor); backgroundPaint.setStyle(Paint.Style.FILL); int shadowColor = changeColorAlpha(mShadowColor, MIN_SHADOW_COLOR_ALPHA); backgroundPaint.setShadowLayer(mShadowRadius, mShadowOffsetX, mShadowOffsetY, shadowColor); textPaint.setColor(mTextColor); textPaint.setTextSize(mTextSize); textPaint.setTextAlign(TextPaint.Align.CENTER); ripplePaint.setColor(darkenColor(mColor)); setWillNotDraw(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setLayerType(View.LAYER_TYPE_SOFTWARE, null); } }
public BotHelpCell(Context context) { super(context); textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint.setTextSize(AndroidUtilities.dp(16)); textPaint.setColor(0xff000000); textPaint.linkColor = 0xff316f9f; urlPaint = new Paint(); urlPaint.setColor(0x33316f9f); }
private static void createAndSendWidget(Context context, String icon, String id, String label) { Log.d(Constants.LOG_TAG, "widget: icon:" + icon + " id:" + id + " label:" + label); if (typeface == null) { typeface = Typeface.createFromAsset(context.getAssets(), "metawatch_8pt_5pxl_CAPS.ttf"); } TextPaint paintSmall = new TextPaint(); paintSmall.setColor(Color.BLACK); paintSmall.setTextSize(8); paintSmall.setTypeface(typeface); paintSmall.setTextAlign(Align.CENTER); label = label.trim(); // Create 16x16 widget { Bitmap iconBmp = loadBitmapFromAssets(context, icon + "_10.bmp"); Bitmap bitmap = Bitmap.createBitmap(16, 16, Bitmap.Config.RGB_565); Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.WHITE); int y = label.length() == 0 ? 3 : 0; canvas.drawBitmap(iconBmp, 2, y, null); canvas.drawText(label, 8, 16, paintSmall); Intent i = createUpdateIntent( bitmap, "localeMWM_" + id + "_16_16", "Locale Plugin Widget (16x16)", 1); context.sendBroadcast(i); } // Create 24x32 widget { Bitmap iconBmp = loadBitmapFromAssets(context, icon + ".bmp"); Bitmap bitmap = Bitmap.createBitmap(24, 32, Bitmap.Config.RGB_565); Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.WHITE); int y = label.length() == 0 ? 7 : 3; canvas.drawBitmap(iconBmp, 0, y, null); canvas.drawText(label, 12, 30, paintSmall); Intent i = createUpdateIntent( bitmap, "localeMWM_" + id + "_24_32", "Locale Plugin Widget (24x32)", 1); context.sendBroadcast(i); } }