2015-09-24 22:52:02 +02:00
|
|
|
/*
|
2019-01-23 18:03:33 +01:00
|
|
|
* This is the source code of Telegram for Android v. 5.x.x.
|
2015-09-24 22:52:02 +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-09-24 22:52:02 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.util.TypedValue;
|
|
|
|
import android.view.Gravity;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
|
|
|
import org.telegram.messenger.LocaleController;
|
|
|
|
import org.telegram.messenger.R;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
2016-04-22 15:49:00 +02:00
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.ActionBar.ThemeDescription;
|
2015-09-24 22:52:02 +02:00
|
|
|
|
|
|
|
public class ChannelIntroActivity extends BaseFragment {
|
|
|
|
|
|
|
|
private ImageView imageView;
|
|
|
|
private TextView createChannelText;
|
|
|
|
private TextView whatIsChannelText;
|
|
|
|
private TextView descriptionText;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public View createView(Context context) {
|
2017-03-31 01:58:05 +02:00
|
|
|
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);
|
2015-09-24 22:52:02 +02:00
|
|
|
actionBar.setCastShadows(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 (width > height) {
|
|
|
|
imageView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.45f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.78f), MeasureSpec.EXACTLY));
|
|
|
|
whatIsChannelText.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
|
|
|
|
descriptionText.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.5f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
|
|
|
|
createChannelText.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(24), MeasureSpec.EXACTLY));
|
|
|
|
} else {
|
|
|
|
imageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.44f), MeasureSpec.EXACTLY));
|
|
|
|
whatIsChannelText.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
|
|
|
|
descriptionText.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.9f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
|
|
|
|
createChannelText.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(24), MeasureSpec.EXACTLY));
|
|
|
|
}
|
|
|
|
|
|
|
|
setMeasuredDimension(width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
|
|
int width = r - l;
|
|
|
|
int height = b - t;
|
|
|
|
|
|
|
|
if (r > b) {
|
|
|
|
int y = (int) (height * 0.05f);
|
|
|
|
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
|
|
|
|
int x = (int) (width * 0.4f);
|
|
|
|
y = (int) (height * 0.14f);
|
|
|
|
whatIsChannelText.layout(x, y, x + whatIsChannelText.getMeasuredWidth(), y + whatIsChannelText.getMeasuredHeight());
|
|
|
|
y = (int) (height * 0.61f);
|
|
|
|
createChannelText.layout(x, y, x + createChannelText.getMeasuredWidth(), y + createChannelText.getMeasuredHeight());
|
|
|
|
x = (int) (width * 0.45f);
|
|
|
|
y = (int) (height * 0.31f);
|
|
|
|
descriptionText.layout(x, y, x + descriptionText.getMeasuredWidth(), y + descriptionText.getMeasuredHeight());
|
|
|
|
} else {
|
|
|
|
int y = (int) (height * 0.05f);
|
|
|
|
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
|
|
|
|
y = (int) (height * 0.59f);
|
|
|
|
whatIsChannelText.layout(0, y, whatIsChannelText.getMeasuredWidth(), y + whatIsChannelText.getMeasuredHeight());
|
|
|
|
y = (int) (height * 0.68f);
|
|
|
|
int x = (int) (width * 0.05f);
|
|
|
|
descriptionText.layout(x, y, x + descriptionText.getMeasuredWidth(), y + descriptionText.getMeasuredHeight());
|
|
|
|
y = (int) (height * 0.86f);
|
|
|
|
createChannelText.layout(0, y, createChannelText.getMeasuredWidth(), y + createChannelText.getMeasuredHeight());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2017-03-31 01:58:05 +02:00
|
|
|
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
2015-09-24 22:52:02 +02:00
|
|
|
ViewGroup viewGroup = (ViewGroup) fragmentView;
|
2019-01-23 18:03:33 +01:00
|
|
|
viewGroup.setOnTouchListener((v, event) -> true);
|
2015-09-24 22:52:02 +02:00
|
|
|
|
|
|
|
imageView = new ImageView(context);
|
|
|
|
imageView.setImageResource(R.drawable.channelintro);
|
|
|
|
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
|
|
|
viewGroup.addView(imageView);
|
|
|
|
|
|
|
|
whatIsChannelText = new TextView(context);
|
2017-03-31 01:58:05 +02:00
|
|
|
whatIsChannelText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
2015-09-24 22:52:02 +02:00
|
|
|
whatIsChannelText.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
|
|
whatIsChannelText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
|
|
|
|
whatIsChannelText.setText(LocaleController.getString("ChannelAlertTitle", R.string.ChannelAlertTitle));
|
|
|
|
viewGroup.addView(whatIsChannelText);
|
|
|
|
|
|
|
|
descriptionText = new TextView(context);
|
2017-03-31 01:58:05 +02:00
|
|
|
descriptionText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
|
2015-09-24 22:52:02 +02:00
|
|
|
descriptionText.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
|
|
descriptionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
|
|
|
descriptionText.setText(LocaleController.getString("ChannelAlertText", R.string.ChannelAlertText));
|
|
|
|
viewGroup.addView(descriptionText);
|
|
|
|
|
|
|
|
createChannelText = new TextView(context);
|
2017-03-31 01:58:05 +02:00
|
|
|
createChannelText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText5));
|
2015-09-24 22:52:02 +02:00
|
|
|
createChannelText.setGravity(Gravity.CENTER);
|
|
|
|
createChannelText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
|
|
|
createChannelText.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
createChannelText.setText(LocaleController.getString("ChannelAlertCreate", R.string.ChannelAlertCreate));
|
|
|
|
viewGroup.addView(createChannelText);
|
2019-01-23 18:03:33 +01:00
|
|
|
createChannelText.setOnClickListener(v -> {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("step", 0);
|
|
|
|
presentFragment(new ChannelCreateActivity(args), true);
|
2015-09-24 22:52:02 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
return fragmentView;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public ThemeDescription[] getThemeDescriptions() {
|
|
|
|
return new ThemeDescription[]{
|
|
|
|
new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite),
|
|
|
|
|
|
|
|
new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite),
|
|
|
|
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2),
|
|
|
|
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarWhiteSelector),
|
|
|
|
|
|
|
|
new ThemeDescription(whatIsChannelText, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
|
|
|
|
new ThemeDescription(descriptionText, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6),
|
|
|
|
new ThemeDescription(createChannelText, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlueText5),
|
|
|
|
};
|
|
|
|
}
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|