2013-10-25 17:19:00 +02:00
|
|
|
/*
|
2013-12-20 20:25:49 +01:00
|
|
|
* This is the source code of Telegram for Android v. 1.3.2.
|
2013-10-25 17:19:00 +02:00
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
|
|
|
* Copyright Nikolai Kudashov, 2013.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
2015-02-01 19:51:02 +01:00
|
|
|
import android.animation.ObjectAnimator;
|
|
|
|
import android.animation.StateListAnimator;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
2014-11-11 23:16:17 +01:00
|
|
|
import android.content.res.Configuration;
|
2015-01-02 23:15:07 +01:00
|
|
|
import android.graphics.Bitmap;
|
2015-02-01 19:51:02 +01:00
|
|
|
import android.graphics.Outline;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.net.Uri;
|
2014-11-10 12:05:22 +01:00
|
|
|
import android.os.Build;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.os.Bundle;
|
2014-11-12 23:16:59 +01:00
|
|
|
import android.text.Html;
|
|
|
|
import android.text.TextUtils;
|
2014-11-10 12:05:22 +01:00
|
|
|
import android.util.TypedValue;
|
|
|
|
import android.view.Gravity;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2015-02-01 19:51:02 +01:00
|
|
|
import android.view.ViewOutlineProvider;
|
2014-11-11 23:16:17 +01:00
|
|
|
import android.view.ViewTreeObserver;
|
2014-11-12 23:16:59 +01:00
|
|
|
import android.widget.AbsListView;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.widget.AdapterView;
|
2014-11-10 12:05:22 +01:00
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.ImageView;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.widget.ListView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.android.AndroidUtilities;
|
2013-10-25 17:19:00 +02:00
|
|
|
import org.telegram.PhoneFormat.PhoneFormat;
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.android.LocaleController;
|
2014-11-12 23:16:59 +01:00
|
|
|
import org.telegram.android.MessagesStorage;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.android.SecretChatHelper;
|
2014-08-22 16:24:33 +02:00
|
|
|
import org.telegram.android.SendMessagesHelper;
|
2015-02-01 19:51:02 +01:00
|
|
|
import org.telegram.android.query.SharedMediaQuery;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.messenger.ApplicationLoader;
|
2014-11-12 23:16:59 +01:00
|
|
|
import org.telegram.messenger.ConnectionsManager;
|
2014-02-28 23:28:25 +01:00
|
|
|
import org.telegram.messenger.TLRPC;
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.android.ContactsController;
|
2013-12-20 20:25:49 +01:00
|
|
|
import org.telegram.messenger.FileLog;
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.android.MessagesController;
|
2014-08-22 16:24:33 +02:00
|
|
|
import org.telegram.android.NotificationCenter;
|
2013-10-25 17:19:00 +02:00
|
|
|
import org.telegram.messenger.R;
|
2014-08-22 16:24:33 +02:00
|
|
|
import org.telegram.android.MessageObject;
|
2014-11-12 23:16:59 +01:00
|
|
|
import org.telegram.messenger.UserConfig;
|
|
|
|
import org.telegram.messenger.Utilities;
|
2014-06-20 02:18:13 +02:00
|
|
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
2014-11-12 23:16:59 +01:00
|
|
|
import org.telegram.ui.AnimationCompat.ViewProxy;
|
2014-11-10 12:05:22 +01:00
|
|
|
import org.telegram.ui.Cells.DividerCell;
|
|
|
|
import org.telegram.ui.Cells.EmptyCell;
|
2014-11-12 23:16:59 +01:00
|
|
|
import org.telegram.ui.Cells.ShadowSectionCell;
|
2014-11-10 12:05:22 +01:00
|
|
|
import org.telegram.ui.Cells.TextCell;
|
|
|
|
import org.telegram.ui.Cells.TextDetailCell;
|
2014-11-12 23:16:59 +01:00
|
|
|
import org.telegram.ui.Cells.UserCell;
|
2014-11-13 21:10:14 +01:00
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.ui.Components.AvatarDrawable;
|
|
|
|
import org.telegram.ui.Components.AvatarUpdater;
|
|
|
|
import org.telegram.ui.Components.BackupImageView;
|
2014-11-13 21:10:14 +01:00
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.ui.Components.IdenticonDrawable;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2014-02-04 19:36:55 +01:00
|
|
|
import java.util.ArrayList;
|
2014-11-12 23:16:59 +01:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Comparator;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.concurrent.Semaphore;
|
2014-02-04 19:36:55 +01:00
|
|
|
|
2014-11-10 12:05:22 +01:00
|
|
|
public class ProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, PhotoViewer.PhotoViewerProvider {
|
2014-11-12 23:16:59 +01:00
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
private ListView listView;
|
|
|
|
private ListAdapter listAdapter;
|
2014-11-10 12:05:22 +01:00
|
|
|
private BackupImageView avatarImage;
|
|
|
|
private TextView nameTextView;
|
|
|
|
private TextView onlineTextView;
|
2014-11-11 23:16:17 +01:00
|
|
|
private ImageView writeButton;
|
2014-11-10 12:05:22 +01:00
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
private int user_id;
|
2014-11-12 23:16:59 +01:00
|
|
|
private int chat_id;
|
2013-10-25 17:19:00 +02:00
|
|
|
private long dialog_id;
|
2014-11-12 23:16:59 +01:00
|
|
|
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;
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
private TLRPC.EncryptedChat currentEncryptedChat;
|
2014-11-12 23:16:59 +01:00
|
|
|
private TLRPC.Chat currentChat;
|
|
|
|
|
|
|
|
private int totalMediaCount = -1;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2014-04-02 19:36:57 +02:00
|
|
|
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;
|
2014-11-12 23:16:59 +01:00
|
|
|
private final static int add_member = 6;
|
|
|
|
private final static int leave_group = 7;
|
|
|
|
private final static int edit_name = 8;
|
2014-04-02 19:36:57 +02:00
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
private int overscrollRow;
|
2014-11-10 12:05:22 +01:00
|
|
|
private int emptyRow;
|
2014-11-12 23:16:59 +01:00
|
|
|
private int emptyRowChat;
|
|
|
|
private int emptyRowChat2;
|
2014-05-17 01:05:49 +02:00
|
|
|
private int phoneRow;
|
2014-10-17 20:29:13 +02:00
|
|
|
private int usernameRow;
|
2014-05-17 01:05:49 +02:00
|
|
|
private int settingsTimerRow;
|
|
|
|
private int settingsKeyRow;
|
|
|
|
private int settingsNotificationsRow;
|
|
|
|
private int sharedMediaRow;
|
2014-11-10 12:05:22 +01:00
|
|
|
private int startSecretChatRow;
|
|
|
|
private int sectionRow;
|
2014-11-12 23:16:59 +01:00
|
|
|
private int membersSectionRow;
|
|
|
|
private int membersEndRow;
|
2014-05-17 01:05:49 +02:00
|
|
|
private int rowCount = 0;
|
|
|
|
|
2014-11-10 12:05:22 +01:00
|
|
|
public ProfileActivity(Bundle args) {
|
2014-06-04 01:31:48 +02:00
|
|
|
super(args);
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
|
|
|
public boolean onFragmentCreate() {
|
2014-06-04 01:31:48 +02:00
|
|
|
user_id = arguments.getInt("user_id", 0);
|
2014-11-12 23:16:59 +01:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
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.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);
|
|
|
|
|
2015-01-02 23:15:07 +01:00
|
|
|
sortedUsers = new ArrayList<>();
|
2014-11-12 23:16:59 +01:00
|
|
|
updateOnlineCount();
|
|
|
|
if (chat_id > 0) {
|
2015-02-01 19:51:02 +01:00
|
|
|
SharedMediaQuery.getMediaCount(-chat_id, SharedMediaQuery.MEDIA_PHOTOVIDEO, classGuid, true);
|
2014-11-12 23:16:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2014-08-22 16:24:33 +02:00
|
|
|
return false;
|
|
|
|
}
|
2014-10-17 20:29:13 +02:00
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaCountDidLoaded);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
2015-02-01 19:51:02 +01:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeChats);
|
2014-11-12 23:16:59 +01:00
|
|
|
updateRowsIds();
|
2014-10-17 20:29:13 +02:00
|
|
|
|
2014-08-22 16:24:33 +02:00
|
|
|
return true;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFragmentDestroy() {
|
|
|
|
super.onFragmentDestroy();
|
2015-03-19 00:09:45 +01:00
|
|
|
if (avatarImage != null) {
|
|
|
|
avatarImage.setImageDrawable(null);
|
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaCountDidLoaded);
|
2014-11-12 23:16:59 +01:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
2015-02-01 19:51:02 +01:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
|
2014-11-12 23:16:59 +01:00
|
|
|
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);
|
|
|
|
avatarUpdater.clear();
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-02-26 02:32:51 +01:00
|
|
|
public View createView(LayoutInflater inflater) {
|
2013-10-25 17:19:00 +02:00
|
|
|
if (fragmentView == null) {
|
2014-11-19 04:46:45 +01:00
|
|
|
actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 ? 5 : chat_id));
|
|
|
|
actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(user_id != 0 ? 5 : chat_id));
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
2014-11-12 23:16:59 +01:00
|
|
|
actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
|
2014-11-17 03:44:57 +01:00
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
actionBar.setOccupyStatusBar(false);
|
|
|
|
}
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
2014-06-04 01:31:48 +02:00
|
|
|
@Override
|
2014-08-22 16:24:33 +02:00
|
|
|
public void onItemClick(final int id) {
|
2014-11-12 23:16:59 +01:00
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
if (id == -1) {
|
|
|
|
finishFragment();
|
|
|
|
} else if (id == block_contact) {
|
2014-06-16 14:36:54 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2014-08-22 16:24:33 +02:00
|
|
|
if (!userBlocked) {
|
|
|
|
builder.setMessage(LocaleController.getString("AreYouSureBlockContact", R.string.AreYouSureBlockContact));
|
|
|
|
} else {
|
|
|
|
builder.setMessage(LocaleController.getString("AreYouSureUnblockContact", R.string.AreYouSureUnblockContact));
|
|
|
|
}
|
2014-06-16 14:36:54 +02:00
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
2014-06-04 01:31:48 +02:00
|
|
|
@Override
|
2014-06-16 14:36:54 +02:00
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
2014-08-22 16:24:33 +02:00
|
|
|
if (!userBlocked) {
|
|
|
|
MessagesController.getInstance().blockUser(user_id);
|
|
|
|
} else {
|
|
|
|
MessagesController.getInstance().unblockUser(user_id);
|
2014-06-16 14:36:54 +02:00
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
2014-06-16 14:36:54 +02:00
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
showAlertDialog(builder);
|
2014-06-04 01:31:48 +02:00
|
|
|
} else if (id == add_contact) {
|
2014-08-22 16:24:33 +02:00
|
|
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
2014-06-04 01:31:48 +02:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("user_id", user.id);
|
|
|
|
presentFragment(new ContactAddActivity(args));
|
|
|
|
} else if (id == share_contact) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("onlySelect", true);
|
|
|
|
args.putBoolean("serverOnly", true);
|
|
|
|
MessagesActivity fragment = new MessagesActivity(args);
|
2014-11-10 12:05:22 +01:00
|
|
|
fragment.setDelegate(ProfileActivity.this);
|
2014-06-04 01:31:48 +02:00
|
|
|
presentFragment(fragment);
|
|
|
|
} else if (id == edit_contact) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("user_id", user_id);
|
|
|
|
presentFragment(new ContactAddActivity(args));
|
|
|
|
} else if (id == delete_contact) {
|
2014-08-22 16:24:33 +02:00
|
|
|
final TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
2014-06-14 10:36:01 +02:00
|
|
|
if (user == null || getParentActivity() == null) {
|
2014-06-04 01:31:48 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2014-07-10 23:15:39 +02:00
|
|
|
builder.setMessage(LocaleController.getString("AreYouSureDeleteContact", R.string.AreYouSureDeleteContact));
|
2014-06-04 01:31:48 +02:00
|
|
|
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) {
|
2015-01-02 23:15:07 +01:00
|
|
|
ArrayList<TLRPC.User> arrayList = new ArrayList<>();
|
2014-06-04 01:31:48 +02:00
|
|
|
arrayList.add(user);
|
|
|
|
ContactsController.getInstance().deleteContact(arrayList);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
2014-06-07 01:35:21 +02:00
|
|
|
showAlertDialog(builder);
|
2014-11-12 23:16:59 +01:00
|
|
|
} 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) {
|
2015-01-02 23:15:07 +01:00
|
|
|
HashMap<Integer, TLRPC.User> users = new HashMap<>();
|
2014-11-12 23:16:59 +01:00
|
|
|
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);
|
2014-11-13 21:10:14 +01:00
|
|
|
presentFragment(new ChangeChatNameActivity(args));
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
createActionBarMenu();
|
|
|
|
|
|
|
|
listAdapter = new ListAdapter(getParentActivity());
|
2013-12-20 20:25:49 +01:00
|
|
|
|
2014-11-10 12:05:22 +01:00
|
|
|
fragmentView = new FrameLayout(getParentActivity());
|
|
|
|
FrameLayout frameLayout = (FrameLayout) fragmentView;
|
|
|
|
|
|
|
|
avatarImage = new BackupImageView(getParentActivity());
|
|
|
|
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30));
|
|
|
|
avatarImage.processDetach = false;
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar.addView(avatarImage);
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
|
|
|
|
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM;
|
|
|
|
layoutParams.width = AndroidUtilities.dp(60);
|
|
|
|
layoutParams.height = AndroidUtilities.dp(60);
|
|
|
|
layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(17);
|
|
|
|
layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(17) : 0;
|
|
|
|
layoutParams.bottomMargin = AndroidUtilities.dp(22);
|
|
|
|
avatarImage.setLayoutParams(layoutParams);
|
2014-11-10 12:05:22 +01:00
|
|
|
avatarImage.setOnClickListener(new View.OnClickListener() {
|
2013-12-20 20:25:49 +01:00
|
|
|
@Override
|
2014-11-10 12:05:22 +01:00
|
|
|
public void onClick(View v) {
|
2014-11-12 23:16:59 +01:00
|
|
|
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);
|
|
|
|
}
|
2014-06-14 10:36:01 +02:00
|
|
|
}
|
2013-12-20 20:25:49 +01:00
|
|
|
}
|
|
|
|
});
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2014-11-10 12:05:22 +01:00
|
|
|
nameTextView = new TextView(getParentActivity());
|
|
|
|
nameTextView.setTextColor(0xffffffff);
|
|
|
|
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
|
|
|
nameTextView.setLines(1);
|
|
|
|
nameTextView.setMaxLines(1);
|
|
|
|
nameTextView.setSingleLine(true);
|
2014-11-12 23:16:59 +01:00
|
|
|
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
|
2014-11-10 12:05:22 +01:00
|
|
|
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
|
|
|
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar.addView(nameTextView);
|
|
|
|
layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
|
|
|
|
layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
|
|
|
layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
|
|
|
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97);
|
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16);
|
|
|
|
layoutParams.bottomMargin = AndroidUtilities.dp(51);
|
|
|
|
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM;
|
|
|
|
nameTextView.setLayoutParams(layoutParams);
|
2014-11-10 12:05:22 +01:00
|
|
|
|
|
|
|
onlineTextView = new TextView(getParentActivity());
|
2014-11-19 04:46:45 +01:00
|
|
|
onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(user_id != 0 ? 5 : chat_id));
|
2014-11-10 12:05:22 +01:00
|
|
|
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
|
|
|
onlineTextView.setLines(1);
|
|
|
|
onlineTextView.setMaxLines(1);
|
|
|
|
onlineTextView.setSingleLine(true);
|
2014-11-12 23:16:59 +01:00
|
|
|
onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
|
2014-11-10 12:05:22 +01:00
|
|
|
onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar.addView(onlineTextView);
|
|
|
|
layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
|
|
|
|
layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
|
|
|
layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
|
|
|
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97);
|
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16);
|
|
|
|
layoutParams.bottomMargin = AndroidUtilities.dp(30);
|
|
|
|
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM;
|
|
|
|
onlineTextView.setLayoutParams(layoutParams);
|
2014-11-10 12:05:22 +01:00
|
|
|
|
|
|
|
listView = new ListView(getParentActivity());
|
|
|
|
listView.setDivider(null);
|
|
|
|
listView.setDividerHeight(0);
|
|
|
|
listView.setVerticalScrollBarEnabled(false);
|
2014-11-19 04:46:45 +01:00
|
|
|
AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(user_id != 0 ? 5 : chat_id));
|
2014-11-10 12:05:22 +01:00
|
|
|
frameLayout.addView(listView);
|
|
|
|
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
|
|
|
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
|
|
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
2014-11-11 23:16:17 +01:00
|
|
|
layoutParams.gravity = Gravity.TOP;
|
2014-11-10 12:05:22 +01:00
|
|
|
listView.setLayoutParams(layoutParams);
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
listView.setAdapter(listAdapter);
|
|
|
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
@Override
|
2014-05-17 01:05:49 +02:00
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
2014-11-10 12:05:22 +01:00
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-20 02:18:13 +02:00
|
|
|
if (i == sharedMediaRow) {
|
2014-06-04 01:31:48 +02:00
|
|
|
Bundle args = new Bundle();
|
2014-11-12 23:16:59 +01:00
|
|
|
if (user_id != 0) {
|
|
|
|
args.putLong("dialog_id", dialog_id != 0 ? dialog_id : user_id);
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
2014-11-12 23:16:59 +01:00
|
|
|
args.putLong("dialog_id", -chat_id);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
presentFragment(new MediaActivity(args));
|
2014-05-17 01:05:49 +02:00
|
|
|
} else if (i == settingsKeyRow) {
|
2014-06-04 01:31:48 +02:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("chat_id", (int)(dialog_id >> 32));
|
|
|
|
presentFragment(new IdenticonActivity(args));
|
2014-05-17 01:05:49 +02:00
|
|
|
} else if (i == settingsTimerRow) {
|
2014-06-14 10:36:01 +02:00
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-10-14 22:36:15 +02:00
|
|
|
showAlertDialog(AndroidUtilities.buildTTLAlert(getParentActivity(), currentEncryptedChat));
|
2014-06-20 02:18:13 +02:00
|
|
|
} else if (i == settingsNotificationsRow) {
|
|
|
|
Bundle args = new Bundle();
|
2014-11-12 23:16:59 +01:00
|
|
|
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);
|
|
|
|
}
|
2014-06-20 02:18:13 +02:00
|
|
|
presentFragment(new ProfileNotificationsActivity(args));
|
2014-11-10 12:05:22 +01:00
|
|
|
} else if (i == startSecretChatRow) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setMessage(LocaleController.getString("AreYouSureSecretChat", R.string.AreYouSureSecretChat));
|
|
|
|
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) {
|
|
|
|
creatingChat = true;
|
2014-12-01 18:56:31 +01:00
|
|
|
SecretChatHelper.getInstance().startSecretChat(getParentActivity(), MessagesController.getInstance().getUser(user_id));
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
showAlertDialog(builder);
|
|
|
|
} else if (i == phoneRow) {
|
|
|
|
final TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
|
|
|
if (user == null || user.phone == null || user.phone.length() == 0 || getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setItems(new CharSequence[] {LocaleController.getString("Call", R.string.Call), LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
if (i == 0) {
|
|
|
|
try {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + user.phone));
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
2015-02-26 02:32:51 +01:00
|
|
|
getParentActivity().startActivityForResult(intent, 500);
|
2014-11-10 12:05:22 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
} else if (i == 1) {
|
|
|
|
if(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
2014-12-01 18:56:31 +01:00
|
|
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
2014-11-24 15:14:40 +01:00
|
|
|
clipboard.setText("+" + user.phone);
|
2014-11-10 12:05:22 +01:00
|
|
|
} else {
|
|
|
|
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
2014-11-24 15:14:40 +01:00
|
|
|
android.content.ClipData clip = android.content.ClipData.newPlainText("label", "+" + user.phone);
|
2014-11-10 12:05:22 +01:00
|
|
|
clipboard.setPrimaryClip(clip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
showAlertDialog(builder);
|
2014-11-12 23:16:59 +01:00
|
|
|
} 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));
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-11-12 23:16:59 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
if (dialog_id != 0) {
|
2015-02-01 19:51:02 +01:00
|
|
|
SharedMediaQuery.getMediaCount(dialog_id, SharedMediaQuery.MEDIA_PHOTOVIDEO, classGuid, true);
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
2015-02-01 19:51:02 +01:00
|
|
|
SharedMediaQuery.getMediaCount(user_id, SharedMediaQuery.MEDIA_PHOTOVIDEO, classGuid, true);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
frameLayout.addView(actionBar);
|
|
|
|
|
2014-11-17 23:04:31 +01:00
|
|
|
if (user_id != 0 || chat_id >= 0 && !currentChat.left) {
|
2014-11-12 23:16:59 +01:00
|
|
|
writeButton = new ImageView(getParentActivity());
|
2015-02-01 19:51:02 +01:00
|
|
|
writeButton.setBackgroundResource(R.drawable.floating_user_states);
|
|
|
|
writeButton.setScaleType(ImageView.ScaleType.CENTER);
|
2014-11-12 23:16:59 +01:00
|
|
|
if (user_id != 0) {
|
2015-02-01 19:51:02 +01:00
|
|
|
writeButton.setImageResource(R.drawable.floating_message);
|
|
|
|
writeButton.setPadding(0, AndroidUtilities.dp(3), 0, 0);
|
2014-11-12 23:16:59 +01:00
|
|
|
} else if (chat_id != 0) {
|
2015-02-01 19:51:02 +01:00
|
|
|
writeButton.setImageResource(R.drawable.floating_camera);
|
2014-11-12 23:16:59 +01:00
|
|
|
}
|
|
|
|
frameLayout.addView(writeButton);
|
2015-02-01 19:51:02 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
StateListAnimator animator = new StateListAnimator();
|
|
|
|
animator.addState(new int[] {android.R.attr.state_pressed}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
|
|
|
|
animator.addState(new int[] {}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
|
|
|
|
writeButton.setStateListAnimator(animator);
|
|
|
|
writeButton.setOutlineProvider(new ViewOutlineProvider() {
|
|
|
|
@Override
|
|
|
|
public void getOutline(View view, Outline outline) {
|
|
|
|
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams();
|
|
|
|
layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
|
|
|
layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
|
|
|
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
|
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
|
|
|
|
layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT);
|
|
|
|
writeButton.setLayoutParams(layoutParams);
|
|
|
|
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;
|
|
|
|
}
|
2015-02-01 19:51:02 +01:00
|
|
|
NotificationCenter.getInstance().removeObserver(ProfileActivity.this, NotificationCenter.closeChats);
|
2014-11-12 23:16:59 +01:00
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
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();
|
2014-11-17 23:04:31 +01:00
|
|
|
} else if (i == 2) {
|
2014-11-12 23:16:59 +01:00
|
|
|
MessagesController.getInstance().changeChatAvatar(chat_id, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
showAlertDialog(builder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
2014-11-10 12:05:22 +01:00
|
|
|
@Override
|
2014-11-12 23:16:59 +01:00
|
|
|
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
2014-11-19 02:23:46 +01:00
|
|
|
checkListViewScroll();
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
updateProfileData();
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
|
|
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
|
|
|
if (parent != null) {
|
|
|
|
parent.removeView(fragmentView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fragmentView;
|
|
|
|
}
|
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
@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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-19 02:23:46 +01:00
|
|
|
private void checkListViewScroll() {
|
|
|
|
if (listView.getChildCount() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int height = 0;
|
|
|
|
View child = listView.getChildAt(0);
|
|
|
|
if (child != null) {
|
|
|
|
if (listView.getFirstVisiblePosition() == 0) {
|
|
|
|
height = AndroidUtilities.dp(88) + (child.getTop() < 0 ? child.getTop() : 0);
|
|
|
|
}
|
|
|
|
if (actionBar.getExtraHeight() != height) {
|
|
|
|
actionBar.setExtraHeight(height, true);
|
|
|
|
needLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
private void needLayout() {
|
|
|
|
FrameLayout.LayoutParams layoutParams;
|
|
|
|
if (listView != null) {
|
|
|
|
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
|
2014-11-17 03:44:57 +01:00
|
|
|
layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight();
|
2014-11-12 23:16:59 +01:00
|
|
|
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);
|
|
|
|
int nameY = avatarY + AndroidUtilities.dp(29 - 10 * diffm);
|
|
|
|
int statusY = avatarY + AndroidUtilities.dp(8 - 7 * diffm);
|
2015-03-26 18:34:47 +01:00
|
|
|
float scale = 1.0f - 0.12f * diffm;
|
2014-11-12 23:16:59 +01:00
|
|
|
|
|
|
|
if (writeButton != null) {
|
|
|
|
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams();
|
2014-11-17 03:44:57 +01:00
|
|
|
layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
|
2014-11-12 23:16:59 +01:00
|
|
|
writeButton.setLayoutParams(layoutParams);
|
|
|
|
ViewProxy.setAlpha(writeButton, diff);
|
2014-11-18 13:37:11 +01:00
|
|
|
writeButton.setVisibility(diff <= 0.02 ? View.GONE : View.VISIBLE);
|
2014-11-19 02:23:46 +01:00
|
|
|
if (writeButton.getVisibility() == View.GONE) {
|
|
|
|
writeButton.clearAnimation();
|
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2015-03-26 18:34:47 +01:00
|
|
|
ViewProxy.setPivotX(nameTextView, 0);
|
|
|
|
ViewProxy.setPivotY(nameTextView, 0);
|
|
|
|
ViewProxy.setScaleX(nameTextView, scale);
|
|
|
|
ViewProxy.setScaleY(nameTextView, scale);
|
2014-11-12 23:16:59 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-11 23:16:17 +01:00
|
|
|
private void fixLayout() {
|
|
|
|
if (fragmentView == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fragmentView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onPreDraw() {
|
|
|
|
if (fragmentView != null) {
|
2014-11-12 23:16:59 +01:00
|
|
|
needLayout();
|
2014-11-11 23:16:17 +01:00
|
|
|
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onConfigurationChanged(Configuration newConfig) {
|
|
|
|
super.onConfigurationChanged(newConfig);
|
|
|
|
fixLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean needAddActionBar() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
@Override
|
2014-10-09 17:55:05 +02:00
|
|
|
public void didReceivedNotification(int id, final Object... args) {
|
2014-08-22 16:24:33 +02:00
|
|
|
if (id == NotificationCenter.updateInterfaces) {
|
2014-02-04 19:36:55 +01:00
|
|
|
int mask = (Integer)args[0];
|
2014-11-12 23:16:59 +01:00
|
|
|
if (user_id != 0) {
|
2014-11-19 16:17:24 +01:00
|
|
|
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
|
2014-11-12 23:16:59 +01:00
|
|
|
updateProfileData();
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
if ((mask & MessagesController.UPDATE_MASK_PHONE) != 0) {
|
|
|
|
if (listView != null) {
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
} 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) {
|
2015-02-27 20:57:58 +01:00
|
|
|
if (listView != null) {
|
|
|
|
int count = listView.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View child = listView.getChildAt(a);
|
|
|
|
if (child instanceof UserCell) {
|
|
|
|
((UserCell) child).update(mask);
|
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.contactsDidLoaded) {
|
2014-06-04 01:31:48 +02:00
|
|
|
createActionBarMenu();
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.mediaCountDidLoaded) {
|
2013-10-25 17:19:00 +02:00
|
|
|
long uid = (Long)args[0];
|
2014-11-12 23:16:59 +01:00
|
|
|
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();
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.encryptedChatCreated) {
|
2013-10-25 17:19:00 +02:00
|
|
|
if (creatingChat) {
|
2014-11-06 22:34:47 +01:00
|
|
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
2014-10-09 17:55:05 +02:00
|
|
|
@Override
|
|
|
|
public void run() {
|
2015-02-01 19:51:02 +01:00
|
|
|
NotificationCenter.getInstance().removeObserver(ProfileActivity.this, NotificationCenter.closeChats);
|
2014-10-09 17:55:05 +02:00
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
2014-11-06 22:34:47 +01:00
|
|
|
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) args[0];
|
2014-10-09 17:55:05 +02:00
|
|
|
Bundle args2 = new Bundle();
|
|
|
|
args2.putInt("enc_id", encryptedChat.id);
|
|
|
|
presentFragment(new ChatActivity(args2), true);
|
|
|
|
}
|
|
|
|
});
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.encryptedChatUpdated) {
|
2013-10-25 17:19:00 +02:00
|
|
|
TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat)args[0];
|
|
|
|
if (currentEncryptedChat != null && chat.id == currentEncryptedChat.id) {
|
|
|
|
currentEncryptedChat = chat;
|
2014-05-17 01:05:49 +02:00
|
|
|
updateRowsIds();
|
2013-10-25 17:19:00 +02:00
|
|
|
if (listAdapter != null) {
|
|
|
|
listAdapter.notifyDataSetChanged();
|
2014-11-19 02:23:46 +01:00
|
|
|
checkListViewScroll();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.blockedUsersDidLoaded) {
|
|
|
|
boolean oldValue = userBlocked;
|
|
|
|
userBlocked = MessagesController.getInstance().blockedUsers.contains(user_id);
|
|
|
|
if (oldValue != userBlocked) {
|
|
|
|
createActionBarMenu();
|
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
} 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();
|
2014-11-19 02:23:46 +01:00
|
|
|
checkListViewScroll();
|
2014-11-12 23:16:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (id == NotificationCenter.closeChats) {
|
|
|
|
removeSelfFromStack();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
2014-06-04 18:00:42 +02:00
|
|
|
super.onResume();
|
2014-06-04 01:31:48 +02:00
|
|
|
if (listAdapter != null) {
|
2013-10-25 17:19:00 +02:00
|
|
|
listAdapter.notifyDataSetChanged();
|
|
|
|
}
|
2014-11-11 23:16:17 +01:00
|
|
|
fixLayout();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
@Override
|
|
|
|
public void updatePhotoAtIndex(int index) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-06-11 01:05:54 +02:00
|
|
|
@Override
|
2014-06-12 03:13:15 +02:00
|
|
|
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
|
2014-06-11 01:05:54 +02:00
|
|
|
if (fileLocation == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
|
|
|
|
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) {
|
|
|
|
photoBig = user.photo.photo_big;
|
2014-06-11 01:05:54 +02:00
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
} 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();
|
|
|
|
object.viewX = coords[0];
|
|
|
|
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
|
|
|
|
object.parentView = avatarImage;
|
|
|
|
object.imageReceiver = avatarImage.imageReceiver;
|
|
|
|
object.user_id = user_id;
|
|
|
|
object.thumb = object.imageReceiver.getBitmap();
|
|
|
|
object.size = -1;
|
2014-11-17 03:44:57 +01:00
|
|
|
object.radius = avatarImage.imageReceiver.getRoundRadius();
|
2014-11-12 23:16:59 +01:00
|
|
|
return object;
|
2014-06-11 01:05:54 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-01-02 23:15:07 +01:00
|
|
|
@Override
|
|
|
|
public Bitmap getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-06-11 02:22:42 +02:00
|
|
|
@Override
|
2014-06-12 03:13:15 +02:00
|
|
|
public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { }
|
2014-06-11 02:22:42 +02:00
|
|
|
|
2014-06-12 03:13:15 +02:00
|
|
|
@Override
|
2014-11-17 23:04:31 +01:00
|
|
|
public void willHidePhotoViewer() {
|
|
|
|
avatarImage.imageReceiver.setVisible(true, true);
|
|
|
|
}
|
2014-06-12 03:13:15 +02:00
|
|
|
|
|
|
|
@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; }
|
2014-06-11 02:22:42 +02:00
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
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++;
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
|
2015-01-02 23:15:07 +01:00
|
|
|
try {
|
|
|
|
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);
|
|
|
|
int status1 = 0;
|
|
|
|
int status2 = 0;
|
|
|
|
if (user1 != null && user1.status != null) {
|
|
|
|
if (user1.id == UserConfig.getClientUserId()) {
|
|
|
|
status1 = ConnectionsManager.getInstance().getCurrentTime() + 50000;
|
|
|
|
} else {
|
|
|
|
status1 = user1.status.expires;
|
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
}
|
2015-01-02 23:15:07 +01:00
|
|
|
if (user2 != null && user2.status != null) {
|
|
|
|
if (user2.id == UserConfig.getClientUserId()) {
|
|
|
|
status2 = ConnectionsManager.getInstance().getCurrentTime() + 50000;
|
|
|
|
} else {
|
|
|
|
status2 = user2.status.expires;
|
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
}
|
2015-01-02 23:15:07 +01:00
|
|
|
if (status1 > 0 && status2 > 0) {
|
|
|
|
if (status1 > status2) {
|
|
|
|
return 1;
|
|
|
|
} else if (status1 < status2) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
} else if (status1 < 0 && status2 < 0) {
|
|
|
|
if (status1 > status2) {
|
|
|
|
return 1;
|
|
|
|
} else if (status1 < status2) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
} else if (status1 < 0 && status2 > 0 || status1 == 0 && status2 != 0) {
|
2014-11-20 15:45:33 +01:00
|
|
|
return -1;
|
2015-01-02 23:15:07 +01:00
|
|
|
} else if (status2 < 0 && status1 > 0 || status2 == 0 && status1 != 0) {
|
2014-11-20 15:45:33 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2015-01-02 23:15:07 +01:00
|
|
|
});
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e); //TODO find crash
|
|
|
|
}
|
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
|
|
|
|
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);
|
2014-11-10 12:05:22 +01:00
|
|
|
} else {
|
2014-11-12 23:16:59 +01:00
|
|
|
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();
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
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);
|
|
|
|
if (user != null && user.username != null && user.username.length() > 0) {
|
|
|
|
usernameRow = rowCount++;
|
|
|
|
} else {
|
|
|
|
usernameRow = -1;
|
|
|
|
}
|
|
|
|
sectionRow = rowCount++;
|
|
|
|
settingsNotificationsRow = rowCount++;
|
|
|
|
sharedMediaRow = rowCount++;
|
|
|
|
if (currentEncryptedChat instanceof TLRPC.TL_encryptedChat) {
|
|
|
|
settingsTimerRow = rowCount++;
|
|
|
|
settingsKeyRow = rowCount++;
|
|
|
|
} else {
|
|
|
|
settingsTimerRow = -1;
|
|
|
|
settingsKeyRow = -1;
|
|
|
|
}
|
|
|
|
if (currentEncryptedChat == null) {
|
|
|
|
startSecretChatRow = rowCount++;
|
|
|
|
} 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;
|
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
private void updateProfileData() {
|
2014-11-17 03:44:57 +01:00
|
|
|
if (avatarImage == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
if (user_id != 0) {
|
|
|
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
|
|
|
TLRPC.FileLocation photo = null;
|
|
|
|
TLRPC.FileLocation photoBig = null;
|
|
|
|
if (user.photo != null) {
|
|
|
|
photo = user.photo.photo_small;
|
|
|
|
photoBig = user.photo.photo_big;
|
|
|
|
}
|
2014-11-19 16:17:24 +01:00
|
|
|
AvatarDrawable avatarDrawable = new AvatarDrawable(user);
|
2014-11-19 04:46:45 +01:00
|
|
|
avatarImage.setImage(photo, "50_50", avatarDrawable);
|
2014-11-10 12:05:22 +01:00
|
|
|
|
2015-02-01 19:51:02 +01:00
|
|
|
if (user instanceof TLRPC.TL_userDeleted) {
|
|
|
|
nameTextView.setText(LocaleController.getString("HiddenName", R.string.HiddenName));
|
|
|
|
} else {
|
|
|
|
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
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;
|
|
|
|
}
|
2014-11-18 13:37:11 +01:00
|
|
|
avatarImage.setImage(photo, "50_50", new AvatarDrawable(chat, true));
|
2014-11-17 23:04:31 +01:00
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
}
|
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
private void createActionBarMenu() {
|
2014-11-11 23:16:17 +01:00
|
|
|
ActionBarMenu menu = actionBar.createMenu();
|
2014-06-04 01:31:48 +02:00
|
|
|
menu.clearItems();
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2014-11-12 23:16:59 +01:00
|
|
|
if (user_id != 0) {
|
|
|
|
if (ContactsController.getInstance().contactsDict.get(user_id) == null) {
|
|
|
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
|
|
|
if (user.phone != null && user.phone.length() != 0) {
|
|
|
|
item.addSubItem(add_contact, LocaleController.getString("AddContact", R.string.AddContact), 0);
|
|
|
|
item.addSubItem(share_contact, LocaleController.getString("ShareContact", R.string.ShareContact), 0);
|
|
|
|
item.addSubItem(block_contact, !userBlocked ? LocaleController.getString("BlockContact", R.string.BlockContact) : LocaleController.getString("Unblock", R.string.Unblock), 0);
|
|
|
|
} else {
|
|
|
|
item.addSubItem(block_contact, !userBlocked ? LocaleController.getString("BlockContact", R.string.BlockContact) : LocaleController.getString("Unblock", R.string.Unblock), 0);
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
2014-11-12 23:16:59 +01:00
|
|
|
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
|
|
|
item.addSubItem(share_contact, LocaleController.getString("ShareContact", R.string.ShareContact), 0);
|
2014-08-22 16:24:33 +02:00
|
|
|
item.addSubItem(block_contact, !userBlocked ? LocaleController.getString("BlockContact", R.string.BlockContact) : LocaleController.getString("Unblock", R.string.Unblock), 0);
|
2014-11-12 23:16:59 +01:00
|
|
|
item.addSubItem(edit_contact, LocaleController.getString("EditContact", R.string.EditContact), 0);
|
|
|
|
item.addSubItem(delete_contact, LocaleController.getString("DeleteContact", R.string.DeleteContact), 0);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
} else if (chat_id != 0) {
|
2014-06-04 01:31:48 +02:00
|
|
|
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
2014-11-12 23:16:59 +01:00
|
|
|
if (chat_id > 0) {
|
|
|
|
item.addSubItem(add_member, LocaleController.getString("AddMember", R.string.AddMember), 0);
|
2014-11-21 01:14:44 +01:00
|
|
|
item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0);
|
2014-11-12 23:16:59 +01:00
|
|
|
item.addSubItem(leave_group, LocaleController.getString("DeleteAndExit", R.string.DeleteAndExit), 0);
|
|
|
|
} else {
|
2014-11-21 01:14:44 +01:00
|
|
|
item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0);
|
2014-11-12 23:16:59 +01:00
|
|
|
item.addSubItem(add_member, LocaleController.getString("AddRecipient", R.string.AddRecipient), 0);
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-14 22:36:15 +02:00
|
|
|
@Override
|
|
|
|
protected void onDialogDismiss() {
|
|
|
|
if (listView != null) {
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
2014-07-10 23:15:39 +02:00
|
|
|
public void didSelectDialog(MessagesActivity messageFragment, long dialog_id, boolean param) {
|
2013-10-25 17:19:00 +02:00
|
|
|
if (dialog_id != 0) {
|
2014-06-04 01:31:48 +02:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("scrollToTopOnResume", true);
|
2015-02-01 19:51:02 +01:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
|
2014-08-22 16:24:33 +02:00
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
2013-10-25 17:19:00 +02:00
|
|
|
int lower_part = (int)dialog_id;
|
|
|
|
if (lower_part != 0) {
|
|
|
|
if (lower_part > 0) {
|
2014-06-04 01:31:48 +02:00
|
|
|
args.putInt("user_id", lower_part);
|
2013-10-25 17:19:00 +02:00
|
|
|
} else if (lower_part < 0) {
|
2014-06-04 01:31:48 +02:00
|
|
|
args.putInt("chat_id", -lower_part);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
} else {
|
2014-06-04 01:31:48 +02:00
|
|
|
args.putInt("enc_id", (int)(dialog_id >> 32));
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
presentFragment(new ChatActivity(args), true);
|
|
|
|
removeSelfFromStack();
|
2014-08-22 16:24:33 +02:00
|
|
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
2015-03-19 00:09:45 +01:00
|
|
|
SendMessagesHelper.getInstance().sendMessage(user, dialog_id, null);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-20 02:18:13 +02:00
|
|
|
private class ListAdapter extends BaseFragmentAdapter {
|
2013-10-25 17:19:00 +02:00
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
public ListAdapter(Context context) {
|
|
|
|
mContext = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean areAllItemsEnabled() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEnabled(int i) {
|
2014-11-12 23:16:59 +01:00
|
|
|
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;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCount() {
|
2014-05-17 01:05:49 +02:00
|
|
|
return rowCount;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@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) {
|
|
|
|
if (view == null) {
|
2014-11-12 23:16:59 +01:00
|
|
|
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);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
} else if (type == 1) {
|
|
|
|
if (view == null) {
|
2014-11-10 12:05:22 +01:00
|
|
|
view = new DividerCell(mContext);
|
|
|
|
view.setPadding(AndroidUtilities.dp(72), 0, 0, 0);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
} else if (type == 2) {
|
2014-08-22 16:24:33 +02:00
|
|
|
final TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
2013-10-25 17:19:00 +02:00
|
|
|
if (view == null) {
|
2014-11-10 12:05:22 +01:00
|
|
|
view = new TextDetailCell(mContext);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
TextDetailCell textDetailCell = (TextDetailCell) view;
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2014-05-17 01:05:49 +02:00
|
|
|
if (i == phoneRow) {
|
2014-11-10 12:05:22 +01:00
|
|
|
String text;
|
2013-10-25 17:19:00 +02:00
|
|
|
if (user.phone != null && user.phone.length() != 0) {
|
2014-11-10 12:05:22 +01:00
|
|
|
text = PhoneFormat.getInstance().format("+" + user.phone);
|
|
|
|
} else {
|
|
|
|
text = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
|
|
|
|
}
|
2014-11-11 23:16:17 +01:00
|
|
|
textDetailCell.setTextAndValueAndIcon(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile), R.drawable.phone_grey);
|
2014-11-10 12:05:22 +01:00
|
|
|
} else if (i == usernameRow) {
|
|
|
|
String text;
|
|
|
|
if (user != null && user.username != null && user.username.length() != 0) {
|
|
|
|
text = "@" + user.username;
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
2014-11-10 12:05:22 +01:00
|
|
|
text = "-";
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
textDetailCell.setTextAndValue(text, LocaleController.getString("Username", R.string.Username));
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
} else if (type == 3) {
|
|
|
|
if (view == null) {
|
2014-11-10 12:05:22 +01:00
|
|
|
view = new TextCell(mContext);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
TextCell textCell = (TextCell) view;
|
2014-11-17 03:44:57 +01:00
|
|
|
textCell.setTextColor(0xff212121);
|
2013-12-20 20:25:49 +01:00
|
|
|
|
2014-05-17 01:05:49 +02:00
|
|
|
if (i == sharedMediaRow) {
|
2014-11-10 12:05:22 +01:00
|
|
|
String value;
|
2013-10-25 17:19:00 +02:00
|
|
|
if (totalMediaCount == -1) {
|
2014-11-10 12:05:22 +01:00
|
|
|
value = LocaleController.getString("Loading", R.string.Loading);
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
2014-11-10 12:05:22 +01:00
|
|
|
value = String.format("%d", totalMediaCount);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
textCell.setTextAndValue(LocaleController.getString("SharedMedia", R.string.SharedMedia), value);
|
2014-05-17 01:05:49 +02:00
|
|
|
} else if (i == settingsTimerRow) {
|
2014-08-22 16:24:33 +02:00
|
|
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32));
|
2014-11-10 12:05:22 +01:00
|
|
|
String value;
|
2013-10-25 17:19:00 +02:00
|
|
|
if (encryptedChat.ttl == 0) {
|
2014-11-10 12:05:22 +01:00
|
|
|
value = LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever);
|
2014-10-17 20:29:13 +02:00
|
|
|
} else {
|
2014-11-10 12:05:22 +01:00
|
|
|
value = AndroidUtilities.formatTTLString(encryptedChat.ttl);
|
2014-10-17 20:29:13 +02:00
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
textCell.setTextAndValue(LocaleController.getString("MessageLifetime", R.string.MessageLifetime), value);
|
|
|
|
} else if (i == settingsNotificationsRow) {
|
2014-11-11 23:16:17 +01:00
|
|
|
textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), R.drawable.profile_list);
|
2014-11-10 12:05:22 +01:00
|
|
|
} else if (i == startSecretChatRow) {
|
|
|
|
textCell.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat));
|
|
|
|
textCell.setTextColor(0xff37a919);
|
|
|
|
} else if (i == settingsKeyRow) {
|
|
|
|
IdenticonDrawable identiconDrawable = new IdenticonDrawable();
|
|
|
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32));
|
2014-12-01 18:56:31 +01:00
|
|
|
identiconDrawable.setEncryptedChat(encryptedChat);
|
2014-11-10 12:05:22 +01:00
|
|
|
textCell.setTextAndValueDrawable(LocaleController.getString("EncryptionKey", R.string.EncryptionKey), identiconDrawable);
|
2014-03-22 23:31:55 +01:00
|
|
|
}
|
2014-11-12 23:16:59 +01:00
|
|
|
} 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);
|
|
|
|
}
|
2014-06-17 16:45:21 +02:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemViewType(int i) {
|
2014-11-12 23:16:59 +01:00
|
|
|
if (i == emptyRow || i == overscrollRow || i == emptyRowChat || i == emptyRowChat2) {
|
2014-05-17 01:05:49 +02:00
|
|
|
return 0;
|
2014-11-10 12:05:22 +01:00
|
|
|
} else if (i == sectionRow) {
|
2014-05-17 01:05:49 +02:00
|
|
|
return 1;
|
2014-11-10 12:05:22 +01:00
|
|
|
} else if (i == phoneRow || i == usernameRow) {
|
2014-05-17 01:05:49 +02:00
|
|
|
return 2;
|
2014-11-10 12:05:22 +01:00
|
|
|
} else if (i == sharedMediaRow || i == settingsTimerRow || i == settingsNotificationsRow || i == startSecretChatRow || i == settingsKeyRow) {
|
2014-05-17 01:05:49 +02:00
|
|
|
return 3;
|
2014-11-12 23:16:59 +01:00
|
|
|
} else if (i > emptyRowChat2 && i < membersEndRow) {
|
|
|
|
return 4;
|
|
|
|
} else if (i == membersSectionRow) {
|
|
|
|
return 5;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getViewTypeCount() {
|
2014-11-12 23:16:59 +01:00
|
|
|
return 6;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEmpty() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|