Java Code Examples for org.telegram.messenger.LocaleController#isRTL()

The following examples show how to use org.telegram.messenger.LocaleController#isRTL() . 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: TextPriceCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public TextPriceCell(Context context) {
    super(context);

    dotstring = LocaleController.isRTL ? " ." : ". ";
    setWillNotDraw(false);

    textView = new TextView(context);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    valueTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setEllipsize(TextUtils.TruncateAt.END);
    valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, 17, 0, 17, 0));
}
 
Example 2
Source File: IntroActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onResume()
{
    super.onResume();
    if (justCreated)
    {
        if (LocaleController.isRTL)
        {
            viewPager.setCurrentItem(6);
            lastPage = 6;
        }
        else
        {
            viewPager.setCurrentItem(0);
            lastPage = 0;
        }
        justCreated = false;
    }
    AndroidUtilities.checkForCrashes(this);
    AndroidUtilities.checkForUpdates(this);
    ConnectionsManager.getInstance(currentAccount).setAppPaused(false, false);
}
 
Example 3
Source File: DialogCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
{
    if (currentDialogId == 0 && customDialog == null)
    {
        return;
    }
    if (checkBox != null)
    {
        int x = LocaleController.isRTL ? (right - left) - AndroidUtilities.dp(42) : AndroidUtilities.dp(42);
        int y = AndroidUtilities.dp(43);
        checkBox.layout(x, y, x + checkBox.getMeasuredWidth(), y + checkBox.getMeasuredHeight());
    }
    if (changed)
    {
        try
        {
            buildLayout();
        }
        catch (Exception e)
        {
            FileLog.e(e);
        }
    }
}
 
Example 4
Source File: DialogCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (currentDialogId == 0 && customDialog == null) {
        return;
    }
    if (checkBox != null) {
        int x = LocaleController.isRTL ? (right - left) - AndroidUtilities.dp(45) : AndroidUtilities.dp(45);
        int y = AndroidUtilities.dp(46);
        checkBox.layout(x, y, x + checkBox.getMeasuredWidth(), y + checkBox.getMeasuredHeight());
    }
    if (changed) {
        try {
            buildLayout();
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
}
 
Example 5
Source File: RecyclerListView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b)
{
    super.onLayout(changed, l, t, r, b);
    if (fastScroll != null)
    {
        selfOnLayout = true;
        if (LocaleController.isRTL)
        {
            fastScroll.layout(0, t, fastScroll.getMeasuredWidth(), t + fastScroll.getMeasuredHeight());
        }
        else
        {
            int x = getMeasuredWidth() - fastScroll.getMeasuredWidth();
            fastScroll.layout(x, t, x + fastScroll.getMeasuredWidth(), t + fastScroll.getMeasuredHeight());
        }
        selfOnLayout = false;
    }
}
 
Example 6
Source File: RecyclerListView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public FastScroll(Context context)
{
    super(context);

    letterPaint.setTextSize(AndroidUtilities.dp(45));
    for (int a = 0; a < 8; a++)
    {
        radii[a] = AndroidUtilities.dp(44);
    }

    scrollX = LocaleController.isRTL ? AndroidUtilities.dp(10) : AndroidUtilities.dp(117);
    updateColors();
}
 
Example 7
Source File: RecyclerListView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public FastScroll(Context context) {
    super(context);

    letterPaint.setTextSize(AndroidUtilities.dp(45));
    for (int a = 0; a < 8; a++) {
        radii[a] = AndroidUtilities.dp(44);
    }

    scrollX = LocaleController.isRTL ? AndroidUtilities.dp(10) : AndroidUtilities.dp(117);
    updateColors();
}
 
