More Android L design

This commit is contained in:
DrKLO 2014-11-13 01:16:59 +03:00
parent 4104a21f6d
commit ea0b86d023
33 changed files with 1208 additions and 2021 deletions

View File

@ -225,11 +225,13 @@ public class ImageReceiver {
if (bitmapDrawable != null) {
if (bitmapShader != null) {
drawRegion.set(imageX, imageY, imageX + imageW, imageY + imageH);
if (isVisible) {
roundRect.set(drawRegion);
shaderMatrix.reset();
shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.FILL);
bitmapShader.setLocalMatrix(shaderMatrix);
canvas.drawRoundRect(roundRect, roundRadius, roundRadius, roundPaint);
}
} else {
int bitmapW = bitmapDrawable.getIntrinsicWidth();
int bitmapH = bitmapDrawable.getIntrinsicHeight();
@ -412,10 +414,12 @@ public class ImageReceiver {
public void setRoundRadius(int value) {
roundRadius = value;
if (roundRadius != 0) {
if (roundPaint == null) {
roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
roundRect = new RectF();
shaderMatrix = new Matrix();
bitmapRect = new RectF();
}
} else {
roundPaint = null;
roundRect = null;

View File

@ -18,6 +18,7 @@ import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController;
import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.ui.AnimationCompat.ViewProxy;
import org.telegram.ui.Cells.DividerCell;
import org.telegram.ui.Cells.GreySectionCell;
import org.telegram.ui.Cells.LetterSectionCell;
@ -28,6 +29,7 @@ import java.util.ArrayList;
import java.util.HashMap;
public class ContactsActivityAdapter extends BaseSectionsAdapter {
private Context mContext;
private boolean onlyUsers;
private boolean needPhonebook;
@ -203,18 +205,18 @@ public class ContactsActivityAdapter extends BaseSectionsAdapter {
}
} else if (type == 0) {
if (convertView == null) {
convertView = new UserCell(mContext);
convertView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 16 : 54), 0, 0, 0);
convertView = new UserCell(mContext, 58);
((UserCell) convertView).setStatusColors(0xffa8a8a8, 0xff3b84c0);
}
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - (onlyUsers ? 0 : 1)));
TLRPC.User user = MessagesController.getInstance().getUser(arr.get(position).user_id);
((UserCell)convertView).setData(user, null, null);
((UserCell)convertView).setData(user, null, null, 0);
if (ignoreUsers != null) {
if (ignoreUsers.containsKey(user.id)) {
((UserCell)convertView).drawAlpha = 0.5f;
ViewProxy.setAlpha(convertView, 0.5f);
} else {
((UserCell)convertView).drawAlpha = 1.0f;
ViewProxy.setAlpha(convertView, 1.0f);
}
}
}

View File

@ -702,8 +702,6 @@ public class DialogCell extends BaseCell {
canvas.restore();
}
avatarImage.draw(canvas);
if (useSeparator) {
if (LocaleController.isRTL) {
canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(72), getMeasuredHeight() - 1, linePaint);
@ -711,5 +709,7 @@ public class DialogCell extends BaseCell {
canvas.drawLine(AndroidUtilities.dp(72), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, linePaint);
}
}
avatarImage.draw(canvas);
}
}

View File

@ -17,11 +17,19 @@ public class EmptyCell extends FrameLayout {
int cellHeight;
public EmptyCell(Context context) {
this(context, 8);
}
public EmptyCell(Context context, int height) {
super(context);
cellHeight = height;
}
public void setHeight(int height) {
cellHeight = height;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(cellHeight), MeasureSpec.EXACTLY));

View File

