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

55 lines
2.4 KiB
Java

package org.telegram.ui.Cells;
import android.content.Context;
import android.view.Gravity;
import android.widget.FrameLayout;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.SimpleTextView;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.LayoutHelper;
@SuppressWarnings("FieldCanBeLocal")
public class LocationDirectionCell extends FrameLayout {
private final Theme.ResourcesProvider resourcesProvider;
private SimpleTextView buttonTextView;
private FrameLayout frameLayout;
public LocationDirectionCell(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context);
this.resourcesProvider = resourcesProvider;
frameLayout = new FrameLayout(context);
frameLayout.setBackground(Theme.AdaptiveRipple.filledRect(getThemedColor(Theme.key_featuredStickers_addButton), 4));
addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP, 16, 10, 16, 0));
buttonTextView = new SimpleTextView(context);
buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
buttonTextView.setGravity(Gravity.CENTER);
buttonTextView.setDrawablePadding(AndroidUtilities.dp(8));
buttonTextView.setTextColor(getThemedColor(Theme.key_featuredStickers_buttonText));
buttonTextView.setTextSize(14);
buttonTextView.setText(LocaleController.getString("Directions", R.string.Directions));
buttonTextView.setLeftDrawable(R.drawable.navigate);
buttonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
frameLayout.addView(buttonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(73), MeasureSpec.EXACTLY));
}
public void setOnButtonClick(OnClickListener onButtonClick) {
frameLayout.setOnClickListener(onButtonClick);
}
private int getThemedColor(String key) {
Integer color = resourcesProvider != null ? resourcesProvider.getColor(key) : null;
return color != null ? color : Theme.getColor(key);
}
}