Example 8
Source File: PollVotesAlert.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (drawPlaceholder || placeholderAlpha != 0) {
        placeholderPaint.setAlpha((int) (255 * placeholderAlpha));
        int cx = avatarImageView.getLeft() + avatarImageView.getMeasuredWidth() / 2;
        int cy = avatarImageView.getTop() + avatarImageView.getMeasuredHeight() / 2;
        canvas.drawCircle(cx, cy, avatarImageView.getMeasuredWidth() / 2, placeholderPaint);

        int w;

        if (placeholderNum % 2 == 0) {
            cx = AndroidUtilities.dp(65);
            w = AndroidUtilities.dp(48);
        } else {
            cx = AndroidUtilities.dp(65);
            w = AndroidUtilities.dp(60);
        }
        if (LocaleController.isRTL) {
            cx = getMeasuredWidth() - cx - w;
        }
        rect.set(cx, cy - AndroidUtilities.dp(4), cx + w, cy + AndroidUtilities.dp(4));
        canvas.drawRoundRect(rect, AndroidUtilities.dp(4), AndroidUtilities.dp(4), placeholderPaint);

        if (placeholderNum % 2 == 0) {
            cx = AndroidUtilities.dp(119);
            w = AndroidUtilities.dp(60);
        } else {
            cx = AndroidUtilities.dp(131);
            w = AndroidUtilities.dp(80);
        }
        if (LocaleController.isRTL) {
            cx = getMeasuredWidth() - cx - w;
        }
        rect.set(cx, cy - AndroidUtilities.dp(4), cx + w, cy + AndroidUtilities.dp(4));
        canvas.drawRoundRect(rect, AndroidUtilities.dp(4), AndroidUtilities.dp(4), placeholderPaint);
    }
    if (needDivider) {
        canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(64), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(64) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
    }
}
 
Example 9
Source File: SendLocationCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    LocationController.SharingLocationInfo currentInfo = LocationController.getInstance(currentAccount).getSharingLocationInfo(dialogId);
    if (currentInfo == null) {
        return;
    }
    int currentTime = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
    if (currentInfo.stopTime < currentTime) {
        return;
    }

    float progress = Math.abs(currentInfo.stopTime - currentTime) / (float) currentInfo.period;
    if (LocaleController.isRTL) {
        rect.set(AndroidUtilities.dp(13), AndroidUtilities.dp(18), AndroidUtilities.dp(43), AndroidUtilities.dp(48));
    } else {
        rect.set(getMeasuredWidth() - AndroidUtilities.dp(43), AndroidUtilities.dp(18), getMeasuredWidth() - AndroidUtilities.dp(13), AndroidUtilities.dp(48));
    }

    int color = Theme.getColor(Theme.key_location_liveLocationProgress);
    Theme.chat_radialProgress2Paint.setColor(color);
    Theme.chat_livePaint.setColor(color);

    canvas.drawArc(rect, -90, -360 * progress, false, Theme.chat_radialProgress2Paint);

    String text = LocaleController.formatLocationLeftTime(Math.abs(currentInfo.stopTime - currentTime));

    float size = Theme.chat_livePaint.measureText(text);

    canvas.drawText(text, rect.centerX() - size / 2, AndroidUtilities.dp(37), Theme.chat_livePaint);
}
 
Example 10
Source File: ThemeCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (needDivider) {
        canvas.drawLine(getPaddingLeft(), getHeight() - 1, getWidth() - getPaddingRight(), getHeight() - 1, Theme.dividerPaint);
    }
    int x = AndroidUtilities.dp(16 + 11);
    if (LocaleController.isRTL) {
        x = getWidth() - x;
    }
    canvas.drawCircle(x, AndroidUtilities.dp(13 + 11), AndroidUtilities.dp(11), paint);
}
 
Example 11
Source File: ThemeCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (needDivider) {
        canvas.drawLine(getPaddingLeft(), getHeight() - 1, getWidth() - getPaddingRight(), getHeight() - 1, Theme.dividerPaint);
    }
    int x = AndroidUtilities.dp(16 + 11);
    if (LocaleController.isRTL) {
        x = getWidth() - x;
    }
    canvas.drawCircle(x, AndroidUtilities.dp(13 + 11), AndroidUtilities.dp(11), paint);
}
 
Example 12
Source File: SettingsSearchCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
    Drawable drawable = getDrawable();
    canvas.save();
    Paint.FontMetricsInt fmPaint = paint.getFontMetricsInt();
    int fontHeight = fmPaint.descent - fmPaint.ascent;
    int centerY = y + fmPaint.descent - fontHeight / 2;
    int transY = centerY - (drawable.getBounds().bottom - drawable.getBounds().top) / 2;
    canvas.translate(x, transY);
    if (LocaleController.isRTL) {
        canvas.scale(-1, 1, drawable.getIntrinsicWidth() / 2, drawable.getIntrinsicHeight() / 2);
    }
    drawable.draw(canvas);
    canvas.restore();
}
 
