package org.telegram.ui; import android.content.Context; import android.graphics.Canvas; import android.util.TypedValue; import android.view.Gravity; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.R; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.LayoutHelper; public class PremiumFeatureCell extends FrameLayout { private final TextView title; private final TextView description; public ImageView imageView; boolean drawDivider; public PremiumPreviewFragment.PremiumFeatureData data; public PremiumFeatureCell(Context context) { super(context); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); title = new TextView(context); title.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); title.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); linearLayout.addView(title, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); description = new TextView(context); description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); description.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText)); description.setLineSpacing(AndroidUtilities.dp(2), 1f); linearLayout.addView(description, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 1, 0, 0)); addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 62, 8, 48, 9)); imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); addView(imageView, LayoutHelper.createFrame(28, 28, 0, 18, 12, 0, 0)); ImageView nextIcon = new ImageView(context); nextIcon.setScaleType(ImageView.ScaleType.CENTER_INSIDE); nextIcon.setImageResource(R.drawable.msg_arrowright); nextIcon.setColorFilter(Theme.getColor(Theme.key_switchTrack)); addView(nextIcon, LayoutHelper.createFrame(24, 24, Gravity.RIGHT | Gravity.CENTER_VERTICAL, 0, 0, 18, 0)); } public void setData(PremiumPreviewFragment.PremiumFeatureData data, boolean drawDivider) { this.data = data; title.setText(data.title); description.setText(data.description); imageView.setImageResource(data.icon); this.drawDivider = drawDivider; } @Override protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); if (drawDivider) { canvas.drawRect(AndroidUtilities.dp(62), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight(), Theme.dividerPaint); } } }