NekoX/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCreateSectionCell.java

62 lines
2.4 KiB
Java
Raw Normal View History

2014-11-10 12:05:22 +01:00
/*
2019-01-23 18:03:33 +01:00
* This is the source code of Telegram for Android v. 5.x.x.
2014-11-10 12:05:22 +01:00
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
2019-01-23 18:03:33 +01:00
* Copyright Nikolai Kudashov, 2013-2018.
2014-11-10 12:05:22 +01:00
*/
package org.telegram.ui.Cells;
import android.content.Context;
2017-03-31 01:58:05 +02:00
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
2014-11-10 12:05:22 +01:00
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.TextView;
2015-09-24 22:52:02 +02:00
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController;
2017-03-31 01:58:05 +02:00
import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.LayoutHelper;
2014-11-10 12:05:22 +01:00
2017-03-31 01:58:05 +02:00
public class GroupCreateSectionCell extends FrameLayout {
private Drawable drawable;
2014-11-10 12:05:22 +01:00
private TextView textView;
2017-03-31 01:58:05 +02:00
public GroupCreateSectionCell(Context context) {
super(context);
2017-03-31 01:58:05 +02:00
setBackgroundColor(Theme.getColor(Theme.key_graySection));
2017-03-31 01:58:05 +02:00
drawable = getResources().getDrawable(R.drawable.shadowdown);
drawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_groupcreate_sectionShadow), PorterDuff.Mode.MULTIPLY));
2014-11-10 12:05:22 +01:00
textView = new TextView(getContext());
2017-03-31 01:58:05 +02:00
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
2014-11-10 12:05:22 +01:00
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
2017-03-31 01:58:05 +02:00
textView.setTextColor(Theme.getColor(Theme.key_groupcreate_sectionText));
2014-11-10 12:05:22 +01:00
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
2015-05-21 23:27:27 +02:00
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 16, 0, 16, 0));
2014-11-10 12:05:22 +01:00
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
2017-03-31 01:58:05 +02:00
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(40), MeasureSpec.EXACTLY));
}
@Override
protected void onDraw(Canvas canvas) {
drawable.setBounds(0, getMeasuredHeight() - AndroidUtilities.dp(3), getMeasuredWidth(), getMeasuredHeight());
drawable.draw(canvas);
2014-11-10 12:05:22 +01:00
}
public void setText(String text) {
textView.setText(text);
}
}