Example 13
Source File: InviteTextCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int height = bottom - top;
    int width = right - left;

    int viewTop = (height - textView.getTextHeight()) / 2;
    int viewLeft = !LocaleController.isRTL ? AndroidUtilities.dp(71) : AndroidUtilities.dp(24);
    textView.layout(viewLeft, viewTop, viewLeft + textView.getMeasuredWidth(), viewTop + textView.getMeasuredHeight());

    viewTop = (height - imageView.getMeasuredHeight()) / 2;
    viewLeft = !LocaleController.isRTL ? AndroidUtilities.dp(20) : width - imageView.getMeasuredWidth() - AndroidUtilities.dp(20);
    imageView.layout(viewLeft, viewTop, viewLeft + imageView.getMeasuredWidth(), viewTop + imageView.getMeasuredHeight());
}
 
Example 14
Source File: Switch.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getCompoundPaddingLeft()
{
    if (!LocaleController.isRTL)
    {
        return super.getCompoundPaddingLeft();
    }
    return super.getCompoundPaddingLeft() + mSwitchWidth;
}
 
Example 15
Source File: RecyclerListView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    paint.setColor(Color.argb(255, colors[0] + (int) ((colors[1] - colors[0]) * bubbleProgress), colors[2] + (int) ((colors[3] - colors[2]) * bubbleProgress), colors[4] + (int) ((colors[5] - colors[4]) * bubbleProgress)));
    int y = (int) Math.ceil((getMeasuredHeight() - AndroidUtilities.dp(24 + 30)) * progress);
    rect.set(scrollX, AndroidUtilities.dp(12) + y, scrollX + AndroidUtilities.dp(5), AndroidUtilities.dp(12 + 30) + y);
    canvas.drawRoundRect(rect, AndroidUtilities.dp(2), AndroidUtilities.dp(2), paint);
    if ((pressed || bubbleProgress != 0)) {
        paint.setAlpha((int) (255 * bubbleProgress));
        int progressY = y + AndroidUtilities.dp(30);
        y -= AndroidUtilities.dp(46);
        float diff = 0;
        if (y <= AndroidUtilities.dp(12)) {
            diff = AndroidUtilities.dp(12) - y;
            y = AndroidUtilities.dp(12);
        }
        float raduisTop;
        float raduisBottom;
        canvas.translate(AndroidUtilities.dp(10), y);
        if (diff <= AndroidUtilities.dp(29)) {
            raduisTop = AndroidUtilities.dp(44);
            raduisBottom = AndroidUtilities.dp(4) + (diff / AndroidUtilities.dp(29)) * AndroidUtilities.dp(40);
        } else {
            diff -= AndroidUtilities.dp(29);
            raduisBottom = AndroidUtilities.dp(44);
            raduisTop = AndroidUtilities.dp(4) + (1.0f - diff / AndroidUtilities.dp(29)) * AndroidUtilities.dp(40);
        }
        if (LocaleController.isRTL && (radii[0] != raduisTop || radii[6] != raduisBottom) || !LocaleController.isRTL && (radii[2] != raduisTop || radii[4] != raduisBottom)) {
            if (LocaleController.isRTL) {
                radii[0] = radii[1] = raduisTop;
                radii[6] = radii[7] = raduisBottom;
            } else {
                radii[2] = radii[3] = raduisTop;
                radii[4] = radii[5] = raduisBottom;
            }
            path.reset();
            rect.set(LocaleController.isRTL ? AndroidUtilities.dp(10) : 0, 0, AndroidUtilities.dp(LocaleController.isRTL ? 98 : 88), AndroidUtilities.dp(88));
            path.addRoundRect(rect, radii, Path.Direction.CW);
            path.close();
        }
        StaticLayout layoutToDraw = letterLayout != null ? letterLayout : oldLetterLayout;
        if (layoutToDraw != null) {
            canvas.save();
            canvas.scale(bubbleProgress, bubbleProgress, scrollX, progressY - y);
            canvas.drawPath(path, paint);
            canvas.translate(textX, textY);
            layoutToDraw.draw(canvas);
            canvas.restore();
        }
    }
    if ((pressed && letterLayout != null && bubbleProgress < 1.0f) || (!pressed || letterLayout == null) && bubbleProgress > 0.0f) {
        long newTime = System.currentTimeMillis();
        long dt = (newTime - lastUpdateTime);
        if (dt < 0 || dt > 17) {
            dt = 17;
        }
        lastUpdateTime = newTime;
        invalidate();
        if (pressed && letterLayout != null) {
            bubbleProgress += dt / 120.0f;
            if (bubbleProgress > 1.0f) {
                bubbleProgress = 1.0f;
            }
        } else {
            bubbleProgress -= dt / 120.0f;
            if (bubbleProgress < 0.0f) {
                bubbleProgress = 0.0f;
            }
        }
    }
}
 