@ -10,6 +10,7 @@ package org.telegram.ui.Cells;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
@ -35,6 +36,7 @@ public class TextCell extends FrameLayout {
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
addView(textView);
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();

View File

@ -25,6 +25,7 @@ public class TextDetailSettingsCell extends FrameLayout {
private TextView valueTextView;
private static Paint paint;
private boolean needDivider;
private boolean multiline;
public TextDetailSettingsCell(Context context) {
super(context);
@ -73,7 +74,7 @@ public class TextDetailSettingsCell extends FrameLayout {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (valueTextView.getMaxLines() == 1) {
if (!multiline) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
} else {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
@ -81,6 +82,7 @@ public class TextDetailSettingsCell extends FrameLayout {
}
public void setMultilineDetail(boolean value) {
multiline = value;
if (value) {
valueTextView.setLines(0);
valueTextView.setMaxLines(0);

View File

@ -1,302 +1,214 @@
/*
* This is the source code of Telegram for Android v. 1.3.x.
* This is the source code of Telegram for Android v. 1.7.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013.
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.ui.Cells;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.android.MessagesController;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.android.ImageReceiver;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Views.BackupImageView;
public class UserCell extends BaseCell {
private static TextPaint namePaint;
private static TextPaint onlinePaint;
private static TextPaint offlinePaint;
private static Paint linePaint;
public class UserCell extends FrameLayout {
private BackupImageView avatarImageView;
private TextView nameTextView;
private TextView statusTextView;
private ImageView imageView;
private AvatarDrawable avatarDrawable;
private TLRPC.User currentUser = null;
private CharSequence currentName;
private ImageReceiver avatarImage;
private AvatarDrawable avatarDrawable;
private CharSequence subLabel;
private TLRPC.User user = null;
private CharSequence currrntStatus;
private int currentDrawable;
private String lastName = null;
private int lastStatus = 0;
private TLRPC.FileLocation lastAvatar = null;
public boolean useSeparator = false;
public float drawAlpha = 1;
private int statusColor = 0xffa8a8a8;
private int statusOnlineColor = 0xff3b84c0;
private int nameLeft;
private int nameTop;
private StaticLayout nameLayout;
private int onlineLeft;
private int onlineTop = AndroidUtilities.dp(36);
private StaticLayout onlineLayout;
public UserCell(Context context) {
public UserCell(Context context, int padding) {
super(context);
init();
avatarImage = new ImageReceiver(this);
avatarImage.setRoundRadius(AndroidUtilities.dp(24));
avatarImageView = new BackupImageView(context);
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(24));
addView(avatarImageView);
LayoutParams layoutParams = (LayoutParams) avatarImageView.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(48);
layoutParams.height = AndroidUtilities.dp(48);
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(7 + padding);
layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(7 + padding) : 0;
layoutParams.topMargin = AndroidUtilities.dp(8);
avatarImageView.setLayoutParams(layoutParams);
avatarDrawable = new AvatarDrawable();
nameTextView = new TextView(context);
nameTextView.setTextColor(0xff000000);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
nameTextView.setLines(1);
nameTextView.setMaxLines(1);
nameTextView.setSingleLine(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
addView(nameTextView);
layoutParams = (LayoutParams) nameTextView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : (68 + padding));
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? (68 + padding) : 16);
layoutParams.topMargin = AndroidUtilities.dp(10.5f);
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
nameTextView.setLayoutParams(layoutParams);
statusTextView = new TextView(context);
statusTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
statusTextView.setLines(1);
statusTextView.setMaxLines(1);
statusTextView.setSingleLine(true);
statusTextView.setEllipsize(TextUtils.TruncateAt.END);
statusTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
addView(statusTextView);
layoutParams = (LayoutParams) statusTextView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : (68 + padding));
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? (68 + padding) : 16);
layoutParams.topMargin = AndroidUtilities.dp(33.5f);
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
statusTextView.setLayoutParams(layoutParams);
imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.CENTER);
addView(imageView);
layoutParams = (LayoutParams) imageView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL;
imageView.setLayoutParams(layoutParams);
}
private void init() {
if (namePaint == null) {
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
namePaint.setTextSize(AndroidUtilities.dp(18));
namePaint.setColor(0xff222222);
onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
onlinePaint.setTextSize(AndroidUtilities.dp(15));
onlinePaint.setColor(0xff316f9f);
offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
offlinePaint.setTextSize(AndroidUtilities.dp(15));
offlinePaint.setColor(0xff999999);
linePaint = new Paint();
linePaint.setColor(0xffdcdcdc);
public void setData(TLRPC.User user, CharSequence name, CharSequence status, int resId) {
if (user == null) {
currrntStatus = null;
currentName = null;
currentUser = null;
nameTextView.setText("");
statusTextView.setText("");
avatarImageView.setImageDrawable(null);
return;
}
}
public void setData(TLRPC.User u, CharSequence n, CharSequence s) {
currentName = n;
user = u;
subLabel = s;
currrntStatus = status;
currentName = name;
currentUser = user;
currentDrawable = resId;
update(0);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (avatarImage != null) {
avatarImage.clearImage();
lastAvatar = null;
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec) - getPaddingRight(), AndroidUtilities.dp(64));
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), MeasureSpec.EXACTLY));
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (user == null) {
super.onLayout(changed, left, top, right, bottom);
return;
}
if (changed) {
buildLayout();
}
}
public void buildLayout() {
int paddingLeft = getPaddingLeft();
int paddingRight = getPaddingRight();
onlineLeft = nameLeft = AndroidUtilities.dp(LocaleController.isRTL ? 11 : 72) + paddingLeft;
int avatarLeft = paddingLeft + (LocaleController.isRTL ? (getMeasuredWidth() - AndroidUtilities.dp(61)) : AndroidUtilities.dp(11));
int nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(LocaleController.isRTL ? 72 : 14);
int avatarTop = AndroidUtilities.dp(8);
CharSequence nameString = "";
if (currentName != null) {
nameString = currentName;
} else {
String nameString2 = "";
if (user != null) {
nameString2 = ContactsController.formatName(user.first_name, user.last_name);
}
nameString = nameString2.replace("\n", " ");
}
if (nameString.length() == 0) {
if (user != null && user.phone != null && user.phone.length() != 0) {
nameString = PhoneFormat.getInstance().format("+" + user.phone);
} else {
nameString = LocaleController.getString("HiddenName", R.string.HiddenName);
}
}
CharSequence nameStringFinal = TextUtils.ellipsize(nameString, namePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
nameLayout = new StaticLayout(nameStringFinal, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
CharSequence onlineString = "";
TextPaint currentOnlinePaint = offlinePaint;
if (subLabel != null) {
onlineString = subLabel;
} else {
onlineString = LocaleController.formatUserStatus(user);
if (user != null && (user.id == UserConfig.getClientUserId() || user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime())) {
currentOnlinePaint = onlinePaint;
onlineString = LocaleController.getString("Online", R.string.Online);
}
}
CharSequence onlineStringFinal = TextUtils.ellipsize(onlineString, currentOnlinePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
onlineLayout = new StaticLayout(onlineStringFinal, currentOnlinePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
nameTop = AndroidUtilities.dp(12);
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(48), AndroidUtilities.dp(48));
double widthpx = 0;
float left = 0;
if (LocaleController.isRTL) {
if (nameLayout.getLineCount() > 0) {
left = nameLayout.getLineLeft(0);
if (left == 0) {
widthpx = Math.ceil(nameLayout.getLineWidth(0));
if (widthpx < nameWidth) {
nameLeft += (nameWidth - widthpx);
}
}
}
if (onlineLayout != null && onlineLayout.getLineCount() > 0) {
left = onlineLayout.getLineLeft(0);
if (left == 0) {
widthpx = Math.ceil(onlineLayout.getLineWidth(0));
if (widthpx < nameWidth) {
onlineLeft += (nameWidth - widthpx);
}
}
}
} else {
if (nameLayout.getLineCount() > 0) {
left = nameLayout.getLineRight(0);
if (left == nameWidth) {
widthpx = Math.ceil(nameLayout.getLineWidth(0));
if (widthpx < nameWidth) {
nameLeft -= (nameWidth - widthpx);
}
}
}
if (onlineLayout != null && onlineLayout.getLineCount() > 0) {
left = onlineLayout.getLineRight(0);
if (left == nameWidth) {
widthpx = Math.ceil(onlineLayout.getLineWidth(0));
if (widthpx < nameWidth) {
onlineLeft -= (nameWidth - widthpx);
}
}
}
}
public void setStatusColors(int color, int onlineColor) {
statusColor = color;
statusOnlineColor = onlineColor;
}
public void update(int mask) {
TLRPC.FileLocation photo = null;
if (user != null) {
if (user.photo != null) {
photo = user.photo.photo_small;
if (currentUser == null) {
return;
}
avatarDrawable.setInfo(user);
} else {
avatarDrawable.setInfo(0, null, null, false);
TLRPC.FileLocation photo = null;
if (currentUser.photo != null) {
photo = currentUser.photo.photo_small;
}
if (mask != 0) {
boolean continueUpdate = false;
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 && user != null) {
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
if (lastAvatar != null && photo == null || lastAvatar == null && photo != null && lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
continueUpdate = true;
}
}
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0 && user != null) {
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
int newStatus = 0;
if (user.status != null) {
newStatus = user.status.expires;
if (currentUser.status != null) {
newStatus = currentUser.status.expires;
}
if (newStatus != lastStatus) {
continueUpdate = true;
}
}
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_NAME) != 0 && user != null) {
String newName = null;
if (user != null) {
newName = user.first_name + user.last_name;
}
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
String newName = currentUser.first_name + currentUser.last_name;
if (newName == null || !newName.equals(lastName)) {
continueUpdate = true;
}
}
if (!continueUpdate) {
return;
}
}
if (user != null) {
if (user.status != null) {
lastStatus = user.status.expires;
avatarDrawable.setInfo(currentUser);
if (currentUser.status != null) {
lastStatus = currentUser.status.expires;
} else {
lastStatus = 0;
}
lastName = user.first_name + user.last_name;
}
lastName = currentUser.first_name + currentUser.last_name;
lastAvatar = photo;
avatarImage.setImage(photo, "50_50", avatarDrawable, false);
if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) {
buildLayout();
if (currentName != null) {
nameTextView.setText(currentName);
} else {
requestLayout();
nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
}
postInvalidate();
}
@Override
protected void onDraw(Canvas canvas) {
if (user == null) {
return;
}
if (useSeparator) {
if (LocaleController.isRTL) {
canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(72), getMeasuredHeight() - 1, linePaint);
if (currrntStatus != null) {
statusTextView.setText(currrntStatus);
statusTextView.setTextColor(statusColor);
} else {
canvas.drawLine(AndroidUtilities.dp(72), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, linePaint);
if (currentUser.id == UserConfig.getClientUserId() || currentUser.status != null && currentUser.status.expires > ConnectionsManager.getInstance().getCurrentTime()) {
statusTextView.setText(LocaleController.getString("Online", R.string.Online));
statusTextView.setTextColor(statusOnlineColor);
} else {
statusTextView.setText(LocaleController.formatUserStatus(currentUser));
statusTextView.setTextColor(statusColor);
}
}
if (drawAlpha != 1) {
canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(), (int)(255 * drawAlpha), Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
}
canvas.save();
canvas.translate(nameLeft, nameTop);
nameLayout.draw(canvas);
canvas.restore();
if (onlineLayout != null) {
canvas.save();
canvas.translate(onlineLeft, onlineTop);
onlineLayout.draw(canvas);
canvas.restore();
}
avatarImage.draw(canvas);
imageView.setVisibility(currentDrawable == 0 ? GONE : VISIBLE);
imageView.setImageResource(currentDrawable);
avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
}

View File

@ -570,7 +570,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
Bundle args = new Bundle();
args.putInt("chat_id", currentChat.id);
ChatProfileActivity fragment = new ChatProfileActivity(args);
ProfileActivity fragment = new ProfileActivity(args);
fragment.setChatInfo(info);
presentFragment(fragment);
}
@ -1196,9 +1196,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
checkAndUpdateAvatar();
}
private void updateOnlineCount() {
private int updateOnlineCount() {
if (info == null) {
return;
return 0;
}
onlineCount = 0;
int currentTime = ConnectionsManager.getInstance().getCurrentTime();
@ -1208,6 +1208,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
onlineCount++;
}
}
return onlineCount;
}
private int getMessageType(MessageObject messageObject) {
@ -1865,15 +1866,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updateTitle();
}
boolean updateSubtitle = false;
if ((updateMask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0) {
updateSubtitle = true;
updateOnlineCount();
}
if ((updateMask & MessagesController.UPDATE_MASK_STATUS) != 0) {
if ((updateMask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0 || (updateMask & MessagesController.UPDATE_MASK_STATUS) != 0) {
if (currentChat != null) {
int lastCount = onlineCount;
if (lastCount != updateOnlineCount()) {
updateSubtitle = true;
}
} else {
updateSubtitle = true;
}
if (updateSubtitle) {
updateSubtitle();
}
if ((updateMask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0 || (updateMask & MessagesController.UPDATE_MASK_NAME) != 0) {
checkAndUpdateAvatar();
@ -1882,9 +1883,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if ((updateMask & MessagesController.UPDATE_MASK_USER_PRINT) != 0) {
CharSequence printString = MessagesController.getInstance().printingStrings.get(dialog_id);
if (lastPrintString != null && printString == null || lastPrintString == null && printString != null || lastPrintString != null && printString != null && !lastPrintString.equals(printString)) {
updateSubtitle();
updateSubtitle = true;
}
}
if (updateSubtitle) {
updateSubtitle();
}
if ((updateMask & MessagesController.UPDATE_MASK_USER_PHONE) != 0) {
updateContactStatus();
}

View File

@ -1,776 +0,0 @@
/*
* This is the source code of Telegram for Android v. 1.3.2.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013.
*/
package org.telegram.ui;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
import org.telegram.android.MessagesStorage;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.android.MessageObject;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.UserCell;
import org.telegram.ui.Views.ActionBar.ActionBar;
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Views.AvatarUpdater;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.ActionBar.BaseFragment;
import org.telegram.ui.Views.SettingsSectionLayout;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.concurrent.Semaphore;
public class ChatProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate, PhotoViewer.PhotoViewerProvider {
private ListView listView;
private ListAdapter listViewAdapter;
private int chat_id;
private String selectedPhone;
private TLRPC.ChatParticipants info;
private TLRPC.TL_chatParticipant selectedUser;
private AvatarUpdater avatarUpdater = new AvatarUpdater();
private int totalMediaCount = -1;
private int onlineCount = -1;
private ArrayList<Integer> sortedUsers = new ArrayList<Integer>();
private TLRPC.Chat currentChat;
private int avatarRow;
private int settingsSectionRow;
private int settingsNotificationsRow;
private int sharedMediaSectionRow;
private int sharedMediaRow;
private int membersSectionRow;
private int membersEndRow;
private int addMemberRow;
private int leaveGroupRow;
private int rowCount = 0;
private static final int done_button = 1;
public ChatProfileActivity(Bundle args) {
super(args);
}
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
chat_id = getArguments().getInt("chat_id", 0);
currentChat = MessagesController.getInstance().getChat(chat_id);
if (currentChat == null) {
final Semaphore semaphore = new Semaphore(0);
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
currentChat = MessagesStorage.getInstance().getChat(chat_id);
semaphore.release();
}
});
try {
semaphore.acquire();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (currentChat != null) {
MessagesController.getInstance().putChat(currentChat, true);
} else {
return false;
}
}
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.chatInfoDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaCountDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeChats);
updateOnlineCount();
if (chat_id > 0) {
MessagesController.getInstance().getMediaCount(-chat_id, classGuid, true);
}
avatarUpdater.delegate = new AvatarUpdater.AvatarUpdaterDelegate() {
@Override
public void didUploadedPhoto(TLRPC.InputFile file, TLRPC.PhotoSize small, TLRPC.PhotoSize big) {
if (chat_id != 0) {
MessagesController.getInstance().changeChatAvatar(chat_id, file);
}
}
};
avatarUpdater.parentFragment = this;
updateRowsIds();
return true;
}
private void updateRowsIds() {
rowCount = 0;
avatarRow = rowCount++;
if (chat_id > 0) {
settingsSectionRow = rowCount++;
settingsNotificationsRow = rowCount++;
sharedMediaSectionRow = rowCount++;
sharedMediaRow = rowCount++;
}
if (info != null && !(info instanceof TLRPC.TL_chatParticipantsForbidden)) {
membersSectionRow = rowCount++;
rowCount += info.participants.size();
membersEndRow = rowCount;
int maxCount = chat_id > 0 ? MessagesController.getInstance().maxGroupCount : MessagesController.getInstance().maxBroadcastCount;
if (info.participants.size() < maxCount) {
addMemberRow = rowCount++;
} else {
addMemberRow = -1;
}
} else {
membersEndRow = -1;
addMemberRow = -1;
membersSectionRow = -1;
}
if (chat_id > 0) {
leaveGroupRow = rowCount++;
}
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.chatInfoDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaCountDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
avatarUpdater.clear();
}
public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
if (chat_id > 0) {
actionBar.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo));
} else {
actionBar.setTitle(LocaleController.getString("BroadcastList", R.string.BroadcastList));
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == done_button) {
openAddMenu();
}
}
});
ActionBarMenu menu = actionBar.createMenu();
View item = menu.addItemResource(done_button, R.layout.group_profile_add_member_layout);
TextView textView = (TextView)item.findViewById(R.id.done_button);
if (textView != null) {
if (chat_id > 0) {
textView.setText(LocaleController.getString("AddMember", R.string.AddMember));
} else {
textView.setText(LocaleController.getString("AddRecipient", R.string.AddRecipient));
}
}
fragmentView = inflater.inflate(R.layout.chat_profile_layout, container, false);
listView = (ListView)fragmentView.findViewById(R.id.listView);
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
if (i > membersSectionRow && i < membersEndRow) {
if (getParentActivity() == null) {
return false;
}
TLRPC.TL_chatParticipant user = info.participants.get(sortedUsers.get(i - membersSectionRow - 1));
if (user.user_id == UserConfig.getClientUserId()) {
return false;
}
if (info.admin_id != UserConfig.getClientUserId() && user.inviter_id != UserConfig.getClientUserId()) {
return false;
}
selectedUser = user;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items = new CharSequence[] {chat_id > 0 ? LocaleController.getString("KickFromGroup", R.string.KickFromGroup) : LocaleController.getString("KickFromBroadcast", R.string.KickFromBroadcast)};
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) {
kickUser(selectedUser);
}
}
});
showAlertDialog(builder);
return true;
}
return false;
}
});
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
if (i == sharedMediaRow) {
Bundle args = new Bundle();
args.putLong("dialog_id", -chat_id);
presentFragment(new MediaActivity(args));
} else if (i == addMemberRow) {
openAddMenu();
} else if (i > membersSectionRow && i < membersEndRow) {
int user_id = info.participants.get(sortedUsers.get(i - membersSectionRow - 1)).user_id;
if (user_id == UserConfig.getClientUserId()) {
return;
}
Bundle args = new Bundle();
args.putInt("user_id", user_id);
presentFragment(new ProfileActivity(args));
} else if (i == settingsNotificationsRow) {
Bundle args = new Bundle();
args.putLong("dialog_id", -chat_id);
presentFragment(new ProfileNotificationsActivity(args));
}
}
});
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView;
}
@Override
public void didSelectContact(TLRPC.User user, String param) {
MessagesController.getInstance().addUserToChat(chat_id, user, info, param != null ? Utilities.parseInt(param) : 0);
}
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
avatarUpdater.onActivityResult(requestCode, resultCode, data);
}
@Override
public void saveSelfArgs(Bundle args) {
if (avatarUpdater != null && avatarUpdater.currentPicturePath != null) {
args.putString("path", avatarUpdater.currentPicturePath);
}
}
@Override
public void restoreSelfArgs(Bundle args) {
MessagesController.getInstance().loadChatInfo(chat_id, null);
if (avatarUpdater != null) {
avatarUpdater.currentPicturePath = args.getString("path");
}
}
@Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
if (fileLocation == null) {
return null;
}
TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id);
if (chat != null && chat.photo != null && chat.photo.photo_big != null) {
TLRPC.FileLocation photoBig = chat.photo.photo_big;
if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View view = listView.getChildAt(a);
BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
if (avatarImage != null) {
int coords[] = new int[2];
avatarImage.getLocationInWindow(coords);
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
object.viewX = coords[0];
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
object.parentView = listView;
object.imageReceiver = avatarImage.imageReceiver;
object.thumb = object.imageReceiver.getBitmap();
object.size = -1;
return object;
}
}
}
}
return null;
}
@Override
public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { }
@Override
public void willHidePhotoViewer() { }
@Override
public boolean isPhotoChecked(int index) { return false; }
@Override
public void setPhotoChecked(int index) { }
@Override
public void cancelButtonPressed() { }
@Override
public void sendButtonPressed(int index) { }
@Override
public int getSelectedCount() { return 0; }
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
if ((mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
updateOnlineCount();
}
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
updateVisibleRows(mask);
}
} else if (id == NotificationCenter.chatInfoDidLoaded) {
int chatId = (Integer)args[0];
if (chatId == chat_id) {
info = (TLRPC.ChatParticipants)args[1];
updateOnlineCount();
updateRowsIds();
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
}
} else if (id == NotificationCenter.mediaCountDidLoaded) {
long uid = (Long)args[0];
int lower_part = (int)uid;
if (lower_part < 0 && chat_id == -lower_part) {
totalMediaCount = (Integer)args[1];
if (listView != null) {
listView.invalidateViews();
}
}
} else if (id == NotificationCenter.closeChats) {
removeSelfFromStack();
}
}
@Override
public void onResume() {
super.onResume();
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
}
public void setChatInfo(TLRPC.ChatParticipants chatParticipants) {
info = chatParticipants;
}
private void updateVisibleRows(int mask) {
if (listView == null) {
return;
}
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof UserCell) {
((UserCell) child).update(mask);
}
}
}
private void updateOnlineCount() {
if (info == null) {
return;
}
onlineCount = 0;
int currentTime = ConnectionsManager.getInstance().getCurrentTime();
sortedUsers.clear();
int i = 0;
for (TLRPC.TL_chatParticipant participant : info.participants) {
TLRPC.User user = MessagesController.getInstance().getUser(participant.user_id);
if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.getClientUserId()) && user.status.expires > 10000) {
onlineCount++;
}
sortedUsers.add(i);
i++;
}
Collections.sort(sortedUsers, new Comparator<Integer>() {
@Override
public int compare(Integer lhs, Integer rhs) {
TLRPC.User user1 = MessagesController.getInstance().getUser(info.participants.get(rhs).user_id);
TLRPC.User user2 = MessagesController.getInstance().getUser(info.participants.get(lhs).user_id);
Integer status1 = 0;
Integer status2 = 0;
if (user1 != null && user1.status != null) {
if (user1.id == UserConfig.getClientUserId()) {
status1 = ConnectionsManager.getInstance().getCurrentTime() + 50000;
} else {
status1 = user1.status.expires;
}
}
if (user2 != null && user2.status != null) {
if (user2.id == UserConfig.getClientUserId()) {
status2 = ConnectionsManager.getInstance().getCurrentTime() + 50000;
} else {
status2 = user2.status.expires;
}
}
return status1.compareTo(status2);
}
});
if (listView != null) {
listView.invalidateViews();
}
}
private void processPhotoMenu(int action) {
if (action == 0) {
TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id);
if (chat.photo != null && chat.photo.photo_big != null) {
PhotoViewer.getInstance().setParentActivity(getParentActivity());
PhotoViewer.getInstance().openPhoto(chat.photo.photo_big, this);
}
} else if (action == 1) {
avatarUpdater.openCamera();
} else if (action == 2) {
avatarUpdater.openGallery();
} else if (action == 3) {
MessagesController.getInstance().changeChatAvatar(chat_id, null);
}
}
private void openAddMenu() {
Bundle args = new Bundle();
args.putBoolean("onlyUsers", true);
args.putBoolean("destroyAfterSelect", true);
args.putBoolean("returnAsResult", true);
//args.putBoolean("allowUsernameSearch", false);
if (chat_id > 0) {
args.putString("selectAlertString", LocaleController.getString("AddToTheGroup", R.string.AddToTheGroup));
}
ContactsActivity fragment = new ContactsActivity(args);
fragment.setDelegate(this);
if (info != null) {
HashMap<Integer, TLRPC.User> users = new HashMap<Integer, TLRPC.User>();
for (TLRPC.TL_chatParticipant p : info.participants) {
users.put(p.user_id, null);
}
fragment.setIgnoreUsers(users);
}
presentFragment(fragment);
}
private void kickUser(TLRPC.TL_chatParticipant user) {
if (user != null) {
MessagesController.getInstance().deleteUserFromChat(chat_id, MessagesController.getInstance().getUser(user.user_id), info);
} else {
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
MessagesController.getInstance().deleteUserFromChat(chat_id, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), info);
MessagesController.getInstance().deleteDialog(-chat_id, 0, false);
finishFragment();
}
}
private class ListAdapter extends BaseFragmentAdapter {
private Context mContext;
public ListAdapter(Context context) {
mContext = context;
}
@Override
public boolean areAllItemsEnabled() {
return false;
}
@Override
public boolean isEnabled(int i) {
return i == settingsNotificationsRow || i == sharedMediaRow || i == addMemberRow || i > membersSectionRow && i < membersEndRow;
}
@Override
public int getCount() {
return rowCount;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int type = getItemViewType(i);
if (type == 0) {
BackupImageView avatarImage;
TextView onlineText;
TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id);
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.chat_profile_avatar_layout, viewGroup, false);
onlineText = (TextView)view.findViewById(R.id.settings_online);
ImageButton button = (ImageButton)view.findViewById(R.id.settings_edit_name);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle args = new Bundle();
args.putInt("chat_id", chat_id);
presentFragment(new ChatProfileChangeNameActivity(args));
}
});
final ImageButton button2 = (ImageButton)view.findViewById(R.id.settings_change_avatar_button);
if (chat_id > 0) {
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items;
int type;
TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id);
if (chat.photo == null || chat.photo.photo_big == null || chat.photo instanceof TLRPC.TL_chatPhotoEmpty) {
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
type = 0;
} else {
items = new CharSequence[]{LocaleController.getString("OpenPhoto", R.string.OpenPhoto), LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
type = 1;
}
final int arg0 = type;
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int action = 0;
if (arg0 == 1) {
if (i == 0) {
action = 0;
} else if (i == 1) {
action = 1;
} else if (i == 2) {
action = 2;
} else if (i == 3) {
action = 3;
}
} else if (arg0 == 0) {
if (i == 0) {
action = 1;
} else if (i == 1) {
action = 2;
}
}
processPhotoMenu(action);
}
});
showAlertDialog(builder);
}
});
} else {
button2.setVisibility(View.GONE);
}
} else {
onlineText = (TextView)view.findViewById(R.id.settings_online);
}
avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
avatarImage.processDetach = false;
TextView textView = (TextView)view.findViewById(R.id.settings_name);
Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf");
textView.setTypeface(typeface);
textView.setText(chat.title);
int count = chat.participants_count;
if (info != null) {
count = info.participants.size();
}
if (count != 0 && onlineCount > 1) {
onlineText.setText(Html.fromHtml(String.format("%s, <font color='#548ab6'>%s</font>", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))));
} else {
onlineText.setText(LocaleController.formatPluralString("Members", count));
}
TLRPC.FileLocation photo = null;
TLRPC.FileLocation photoBig = null;
if (chat.photo != null) {
photo = chat.photo.photo_small;
photoBig = chat.photo.photo_big;
}
avatarImage.setImage(photo, "50_50", new AvatarDrawable(chat));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
return view;
} else if (type == 1) {
if (view == null) {
view = new SettingsSectionLayout(mContext);
}
if (i == settingsSectionRow) {
((SettingsSectionLayout) view).setText(LocaleController.getString("SETTINGS", R.string.SETTINGS));
} else if (i == sharedMediaSectionRow) {
} else if (i == membersSectionRow) {
TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id);
int count = chat.participants_count;
if (info != null) {
count = info.participants.size();
}
((SettingsSectionLayout) view).setText(LocaleController.formatPluralString("Members", count).toUpperCase());
}
} else if (type == 2) {
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.user_profile_leftright_row_layout, viewGroup, false);
}
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
View divider = view.findViewById(R.id.settings_row_divider);
if (i == sharedMediaRow) {
textView.setText(LocaleController.getString("SharedMedia", R.string.SharedMedia));
if (totalMediaCount == -1) {
detailTextView.setText(LocaleController.getString("Loading", R.string.Loading));
} else {
detailTextView.setText(String.format("%d", totalMediaCount));
}
divider.setVisibility(View.INVISIBLE);
}
} else if (type == 3) {
TLRPC.TL_chatParticipant part = info.participants.get(sortedUsers.get(i - membersSectionRow - 1));
TLRPC.User user = MessagesController.getInstance().getUser(part.user_id);
if (view == null) {
view = new UserCell(mContext);
((UserCell)view).useSeparator = true;
}
((UserCell)view).setData(user, null, null);
} else if (type == 4) {
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.chat_profile_add_row, viewGroup, false);
TextView textView = (TextView)view.findViewById(R.id.messages_list_row_name);
if (chat_id > 0) {
textView.setText(LocaleController.getString("AddMember", R.string.AddMember));
} else {
textView.setText(LocaleController.getString("AddRecipient", R.string.AddRecipient));
View divider = view.findViewById(R.id.settings_row_divider);
divider.setVisibility(View.INVISIBLE);
}
}
} else if (type == 5) {
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_logout_button, viewGroup, false);
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
textView.setText(LocaleController.getString("DeleteAndExit", R.string.DeleteAndExit));
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
kickUser(null);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
}
});
}
} else if (type == 6) {
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_row_button_layout, viewGroup, false);
}
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
View divider = view.findViewById(R.id.settings_row_divider);
if (i == settingsNotificationsRow) {
textView.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
divider.setVisibility(View.INVISIBLE);
}
}
return view;
}
@Override
public int getItemViewType(int i) {
if (i == avatarRow) {
return 0;
} else if (i == settingsSectionRow || i == sharedMediaSectionRow || i == membersSectionRow) {
return 1;
} else if (i == sharedMediaRow) {
return 2;
} else if (i == addMemberRow) {
return 4;
} else if (i == leaveGroupRow) {
return 5;
} else if (i > membersSectionRow && i < membersEndRow) {
return 3;
} else if (i == settingsNotificationsRow) {
return 6;
}
return 0;
}
@Override
public int getViewTypeCount() {
return 7;
}
@Override
public boolean isEmpty() {
return false;
}
}
}

