NekoX/TMessagesProj/src/main/java/org/telegram/ui/PrivacyUsersActivity.java

562 lines
26 KiB
Java
Raw Normal View History

2014-11-17 03:44:57 +01:00
/*
2019-06-04 12:14:50 +02:00
* This is the source code of Telegram for Android v. 5.x.x.
2014-11-17 03:44:57 +01:00
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
2019-01-23 18:03:33 +01:00
* Copyright Nikolai Kudashov, 2013-2018.
2014-11-17 03:44:57 +01:00
*/
package org.telegram.ui;
import android.content.Context;
import android.os.Bundle;
2019-06-04 12:14:50 +02:00
import android.text.TextUtils;
2014-11-17 03:44:57 +01:00
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import org.telegram.PhoneFormat.PhoneFormat;
2021-09-20 07:54:41 +02:00
import org.telegram.messenger.DialogObject;
2015-09-24 22:52:02 +02:00
import org.telegram.messenger.LocaleController;
2019-06-04 12:14:50 +02:00
import org.telegram.tgnet.TLRPC;
2015-09-24 22:52:02 +02:00
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
2014-11-17 03:44:57 +01:00
import org.telegram.messenger.R;
2017-03-31 01:58:05 +02:00
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
2019-06-04 12:14:50 +02:00
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.ManageChatTextCell;
import org.telegram.ui.Cells.ManageChatUserCell;
import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.BaseFragment;
2017-03-31 01:58:05 +02:00
import org.telegram.ui.Components.EmptyTextProgressView;
import org.telegram.ui.Components.LayoutHelper;
2017-03-31 01:58:05 +02:00
import org.telegram.ui.Components.RecyclerListView;
2014-11-17 03:44:57 +01:00
import java.util.ArrayList;
2019-05-14 14:08:05 +02:00
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
2019-06-04 12:14:50 +02:00
public class PrivacyUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
2014-11-17 03:44:57 +01:00
2017-03-31 01:58:05 +02:00
private RecyclerListView listView;
2019-08-22 01:53:26 +02:00
private LinearLayoutManager layoutManager;
2014-11-17 03:44:57 +01:00
private ListAdapter listViewAdapter;
2017-03-31 01:58:05 +02:00
private EmptyTextProgressView emptyView;
2019-06-04 12:14:50 +02:00
private int rowCount;
private int blockUserRow;
private int blockUserDetailRow;
private int usersHeaderRow;
private int usersStartRow;
private int usersEndRow;
private int usersDetailRow;
2014-11-17 03:44:57 +01:00
2019-06-04 12:14:50 +02:00
private boolean blockedUsersActivity;
2016-03-06 02:49:31 +01:00
2019-06-04 12:14:50 +02:00
private boolean isGroup;
2021-09-20 07:54:41 +02:00
private ArrayList<Long> uidArray;
2014-11-17 03:44:57 +01:00
private boolean isAlwaysShare;
2016-03-06 02:49:31 +01:00
private PrivacyActivityDelegate delegate;
2020-03-30 14:00:09 +02:00
private int currentType;
public static final int TYPE_PRIVACY = 0;
public static final int TYPE_BLOCKED = 1;
public static final int TYPE_FILTER = 2;
2014-11-17 03:44:57 +01:00
2019-06-04 12:14:50 +02:00
public interface PrivacyActivityDelegate {
2021-09-20 07:54:41 +02:00
void didUpdateUserList(ArrayList<Long> ids, boolean added);
2019-06-04 12:14:50 +02:00
}
public PrivacyUsersActivity() {
super();
2020-03-30 14:00:09 +02:00
currentType = TYPE_BLOCKED;
2019-06-04 12:14:50 +02:00
blockedUsersActivity = true;
}
2014-11-17 03:44:57 +01:00
2021-09-20 07:54:41 +02:00
public PrivacyUsersActivity(int type, ArrayList<Long> users, boolean group, boolean always) {
2014-11-17 03:44:57 +01:00
super();
uidArray = users;
isAlwaysShare = always;
2016-03-06 02:49:31 +01:00
isGroup = group;
2019-06-04 12:14:50 +02:00
blockedUsersActivity = false;
2020-03-30 14:00:09 +02:00
currentType = type;
2014-11-17 03:44:57 +01:00
}
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
2018-07-30 04:07:02 +02:00
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.updateInterfaces);
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-06-04 12:14:50 +02:00
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.blockedUsersDidLoad);
}
2014-11-17 03:44:57 +01:00
return true;
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
2018-07-30 04:07:02 +02:00
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.updateInterfaces);
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-06-04 12:14:50 +02:00
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.blockedUsersDidLoad);
}
2014-11-17 03:44:57 +01:00
}
@Override
2015-07-22 20:56:37 +02:00
public View createView(Context context) {
2015-04-09 20:00:14 +02:00
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-06-04 12:14:50 +02:00
actionBar.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers));
2020-03-30 14:00:09 +02:00
} else if (currentType == TYPE_FILTER) {
if (isAlwaysShare) {
actionBar.setTitle(LocaleController.getString("FilterAlwaysShow", R.string.FilterAlwaysShow));
} else {
actionBar.setTitle(LocaleController.getString("FilterNeverShow", R.string.FilterNeverShow));
}
2015-04-09 20:00:14 +02:00
} else {
2019-06-04 12:14:50 +02:00
if (isGroup) {
if (isAlwaysShare) {
actionBar.setTitle(LocaleController.getString("AlwaysAllow", R.string.AlwaysAllow));
} else {
actionBar.setTitle(LocaleController.getString("NeverAllow", R.string.NeverAllow));
}
2016-03-06 02:49:31 +01:00
} else {
2019-06-04 12:14:50 +02:00
if (isAlwaysShare) {
actionBar.setTitle(LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
} else {
actionBar.setTitle(LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
}
2016-03-06 02:49:31 +01:00
}
2015-04-09 20:00:14 +02:00
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
2014-11-17 03:44:57 +01:00
}
}
2015-04-09 20:00:14 +02:00
});
fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView;
2019-06-04 12:14:50 +02:00
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
2015-04-09 20:00:14 +02:00
2017-03-31 01:58:05 +02:00
emptyView = new EmptyTextProgressView(context);
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-06-04 12:14:50 +02:00
emptyView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));
} else {
emptyView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
}
2017-03-31 01:58:05 +02:00
frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
2015-04-09 20:00:14 +02:00
2017-03-31 01:58:05 +02:00
listView = new RecyclerListView(context);
listView.setEmptyView(emptyView);
2019-08-22 01:53:26 +02:00
listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
2019-06-04 12:14:50 +02:00
listView.setVerticalScrollBarEnabled(false);
2015-04-09 20:00:14 +02:00
listView.setAdapter(listViewAdapter = new ListAdapter(context));
2017-03-31 01:58:05 +02:00
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? RecyclerListView.SCROLLBAR_POSITION_LEFT : RecyclerListView.SCROLLBAR_POSITION_RIGHT);
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
2019-01-23 18:03:33 +01:00
listView.setOnItemClickListener((view, position) -> {
2019-06-04 12:14:50 +02:00
if (position == blockUserRow) {
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-07-18 15:01:39 +02:00
presentFragment(new DialogOrContactPickerActivity());
2019-06-04 12:14:50 +02:00
} else {
Bundle args = new Bundle();
args.putBoolean(isAlwaysShare ? "isAlwaysShare" : "isNeverShare", true);
2020-03-30 14:00:09 +02:00
if (isGroup) {
args.putInt("chatAddType", 1);
} else if (currentType == TYPE_FILTER) {
args.putInt("chatAddType", 2);
}
2019-06-04 12:14:50 +02:00
GroupCreateActivity fragment = new GroupCreateActivity(args);
fragment.setDelegate(ids -> {
2021-09-20 07:54:41 +02:00
for (Long id1 : ids) {
2019-06-04 12:14:50 +02:00
if (uidArray.contains(id1)) {
continue;
}
uidArray.add(id1);
}
updateRows();
if (delegate != null) {
delegate.didUpdateUserList(uidArray, true);
}
});
presentFragment(fragment);
}
} else if (position >= usersStartRow && position < usersEndRow) {
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-06-04 12:14:50 +02:00
Bundle args = new Bundle();
2021-09-20 07:54:41 +02:00
args.putLong("user_id", getMessagesController().blockePeers.keyAt(position - usersStartRow));
2019-06-04 12:14:50 +02:00
presentFragment(new ProfileActivity(args));
} else {
Bundle args = new Bundle();
2021-09-20 07:54:41 +02:00
long uid = uidArray.get(position - usersStartRow);
if (DialogObject.isUserDialog(uid)) {
args.putLong("user_id", uid);
2019-06-04 12:14:50 +02:00
} else {
2021-09-20 07:54:41 +02:00
args.putLong("chat_id", -uid);
2019-06-04 12:14:50 +02:00
}
presentFragment(new ProfileActivity(args));
}
2015-04-09 20:00:14 +02:00
}
});
2019-06-04 12:14:50 +02:00
2019-01-23 18:03:33 +01:00
listView.setOnItemLongClickListener((view, position) -> {
2019-06-04 12:14:50 +02:00
if (position >= usersStartRow && position < usersEndRow) {
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2020-09-30 15:48:47 +02:00
showUnblockAlert(getMessagesController().blockePeers.keyAt(position - usersStartRow));
2019-06-04 12:14:50 +02:00
} else {
showUnblockAlert(uidArray.get(position - usersStartRow));
}
return true;
2014-11-17 03:44:57 +01:00
}
2019-06-04 12:14:50 +02:00
return false;
});
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-08-22 01:53:26 +02:00
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (getMessagesController().blockedEndReached) {
return;
}
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
int visibleItemCount = Math.abs(layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1;
int totalItemCount = recyclerView.getAdapter().getItemCount();
if (visibleItemCount > 0) {
if (layoutManager.findLastVisibleItemPosition() >= totalItemCount - 10) {
2020-09-30 15:48:47 +02:00
getMessagesController().getBlockedPeers(false);
2019-08-22 01:53:26 +02:00
}
}
}
});
2020-03-30 14:00:09 +02:00
if (getMessagesController().totalBlockedCount < 0) {
emptyView.showProgress();
} else {
emptyView.showTextView();
}
2019-06-04 12:14:50 +02:00
}
2020-03-30 14:00:09 +02:00
2019-06-04 12:14:50 +02:00
updateRows();
return fragmentView;
}
public void setDelegate(PrivacyActivityDelegate privacyActivityDelegate) {
delegate = privacyActivityDelegate;
}
2021-09-20 07:54:41 +02:00
private void showUnblockAlert(Long uid) {
2019-06-04 12:14:50 +02:00
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items;
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-06-04 12:14:50 +02:00
items = new CharSequence[]{LocaleController.getString("Unblock", R.string.Unblock)};
} else {
items = new CharSequence[]{LocaleController.getString("Delete", R.string.Delete)};
}
builder.setItems(items, (dialogInterface, i) -> {
if (i == 0) {
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2020-09-30 15:48:47 +02:00
getMessagesController().unblockPeer(uid);
2019-06-04 12:14:50 +02:00
} else {
2020-03-30 14:00:09 +02:00
uidArray.remove(uid);
2019-06-04 12:14:50 +02:00
updateRows();
2019-01-23 18:03:33 +01:00
if (delegate != null) {
2019-06-04 12:14:50 +02:00
delegate.didUpdateUserList(uidArray, false);
}
if (uidArray.isEmpty()) {
finishFragment();
2019-01-23 18:03:33 +01:00
}
}
2019-06-04 12:14:50 +02:00
}
2015-04-09 20:00:14 +02:00
});
2019-06-04 12:14:50 +02:00
showDialog(builder.create());
}
2015-04-09 20:00:14 +02:00
2019-06-04 12:14:50 +02:00
private void updateRows() {
rowCount = 0;
2019-08-22 01:53:26 +02:00
if (!blockedUsersActivity || getMessagesController().totalBlockedCount >= 0) {
2019-06-04 12:14:50 +02:00
blockUserRow = rowCount++;
blockUserDetailRow = rowCount++;
int count;
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2020-09-30 15:48:47 +02:00
count = getMessagesController().blockePeers.size();
2019-06-04 12:14:50 +02:00
} else {
count = uidArray.size();
}
if (count != 0) {
usersHeaderRow = rowCount++;
usersStartRow = rowCount;
rowCount += count;
usersEndRow = rowCount;
usersDetailRow = rowCount++;
} else {
usersHeaderRow = -1;
usersStartRow = -1;
usersEndRow = -1;
usersDetailRow = -1;
}
}
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
2014-11-17 03:44:57 +01:00
}
@Override
2018-07-30 04:07:02 +02:00
public void didReceivedNotification(int id, int account, Object... args) {
2014-11-17 03:44:57 +01:00
if (id == NotificationCenter.updateInterfaces) {
2017-03-31 01:58:05 +02:00
int mask = (Integer) args[0];
2014-11-17 03:44:57 +01:00
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
updateVisibleRows(mask);
}
2019-06-04 12:14:50 +02:00
} else if (id == NotificationCenter.blockedUsersDidLoad) {
emptyView.showTextView();
updateRows();
2014-11-17 03:44:57 +01:00
}
}
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);
2019-06-04 12:14:50 +02:00
if (child instanceof ManageChatUserCell) {
((ManageChatUserCell) child).update(mask);
2014-11-17 03:44:57 +01:00
}
}
}
@Override
public void onResume() {
super.onResume();
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
}
2019-06-04 12:14:50 +02:00
@Override
public void didSelectContact(final TLRPC.User user, String param, ContactsActivity activity) {
if (user == null) {
return;
}
2020-09-30 15:48:47 +02:00
getMessagesController().blockPeer(user.id);
2019-06-04 12:14:50 +02:00
}
2017-03-31 01:58:05 +02:00
private class ListAdapter extends RecyclerListView.SelectionAdapter {
2014-11-17 03:44:57 +01:00
private Context mContext;
public ListAdapter(Context context) {
mContext = context;
}
@Override
2019-06-04 12:14:50 +02:00
public int getItemCount() {
return rowCount;
2014-11-17 03:44:57 +01:00
}
@Override
2019-06-04 12:14:50 +02:00
public boolean isEnabled(RecyclerView.ViewHolder holder) {
int viewType = holder.getItemViewType();
return viewType == 0 || viewType == 2;
2014-11-17 03:44:57 +01:00
}
@Override
2017-03-31 01:58:05 +02:00
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view;
switch (viewType) {
case 0:
2019-06-04 12:14:50 +02:00
view = new ManageChatUserCell(mContext, 7, 6, true);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
((ManageChatUserCell) view).setDelegate((cell, click) -> {
if (click) {
2021-09-20 07:54:41 +02:00
showUnblockAlert((Long) cell.getTag());
2019-06-04 12:14:50 +02:00
}
return true;
});
2017-03-31 01:58:05 +02:00
break;
case 1:
2019-06-04 12:14:50 +02:00
view = new TextInfoPrivacyCell(mContext);
break;
case 2:
view = new ManageChatTextCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 3:
2017-03-31 01:58:05 +02:00
default:
2020-03-30 14:00:09 +02:00
HeaderCell headerCell = new HeaderCell(mContext, Theme.key_windowBackgroundWhiteBlueHeader, 21, 11, false);
2019-06-04 12:14:50 +02:00
headerCell.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
headerCell.setHeight(43);
view = headerCell;
2017-03-31 01:58:05 +02:00
break;
2014-11-17 03:44:57 +01:00
}
2017-03-31 01:58:05 +02:00
return new RecyclerListView.Holder(view);
2014-11-17 03:44:57 +01:00
}
@Override
2017-03-31 01:58:05 +02:00
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
2019-06-04 12:14:50 +02:00
switch (holder.getItemViewType()) {
case 0:
ManageChatUserCell userCell = (ManageChatUserCell) holder.itemView;
2021-09-20 07:54:41 +02:00
long uid;
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2020-09-30 15:48:47 +02:00
uid = getMessagesController().blockePeers.keyAt(position - usersStartRow);
2019-06-04 12:14:50 +02:00
} else {
uid = uidArray.get(position - usersStartRow);
}
userCell.setTag(uid);
if (uid > 0) {
TLRPC.User user = getMessagesController().getUser(uid);
if (user != null) {
String number;
if (user.bot) {
number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1);
} else if (user.phone != null && user.phone.length() != 0) {
number = PhoneFormat.getInstance().format("+" + user.phone);
} else {
number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
}
userCell.setData(user, null, number, position != usersEndRow - 1);
}
} else {
TLRPC.Chat chat = getMessagesController().getChat(-uid);
if (chat != null) {
String subtitle;
if (chat.participants_count != 0) {
subtitle = LocaleController.formatPluralString("Members", chat.participants_count);
2019-07-18 15:01:39 +02:00
} else if (chat.has_geo) {
subtitle = LocaleController.getString("MegaLocation", R.string.MegaLocation);
2019-06-04 12:14:50 +02:00
} else if (TextUtils.isEmpty(chat.username)) {
subtitle = LocaleController.getString("MegaPrivate", R.string.MegaPrivate);
} else {
subtitle = LocaleController.getString("MegaPublic", R.string.MegaPublic);
}
userCell.setData(chat, null, subtitle, position != usersEndRow - 1);
}
}
break;
case 1:
TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
if (position == blockUserDetailRow) {
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-06-04 12:14:50 +02:00
privacyCell.setText(LocaleController.getString("BlockedUsersInfo", R.string.BlockedUsersInfo));
} else {
privacyCell.setText(null);
}
if (usersStartRow == -1) {
privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
} else {
privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
}
} else if (position == usersDetailRow) {
privacyCell.setText("");
privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
}
break;
case 2:
ManageChatTextCell actionCell = (ManageChatTextCell) holder.itemView;
actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-06-04 12:14:50 +02:00
actionCell.setText(LocaleController.getString("BlockUser", R.string.BlockUser), null, R.drawable.actions_addmember2, false);
} else {
actionCell.setText(LocaleController.getString("PrivacyAddAnException", R.string.PrivacyAddAnException), null, R.drawable.actions_addmember2, false);
}
break;
case 3:
HeaderCell headerCell = (HeaderCell) holder.itemView;
if (position == usersHeaderRow) {
2020-03-30 14:00:09 +02:00
if (currentType == TYPE_BLOCKED) {
2019-08-22 01:53:26 +02:00
headerCell.setText(LocaleController.formatPluralString("BlockedUsersCount", getMessagesController().totalBlockedCount));
2019-06-04 12:14:50 +02:00
} else {
headerCell.setText(LocaleController.getString("PrivacyExceptions", R.string.PrivacyExceptions));
}
}
break;
2014-11-17 03:44:57 +01:00
}
}
@Override
2019-06-04 12:14:50 +02:00
public int getItemViewType(int position) {
if (position == usersHeaderRow) {
return 3;
} else if (position == blockUserRow) {
return 2;
} else if (position == blockUserDetailRow || position == usersDetailRow) {
2017-03-31 01:58:05 +02:00
return 1;
2019-06-04 12:14:50 +02:00
} else {
return 0;
2017-03-31 01:58:05 +02:00
}
2014-11-17 03:44:57 +01:00
}
2017-03-31 01:58:05 +02:00
}
2014-11-17 03:44:57 +01:00
2017-03-31 01:58:05 +02:00
@Override
2020-04-24 11:21:58 +02:00
public ArrayList<ThemeDescription> getThemeDescriptions() {
ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
2019-01-23 18:03:33 +01:00
ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> {
if (listView != null) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
2019-06-04 12:14:50 +02:00
if (child instanceof ManageChatUserCell) {
((ManageChatUserCell) child).update(0);
2017-03-31 01:58:05 +02:00
}
}
}
};
2019-06-04 12:14:50 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{ManageChatUserCell.class, ManageChatTextCell.class, HeaderCell.class}, null, null, null, Theme.key_windowBackgroundWhite));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(emptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_emptyListPlaceholder));
themeDescriptions.add(new ThemeDescription(emptyView, ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, Theme.key_progressCircle));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
2019-06-04 12:14:50 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{ManageChatUserCell.class}, new String[]{"nameTextView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{ManageChatUserCell.class}, new String[]{"statusColor"}, null, null, cellDelegate, Theme.key_windowBackgroundWhiteGrayText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{ManageChatUserCell.class}, new String[]{"statusOnlineColor"}, null, null, cellDelegate, Theme.key_windowBackgroundWhiteBlueText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{ManageChatUserCell.class}, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundRed));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundOrange));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundViolet));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundGreen));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundCyan));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink));
2019-06-04 12:14:50 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{ManageChatTextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{ManageChatTextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{ManageChatTextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueButton));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{ManageChatTextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueIcon));
return themeDescriptions;
2014-11-17 03:44:57 +01:00
}
}