Example 16
Source File: SharedLinkCell.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (titleLayout != null) {
        canvas.save();
        canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), titleY);
        titleLayout.draw(canvas);
        canvas.restore();
    }

    if (descriptionLayout != null) {
        descriptionTextPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        canvas.save();
        canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), descriptionY);
        descriptionLayout.draw(canvas);
        canvas.restore();
    }

    if (descriptionLayout2 != null) {
        descriptionTextPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        canvas.save();
        canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), description2Y);
        descriptionLayout2.draw(canvas);
        canvas.restore();
    }

    if (!linkLayout.isEmpty()) {
        descriptionTextPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkText));
        int offset = 0;
        for (int a = 0; a < linkLayout.size(); a++) {
            StaticLayout layout = linkLayout.get(a);
            if (layout.getLineCount() > 0) {
                canvas.save();
                canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), linkY + offset);
                if (pressedLink == a) {
                    canvas.drawPath(urlPath, Theme.linkSelectionPaint);
                }
                layout.draw(canvas);
                canvas.restore();
                offset += layout.getLineBottom(layout.getLineCount() - 1);
            }
        }
    }

    letterDrawable.draw(canvas);
    if (drawLinkImageView) {
        linkImageView.draw(canvas);
    }

    if (needDivider) {
        if (LocaleController.isRTL) {
            canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, Theme.dividerPaint);
        } else {
            canvas.drawLine(AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, Theme.dividerPaint);
        }
    }
}
 
Example 17
Source File: ActionBarMenuItem.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public TextView addSubItem(int id, CharSequence text) {
    createPopupLayout();
    TextView textView = new TextView(getContext());
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    if (!LocaleController.isRTL) {
        textView.setGravity(Gravity.CENTER_VERTICAL);
    } else {
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    }
    textView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setMinWidth(AndroidUtilities.dp(196));
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setTag(id);
    textView.setText(text);
    popupLayout.addView(textView);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
    if (LocaleController.isRTL) {
        layoutParams.gravity = Gravity.RIGHT;
    }
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    textView.setLayoutParams(layoutParams);

    textView.setOnClickListener(view -> {
        if (popupWindow != null && popupWindow.isShowing()) {
            if (processedPopupClick) {
                return;
            }
            processedPopupClick = true;
            if (!allowCloseAnimation) {
                popupWindow.setAnimationStyle(R.style.PopupAnimation);
            }
            popupWindow.dismiss(allowCloseAnimation);
        }
        if (parentMenu != null) {
            parentMenu.onItemClick((Integer) view.getTag());
        } else if (delegate != null) {
            delegate.onItemClick((Integer) view.getTag());
        }
    });
    return textView;
}
 