View File

@ -119,11 +119,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
if (destroyAfterSelect) {
actionBar.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact));
} else {
actionBar.setTitle(LocaleController.getString("Contacts", R.string.Contacts));
}
actionBar.setTitle(destroyAfterSelect ? LocaleController.getString("SelectContact", R.string.SelectContact) : LocaleController.getString("Contacts", R.string.Contacts));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override

View File

@ -9,7 +9,6 @@
package org.telegram.ui;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
@ -23,6 +22,8 @@ import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextWatcher;
import android.text.style.ImageSpan;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@ -30,38 +31,34 @@ import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.LocaleController;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.Adapters.BaseSectionsAdapter;
import org.telegram.ui.Adapters.ContactsActivityAdapter;
import org.telegram.ui.Adapters.ContactsActivitySearchAdapter;
import org.telegram.ui.Views.ActionBar.ActionBar;
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.ActionBar.BaseFragment;
import org.telegram.ui.Views.PinnedHeaderListView;
import org.telegram.ui.Views.SectionedBaseAdapter;
import org.telegram.ui.Views.SettingsSectionLayout;
import org.telegram.ui.Views.SectionsListView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;
public class GroupCreateActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
public static class XImageSpan extends ImageSpan {
public class XImageSpan extends ImageSpan {
public int uid;
public XImageSpan(Drawable d, int verticalAlignment) {
@ -75,7 +72,6 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
int sz = super.getSize(paint, text, start, end, fm);
int offset = AndroidUtilities.dp(6);
int w = (fm.bottom - fm.top) / 2;
fm.top = -w - offset;
@ -83,30 +79,25 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
fm.ascent = -w - offset;
fm.leading = 0;
fm.descent = w - offset;
return sz;
}
}
private SectionedBaseAdapter listViewAdapter;
private PinnedHeaderListView listView;
private BaseSectionsAdapter listViewAdapter;
private TextView emptyTextView;
private EditText userSelectEditText;
private SectionsListView listView;
private ContactsActivitySearchAdapter searchListViewAdapter;
private int beforeChangeIndex;
private int maxCount = 200;
private boolean ignoreChange = false;
private boolean isBroadcast = false;
private int maxCount = 200;
private HashMap<Integer, XImageSpan> selectedContacts = new HashMap<Integer, XImageSpan>();
private ArrayList<XImageSpan> allSpans = new ArrayList<XImageSpan>();
private boolean searchWas;
private boolean searching;
private Timer searchTimer;
public ArrayList<TLRPC.User> searchResult;
public ArrayList<CharSequence> searchResultNames;
private CharSequence changeString;
private int beforeChangeIndex;
private HashMap<Integer, XImageSpan> selectedContacts = new HashMap<Integer, XImageSpan>();
private ArrayList<XImageSpan> allSpans = new ArrayList<XImageSpan>();
private final static int done_button = 1;
@ -139,13 +130,12 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
@Override
public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) {
searching = false;
searchWas = false;
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
if (isBroadcast) {
actionBar.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
} else {
actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
}
actionBar.setTitle(isBroadcast ? LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList) : LocaleController.getString("NewGroup", R.string.NewGroup));
actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@ -165,26 +155,99 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
}
});
ActionBarMenu menu = actionBar.createMenu();
View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout);
TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button);
doneTextView.setText(LocaleController.getString("Next", R.string.Next));
searching = false;
searchWas = false;
searchListViewAdapter = new ContactsActivitySearchAdapter(getParentActivity(), null, false);
listViewAdapter = new ContactsActivityAdapter(getParentActivity(), true, false, null);
fragmentView = inflater.inflate(R.layout.group_create_layout, container, false);
/*
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/top_layout"
android:layout_gravity="top">
<EditText
android:textColorHint="#a6a6a6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:minHeight="52dp"
android:gravity="right|center_vertical"
android:maxLines="2"
android:paddingTop="3dp"
android:layout_marginTop="0dp"
android:inputType="textFilter|textNoSuggestions|textMultiLine"
android:imeOptions="flagNoExtractUi"
android:textCursorDrawable="@null"
android:textColor="#000000"/>
</FrameLayout>
------------RTL---------- END
<EditText
android:textColorHint="#a6a6a6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:minHeight="52dp"
android:gravity="left|center_vertical"
android:maxLines="2"
android:paddingTop="3dp"
android:layout_marginTop="0dp"
android:inputType="textFilter|textNoSuggestions|textMultiLine"
android:imeOptions="flagNoExtractUi"
android:textCursorDrawable="@null"
android:textColor="#000000"/>
*/
fragmentView = new LinearLayout(getParentActivity());
LinearLayout linearLayout = (LinearLayout) fragmentView;
linearLayout.setOrientation(LinearLayout.VERTICAL);
emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(24);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setVisibility(View.INVISIBLE);
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
linearLayout.addView(emptyTextView);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP;
emptyTextView.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
userSelectEditText = (EditText)fragmentView.findViewById(R.id.bubble_input_text);
FrameLayout frameLayout = new FrameLayout(getParentActivity());
linearLayout.addView(frameLayout);
layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.TOP;
frameLayout.setLayoutParams(layoutParams);
userSelectEditText = new EditText(getParentActivity());
userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
frameLayout.addView(userSelectEditText);
userSelectEditText.setHint(LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
if (Build.VERSION.SDK_INT >= 11) {
userSelectEditText.setTextIsSelectable(false);
@ -256,11 +319,23 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
});
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
listView = new SectionsListView(getParentActivity());
listView.setEmptyView(emptyTextView);
listView.setVerticalScrollBarEnabled(false);
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setFastScrollEnabled(true);
listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
listView.setAdapter(listViewAdapter);
if (Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(true);
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
}
((FrameLayout) fragmentView).addView(listView);
layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
listView.setLayoutParams(layoutParams);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
@ -315,7 +390,6 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
}
});
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView absListView, int i) {
@ -337,6 +411,29 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
return fragmentView;
}
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.contactsDidLoaded) {
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
} else if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
if (listView != null) {
listView.invalidateViews();
}
}
} else if (id == NotificationCenter.chatDidCreated) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
removeSelfFromStack();
}
});
}
}
public XImageSpan createAndPutChipForUser(TLRPC.User user) {
LayoutInflater lf = (LayoutInflater)ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View textView = lf.inflate(R.layout.group_create_bubble, null);
@ -374,253 +471,4 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
userSelectEditText.setSelection(ssb.length());
return span;
}
public void searchDialogs(final String query) {
if (query == null) {
searchResult = null;
searchResultNames = null;
} else {
try {
if (searchTimer != null) {
searchTimer.cancel();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
searchTimer = new Timer();
searchTimer.schedule(new TimerTask() {
@Override
public void run() {
try {
searchTimer.cancel();
searchTimer = null;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
processSearch(query);
}
}, 100, 300);
}
}
private void processSearch(final String query) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>();
contactsCopy.addAll(ContactsController.getInstance().contacts);
Utilities.searchQueue.postRunnable(new Runnable() {
@Override
public void run() {
if (query.length() == 0) {
updateSearchResults(new ArrayList<TLRPC.User>(), new ArrayList<CharSequence>());
return;
}
long time = System.currentTimeMillis();
ArrayList<TLRPC.User> resultArray = new ArrayList<TLRPC.User>();
ArrayList<CharSequence> resultArrayNames = new ArrayList<CharSequence>();
String q = query.toLowerCase();
for (TLRPC.TL_contact contact : contactsCopy) {
TLRPC.User user = MessagesController.getInstance().getUser(contact.user_id);
if (user.first_name.toLowerCase().startsWith(q) || user.last_name.toLowerCase().startsWith(q)) {
if (user.id == UserConfig.getClientUserId()) {
continue;
}
resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q));
resultArray.add(user);
}
}
updateSearchResults(resultArray, resultArrayNames);
}
});
}
});
}
private void updateSearchResults(final ArrayList<TLRPC.User> users, final ArrayList<CharSequence> names) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
searchResult = users;
searchResultNames = names;
listViewAdapter.notifyDataSetChanged();
}
});
}
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.contactsDidLoaded) {
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
} else if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
if (listView != null) {
listView.invalidateViews();
}
}
} else if (id == NotificationCenter.chatDidCreated) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
removeSelfFromStack();
}
});
}
}
private class ListAdapter extends SectionedBaseAdapter {
private Context mContext;
public ListAdapter(Context context) {
mContext = context;
}
@Override
public Object getItem(int section, int position) {
return null;
}
@Override
public long getItemId(int section, int position) {
return 0;
}
@Override
public int getSectionCount() {
if (searching && searchWas) {
return searchResult == null || searchResult.isEmpty() ? 0 : 1;
}
return ContactsController.getInstance().sortedUsersSectionsArray.size();
}
@Override
public int getCountForSection(int section) {
if (searching && searchWas) {
return searchResult == null ? 0 : searchResult.size();
}
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
return arr.size();
}
@Override
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
TLRPC.User user;
int size;
if (searchWas && searching) {
user = MessagesController.getInstance().getUser(searchResult.get(position).id);
size = searchResult.size();
} else {
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
user = MessagesController.getInstance().getUser(arr.get(position).user_id);
size = arr.size();
}
if (convertView == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = li.inflate(R.layout.group_create_row_layout, parent, false);
}
ContactListRowHolder holder = (ContactListRowHolder)convertView.getTag();
if (holder == null) {
holder = new ContactListRowHolder(convertView);
convertView.setTag(holder);
}
ImageView checkButton = (ImageView)convertView.findViewById(R.id.settings_row_check_button);
if (selectedContacts.containsKey(user.id)) {
checkButton.setImageResource(R.drawable.btn_check_on_holo_light);
} else {
checkButton.setImageResource(R.drawable.btn_check_off_holo_light);
}
View divider = convertView.findViewById(R.id.settings_row_divider);
if (position == size - 1) {
divider.setVisibility(View.INVISIBLE);
} else {
divider.setVisibility(View.VISIBLE);
}
if (searchWas && searching) {
holder.nameTextView.setText(searchResultNames.get(position));
} else {
String name = ContactsController.formatName(user.first_name, user.last_name);
if (name.length() == 0) {
if (user.phone != null && user.phone.length() != 0) {
name = PhoneFormat.getInstance().format("+" + user.phone);
} else {
name = LocaleController.getString("HiddenName", R.string.HiddenName);
}
}
holder.nameTextView.setText(name);
}
TLRPC.FileLocation photo = null;
if (user.photo != null) {
photo = user.photo.photo_small;
}
holder.avatarDrawable.setInfo(user.id, user.first_name, user.last_name, false);
holder.avatarImage.setImage(photo, "50_50", holder.avatarDrawable);
holder.messageTextView.setText(LocaleController.formatUserStatus(user));
if (user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime()) {
holder.messageTextView.setTextColor(0xff548ab6);
} else {
holder.messageTextView.setTextColor(0xff808080);
}
return convertView;
}
@Override
public int getItemViewType(int section, int position) {
return 0;
}
@Override
public int getItemViewTypeCount() {
return 1;
}
@Override
public int getSectionHeaderViewType(int section) {
return 0;
}
@Override
public int getSectionHeaderViewTypeCount() {
return 1;
}
@Override
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = new SettingsSectionLayout(mContext);
convertView.setBackgroundColor(0xffffffff);
}
if (searching && searchWas) {
((SettingsSectionLayout) convertView).setText(LocaleController.getString("AllContacts", R.string.AllContacts));
} else {
((SettingsSectionLayout) convertView).setText(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
}
return convertView;
}
}
public static class ContactListRowHolder {
public BackupImageView avatarImage;
public TextView messageTextView;
public TextView nameTextView;
public AvatarDrawable avatarDrawable = new AvatarDrawable();
public ContactListRowHolder(View view) {
messageTextView = (TextView)view.findViewById(R.id.messages_list_row_message);
nameTextView = (TextView)view.findViewById(R.id.messages_list_row_name);
avatarImage = (BackupImageView)view.findViewById(R.id.messages_list_row_avatar);
}
}
}

