2015-05-03 13:48:36 +02:00
|
|
|
/*
|
2019-01-23 18:03:33 +01:00
|
|
|
* This is the source code of Telegram for Android v. 5.x.x
|
2015-05-03 13:48:36 +02: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.
|
2015-05-03 13:48:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui.Cells;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2017-03-31 01:58:05 +02:00
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
import android.graphics.PorterDuffColorFilter;
|
2015-05-03 13:48:36 +02:00
|
|
|
import android.util.TypedValue;
|
|
|
|
import android.view.Gravity;
|
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
2015-05-03 13:48:36 +02:00
|
|
|
import org.telegram.messenger.R;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
2015-05-03 13:48:36 +02:00
|
|
|
import org.telegram.ui.Components.LayoutHelper;
|
|
|
|
|
|
|
|
public class LocationPoweredCell extends FrameLayout {
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
private TextView textView;
|
|
|
|
private TextView textView2;
|
|
|
|
private ImageView imageView;
|
2021-09-20 00:10:42 +02:00
|
|
|
private final Theme.ResourcesProvider resourcesProvider;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
2021-09-20 00:10:42 +02:00
|
|
|
public LocationPoweredCell(Context context, Theme.ResourcesProvider resourcesProvider) {
|
2015-05-03 13:48:36 +02:00
|
|
|
super(context);
|
2021-09-20 00:10:42 +02:00
|
|
|
this.resourcesProvider = resourcesProvider;
|
2015-05-03 13:48:36 +02:00
|
|
|
|
|
|
|
LinearLayout linearLayout = new LinearLayout(context);
|
|
|
|
addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
textView = new TextView(context);
|
2015-05-03 13:48:36 +02:00
|
|
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
2021-09-20 00:10:42 +02:00
|
|
|
textView.setTextColor(getThemedColor(Theme.key_windowBackgroundWhiteGrayText3));
|
2015-05-03 13:48:36 +02:00
|
|
|
textView.setText("Powered by");
|
|
|
|
linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
imageView = new ImageView(context);
|
2015-05-03 13:48:36 +02:00
|
|
|
imageView.setImageResource(R.drawable.foursquare);
|
2021-09-20 11:14:20 +02:00
|
|
|
imageView.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_windowBackgroundWhiteGrayText3), PorterDuff.Mode.SRC_IN));
|
2015-05-03 13:48:36 +02:00
|
|
|
imageView.setPadding(0, AndroidUtilities.dp(2), 0, 0);
|
|
|
|
linearLayout.addView(imageView, LayoutHelper.createLinear(35, LayoutHelper.WRAP_CONTENT));
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
textView2 = new TextView(context);
|
|
|
|
textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
2021-09-20 00:10:42 +02:00
|
|
|
textView2.setTextColor(getThemedColor(Theme.key_windowBackgroundWhiteGrayText3));
|
2017-03-31 01:58:05 +02:00
|
|
|
textView2.setText("Foursquare");
|
|
|
|
linearLayout.addView(textView2, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
|
2015-05-03 13:48:36 +02: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(56), MeasureSpec.EXACTLY));
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2021-09-20 00:10:42 +02:00
|
|
|
|
|
|
|
private int getThemedColor(String key) {
|
|
|
|
Integer color = resourcesProvider != null ? resourcesProvider.getColor(key) : null;
|
|
|
|
return color != null ? color : Theme.getColor(key);
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|