Example 18
Source File: SessionCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public SessionCell(Context context, int type) {
    super(context);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setWeightSum(1);


    if (type == 1) {
        addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 11 : 45), 11, (LocaleController.isRTL ? 45 : 11), 0));

        avatarDrawable = new AvatarDrawable();
        avatarDrawable.setTextSize(AndroidUtilities.dp(10));

        imageView = new BackupImageView(context);
        imageView.setRoundRadius(AndroidUtilities.dp(10));
        addView(imageView, LayoutHelper.createFrame(20, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 17), 13, (LocaleController.isRTL ? 17 : 0), 0));
    } else {
        addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 11 : 17), 11, (LocaleController.isRTL ? 17 : 11), 0));
    }

    nameTextView = new TextView(context);
    nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    nameTextView.setLines(1);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);

    onlineTextView = new TextView(context);
    onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    onlineTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP);

    if (LocaleController.isRTL) {
        linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 2, 0, 0));
        linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.RIGHT | Gravity.TOP, 10, 0, 0, 0));
    } else {
        linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.LEFT | Gravity.TOP, 0, 0, 10, 0));
        linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 2, 0, 0));
    }

    detailTextView = new TextView(context);
    detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    detailTextView.setLines(1);
    detailTextView.setMaxLines(1);
    detailTextView.setSingleLine(true);
    detailTextView.setEllipsize(TextUtils.TruncateAt.END);
    detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 36, 17, 0));

    detailExTextView = new TextView(context);
    detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
    detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    detailExTextView.setLines(1);
    detailExTextView.setMaxLines(1);
    detailExTextView.setSingleLine(true);
    detailExTextView.setEllipsize(TextUtils.TruncateAt.END);
    detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 59, 17, 0));
}
 
Example 19
Source File: ActionBarMenuItem.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public TextView addSubItem(int id, CharSequence text)
{
    createPopupLayout();
    TextView textView = new TextView(getContext());
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    if (!LocaleController.isRTL)
    {
        textView.setGravity(Gravity.CENTER_VERTICAL);
    }
    else
    {
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    }
    textView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setMinWidth(AndroidUtilities.dp(196));
    textView.setTag(id);
    textView.setText(text);
    popupLayout.addView(textView);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
    if (LocaleController.isRTL)
    {
        layoutParams.gravity = Gravity.RIGHT;
    }
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    textView.setLayoutParams(layoutParams);

    textView.setOnClickListener(view ->
    {
        if (popupWindow != null && popupWindow.isShowing())
        {
            if (processedPopupClick)
            {
                return;
            }
            processedPopupClick = true;
            popupWindow.dismiss(allowCloseAnimation);
        }
        if (parentMenu != null)
        {
            parentMenu.onItemClick((Integer) view.getTag());
        }
        else if (delegate != null)
        {
            delegate.onItemClick((Integer) view.getTag());
        }
    });
    return textView;
}
 
Example 20
Source File: DialogMeUrlCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (isSelected) {
        canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), Theme.dialogs_tabletSeletedPaint);
    }

    if (drawNameLock) {
        setDrawableBounds(Theme.dialogs_lockDrawable, nameLockLeft, nameLockTop);
        Theme.dialogs_lockDrawable.draw(canvas);
    } else if (drawNameGroup) {
        setDrawableBounds(Theme.dialogs_groupDrawable, nameLockLeft, nameLockTop);
        Theme.dialogs_groupDrawable.draw(canvas);
    } else if (drawNameBroadcast) {
        setDrawableBounds(Theme.dialogs_broadcastDrawable, nameLockLeft, nameLockTop);
        Theme.dialogs_broadcastDrawable.draw(canvas);
    } else if (drawNameBot) {
        setDrawableBounds(Theme.dialogs_botDrawable, nameLockLeft, nameLockTop);
        Theme.dialogs_botDrawable.draw(canvas);
    }

    if (nameLayout != null) {
        canvas.save();
        canvas.translate(nameLeft, AndroidUtilities.dp(13));
        nameLayout.draw(canvas);
        canvas.restore();
    }

    if (messageLayout != null) {
        canvas.save();
        canvas.translate(messageLeft, messageTop);
        try {
            messageLayout.draw(canvas);
        } catch (Exception e) {
            FileLog.e(e);
        }
        canvas.restore();
    }

    if (drawVerified) {
        setDrawableBounds(Theme.dialogs_verifiedDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f));
        setDrawableBounds(Theme.dialogs_verifiedCheckDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f));
        Theme.dialogs_verifiedDrawable.draw(canvas);
        Theme.dialogs_verifiedCheckDrawable.draw(canvas);
    }

    if (useSeparator) {
        if (LocaleController.isRTL) {
            canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, Theme.dividerPaint);
        } else {
            canvas.drawLine(AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, Theme.dividerPaint);
        }
    }

    avatarImage.draw(canvas);
}