use of org.telegram.ui.Components.TypingDotsDrawable in project Telegram-FOSS by Telegram-FOSS-Team.
the class PopupNotificationActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Theme.createDialogsResources(this);
Theme.createChatResources(this, false);
AndroidUtilities.fillStatusBarHeight(this);
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.appDidLogout);
NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.messagePlayingDidReset);
NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.contactsDidLoad);
}
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.pushMessagesUpdated);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiLoaded);
classGuid = ConnectionsManager.generateClassGuid();
statusDrawables[0] = new TypingDotsDrawable(false);
statusDrawables[1] = new RecordStatusDrawable(false);
statusDrawables[2] = new SendingFileDrawable(false);
statusDrawables[3] = new PlayingGameDrawable(false, null);
statusDrawables[4] = new RoundStatusDrawable(false);
SizeNotifierFrameLayout contentView = new SizeNotifierFrameLayout(this) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(widthSize, heightSize);
int keyboardSize = measureKeyboardHeight();
if (keyboardSize <= AndroidUtilities.dp(20)) {
heightSize -= chatActivityEnterView.getEmojiPadding();
}
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
if (child.getVisibility() == GONE) {
continue;
}
if (chatActivityEnterView.isPopupView(child)) {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
} else if (chatActivityEnterView.isRecordCircle(child)) {
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
} else {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), heightSize + AndroidUtilities.dp(2)), MeasureSpec.EXACTLY));
}
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
int paddingBottom = measureKeyboardHeight() <= AndroidUtilities.dp(20) ? chatActivityEnterView.getEmojiPadding() : 0;
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == GONE) {
continue;
}
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
int width = child.getMeasuredWidth();
int height = child.getMeasuredHeight();
int childLeft;
int childTop;
int gravity = lp.gravity;
if (gravity == -1) {
gravity = Gravity.TOP | Gravity.LEFT;
}
final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
switch(absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
case Gravity.CENTER_HORIZONTAL:
childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
break;
case Gravity.RIGHT:
childLeft = r - width - lp.rightMargin;
break;
case Gravity.LEFT:
default:
childLeft = lp.leftMargin;
}
switch(verticalGravity) {
case Gravity.CENTER_VERTICAL:
childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
break;
case Gravity.BOTTOM:
childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
break;
default:
childTop = lp.topMargin;
}
if (chatActivityEnterView.isPopupView(child)) {
childTop = paddingBottom != 0 ? getMeasuredHeight() - paddingBottom : getMeasuredHeight();
} else if (chatActivityEnterView.isRecordCircle(child)) {
childTop = popupContainer.getTop() + popupContainer.getMeasuredHeight() - child.getMeasuredHeight() - lp.bottomMargin;
childLeft = popupContainer.getLeft() + popupContainer.getMeasuredWidth() - child.getMeasuredWidth() - lp.rightMargin;
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
}
notifyHeightChanged();
}
};
setContentView(contentView);
contentView.setBackgroundColor(0x99000000);
RelativeLayout relativeLayout = new RelativeLayout(this);
contentView.addView(relativeLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
popupContainer = new RelativeLayout(this) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int w = chatActivityEnterView.getMeasuredWidth();
int h = chatActivityEnterView.getMeasuredHeight();
for (int a = 0, count; a < getChildCount(); a++) {
View v = getChildAt(a);
if (v.getTag() instanceof String) {
v.measure(MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(h - AndroidUtilities.dp(3), MeasureSpec.EXACTLY));
}
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
for (int a = 0, count; a < getChildCount(); a++) {
View v = getChildAt(a);
if (v.getTag() instanceof String) {
v.layout(v.getLeft(), chatActivityEnterView.getTop() + AndroidUtilities.dp(3), v.getRight(), chatActivityEnterView.getBottom());
}
}
}
};
popupContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
relativeLayout.addView(popupContainer, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 240, 12, 0, 12, 0, RelativeLayout.CENTER_IN_PARENT));
if (chatActivityEnterView != null) {
chatActivityEnterView.onDestroy();
}
chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, false);
chatActivityEnterView.setId(id_chat_compose_panel);
popupContainer.addView(chatActivityEnterView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, RelativeLayout.ALIGN_PARENT_BOTTOM));
chatActivityEnterView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
@Override
public void onMessageSend(CharSequence message, boolean notify, int scheduleDate) {
if (currentMessageObject == null) {
return;
}
if (currentMessageNum >= 0 && currentMessageNum < popupMessages.size()) {
popupMessages.remove(currentMessageNum);
}
MessagesController.getInstance(currentMessageObject.currentAccount).markDialogAsRead(currentMessageObject.getDialogId(), currentMessageObject.getId(), Math.max(0, currentMessageObject.getId()), currentMessageObject.messageOwner.date, true, 0, 0, true, 0);
currentMessageObject = null;
getNewMessage();
}
@Override
public void onTextChanged(CharSequence text, boolean big) {
}
@Override
public void onTextSelectionChanged(int start, int end) {
}
@Override
public void onTextSpansChanged(CharSequence text) {
}
@Override
public void onStickersExpandedChange() {
}
@Override
public void onSwitchRecordMode(boolean video) {
}
@Override
public void onPreAudioVideoRecord() {
}
@Override
public void onMessageEditEnd(boolean loading) {
}
@Override
public void needSendTyping() {
if (currentMessageObject != null) {
MessagesController.getInstance(currentMessageObject.currentAccount).sendTyping(currentMessageObject.getDialogId(), 0, 0, classGuid);
}
}
@Override
public void onAttachButtonHidden() {
}
@Override
public void onAttachButtonShow() {
}
@Override
public void onWindowSizeChanged(int size) {
}
@Override
public void onStickersTab(boolean opened) {
}
@Override
public void didPressAttachButton() {
}
@Override
public void needStartRecordVideo(int state, boolean notify, int scheduleDate) {
}
@Override
public void needStartRecordAudio(int state) {
}
@Override
public void needChangeVideoPreviewState(int state, float seekProgress) {
}
@Override
public void needShowMediaBanHint() {
}
@Override
public void onUpdateSlowModeButton(View button, boolean show, CharSequence time) {
}
@Override
public void onSendLongClick() {
}
@Override
public void onAudioVideoInterfaceUpdated() {
}
});
messageContainer = new FrameLayoutTouch(this);
popupContainer.addView(messageContainer, 0);
actionBar = new ActionBar(this);
actionBar.setOccupyStatusBar(false);
actionBar.setBackButtonImage(R.drawable.ic_close_white);
actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault));
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSelector), false);
popupContainer.addView(actionBar);
ViewGroup.LayoutParams layoutParams = actionBar.getLayoutParams();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
actionBar.setLayoutParams(layoutParams);
ActionBarMenu menu = actionBar.createMenu();
ActionBarMenuItem view = menu.addItemWithWidth(2, 0, AndroidUtilities.dp(56));
countText = new TextView(this);
countText.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubtitle));
countText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
countText.setGravity(Gravity.CENTER);
view.addView(countText, LayoutHelper.createFrame(56, LayoutHelper.MATCH_PARENT));
avatarContainer = new FrameLayout(this);
avatarContainer.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
actionBar.addView(avatarContainer);
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
layoutParams2.height = LayoutHelper.MATCH_PARENT;
layoutParams2.width = LayoutHelper.WRAP_CONTENT;
layoutParams2.rightMargin = AndroidUtilities.dp(48);
layoutParams2.leftMargin = AndroidUtilities.dp(60);
layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
avatarContainer.setLayoutParams(layoutParams2);
avatarImageView = new BackupImageView(this);
avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
avatarContainer.addView(avatarImageView);
layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams();
layoutParams2.width = AndroidUtilities.dp(42);
layoutParams2.height = AndroidUtilities.dp(42);
layoutParams2.topMargin = AndroidUtilities.dp(3);
avatarImageView.setLayoutParams(layoutParams2);
nameTextView = new TextView(this);
nameTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle));
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
nameTextView.setLines(1);
nameTextView.setMaxLines(1);
nameTextView.setSingleLine(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setGravity(Gravity.LEFT);
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
avatarContainer.addView(nameTextView);
layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
layoutParams2.width = LayoutHelper.WRAP_CONTENT;
layoutParams2.height = LayoutHelper.WRAP_CONTENT;
layoutParams2.leftMargin = AndroidUtilities.dp(54);
layoutParams2.bottomMargin = AndroidUtilities.dp(22);
layoutParams2.gravity = Gravity.BOTTOM;
nameTextView.setLayoutParams(layoutParams2);
onlineTextView = new TextView(this);
onlineTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubtitle));
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
onlineTextView.setLines(1);
onlineTextView.setMaxLines(1);
onlineTextView.setSingleLine(true);
onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
onlineTextView.setGravity(Gravity.LEFT);
avatarContainer.addView(onlineTextView);
layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
layoutParams2.width = LayoutHelper.WRAP_CONTENT;
layoutParams2.height = LayoutHelper.WRAP_CONTENT;
layoutParams2.leftMargin = AndroidUtilities.dp(54);
layoutParams2.bottomMargin = AndroidUtilities.dp(4);
layoutParams2.gravity = Gravity.BOTTOM;
onlineTextView.setLayoutParams(layoutParams2);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
onFinish();
finish();
} else if (id == 1) {
openCurrentMessage();
} else if (id == 2) {
switchToNextMessage();
}
}
});
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "screen");
wakeLock.setReferenceCounted(false);
handleIntent(getIntent());
}
use of org.telegram.ui.Components.TypingDotsDrawable in project Telegram-FOSS by Telegram-FOSS-Team.
the class Theme method getChatStatusDrawable.
public static StatusDrawable getChatStatusDrawable(int type) {
if (type < 0 || type > 5) {
return null;
}
StatusDrawable statusDrawable = chat_status_drawables[type];
if (statusDrawable != null) {
return statusDrawable;
}
switch(type) {
case 0:
chat_status_drawables[0] = new TypingDotsDrawable(true);
break;
case 1:
chat_status_drawables[1] = new RecordStatusDrawable(true);
break;
case 2:
chat_status_drawables[2] = new SendingFileDrawable(true);
break;
case 3:
chat_status_drawables[3] = new PlayingGameDrawable(true, null);
break;
case 4:
chat_status_drawables[4] = new RoundStatusDrawable(true);
break;
case 5:
chat_status_drawables[5] = new ChoosingStickerStatusDrawable(true);
break;
}
statusDrawable = chat_status_drawables[type];
statusDrawable.start();
statusDrawable.setColor(getColor(key_chats_actionMessage));
return statusDrawable;
}
Aggregations