use of org.telegram.ui.Components.ShareLocationDrawable in project Telegram-FOSS by Telegram-FOSS-Team.
the class ActionIntroActivity method createView.
@Override
public View createView(Context context) {
if (actionBar != null) {
actionBar.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setItemsColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2), false);
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_actionBarWhiteSelector), false);
actionBar.setCastShadows(false);
actionBar.setAddToContainer(false);
if (!AndroidUtilities.isTablet()) {
actionBar.showActionModeTop();
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
}
fragmentView = new ViewGroup(context) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if (actionBar != null) {
actionBar.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), heightMeasureSpec);
}
switch(currentType) {
case ACTION_TYPE_CHANNEL_CREATE:
{
if (width > height) {
imageView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.45f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.68f), MeasureSpec.EXACTLY));
titleTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
} else {
imageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.399f), MeasureSpec.EXACTLY));
titleTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec(width - AndroidUtilities.dp(86), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
}
break;
}
case ACTION_TYPE_QR_LOGIN:
{
if (showingAsBottomSheet) {
imageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.32f), MeasureSpec.EXACTLY));
titleTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionLayout.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
height = imageView.getMeasuredHeight() + titleTextView.getMeasuredHeight() + AndroidUtilities.dp(20) + titleTextView.getMeasuredHeight() + descriptionLayout.getMeasuredHeight() + buttonTextView.getMeasuredHeight();
} else if (width > height) {
imageView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.45f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.68f), MeasureSpec.EXACTLY));
titleTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionLayout.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
} else {
imageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.399f), MeasureSpec.EXACTLY));
titleTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionLayout.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
}
break;
}
case ACTION_TYPE_NEARBY_LOCATION_ACCESS:
case ACTION_TYPE_NEARBY_LOCATION_ENABLED:
{
imageView.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(100), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(100), MeasureSpec.EXACTLY));
if (width > height) {
titleTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
} else {
titleTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
}
break;
}
case ACTION_TYPE_NEARBY_GROUP_CREATE:
{
if (width > height) {
imageView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.45f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.78f), MeasureSpec.AT_MOST));
subtitleTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.45f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
titleTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText2.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
} else {
imageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.44f), MeasureSpec.AT_MOST));
titleTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
subtitleTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText2.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
}
break;
}
case ACTION_TYPE_CHANGE_PHONE_NUMBER:
{
if (width > height) {
imageView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.45f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.78f), MeasureSpec.AT_MOST));
subtitleTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.45f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
titleTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
} else {
imageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.44f), MeasureSpec.AT_MOST));
titleTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
subtitleTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
buttonTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
}
break;
}
}
setMeasuredDimension(width, height);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (actionBar != null) {
actionBar.layout(0, 0, r, actionBar.getMeasuredHeight());
}
int width = r - l;
int height = b - t;
switch(currentType) {
case ACTION_TYPE_CHANNEL_CREATE:
{
if (r > b) {
int y = (height - imageView.getMeasuredHeight()) / 2;
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
int x = (int) (width * 0.4f);
y = (int) (height * 0.22f);
titleTextView.layout(x, y, x + titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
x = (int) (width * 0.4f);
y = (int) (height * 0.39f);
descriptionText.layout(x, y, x + descriptionText.getMeasuredWidth(), y + descriptionText.getMeasuredHeight());
x = (int) (width * 0.4f + (width * 0.6f - buttonTextView.getMeasuredWidth()) / 2);
y = (int) (height * 0.69f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
} else {
int y = (int) (height * 0.188f);
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y = (int) (height * 0.651f);
titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
y = (int) (height * 0.731f);
descriptionText.layout(0, y, descriptionText.getMeasuredWidth(), y + descriptionText.getMeasuredHeight());
int x = (width - buttonTextView.getMeasuredWidth()) / 2;
y = (int) (height * 0.853f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
}
break;
}
case ACTION_TYPE_QR_LOGIN:
{
if (showingAsBottomSheet) {
int y;
y = 0;
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y = (int) (height * 0.403f);
titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
y = (int) (height * 0.631f);
int x = (getMeasuredWidth() - descriptionLayout.getMeasuredWidth()) / 2;
descriptionLayout.layout(x, y, x + descriptionLayout.getMeasuredWidth(), y + descriptionLayout.getMeasuredHeight());
x = (width - buttonTextView.getMeasuredWidth()) / 2;
y = (int) (height * 0.853f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
} else if (r > b) {
int y = (height - imageView.getMeasuredHeight()) / 2;
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
int x = (int) (width * 0.4f);
y = (int) (height * 0.08f);
titleTextView.layout(x, y, x + titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
x = (int) (width * 0.4f + (width * 0.6f - descriptionLayout.getMeasuredWidth()) / 2);
y = (int) (height * 0.25f);
descriptionLayout.layout(x, y, x + descriptionLayout.getMeasuredWidth(), y + descriptionLayout.getMeasuredHeight());
x = (int) (width * 0.4f + (width * 0.6f - buttonTextView.getMeasuredWidth()) / 2);
y = (int) (height * 0.78f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
} else {
int y;
if (AndroidUtilities.displaySize.y < 1800) {
y = (int) (height * 0.06f);
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y = (int) (height * 0.463f);
titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
y = (int) (height * 0.543f);
} else {
y = (int) (height * 0.148f);
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y = (int) (height * 0.551f);
titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
y = (int) (height * 0.631f);
}
int x = (getMeasuredWidth() - descriptionLayout.getMeasuredWidth()) / 2;
descriptionLayout.layout(x, y, x + descriptionLayout.getMeasuredWidth(), y + descriptionLayout.getMeasuredHeight());
x = (width - buttonTextView.getMeasuredWidth()) / 2;
y = (int) (height * 0.853f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
}
break;
}
case ACTION_TYPE_NEARBY_LOCATION_ACCESS:
case ACTION_TYPE_NEARBY_LOCATION_ENABLED:
{
if (r > b) {
int y = (height - imageView.getMeasuredHeight()) / 2;
int x = (int) (width * 0.5f - imageView.getMeasuredWidth()) / 2;
imageView.layout(x, y, x + imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
x = (int) (width * 0.4f);
y = (int) (height * 0.14f);
titleTextView.layout(x, y, x + titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
x = (int) (width * 0.4f);
y = (int) (height * 0.31f);
descriptionText.layout(x, y, x + descriptionText.getMeasuredWidth(), y + descriptionText.getMeasuredHeight());
x = (int) (width * 0.4f + (width * 0.6f - buttonTextView.getMeasuredWidth()) / 2);
y = (int) (height * 0.78f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
} else {
int y = (int) (height * 0.214f);
int x = (width - imageView.getMeasuredWidth()) / 2;
imageView.layout(x, y, x + imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y = (int) (height * 0.414f);
titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
y = (int) (height * 0.493f);
descriptionText.layout(0, y, descriptionText.getMeasuredWidth(), y + descriptionText.getMeasuredHeight());
x = (width - buttonTextView.getMeasuredWidth()) / 2;
y = (int) (height * 0.71f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
}
break;
}
case ACTION_TYPE_NEARBY_GROUP_CREATE:
{
if (r > b) {
int y = (int) (height * 0.9f - imageView.getMeasuredHeight()) / 2;
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y += imageView.getMeasuredHeight() + AndroidUtilities.dp(10);
subtitleTextView.layout(0, y, subtitleTextView.getMeasuredWidth(), y + subtitleTextView.getMeasuredHeight());
int x = (int) (width * 0.4f);
y = (int) (height * 0.12f);
titleTextView.layout(x, y, x + titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
x = (int) (width * 0.4f);
y = (int) (height * 0.26f);
descriptionText.layout(x, y, x + descriptionText.getMeasuredWidth(), y + descriptionText.getMeasuredHeight());
x = (int) (width * 0.4f + (width * 0.6f - buttonTextView.getMeasuredWidth()) / 2);
y = (int) (height * 0.6f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
x = (int) (width * 0.4f);
y = getMeasuredHeight() - descriptionText2.getMeasuredHeight() - AndroidUtilities.dp(20);
descriptionText2.layout(x, y, x + descriptionText2.getMeasuredWidth(), y + descriptionText2.getMeasuredHeight());
} else {
int y = (int) (height * 0.197f);
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y = (int) (height * 0.421f);
titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
y = (int) (height * 0.477f);
subtitleTextView.layout(0, y, subtitleTextView.getMeasuredWidth(), y + subtitleTextView.getMeasuredHeight());
y = (int) (height * 0.537f);
descriptionText.layout(0, y, descriptionText.getMeasuredWidth(), y + descriptionText.getMeasuredHeight());
int x = (width - buttonTextView.getMeasuredWidth()) / 2;
y = (int) (height * 0.71f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
y = getMeasuredHeight() - descriptionText2.getMeasuredHeight() - AndroidUtilities.dp(20);
descriptionText2.layout(0, y, descriptionText2.getMeasuredWidth(), y + descriptionText2.getMeasuredHeight());
}
break;
}
case ACTION_TYPE_CHANGE_PHONE_NUMBER:
{
if (r > b) {
int y = (int) (height * 0.95f - imageView.getMeasuredHeight()) / 2;
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y += imageView.getMeasuredHeight() + AndroidUtilities.dp(10);
subtitleTextView.layout(0, y, subtitleTextView.getMeasuredWidth(), y + subtitleTextView.getMeasuredHeight());
int x = (int) (width * 0.4f);
y = (int) (height * 0.12f);
titleTextView.layout(x, y, x + titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
x = (int) (width * 0.4f);
y = (int) (height * 0.24f);
descriptionText.layout(x, y, x + descriptionText.getMeasuredWidth(), y + descriptionText.getMeasuredHeight());
x = (int) (width * 0.4f + (width * 0.6f - buttonTextView.getMeasuredWidth()) / 2);
y = (int) (height * 0.8f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
} else {
int y = (int) (height * 0.2229f);
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y = (int) (height * 0.352f);
titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
y = (int) (height * 0.409f);
subtitleTextView.layout(0, y, subtitleTextView.getMeasuredWidth(), y + subtitleTextView.getMeasuredHeight());
y = (int) (height * 0.468f);
descriptionText.layout(0, y, descriptionText.getMeasuredWidth(), y + descriptionText.getMeasuredHeight());
int x = (width - buttonTextView.getMeasuredWidth()) / 2;
y = (int) (height * 0.805f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
}
break;
}
}
}
};
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
ViewGroup viewGroup = (ViewGroup) fragmentView;
viewGroup.setOnTouchListener((v, event) -> true);
if (actionBar != null) {
viewGroup.addView(actionBar);
}
imageView = new RLottieImageView(context);
viewGroup.addView(imageView);
titleTextView = new TextView(context);
titleTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
titleTextView.setGravity(Gravity.CENTER_HORIZONTAL);
titleTextView.setPadding(AndroidUtilities.dp(32), 0, AndroidUtilities.dp(32), 0);
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
viewGroup.addView(titleTextView);
subtitleTextView = new TextView(context);
subtitleTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
subtitleTextView.setGravity(Gravity.CENTER_HORIZONTAL);
subtitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
subtitleTextView.setSingleLine(true);
subtitleTextView.setEllipsize(TextUtils.TruncateAt.END);
if (currentType == ACTION_TYPE_NEARBY_GROUP_CREATE) {
subtitleTextView.setPadding(AndroidUtilities.dp(24), 0, AndroidUtilities.dp(24), 0);
} else {
subtitleTextView.setPadding(AndroidUtilities.dp(32), 0, AndroidUtilities.dp(32), 0);
}
subtitleTextView.setVisibility(View.GONE);
viewGroup.addView(subtitleTextView);
descriptionText = new TextView(context);
descriptionText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
descriptionText.setGravity(Gravity.CENTER_HORIZONTAL);
descriptionText.setLineSpacing(AndroidUtilities.dp(2), 1);
descriptionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
if (currentType == ACTION_TYPE_NEARBY_GROUP_CREATE) {
descriptionText.setPadding(AndroidUtilities.dp(24), 0, AndroidUtilities.dp(24), 0);
} else {
descriptionText.setPadding(AndroidUtilities.dp(32), 0, AndroidUtilities.dp(32), 0);
}
viewGroup.addView(descriptionText);
if (currentType == ACTION_TYPE_QR_LOGIN) {
descriptionLayout = new LinearLayout(context);
descriptionLayout.setOrientation(LinearLayout.VERTICAL);
descriptionLayout.setPadding(AndroidUtilities.dp(24), 0, AndroidUtilities.dp(24), 0);
descriptionLayout.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
viewGroup.addView(descriptionLayout);
for (int a = 0; a < 3; a++) {
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
descriptionLayout.addView(linearLayout, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, a != 2 ? 7 : 0));
desctiptionLines[a * 2] = new TextView(context);
desctiptionLines[a * 2].setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
desctiptionLines[a * 2].setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
desctiptionLines[a * 2].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
desctiptionLines[a * 2].setText(String.format(LocaleController.isRTL ? ".%d" : "%d.", a + 1));
desctiptionLines[a * 2].setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
desctiptionLines[a * 2 + 1] = new TextView(context);
desctiptionLines[a * 2 + 1].setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
desctiptionLines[a * 2 + 1].setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
desctiptionLines[a * 2 + 1].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
if (a == 0) {
desctiptionLines[a * 2 + 1].setLinkTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkText));
desctiptionLines[a * 2 + 1].setHighlightColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkSelection));
String text = LocaleController.getString("AuthAnotherClientInfo1", R.string.AuthAnotherClientInfo1);
SpannableStringBuilder spanned = new SpannableStringBuilder(text);
int index1 = text.indexOf('*');
int index2 = text.lastIndexOf('*');
if (index1 != -1 && index2 != -1 && index1 != index2) {
desctiptionLines[a * 2 + 1].setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
spanned.replace(index2, index2 + 1, "");
spanned.replace(index1, index1 + 1, "");
spanned.setSpan(new URLSpanNoUnderline(LocaleController.getString("AuthAnotherClientDownloadClientUrl", R.string.AuthAnotherClientDownloadClientUrl)), index1, index2 - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
desctiptionLines[a * 2 + 1].setText(spanned);
} else if (a == 1) {
desctiptionLines[a * 2 + 1].setText(LocaleController.getString("AuthAnotherClientInfo2", R.string.AuthAnotherClientInfo2));
} else {
desctiptionLines[a * 2 + 1].setText(LocaleController.getString("AuthAnotherClientInfo3", R.string.AuthAnotherClientInfo3));
}
if (LocaleController.isRTL) {
linearLayout.setGravity(Gravity.RIGHT);
linearLayout.addView(desctiptionLines[a * 2 + 1], LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1.0f));
linearLayout.addView(desctiptionLines[a * 2], LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 4, 0, 0, 0));
} else {
linearLayout.addView(desctiptionLines[a * 2], LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 0, 4, 0));
linearLayout.addView(desctiptionLines[a * 2 + 1], LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
}
}
descriptionText.setVisibility(View.GONE);
}
descriptionText2 = new TextView(context);
descriptionText2.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
descriptionText2.setGravity(Gravity.CENTER_HORIZONTAL);
descriptionText2.setLineSpacing(AndroidUtilities.dp(2), 1);
descriptionText2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
descriptionText2.setVisibility(View.GONE);
if (currentType == ACTION_TYPE_NEARBY_GROUP_CREATE) {
descriptionText2.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0);
} else {
descriptionText2.setPadding(AndroidUtilities.dp(32), 0, AndroidUtilities.dp(32), 0);
}
viewGroup.addView(descriptionText2);
buttonTextView = new TextView(context) {
CellFlickerDrawable cellFlickerDrawable;
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (flickerButton) {
if (cellFlickerDrawable == null) {
cellFlickerDrawable = new CellFlickerDrawable();
cellFlickerDrawable.drawFrame = false;
cellFlickerDrawable.repeatProgress = 2f;
}
cellFlickerDrawable.setParentWidth(getMeasuredWidth());
AndroidUtilities.rectTmp.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
cellFlickerDrawable.draw(canvas, AndroidUtilities.rectTmp, AndroidUtilities.dp(4));
invalidate();
}
}
};
buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
buttonTextView.setGravity(Gravity.CENTER);
buttonTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
buttonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
buttonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
buttonTextView.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
viewGroup.addView(buttonTextView);
buttonTextView.setOnClickListener(v -> {
if (getParentActivity() == null) {
return;
}
switch(currentType) {
case ACTION_TYPE_QR_LOGIN:
{
if (getParentActivity() == null) {
return;
}
if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
getParentActivity().requestPermissions(new String[] { Manifest.permission.CAMERA }, CAMERA_PERMISSION_REQUEST_CODE);
return;
}
processOpenQrReader();
break;
}
case ACTION_TYPE_CHANNEL_CREATE:
{
Bundle args = new Bundle();
args.putInt("step", 0);
presentFragment(new ChannelCreateActivity(args), true);
break;
}
case ACTION_TYPE_NEARBY_LOCATION_ACCESS:
{
getParentActivity().requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION }, 2);
break;
}
case ACTION_TYPE_NEARBY_LOCATION_ENABLED:
{
try {
getParentActivity().startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
} catch (Exception e) {
FileLog.e(e);
}
break;
}
case ACTION_TYPE_NEARBY_GROUP_CREATE:
{
if (currentGroupCreateAddress == null || currentGroupCreateLocation == null) {
return;
}
Bundle args = new Bundle();
long[] array = new long[] { getUserConfig().getClientUserId() };
args.putLongArray("result", array);
args.putInt("chatType", ChatObject.CHAT_TYPE_MEGAGROUP);
args.putString("address", currentGroupCreateAddress);
args.putParcelable("location", currentGroupCreateLocation);
presentFragment(new GroupCreateFinalActivity(args), true);
break;
}
case ACTION_TYPE_CHANGE_PHONE_NUMBER:
{
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("PhoneNumberChangeTitle", R.string.PhoneNumberChangeTitle));
builder.setMessage(LocaleController.getString("PhoneNumberAlert", R.string.PhoneNumberAlert));
builder.setPositiveButton(LocaleController.getString("Change", R.string.Change), (dialogInterface, i) -> presentFragment(new ChangePhoneActivity(), true));
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
break;
}
}
});
switch(currentType) {
case ACTION_TYPE_CHANNEL_CREATE:
{
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
imageView.setAnimation(R.raw.channel_create, 200, 200);
titleTextView.setText(LocaleController.getString("ChannelAlertTitle", R.string.ChannelAlertTitle));
descriptionText.setText(LocaleController.getString("ChannelAlertText", R.string.ChannelAlertText));
buttonTextView.setText(LocaleController.getString("ChannelAlertCreate2", R.string.ChannelAlertCreate2));
imageView.playAnimation();
flickerButton = true;
break;
}
case ACTION_TYPE_NEARBY_LOCATION_ACCESS:
{
imageView.setBackgroundDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(100), Theme.getColor(Theme.key_chats_archiveBackground)));
imageView.setImageDrawable(new ShareLocationDrawable(context, 3));
imageView.setScaleType(ImageView.ScaleType.CENTER);
titleTextView.setText(LocaleController.getString("PeopleNearby", R.string.PeopleNearby));
descriptionText.setText(LocaleController.getString("PeopleNearbyAccessInfo", R.string.PeopleNearbyAccessInfo));
buttonTextView.setText(LocaleController.getString("PeopleNearbyAllowAccess", R.string.PeopleNearbyAllowAccess));
break;
}
case ACTION_TYPE_NEARBY_LOCATION_ENABLED:
{
imageView.setBackgroundDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(100), Theme.getColor(Theme.key_chats_archiveBackground)));
imageView.setImageDrawable(new ShareLocationDrawable(context, 3));
imageView.setScaleType(ImageView.ScaleType.CENTER);
titleTextView.setText(LocaleController.getString("PeopleNearby", R.string.PeopleNearby));
descriptionText.setText(LocaleController.getString("PeopleNearbyGpsInfo", R.string.PeopleNearbyGpsInfo));
buttonTextView.setText(LocaleController.getString("PeopleNearbyGps", R.string.PeopleNearbyGps));
break;
}
case ACTION_TYPE_QR_LOGIN:
{
colors = new int[8];
updateColors();
imageView.setAnimation(R.raw.qr_login, 334, 334, colors);
imageView.setScaleType(ImageView.ScaleType.CENTER);
titleTextView.setText(LocaleController.getString("AuthAnotherClient", R.string.AuthAnotherClient));
buttonTextView.setText(LocaleController.getString("AuthAnotherClientScan", R.string.AuthAnotherClientScan));
imageView.playAnimation();
break;
}
case ACTION_TYPE_NEARBY_GROUP_CREATE:
{
subtitleTextView.setVisibility(View.VISIBLE);
descriptionText2.setVisibility(View.VISIBLE);
imageView.setImageResource(Theme.getCurrentTheme().isDark() ? R.drawable.groupsintro2 : R.drawable.groupsintro);
imageView.setScaleType(ImageView.ScaleType.CENTER);
subtitleTextView.setText(currentGroupCreateDisplayAddress != null ? currentGroupCreateDisplayAddress : "");
titleTextView.setText(LocaleController.getString("NearbyCreateGroup", R.string.NearbyCreateGroup));
descriptionText.setText(LocaleController.getString("NearbyCreateGroupInfo", R.string.NearbyCreateGroupInfo));
descriptionText2.setText(LocaleController.getString("NearbyCreateGroupInfo2", R.string.NearbyCreateGroupInfo2));
buttonTextView.setText(LocaleController.getString("NearbyStartGroup", R.string.NearbyStartGroup));
break;
}
case ACTION_TYPE_CHANGE_PHONE_NUMBER:
{
subtitleTextView.setVisibility(View.VISIBLE);
drawable1 = context.getResources().getDrawable(R.drawable.sim_old);
drawable2 = context.getResources().getDrawable(R.drawable.sim_new);
drawable1.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_changephoneinfo_image), PorterDuff.Mode.MULTIPLY));
drawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_changephoneinfo_image2), PorterDuff.Mode.MULTIPLY));
imageView.setImageDrawable(new CombinedDrawable(drawable1, drawable2));
imageView.setScaleType(ImageView.ScaleType.CENTER);
UserConfig userConfig = getUserConfig();
TLRPC.User user = getMessagesController().getUser(userConfig.clientUserId);
if (user == null) {
user = userConfig.getCurrentUser();
}
if (user != null) {
subtitleTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
}
titleTextView.setText(LocaleController.getString("PhoneNumberChange2", R.string.PhoneNumberChange2));
descriptionText.setText(AndroidUtilities.replaceTags(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp)));
buttonTextView.setText(LocaleController.getString("PhoneNumberChange2", R.string.PhoneNumberChange2));
break;
}
}
if (flickerButton) {
buttonTextView.setPadding(AndroidUtilities.dp(34), AndroidUtilities.dp(8), AndroidUtilities.dp(34), AndroidUtilities.dp(8));
buttonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
}
return fragmentView;
}
Aggregations