2014-11-10 12:05:22 +01:00
|
|
|
/*
|
2015-10-29 18:10:07 +01:00
|
|
|
* This is the source code of Telegram for Android v. 3.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).
|
|
|
|
*
|
2016-01-11 18:19:48 +01:00
|
|
|
* Copyright Nikolai Kudashov, 2013-2016.
|
2014-11-10 12:05:22 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui.Cells;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.graphics.drawable.Drawable;
|
2014-11-12 23:16:59 +01:00
|
|
|
import android.text.TextUtils;
|
2014-11-10 12:05:22 +01:00
|
|
|
import android.util.TypedValue;
|
|
|
|
import android.view.Gravity;
|
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
|
|
|
import org.telegram.messenger.LocaleController;
|
2015-05-03 13:48:36 +02:00
|
|
|
import org.telegram.ui.Components.LayoutHelper;
|
2014-11-10 12:05:22 +01:00
|
|
|
|
|
|
|
public class TextCell extends FrameLayout {
|
|
|
|
|
|
|
|
private TextView textView;
|
|
|
|
private TextView valueTextView;
|
|
|
|
private ImageView imageView;
|
|
|
|
private ImageView valueImageView;
|
|
|
|
|
|
|
|
public TextCell(Context context) {
|
|
|
|
super(context);
|
|
|
|
|
|
|
|
textView = new TextView(context);
|
2014-11-17 03:44:57 +01:00
|
|
|
textView.setTextColor(0xff212121);
|
2014-11-10 12:05:22 +01:00
|
|
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
|
|
|
textView.setLines(1);
|
|
|
|
textView.setMaxLines(1);
|
|
|
|
textView.setSingleLine(true);
|
2014-11-12 23:16:59 +01:00
|
|
|
textView.setEllipsize(TextUtils.TruncateAt.END);
|
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, LocaleController.isRTL ? 16 : 71, 0, LocaleController.isRTL ? 71 : 16, 0));
|
2014-11-10 12:05:22 +01:00
|
|
|
|
|
|
|
valueTextView = new TextView(context);
|
|
|
|
valueTextView.setTextColor(0xff2f8cc9);
|
|
|
|
valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
|
|
|
valueTextView.setLines(1);
|
|
|
|
valueTextView.setMaxLines(1);
|
|
|
|
valueTextView.setSingleLine(true);
|
|
|
|
valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
|
2015-05-21 23:27:27 +02:00
|
|
|
addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 24 : 0, 0, LocaleController.isRTL ? 0 : 24, 0));
|
2014-11-10 12:05:22 +01:00
|
|
|
|
|
|
|
imageView = new ImageView(context);
|
|
|
|
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
2015-09-24 22:52:02 +02:00
|
|
|
addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 16, 5, LocaleController.isRTL ? 16 : 0, 0));
|
2014-11-10 12:05:22 +01:00
|
|
|
|
|
|
|
valueImageView = new ImageView(context);
|
|
|
|
valueImageView.setScaleType(ImageView.ScaleType.CENTER);
|
2015-05-21 23:27:27 +02:00
|
|
|
addView(valueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 24 : 0, 0, LocaleController.isRTL ? 0 : 24, 0));
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
2015-11-26 22:04:02 +01:00
|
|
|
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setTextColor(int color) {
|
|
|
|
textView.setTextColor(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setText(String text) {
|
|
|
|
textView.setText(text);
|
2015-04-09 20:00:14 +02:00
|
|
|
imageView.setVisibility(INVISIBLE);
|
|
|
|
valueTextView.setVisibility(INVISIBLE);
|
|
|
|
valueImageView.setVisibility(INVISIBLE);
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setTextAndIcon(String text, int resId) {
|
|
|
|
textView.setText(text);
|
|
|
|
imageView.setImageResource(resId);
|
|
|
|
imageView.setVisibility(VISIBLE);
|
2015-04-09 20:00:14 +02:00
|
|
|
valueTextView.setVisibility(INVISIBLE);
|
|
|
|
valueImageView.setVisibility(INVISIBLE);
|
2015-11-26 22:04:02 +01:00
|
|
|
imageView.setPadding(0, AndroidUtilities.dp(7), 0, 0);
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
|
2014-11-10 12:05:22 +01:00
|
|
|
public void setTextAndValue(String text, String value) {
|
|
|
|
textView.setText(text);
|
|
|
|
valueTextView.setText(value);
|
|
|
|
valueTextView.setVisibility(VISIBLE);
|
2015-04-09 20:00:14 +02:00
|
|
|
imageView.setVisibility(INVISIBLE);
|
|
|
|
valueImageView.setVisibility(INVISIBLE);
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setTextAndValueDrawable(String text, Drawable drawable) {
|
|
|
|
textView.setText(text);
|
|
|
|
valueImageView.setVisibility(VISIBLE);
|
|
|
|
valueImageView.setImageDrawable(drawable);
|
2015-04-09 20:00:14 +02:00
|
|
|
valueTextView.setVisibility(INVISIBLE);
|
|
|
|
imageView.setVisibility(INVISIBLE);
|
2015-11-26 22:04:02 +01:00
|
|
|
imageView.setPadding(0, AndroidUtilities.dp(7), 0, 0);
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
|
|
|
}
|