View File

@ -389,14 +389,10 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
@Override
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
TLRPC.User user = MessagesController.getInstance().getUser(selectedContacts.get(position));
if (convertView == null) {
convertView = new UserCell(mContext);
convertView = new UserCell(mContext, 1);
}
((UserCell)convertView).setData(user, null, null);
((UserCell) convertView).useSeparator = position != selectedContacts.size() - 1;
((UserCell) convertView).setData(user, null, null, 0);
return convertView;
}

View File

@ -355,7 +355,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
} else if (fragmentName.equals("chat_profile")) {
if (args != null) {
ChatProfileActivity profile = new ChatProfileActivity(args);
ProfileActivity profile = new ProfileActivity(args);
if (actionBarLayout.addFragmentToStack(profile)) {
profile.restoreSelfArgs(savedInstanceState);
}
@ -1009,7 +1009,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
outState.putString("fragment", "group");
} else if (lastFragment instanceof SettingsWallpapersActivity) {
outState.putString("fragment", "wallpapers");
} else if (lastFragment instanceof ChatProfileActivity && args != null) {
} else if (lastFragment instanceof ProfileActivity && ((ProfileActivity) lastFragment).isChat() && args != null) {
outState.putBundle("args", args);
outState.putString("fragment", "chat_profile");
}

View File

@ -16,12 +16,15 @@ import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
@ -31,7 +34,9 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.LocaleController;
import org.telegram.android.MessagesStorage;
import org.telegram.android.SendMessagesHelper;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog;
@ -39,22 +44,33 @@ import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.android.MessageObject;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.AnimationCompat.ViewProxy;
import org.telegram.ui.Cells.DividerCell;
import org.telegram.ui.Cells.EmptyCell;
import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.TextCell;
import org.telegram.ui.Cells.TextDetailCell;
import org.telegram.ui.Cells.UserCell;
import org.telegram.ui.Views.ActionBar.ActionBar;
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Views.AvatarUpdater;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.ActionBar.BaseFragment;
import org.telegram.ui.Views.IdenticonDrawable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.concurrent.Semaphore;
public class ProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, PhotoViewer.PhotoViewerProvider {
private ListView listView;
private ListAdapter listAdapter;
private BackupImageView avatarImage;
@ -63,19 +79,35 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
private ImageView writeButton;
private int user_id;
private int totalMediaCount = -1;
private boolean creatingChat = false;
private int chat_id;
private long dialog_id;
private boolean creatingChat;
private boolean userBlocked;
private AvatarUpdater avatarUpdater;
private TLRPC.ChatParticipants info;
private TLRPC.TL_chatParticipant selectedUser;
private int onlineCount = -1;
private ArrayList<Integer> sortedUsers;
private TLRPC.EncryptedChat currentEncryptedChat;
private boolean userBlocked = false;
private TLRPC.Chat currentChat;
private int totalMediaCount = -1;
private final static int add_contact = 1;
private final static int block_contact = 2;
private final static int share_contact = 3;
private final static int edit_contact = 4;
private final static int delete_contact = 5;
private final static int add_member = 6;
private final static int leave_group = 7;
private final static int edit_name = 8;
private int overscrollRow;
private int emptyRow;
private int emptyRowChat;
private int emptyRowChat2;
private int phoneRow;
private int usernameRow;
private int settingsTimerRow;
@ -84,6 +116,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
private int sharedMediaRow;
private int startSecretChatRow;
private int sectionRow;
private int membersSectionRow;
private int membersEndRow;
private int rowCount = 0;
public ProfileActivity(Bundle args) {
@ -93,23 +127,73 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public boolean onFragmentCreate() {
user_id = arguments.getInt("user_id", 0);
chat_id = getArguments().getInt("chat_id", 0);
if (user_id != 0) {
dialog_id = arguments.getLong("dialog_id", 0);
if (dialog_id != 0) {
currentEncryptedChat = MessagesController.getInstance().getEncryptedChat((int) (dialog_id >> 32));
}
updateRowsIds();
if (MessagesController.getInstance().getUser(user_id) == null) {
return false;
}
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaCountDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatCreated);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatUpdated);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.blockedUsersDidLoaded);
userBlocked = MessagesController.getInstance().blockedUsers.contains(user_id);
MessagesController.getInstance().loadFullUser(MessagesController.getInstance().getUser(user_id), classGuid);
} else if (chat_id != 0) {
currentChat = MessagesController.getInstance().getChat(chat_id);
if (currentChat == null) {
final Semaphore semaphore = new Semaphore(0);
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
currentChat = MessagesStorage.getInstance().getChat(chat_id);
semaphore.release();
}
});
try {
semaphore.acquire();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (currentChat != null) {
MessagesController.getInstance().putChat(currentChat, true);
} else {
return false;
}
}
NotificationCenter.getInstance().addObserver(this, NotificationCenter.chatInfoDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeChats);
sortedUsers = new ArrayList<Integer>();
updateOnlineCount();
if (chat_id > 0) {
MessagesController.getInstance().getMediaCount(-chat_id, classGuid, true);
}
avatarUpdater = new AvatarUpdater();
avatarUpdater.delegate = new AvatarUpdater.AvatarUpdaterDelegate() {
@Override
public void didUploadedPhoto(TLRPC.InputFile file, TLRPC.PhotoSize small, TLRPC.PhotoSize big) {
if (chat_id != 0) {
MessagesController.getInstance().changeChatAvatar(chat_id, file);
}
}
};
avatarUpdater.parentFragment = this;
} else {
return false;
}
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaCountDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
updateRowsIds();
return true;
}
@ -117,27 +201,35 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaCountDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
if (user_id != 0) {
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatCreated);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatUpdated);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.blockedUsersDidLoaded);
MessagesController.getInstance().cancelLoadFullUser(user_id);
} else if (chat_id != 0) {
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.chatInfoDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
avatarUpdater.clear();
}
}
@Override
public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) {
actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id));
actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(user_id));
actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 ? user_id : chat_id));
actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(user_id != 0 ? user_id : chat_id));
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setExtraHeight(AndroidUtilities.dp(88));
actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(final int id) {
if (getParentActivity() == null) {
return;
}
if (id == -1) {
finishFragment();
} else if (id == block_contact) {
@ -194,6 +286,46 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
} else if (id == add_member) {
Bundle args = new Bundle();
args.putBoolean("onlyUsers", true);
args.putBoolean("destroyAfterSelect", true);
args.putBoolean("returnAsResult", true);
//args.putBoolean("allowUsernameSearch", false);
if (chat_id > 0) {
args.putString("selectAlertString", LocaleController.getString("AddToTheGroup", R.string.AddToTheGroup));
}
ContactsActivity fragment = new ContactsActivity(args);
fragment.setDelegate(new ContactsActivity.ContactsActivityDelegate() {
@Override
public void didSelectContact(TLRPC.User user, String param) {
MessagesController.getInstance().addUserToChat(chat_id, user, info, param != null ? Utilities.parseInt(param) : 0);
}
});
if (info != null) {
HashMap<Integer, TLRPC.User> users = new HashMap<Integer, TLRPC.User>();
for (TLRPC.TL_chatParticipant p : info.participants) {
users.put(p.user_id, null);
}
fragment.setIgnoreUsers(users);
}
presentFragment(fragment);
} else if (id == leave_group) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
kickUser(null);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
} else if (id == edit_name) {
Bundle args = new Bundle();
args.putInt("chat_id", chat_id);
presentFragment(new ChatProfileChangeNameActivity(args));
}
}
});
@ -204,7 +336,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
fragmentView = new FrameLayout(getParentActivity());
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.addView(actionBar);
avatarImage = new BackupImageView(getParentActivity());
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30));
@ -221,11 +352,19 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
avatarImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (user_id != 0) {
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user.photo != null && user.photo.photo_big != null) {
PhotoViewer.getInstance().setParentActivity(getParentActivity());
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, ProfileActivity.this);
}
} else if (chat_id != 0) {
TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id);
if (chat.photo != null && chat.photo.photo_big != null) {
PhotoViewer.getInstance().setParentActivity(getParentActivity());
PhotoViewer.getInstance().openPhoto(chat.photo.photo_big, ProfileActivity.this);
}
}
}
});
@ -235,6 +374,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
nameTextView.setLines(1);
nameTextView.setMaxLines(1);
nameTextView.setSingleLine(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
actionBar.addView(nameTextView);
@ -248,11 +388,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
nameTextView.setLayoutParams(layoutParams);
onlineTextView = new TextView(getParentActivity());
onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(user_id));
onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(user_id != 0 ? user_id : chat_id));
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
onlineTextView.setLines(1);
onlineTextView.setMaxLines(1);
onlineTextView.setSingleLine(true);
onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
actionBar.addView(onlineTextView);
layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
@ -265,10 +406,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
onlineTextView.setLayoutParams(layoutParams);
listView = new ListView(getParentActivity());
listView.setDrawingCacheEnabled(false);
listView.setDrawingCacheBackgroundColor(0);
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false);
AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(user_id));
AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(user_id != 0 ? user_id : chat_id));
frameLayout.addView(listView);
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
@ -285,10 +428,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
if (i == sharedMediaRow) {
Bundle args = new Bundle();
if (dialog_id != 0) {
args.putLong("dialog_id", dialog_id);
if (user_id != 0) {
args.putLong("dialog_id", dialog_id != 0 ? dialog_id : user_id);
} else {
args.putLong("dialog_id", user_id);
args.putLong("dialog_id", -chat_id);
}
presentFragment(new MediaActivity(args));
} else if (i == settingsKeyRow) {
@ -302,7 +445,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
showAlertDialog(AndroidUtilities.buildTTLAlert(getParentActivity(), currentEncryptedChat));
} else if (i == settingsNotificationsRow) {
Bundle args = new Bundle();
if (user_id != 0) {
args.putLong("dialog_id", dialog_id == 0 ? user_id : dialog_id);
} else if (chat_id != 0) {
args.putLong("dialog_id", -chat_id);
}
presentFragment(new ProfileNotificationsActivity(args));
} else if (i == startSecretChatRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
@ -348,17 +495,69 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
});
showAlertDialog(builder);
} else if (i > emptyRowChat2 && i < membersEndRow) {
int user_id = info.participants.get(sortedUsers.get(i - emptyRowChat2 - 1)).user_id;
if (user_id == UserConfig.getClientUserId()) {
return;
}
Bundle args = new Bundle();
args.putInt("user_id", user_id);
presentFragment(new ProfileActivity(args));
}
}
});
if (chat_id != 0) {
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
if (i > emptyRowChat2 && i < membersEndRow) {
if (getParentActivity() == null) {
return false;
}
TLRPC.TL_chatParticipant user = info.participants.get(sortedUsers.get(i - emptyRowChat2 - 1));
if (user.user_id == UserConfig.getClientUserId()) {
return false;
}
if (info.admin_id != UserConfig.getClientUserId() && user.inviter_id != UserConfig.getClientUserId()) {
return false;
}
selectedUser = user;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items = new CharSequence[]{chat_id > 0 ? LocaleController.getString("KickFromGroup", R.string.KickFromGroup) : LocaleController.getString("KickFromBroadcast", R.string.KickFromBroadcast)};
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) {
kickUser(selectedUser);
}
}
});
showAlertDialog(builder);
return true;
}
return false;
}
});
}
if (dialog_id != 0) {
MessagesController.getInstance().getMediaCount(dialog_id, classGuid, true);
} else {
MessagesController.getInstance().getMediaCount(user_id, classGuid, true);
}
frameLayout.addView(actionBar);
if (user_id != 0 || chat_id >= 0) {
writeButton = new ImageView(getParentActivity());
if (user_id != 0) {
writeButton.setImageResource(R.drawable.floating_user_states);
} else if (chat_id != 0) {
writeButton.setImageResource(R.drawable.floating_group_states);
}
frameLayout.addView(writeButton);
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
@ -370,6 +569,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
writeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getParentActivity() == null) {
return;
}
if (user_id != 0) {
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user == null || user instanceof TLRPC.TL_userEmpty) {
return;
@ -378,10 +581,61 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
Bundle args = new Bundle();
args.putInt("user_id", user_id);
presentFragment(new ChatActivity(args), true);
} else if (chat_id != 0) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items;
TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id);
if (chat.photo == null || chat.photo.photo_big == null || chat.photo instanceof TLRPC.TL_chatPhotoEmpty) {
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
} else {
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
}
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int action = 0;
if (i == 0) {
avatarUpdater.openCamera();
} else if (i == 1) {
avatarUpdater.openGallery();
} else if (i == 3) {
MessagesController.getInstance().changeChatAvatar(chat_id, null);
}
}
});
showAlertDialog(builder);
}
}
});
}
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (totalItemCount == 0) {
return;
}
int height = 0;
View child = view.getChildAt(0);
if (child != null) {
if (firstVisibleItem == 0) {
height = AndroidUtilities.dp(88) + child.getTop();
}
if (actionBar.getExtraHeight() != height) {
actionBar.setExtraHeight(height, true);
needLayout();
}
}
}
});
updateUserData();
updateProfileData();
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
@ -391,6 +645,85 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
return fragmentView;
}
@Override
public void saveSelfArgs(Bundle args) {
if (chat_id != 0) {
if (avatarUpdater != null && avatarUpdater.currentPicturePath != null) {
args.putString("path", avatarUpdater.currentPicturePath);
}
}
}
@Override
public void restoreSelfArgs(Bundle args) {
if (chat_id != 0) {
MessagesController.getInstance().loadChatInfo(chat_id, null);
if (avatarUpdater != null) {
avatarUpdater.currentPicturePath = args.getString("path");
}
}
}
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
if (chat_id != 0) {
avatarUpdater.onActivityResult(requestCode, resultCode, data);
}
}
private void needLayout() {
FrameLayout.LayoutParams layoutParams;
if (listView != null) {
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight();
listView.setLayoutParams(layoutParams);
}
if (avatarImage != null) {
float diff = actionBar.getExtraHeight() / (float)AndroidUtilities.dp(88);
float diffm = 1.0f - diff;
int avatarSize = 42 + (int)(18 * diff);
int avatarX = 17 + (int)(47 * diffm);
int avatarY = AndroidUtilities.dp(22) - (int)((AndroidUtilities.dp(22) - (AndroidUtilities.getCurrentActionBarHeight() - AndroidUtilities.dp(42)) / 2) * (1.0f - diff));
int nameX = 97 + (int)(21 * diffm);
int nameEndX = 16 + (int)(32 * diffm);
float nameFontSize = 20 - 2 * diffm;
int nameY = avatarY + AndroidUtilities.dp(29 - 10 * diffm);
int statusY = avatarY + AndroidUtilities.dp(8 - 7 * diffm);
if (writeButton != null) {
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams();
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
writeButton.setLayoutParams(layoutParams);
ViewProxy.setAlpha(writeButton, diff);
writeButton.setVisibility(diff == 0 ? View.GONE : View.VISIBLE);
}
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(avatarSize / 2));
layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(avatarSize);
layoutParams.height = AndroidUtilities.dp(avatarSize);
layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(avatarX);
layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(avatarX) : 0;
layoutParams.bottomMargin = avatarY;
avatarImage.setLayoutParams(layoutParams);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, nameFontSize);
layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameEndX : nameX);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameX : nameEndX);
layoutParams.bottomMargin = nameY;
nameTextView.setLayoutParams(layoutParams);
layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameEndX : nameX);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameX : nameEndX);
layoutParams.bottomMargin = statusY;
onlineTextView.setLayoutParams(layoutParams);
}
}
private void fixLayout() {
if (fragmentView == null) {
return;
@ -399,12 +732,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public boolean onPreDraw() {
if (fragmentView != null) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) listView.getLayoutParams();
layoutParams.topMargin = actionBar.getHeight();
listView.setLayoutParams(layoutParams);
layoutParams = (ViewGroup.MarginLayoutParams) writeButton.getLayoutParams();
layoutParams.topMargin = actionBar.getHeight() - AndroidUtilities.dp(29.5f);
writeButton.setLayoutParams(layoutParams);
needLayout();
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
}
return false;
@ -423,22 +751,49 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
return false;
}
@Override
public void didReceivedNotification(int id, final Object... args) {
if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
if (user_id != 0) {
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
updateUserData();
updateProfileData();
}
} else if (chat_id != 0) {
if ((mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
updateOnlineCount();
updateProfileData();
}
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof UserCell) {
((UserCell) child).update(mask);
}
}
}
}
} else if (id == NotificationCenter.contactsDidLoaded) {
createActionBarMenu();
} else if (id == NotificationCenter.mediaCountDidLoaded) {
long uid = (Long)args[0];
if (user_id != 0) {
if (uid > 0 && user_id == uid && dialog_id == 0 || dialog_id != 0 && dialog_id == uid) {
totalMediaCount = (Integer) args[1];
if (listView != null) {
listView.invalidateViews();
}
}
} else if (chat_id != 0) {
int lower_part = (int)uid;
if (lower_part < 0 && chat_id == -lower_part) {
totalMediaCount = (Integer)args[1];
if (listView != null) {
listView.invalidateViews();
}
}
}
} else if (id == NotificationCenter.encryptedChatCreated) {
if (creatingChat) {
AndroidUtilities.runOnUIThread(new Runnable() {
@ -467,6 +822,18 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (oldValue != userBlocked) {
createActionBarMenu();
}
} else if (id == NotificationCenter.chatInfoDidLoaded) {
int chatId = (Integer)args[0];
if (chatId == chat_id) {
info = (TLRPC.ChatParticipants)args[1];
updateOnlineCount();
updateRowsIds();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
} else if (id == NotificationCenter.closeChats) {
removeSelfFromStack();
}
}
@ -484,10 +851,22 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (fileLocation == null) {
return null;
}
TLRPC.FileLocation photoBig = null;
if (user_id != 0) {
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user != null && user.photo != null && user.photo.photo_big != null) {
TLRPC.FileLocation photoBig = user.photo.photo_big;
if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
photoBig = user.photo.photo_big;
}
} else if (chat_id != 0) {
TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id);
if (chat != null && chat.photo != null && chat.photo.photo_big != null) {
photoBig = chat.photo.photo_big;
}
}
if (photoBig != null && photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
int coords[] = new int[2];
avatarImage.getLocationInWindow(coords);
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
@ -500,7 +879,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
object.size = -1;
return object;
}
}
return null;
}
@ -525,8 +903,77 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public int getSelectedCount() { return 0; }
private void updateOnlineCount() {
if (info == null) {
return;
}
onlineCount = 0;
int currentTime = ConnectionsManager.getInstance().getCurrentTime();
sortedUsers.clear();
int i = 0;
for (TLRPC.TL_chatParticipant participant : info.participants) {
TLRPC.User user = MessagesController.getInstance().getUser(participant.user_id);
if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.getClientUserId()) && user.status.expires > 10000) {
onlineCount++;
}
sortedUsers.add(i);
i++;
}
Collections.sort(sortedUsers, new Comparator<Integer>() {
@Override
public int compare(Integer lhs, Integer rhs) {
TLRPC.User user1 = MessagesController.getInstance().getUser(info.participants.get(rhs).user_id);
TLRPC.User user2 = MessagesController.getInstance().getUser(info.participants.get(lhs).user_id);
Integer status1 = 0;
Integer status2 = 0;
if (user1 != null && user1.status != null) {
if (user1.id == UserConfig.getClientUserId()) {
status1 = ConnectionsManager.getInstance().getCurrentTime() + 50000;
} else {
status1 = user1.status.expires;
}
}
if (user2 != null && user2.status != null) {
if (user2.id == UserConfig.getClientUserId()) {
status2 = ConnectionsManager.getInstance().getCurrentTime() + 50000;
} else {
status2 = user2.status.expires;
}
}
return status1.compareTo(status2);
}
});
if (listView != null) {
listView.invalidateViews();
}
}
public void setChatInfo(TLRPC.ChatParticipants chatParticipants) {
info = chatParticipants;
}
private void kickUser(TLRPC.TL_chatParticipant user) {
if (user != null) {
MessagesController.getInstance().deleteUserFromChat(chat_id, MessagesController.getInstance().getUser(user.user_id), info);
} else {
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
MessagesController.getInstance().deleteUserFromChat(chat_id, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), info);
MessagesController.getInstance().deleteDialog(-chat_id, 0, false);
finishFragment();
}
}
public boolean isChat() {
return chat_id != 0;
}
private void updateRowsIds() {
rowCount = 0;
overscrollRow = rowCount++;
if (user_id != 0) {
emptyRow = rowCount++;
phoneRow = rowCount++;
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
@ -550,9 +997,29 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} else {
startSecretChatRow = -1;
}
} else if (chat_id != 0) {
if (chat_id > 0) {
emptyRow = rowCount++;
settingsNotificationsRow = rowCount++;
sharedMediaRow = rowCount++;
emptyRowChat = rowCount++;
membersSectionRow = rowCount++;
}
if (info != null && !(info instanceof TLRPC.TL_chatParticipantsForbidden)) {
emptyRowChat2 = rowCount++;
rowCount += info.participants.size();
membersEndRow = rowCount;
int maxCount = chat_id > 0 ? MessagesController.getInstance().maxGroupCount : MessagesController.getInstance().maxBroadcastCount;
} else {
membersEndRow = -1;
membersSectionRow = -1;
emptyRowChat2 = -1;
}
}
}
private void updateUserData() {
private void updateProfileData() {
if (user_id != 0) {
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
TLRPC.FileLocation photo = null;
TLRPC.FileLocation photoBig = null;
@ -561,18 +1028,45 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
photoBig = user.photo.photo_big;
}
avatarImage.setImage(photo, "50_50", new AvatarDrawable(user, true));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
onlineTextView.setText(LocaleController.formatUserStatus(user));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
} else if (chat_id != 0) {
TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id);
if (chat != null) {
currentChat = chat;
}
nameTextView.setText(chat.title);
int count = chat.participants_count;
if (info != null) {
count = info.participants.size();
}
if (count != 0 && onlineCount > 1) {
onlineTextView.setText(Html.fromHtml(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))));
} else {
onlineTextView.setText(LocaleController.formatPluralString("Members", count));
}
TLRPC.FileLocation photo = null;
TLRPC.FileLocation photoBig = null;
if (chat.photo != null) {
photo = chat.photo.photo_small;
photoBig = chat.photo.photo_big;
}
avatarImage.setImage(photo, "50_50", new AvatarDrawable(chat));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
}
}
private void createActionBarMenu() {
ActionBarMenu menu = actionBar.createMenu();
menu.clearItems();
if (user_id != 0) {
if (ContactsController.getInstance().contactsDict.get(user_id) == null) {
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user == null) {
@ -593,6 +1087,16 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
item.addSubItem(edit_contact, LocaleController.getString("EditContact", R.string.EditContact), 0);
item.addSubItem(delete_contact, LocaleController.getString("DeleteContact", R.string.DeleteContact), 0);
}
} else if (chat_id != 0) {
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0);
if (chat_id > 0) {
item.addSubItem(add_member, LocaleController.getString("AddMember", R.string.AddMember), 0);
item.addSubItem(leave_group, LocaleController.getString("DeleteAndExit", R.string.DeleteAndExit), 0);
} else {
item.addSubItem(add_member, LocaleController.getString("AddRecipient", R.string.AddRecipient), 0);
}
}
}
@Override
@ -639,7 +1143,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public boolean isEnabled(int i) {
if (user_id != 0) {
return i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow || i == startSecretChatRow;
} else if (chat_id != 0) {
return i == settingsNotificationsRow || i == sharedMediaRow || i > emptyRowChat2 && i < membersEndRow;
}
return false;
}
@Override
@ -667,7 +1176,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
int type = getItemViewType(i);
if (type == 0) {
if (view == null) {
view = new EmptyCell(mContext, 36);
view = new EmptyCell(mContext);
}
if (i == overscrollRow) {
((EmptyCell) view).setHeight(88);
} else if (i == emptyRowChat || i == emptyRowChat2) {
((EmptyCell) view).setHeight(8);
} else {
((EmptyCell) view).setHeight(36);
}
} else if (type == 1) {
if (view == null) {
@ -733,13 +1249,24 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
identiconDrawable.setBytes(encryptedChat.auth_key);
textCell.setTextAndValueDrawable(LocaleController.getString("EncryptionKey", R.string.EncryptionKey), identiconDrawable);
}
} else if (type == 4) {
if (view == null) {
view = new UserCell(mContext, 61);
}
TLRPC.TL_chatParticipant part = info.participants.get(sortedUsers.get(i - emptyRowChat2 - 1));
((UserCell)view).setData(MessagesController.getInstance().getUser(part.user_id), null, null, i == emptyRowChat2 + 1 ? R.drawable.menu_newgroup : 0);
} else if (type == 5) {
if (view == null) {
view = new ShadowSectionCell(mContext);
}
}
return view;
}
@Override
public int getItemViewType(int i) {
if (i == emptyRow) {
if (i == emptyRow || i == overscrollRow || i == emptyRowChat || i == emptyRowChat2) {
return 0;
} else if (i == sectionRow) {
return 1;
@ -747,13 +1274,17 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
return 2;
} else if (i == sharedMediaRow || i == settingsTimerRow || i == settingsNotificationsRow || i == startSecretChatRow || i == settingsKeyRow) {
return 3;
} else if (i > emptyRowChat2 && i < membersEndRow) {
return 4;
} else if (i == membersSectionRow) {
return 5;
}
return 0;
}
@Override
public int getViewTypeCount() {
return 4;
return 6;
}
@Override

View File

@ -18,9 +18,11 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.Spannable;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.Base64;
import android.util.TypedValue;
@ -30,6 +32,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
@ -58,6 +61,7 @@ import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.UserConfig;
import org.telegram.android.MessageObject;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.AnimationCompat.ViewProxy;
import org.telegram.ui.Cells.TextInfoCell;
import org.telegram.ui.Cells.EmptyCell;
import org.telegram.ui.Cells.HeaderCell;
@ -88,6 +92,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
private ImageView writeButton;
private AvatarUpdater avatarUpdater = new AvatarUpdater();
private int overscrollRow;
private int emptyRow;
private int numberSectionRow;
private int numberRow;
@ -200,6 +205,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
rowCount = 0;
overscrollRow = rowCount++;
emptyRow = rowCount++;
numberSectionRow = rowCount++;
numberRow = rowCount++;
@ -261,7 +267,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(5));
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setExtraHeight(AndroidUtilities.dp(88));
actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
@ -306,7 +312,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
fragmentView = new FrameLayout(getParentActivity());
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.addView(actionBar);
avatarImage = new BackupImageView(getParentActivity());
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30));
@ -337,6 +342,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
nameTextView.setLines(1);
nameTextView.setMaxLines(1);
nameTextView.setSingleLine(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
actionBar.addView(nameTextView);
@ -355,6 +361,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
onlineTextView.setLines(1);
onlineTextView.setMaxLines(1);
onlineTextView.setSingleLine(true);
onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
actionBar.addView(onlineTextView);
layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
@ -368,6 +375,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
listView = new ListView(getParentActivity());
listView.setDivider(null);
listView.setDrawingCacheEnabled(false);
listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false);
AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5));
@ -624,6 +632,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
}
});
frameLayout.addView(actionBar);
writeButton = new ImageView(getParentActivity());
writeButton.setImageResource(R.drawable.floating_group_states);
frameLayout.addView(writeButton);
@ -676,6 +686,31 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
}
});
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (totalItemCount == 0) {
return;
}
int height = 0;
View child = view.getChildAt(0);
if (child != null) {
if (firstVisibleItem == 0) {
height = AndroidUtilities.dp(88) + child.getTop();
}
if (actionBar.getExtraHeight() != height) {
actionBar.setExtraHeight(height, true);
needLayout();
}
}
}
});
updateUserData();
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
@ -864,6 +899,57 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
fixLayout();
}
private void needLayout() {
FrameLayout.LayoutParams layoutParams;
if (listView != null) {
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight();
listView.setLayoutParams(layoutParams);
}
if (avatarImage != null) {
float diff = actionBar.getExtraHeight() / (float)AndroidUtilities.dp(88);
float diffm = 1.0f - diff;
int avatarSize = 42 + (int)(18 * diff);
int avatarX = 17 + (int)(47 * diffm);
int avatarY = AndroidUtilities.dp(22) - (int)((AndroidUtilities.dp(22) - (AndroidUtilities.getCurrentActionBarHeight() - AndroidUtilities.dp(42)) / 2) * (1.0f - diff));
int nameX = 97 + (int)(21 * diffm);
int nameEndX = 16 + (int)(32 * diffm);
float nameFontSize = 20 - 2 * diffm;
int nameY = avatarY + AndroidUtilities.dp(29 - 10 * diffm);
int statusY = avatarY + AndroidUtilities.dp(8 - 7 * diffm);
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams();
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
writeButton.setLayoutParams(layoutParams);
ViewProxy.setAlpha(writeButton, diff);
writeButton.setVisibility(diff == 0 ? View.GONE : View.VISIBLE);
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(avatarSize / 2));
layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(avatarSize);
layoutParams.height = AndroidUtilities.dp(avatarSize);
layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(avatarX);
layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(avatarX) : 0;
layoutParams.bottomMargin = avatarY;
avatarImage.setLayoutParams(layoutParams);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, nameFontSize);
layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameEndX : nameX);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameX : nameEndX);
layoutParams.bottomMargin = nameY;
nameTextView.setLayoutParams(layoutParams);
layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameEndX : nameX);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameX : nameEndX);
layoutParams.bottomMargin = statusY;
onlineTextView.setLayoutParams(layoutParams);
}
}
private void fixLayout() {
if (fragmentView == null) {
return;
@ -872,12 +958,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override
public boolean onPreDraw() {
if (fragmentView != null) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) listView.getLayoutParams();
layoutParams.topMargin = actionBar.getHeight();
listView.setLayoutParams(layoutParams);
layoutParams = (ViewGroup.MarginLayoutParams) writeButton.getLayoutParams();
layoutParams.topMargin = actionBar.getHeight() - AndroidUtilities.dp(29.5f);
writeButton.setLayoutParams(layoutParams);
needLayout();
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
}
return false;
@ -897,7 +978,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
onlineTextView.setText(LocaleController.formatUserStatus(user));
onlineTextView.setText(LocaleController.getString("Online", R.string.Online));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
}
@ -971,7 +1052,12 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
int type = getItemViewType(i);
if (type == 0) {
if (view == null) {
view = new EmptyCell(mContext, 16);
view = new EmptyCell(mContext);
}
if (i == overscrollRow) {
((EmptyCell) view).setHeight(88);
} else {
((EmptyCell) view).setHeight(16);
}
} else if (type == 1) {
if (view == null) {
@ -1131,7 +1217,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override
public int getItemViewType(int i) {
if (i == emptyRow) {
if (i == emptyRow || i == overscrollRow) {
return 0;
} if (i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == mediaDownloadSection || i == contactsSectionRow) {
return 1;

View File

@ -11,13 +11,17 @@ package org.telegram.ui;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.telegram.PhoneFormat.PhoneFormat;
@ -27,6 +31,7 @@ import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.TextInfoCell;
import org.telegram.ui.Cells.UserCell;
import org.telegram.ui.Views.ActionBar.ActionBar;
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
@ -35,8 +40,8 @@ import org.telegram.ui.Views.ActionBar.BaseFragment;
public class SettingsBlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
private ListView listView;
private ListAdapter listViewAdapter;
private View progressView;
private TextView emptyView;
private FrameLayout progressView;
private TextView emptyTextView;
private int selectedUserId;
private final static int block_user = 1;
@ -83,27 +88,58 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
ActionBarMenu menu = actionBar.createMenu();
menu.addItem(block_user, R.drawable.plus);
fragmentView = inflater.inflate(R.layout.settings_blocked_users_layout, container, false);
listViewAdapter = new ListAdapter(getParentActivity());
listView = (ListView)fragmentView.findViewById(R.id.listView);
progressView = fragmentView.findViewById(R.id.progressLayout);
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
emptyView.setOnTouchListener(new View.OnTouchListener() {
fragmentView = new FrameLayout(getParentActivity());
FrameLayout frameLayout = (FrameLayout) fragmentView;
emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(24);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setVisibility(View.INVISIBLE);
emptyTextView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));
frameLayout.addView(emptyTextView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP;
emptyTextView.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
emptyView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));
if (MessagesController.getInstance().loadingBlockedUsers) {
progressView.setVisibility(View.VISIBLE);
emptyView.setVisibility(View.GONE);
listView.setEmptyView(null);
} else {
progressView.setVisibility(View.GONE);
listView.setEmptyView(emptyView);
progressView = new FrameLayout(getParentActivity());
frameLayout.addView(progressView);
layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
progressView.setLayoutParams(layoutParams);
ProgressBar progressBar = new ProgressBar(getParentActivity());
progressView.addView(progressBar);
layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.CENTER;
progressView.setLayoutParams(layoutParams);
listView = new ListView(getParentActivity());
listView.setEmptyView(emptyTextView);
listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
if (Build.VERSION.SDK_INT >= 11) {
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
}
listView.setAdapter(listViewAdapter);
frameLayout.addView(listView);
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
listView.setLayoutParams(layoutParams);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
@ -140,6 +176,15 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
return true;
}
});
if (MessagesController.getInstance().loadingBlockedUsers) {
progressView.setVisibility(View.VISIBLE);
emptyTextView.setVisibility(View.GONE);
listView.setEmptyView(null);
} else {
progressView.setVisibility(View.GONE);
listView.setEmptyView(emptyTextView);
}
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
@ -161,7 +206,7 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
progressView.setVisibility(View.GONE);
}
if (listView != null && listView.getEmptyView() == null) {
listView.setEmptyView(emptyView);
listView.setEmptyView(emptyTextView);
}
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
@ -243,17 +288,14 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
int type = getItemViewType(i);
if (type == 0) {
if (view == null) {
view = new UserCell(mContext);
((UserCell)view).useSeparator = true;
view = new UserCell(mContext, 1);
}
TLRPC.User user = MessagesController.getInstance().getUser(MessagesController.getInstance().blockedUsers.get(i));
((UserCell)view).setData(user, null, user.phone != null && user.phone.length() != 0 ? PhoneFormat.getInstance().format("+" + user.phone) : LocaleController.getString("NumberUnknown", R.string.NumberUnknown));
((UserCell)view).setData(user, null, user.phone != null && user.phone.length() != 0 ? PhoneFormat.getInstance().format("+" + user.phone) : LocaleController.getString("NumberUnknown", R.string.NumberUnknown), 0);
} else if (type == 1) {
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_unblock_info_row_layout, viewGroup, false);
TextView textView = (TextView)view.findViewById(R.id.info_text_view);
textView.setText(LocaleController.getString("UnblockText", R.string.UnblockText));
view = new TextInfoCell(mContext);
((TextInfoCell) view).setText(LocaleController.getString("UnblockText", R.string.UnblockText));
}
}
return view;

