mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-03-03 07:48:36 +00:00
Use custom config for chat folders.
This commit is contained in:
committed by
Greyson Parrelli
parent
cc5e3fc085
commit
fdeaf77fc0
@@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.components.emoji.SimpleEmojiTextView;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.ContextUtil;
|
||||
import org.thoughtcrime.securesms.util.DrawableUtil;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
import org.thoughtcrime.securesms.util.SpanUtil;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
@@ -77,9 +78,9 @@ public class FromTextView extends SimpleEmojiTextView {
|
||||
|
||||
setText(builder);
|
||||
|
||||
if (recipient.isBlocked()) setCompoundDrawablesRelativeWithIntrinsicBounds(getBlocked(), null, null, null);
|
||||
else if (isPinned) setCompoundDrawablesRelativeWithIntrinsicBounds(getPinned(), null, null, null);
|
||||
else setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
|
||||
if (recipient.isBlocked()) setCompoundDrawablesRelativeWithIntrinsicBounds(getBlocked(), null, null, null);
|
||||
else if (RemoteConfig.getShowChatFolders() && isPinned) setCompoundDrawablesRelativeWithIntrinsicBounds(getPinned(), null, null, null);
|
||||
else setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
private Drawable getBlocked() {
|
||||
|
||||
@@ -60,7 +60,7 @@ class ChatsSettingsFragment : DSLSettingsFragment(R.string.preferences_chats__ch
|
||||
|
||||
dividerPref()
|
||||
|
||||
if (RemoteConfig.internalUser) {
|
||||
if (RemoteConfig.showChatFolders) {
|
||||
sectionHeaderPref(R.string.ChatsSettingsFragment__chat_folders)
|
||||
|
||||
clickPref(
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.thoughtcrime.securesms.database.model.UpdateDescription;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
import org.thoughtcrime.securesms.util.SignalTrace;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -173,6 +174,7 @@ abstract class ConversationListDataSource implements PagedDataSource<Long, Conve
|
||||
private int totalCount;
|
||||
private int pinnedCount;
|
||||
private int archivedCount;
|
||||
private int unpinnedCount;
|
||||
|
||||
UnarchivedConversationListDataSource(@NonNull ChatFolderRecord chatFolder, @NonNull ConversationFilter conversationFilter, boolean showConversationFooterTip) {
|
||||
super(chatFolder, conversationFilter, showConversationFooterTip);
|
||||
@@ -184,12 +186,21 @@ abstract class ConversationListDataSource implements PagedDataSource<Long, Conve
|
||||
|
||||
pinnedCount = threadTable.getPinnedConversationListCount(conversationFilter, chatFolder);
|
||||
archivedCount = threadTable.getArchivedConversationListCount(conversationFilter);
|
||||
unpinnedCount = unarchivedCount - pinnedCount;
|
||||
totalCount = unarchivedCount;
|
||||
|
||||
if (chatFolder.getFolderType() == ChatFolderRecord.FolderType.ALL && archivedCount != 0) {
|
||||
totalCount++;
|
||||
}
|
||||
|
||||
if (!RemoteConfig.getShowChatFolders() && pinnedCount != 0) {
|
||||
if (unpinnedCount != 0) {
|
||||
totalCount += 2;
|
||||
} else {
|
||||
totalCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
@@ -198,11 +209,25 @@ abstract class ConversationListDataSource implements PagedDataSource<Long, Conve
|
||||
List<Cursor> cursors = new ArrayList<>(5);
|
||||
long originalLimit = limit;
|
||||
|
||||
if (!RemoteConfig.getShowChatFolders() && offset == 0 && hasPinnedHeader()) {
|
||||
MatrixCursor pinnedHeaderCursor = new MatrixCursor(ConversationReader.HEADER_COLUMN);
|
||||
pinnedHeaderCursor.addRow(ConversationReader.PINNED_HEADER);
|
||||
cursors.add(pinnedHeaderCursor);
|
||||
limit--;
|
||||
}
|
||||
|
||||
Cursor pinnedCursor = threadTable.getUnarchivedConversationList(conversationFilter, true, offset, limit, chatFolder);
|
||||
cursors.add(pinnedCursor);
|
||||
limit -= pinnedCursor.getCount();
|
||||
|
||||
long unpinnedOffset = Math.max(0, offset - pinnedCount);
|
||||
if (!RemoteConfig.getShowChatFolders() && offset == 0 && hasUnpinnedHeader()) {
|
||||
MatrixCursor unpinnedHeaderCursor = new MatrixCursor(ConversationReader.HEADER_COLUMN);
|
||||
unpinnedHeaderCursor.addRow(ConversationReader.UNPINNED_HEADER);
|
||||
cursors.add(unpinnedHeaderCursor);
|
||||
limit--;
|
||||
}
|
||||
|
||||
long unpinnedOffset = Math.max(0, offset - pinnedCount - getHeaderOffset());
|
||||
Cursor unpinnedCursor = threadTable.getUnarchivedConversationList(conversationFilter, false, unpinnedOffset, limit, chatFolder);
|
||||
cursors.add(unpinnedCursor);
|
||||
|
||||
@@ -223,6 +248,25 @@ abstract class ConversationListDataSource implements PagedDataSource<Long, Conve
|
||||
return new MergeCursor(cursors.toArray(new Cursor[]{}));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getHeaderOffset() {
|
||||
if (RemoteConfig.getShowChatFolders()) {
|
||||
return 0;
|
||||
} else {
|
||||
return (hasPinnedHeader() ? 1 : 0) + (hasUnpinnedHeader() ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean hasPinnedHeader() {
|
||||
return pinnedCount != 0;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean hasUnpinnedHeader() {
|
||||
return hasPinnedHeader() && unpinnedCount != 0;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean hasArchivedFooter() {
|
||||
return archivedCount != 0 && chatFolder.getFolderType() == ChatFolderRecord.FolderType.ALL;
|
||||
|
||||
@@ -300,7 +300,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
||||
|
||||
fab.setVisibility(View.VISIBLE);
|
||||
cameraFab.setVisibility(View.VISIBLE);
|
||||
chatFolderList.setVisibility(RemoteConfig.internalUser() ? View.VISIBLE : View.GONE);
|
||||
chatFolderList.setVisibility(RemoteConfig.getShowChatFolders() ? View.VISIBLE : View.GONE);
|
||||
|
||||
contactSearchMediator = new ContactSearchMediator(this,
|
||||
Collections.emptySet(),
|
||||
|
||||
@@ -1103,6 +1103,14 @@ object RemoteConfig {
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
/** Whether or not to show chat folders. */
|
||||
@JvmStatic
|
||||
val showChatFolders: Boolean by remoteBoolean(
|
||||
key = "android.showChatFolders",
|
||||
defaultValue = false,
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("newCallUi")
|
||||
val newCallUi: Boolean by remoteBoolean(
|
||||
|
||||
Reference in New Issue
Block a user