View File

@ -452,8 +452,15 @@ public class ActionBar extends FrameLayout {
positionBackOverlay(getMeasuredWidth(), getMeasuredHeight());
}
public void setExtraHeight(int value) {
public void setExtraHeight(int value, boolean layout) {
extraHeight = value;
if (layout) {
requestLayout();
}
}
public int getExtraHeight() {
return extraHeight;
}
private void positionBackOverlay(int widthMeasureSpec, int heightMeasureSpec) {

View File

@ -31,7 +31,6 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import java.lang.reflect.Field;
@ -186,7 +185,7 @@ public class ActionBarMenuItem extends ImageView {
if (LocaleController.isRTL) {
layoutParams.gravity = Gravity.RIGHT;
}
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = AndroidUtilities.dp(48);
textView.setLayoutParams(layoutParams);
textView.setOnClickListener(new OnClickListener() {
@ -389,7 +388,6 @@ public class ActionBarMenuItem extends ImageView {
if (popupWindow != null && popupWindow.isShowing()) {
int x = parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft();
int y = -getMeasuredHeight();
FileLog.e("tmessages", "x = " + x + " y = " + y);
popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1);
}
}

View File

@ -21,6 +21,7 @@ import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.ApplicationLoader;
public class AvatarDrawable extends Drawable {
@ -33,11 +34,14 @@ public class AvatarDrawable extends Drawable {
private static int[] arrColorsButtons = {R.drawable.bar_selector_red, R.drawable.bar_selector_orange, R.drawable.bar_selector_yellow,
R.drawable.bar_selector_green, R.drawable.bar_selector_cyan, R.drawable.bar_selector_blue, R.drawable.bar_selector_violet, R.drawable.bar_selector_pink};
private static Drawable broadcastDrawable;
private int color;
private StaticLayout textLayout;
private float textWidth;
private float textHeight;
private boolean isProfile;
private boolean drawBrodcast;
public AvatarDrawable() {
super();
@ -46,6 +50,8 @@ public class AvatarDrawable extends Drawable {
namePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
namePaint.setColor(0xffffffff);
namePaint.setTextSize(AndroidUtilities.dp(20));
broadcastDrawable = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.broadcast_w);
}
}
@ -116,6 +122,8 @@ public class AvatarDrawable extends Drawable {
color = arrColors[Math.abs(id) % arrColors.length];
}
drawBrodcast = isBroadcast;
String text = "";
if (firstName != null && firstName.length() > 0) {
text += firstName.substring(0, 1);
@ -145,17 +153,23 @@ public class AvatarDrawable extends Drawable {
if (bounds == null) {
return;
}
int size = bounds.right - bounds.left;
int size = bounds.width();
paint.setColor(color);
canvas.save();
canvas.translate(bounds.left, bounds.top);
canvas.drawCircle(size / 2, size / 2, size / 2, paint);
if (drawBrodcast && broadcastDrawable != null) {
int x = (size - broadcastDrawable.getIntrinsicWidth()) / 2;
int y = (size - broadcastDrawable.getIntrinsicHeight()) / 2;
broadcastDrawable.setBounds(x, y, x + broadcastDrawable.getIntrinsicWidth(), y + broadcastDrawable.getIntrinsicHeight());
broadcastDrawable.draw(canvas);
} else {
if (textLayout != null) {
canvas.translate((size - textWidth) / 2, (size - textHeight) / 2);
textLayout.draw(canvas);
}
}
canvas.restore();
}

View File

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="66dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/messages_list_row_avatar"
android:contentDescription=""
android:layout_marginRight="24dp"
android:src="@drawable/addmember"
android:scaleType="center"
android:layout_gravity="center_vertical|right"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/messages_list_row_name"
android:textSize="18dp"
android:layout_marginRight="61dp"
android:ellipsize="end"
android:gravity="right"
android:textColor="#000000"
android:maxLines="1"
android:layout_gravity="center_vertical|right"/>
<View android:background="@color/divider"
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:id="@+id/settings_row_divider"/>
</FrameLayout>

View File

@ -1,78 +0,0 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center_vertical|right"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="13dp"
android:paddingBottom="12dp">
<ImageButton
android:id="@+id/settings_edit_name"
android:background="@drawable/list_selector"
android:clickable="true"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_edit"/>
<View
android:background="#e8e8e8"
android:layout_width="1dp"
android:layout_height="48dp"/>
<LinearLayout
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="13dp"
android:layout_marginBottom="1dp"
android:layout_weight="1">
<TextView
android:textSize="21dp"
android:textColor="#333333"
android:id="@+id/settings_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:lines="1"
android:ellipsize="end"
android:singleLine="true"
android:layout_gravity="right"
android:gravity="right"/>
<TextView
android:textSize="14dp"
android:textColor="#999999"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:maxLines="1"
android:lines="1"
android:ellipsize="end"
android:id="@+id/settings_online"
android:layout_gravity="right"
android:gravity="right"/>
</LinearLayout>
<FrameLayout
android:layout_width="64dp"
android:layout_height="64dp">
<org.telegram.ui.Views.BackupImageView
android:id="@+id/settings_avatar_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<ImageButton
android:id="@+id/settings_change_avatar_button"
android:background="@drawable/photo_spinner"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
</LinearLayout>

View File

@ -1,68 +0,0 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/top_layout"
android:layout_gravity="top">
<EditText
android:textSize="16dp"
android:textColorHint="#a6a6a6"
android:id="@+id/bubble_input_text"
android:paddingLeft="60dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:minHeight="52dp"
android:gravity="right|center_vertical"
android:maxLines="2"
android:paddingTop="3dp"
android:layout_marginTop="0dp"
android:inputType="textFilter|textNoSuggestions|textMultiLine"
android:imeOptions="flagNoExtractUi"
android:textCursorDrawable="@null"
android:textColor="#000000"/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.telegram.ui.Views.PinnedHeaderListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listView"
android:clipToPadding="false"
android:fadingEdge="none"
android:fadingEdgeLength="0dp"
android:paddingLeft="30dp"
android:paddingRight="16dp"
android:dividerHeight="0dp"
android:divider="@null"
android:paddingBottom="16dp"
android:fastScrollEnabled="true"
android:fastScrollAlwaysVisible="true"
android:scrollbarStyle="outsideOverlay"
android:verticalScrollbarPosition="left"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:id="@+id/searchEmptyView"
android:visibility="invisible"/>
</FrameLayout>
</LinearLayout>

View File

@ -1,3 +1,11 @@
<!--
~ This is the source code of Telegram for Android v. 1.7.x.
~ It is licensed under GNU GPL v. 2 or later.
~ You should have received a copy of the license in this archive (see LICENSE).
~
~ Copyright Nikolai Kudashov, 2013-2014.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"

View File

@ -1,35 +0,0 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_gravity="top">
<TextView
android:textSize="18dp"
android:textColor="#333333"
android:id="@+id/settings_row_text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:layout_gravity="top|right"/>
<TextView
android:textSize="18dp"
android:textColor="#316f9f"
android:id="@+id/settings_row_text_detail"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"/>
<View
android:background="@color/divider"
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:id="@+id/settings_row_divider"/>
</FrameLayout>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="66dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/messages_list_row_avatar"
android:contentDescription=""
android:src="@drawable/addmember"
android:scaleType="center"
android:layout_gravity="center_vertical"
android:layout_marginLeft="24dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/messages_list_row_name"
android:textSize="18dp"
android:layout_marginLeft="61dp"
android:ellipsize="end"
android:textColor="#000000"
android:maxLines="1"
android:layout_gravity="center_vertical"/>
<View android:background="@color/divider"
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:id="@+id/settings_row_divider"/>
</FrameLayout>

View File

@ -1,74 +0,0 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="13dp"
android:paddingBottom="12dp">
<FrameLayout
android:layout_width="64dp"
android:layout_height="64dp">
<org.telegram.ui.Views.BackupImageView
android:id="@+id/settings_avatar_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<ImageButton
android:id="@+id/settings_change_avatar_button"
android:background="@drawable/photo_spinner"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
<LinearLayout
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="1dp"
android:layout_weight="1">
<TextView
android:textSize="21dp"
android:textColor="#333333"
android:id="@+id/settings_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:lines="1"
android:ellipsize="end"
android:singleLine="true"/>
<TextView
android:textSize="14dp"
android:textColor="#999999"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:maxLines="1"
android:lines="1"
android:ellipsize="end"
android:id="@+id/settings_online"/>
</LinearLayout>
<View
android:background="#e8e8e8"
android:layout_width="1dp"
android:layout_height="48dp"/>
<ImageButton
android:id="@+id/settings_edit_name"
android:background="@drawable/list_selector"
android:clickable="true"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_edit"/>
</LinearLayout>

View File

@ -1,65 +0,0 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/top_layout"
android:layout_gravity="top">
<EditText
android:textSize="16dp"
android:textColorHint="#a6a6a6"
android:id="@+id/bubble_input_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:minHeight="52dp"
android:gravity="left|center_vertical"
android:maxLines="2"
android:paddingTop="3dp"
android:layout_marginTop="0dp"
android:inputType="textFilter|textNoSuggestions|textMultiLine"
android:imeOptions="flagNoExtractUi"
android:textCursorDrawable="@null"
android:textColor="#000000"/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.telegram.ui.Views.PinnedHeaderListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listView"
android:clipToPadding="false"
android:fadingEdge="none"
android:fadingEdgeLength="0dp"
android:paddingLeft="16dp"
android:paddingRight="30dp"
android:dividerHeight="0dp"
android:divider="@null"
android:paddingBottom="16dp"
android:fastScrollEnabled="true"
android:fastScrollAlwaysVisible="true"
android:scrollbarStyle="outsideOverlay"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:id="@+id/searchEmptyView"
android:visibility="invisible"/>
</FrameLayout>
</LinearLayout>

View File

@ -1,44 +0,0 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:clipToPadding="false"
android:fadingEdge="none"
android:fadingEdgeLength="0dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:dividerHeight="0dp"
android:divider="@null"
android:scrollbars="none"
android:paddingBottom="16dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:id="@+id/searchEmptyView"/>
<LinearLayout
android:id="@+id/progressLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>

View File

@ -1,24 +0,0 @@
<!--
~ This is the source code of Telegram for Android v. 1.7.x.
~ It is licensed under GNU GPL v. 2 or later.
~ You should have received a copy of the license in this archive (see LICENSE).
~
~ Copyright Nikolai Kudashov, 2013-2014.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="56dp"
android:paddingTop="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/logout_button_states"
android:gravity="center"
android:textSize="17dp"
android:textColor="#000000"
android:id="@+id/settings_row_text"/>
</FrameLayout>

View File

@ -1,3 +1,11 @@
<!--
~ This is the source code of Telegram for Android v. 1.7.x.
~ It is licensed under GNU GPL v. 2 or later.
~ You should have received a copy of the license in this archive (see LICENSE).
~
~ Copyright Nikolai Kudashov, 2013-2014.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"

View File

@ -1,14 +0,0 @@
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="48dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#9a9a9a"
android:textSize="15dp"
android:id="@+id/info_text_view"/>
</FrameLayout>

View File

@ -1,36 +0,0 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_gravity="top">
<TextView
android:textSize="18dp"
android:textColor="#333333"
android:id="@+id/settings_row_text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:layout_gravity="top"/>
<TextView
android:textSize="18dp"
android:textColor="#316f9f"
android:id="@+id/settings_row_text_detail"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:layout_gravity="right"/>
<View
android:background="@color/divider"
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:id="@+id/settings_row_divider"/>
</FrameLayout>

View File

@ -60,7 +60,7 @@
<string name="NewBroadcastList">New Broadcast List</string>
<string name="EnterListName">Enter list name</string>
<string name="YouCreatedBroadcastList">You created a broadcast list</string>
<string name="AddRecipient">Add Recipient</string>
<string name="AddRecipient">Add recipient</string>
<string name="KickFromBroadcast">Remove from broadcast list</string>
<!--documents view-->
<string name="SelectFile">Select File</string>
@ -240,7 +240,7 @@
<string name="NotificationsAndSounds">Notifications and Sounds</string>
<string name="BlockedUsers">Blocked Users</string>
<string name="SaveIncomingPhotos">Save Incoming Photos</string>
<string name="LogOut">Log Out</string>
<string name="LogOut">Log out</string>
<string name="YourFirstNameAndLastName">YOUR FIRST AND LAST NAME</string>
<string name="NoSound">No sound</string>
<string name="Default">Default</string>
@ -285,7 +285,7 @@
<string name="WhenRoaming">When roaming</string>
<string name="NoMediaAutoDownload">No media</string>
<string name="SaveToGallerySettings">Save to gallery</string>
<string name="EditName">Edit Name</string>
<string name="EditName">Edit name</string>
<!--media view-->
<string name="NoMedia">No shared media yet</string>
<string name="CancelDownload">Cancel Download</string>