mirror of https://github.com/NekoX-Dev/NekoX.git
Refine hide "All Chats":
- display and automatically remove "All Chats" tab when switching - allow to press title "Nekogram X" to open "All Chats", preventing from using Back
This commit is contained in:
parent
988eb00623
commit
4da82b928c
|
@ -42,6 +42,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.AccountInstance;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
|
@ -55,13 +56,6 @@ import org.telegram.ui.ActionBar.Theme;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
|
||||
public class FilterTabsView extends FrameLayout {
|
||||
|
@ -989,6 +983,8 @@ public class FilterTabsView extends FrameLayout {
|
|||
delegate.onPageSelected(id, scrollingForward);
|
||||
}
|
||||
scrollToChild(position);
|
||||
if (NekoConfig.hideAllTab && showAllChatsTab && id != Integer.MAX_VALUE)
|
||||
toggleAllTabs(false);
|
||||
}
|
||||
|
||||
public void selectFirstTab() {
|
||||
|
@ -1215,10 +1211,8 @@ public class FilterTabsView extends FrameLayout {
|
|||
if (!tabs.isEmpty()) {
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec) - AndroidUtilities.dp(7) - AndroidUtilities.dp(7);
|
||||
Tab firstTab = tabs.get(0);
|
||||
if (!NekoConfig.hideAllTab)
|
||||
firstTab.setTitle(LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
|
||||
int tabWith = firstTab.getWidth(false);
|
||||
if (!NekoConfig.hideAllTab)
|
||||
if (showAllChatsTab)
|
||||
firstTab.setTitle(allTabsWidth > width ? LocaleController.getString("FilterAllChatsShort", R.string.FilterAllChatsShort) : LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
|
||||
int trueTabsWidth = allTabsWidth - tabWith;
|
||||
trueTabsWidth += firstTab.getWidth(false);
|
||||
|
@ -1297,6 +1291,8 @@ public class FilterTabsView extends FrameLayout {
|
|||
manualScrollingToId = -1;
|
||||
currentPosition = position;
|
||||
selectedTabId = id;
|
||||
if (NekoConfig.hideAllTab && showAllChatsTab)
|
||||
toggleAllTabs(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1367,7 +1363,7 @@ public class FilterTabsView extends FrameLayout {
|
|||
invalidated = true;
|
||||
requestLayout();
|
||||
allTabsWidth = 0;
|
||||
if (!NekoConfig.hideAllTab)
|
||||
if (showAllChatsTab)
|
||||
tabs.get(0).setTitle(LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
|
||||
for (int b = 0; b < N; b++) {
|
||||
allTabsWidth += tabs.get(b).getWidth(true) + AndroidUtilities.dp(32);
|
||||
|
@ -1399,7 +1395,7 @@ public class FilterTabsView extends FrameLayout {
|
|||
listView.setItemAnimator(itemAnimator);
|
||||
adapter.notifyDataSetChanged();
|
||||
allTabsWidth = 0;
|
||||
if (!NekoConfig.hideAllTab)
|
||||
if (showAllChatsTab)
|
||||
tabs.get(0).setTitle(LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
|
||||
for (int b = 0, N = tabs.size(); b < N; b++) {
|
||||
allTabsWidth += tabs.get(b).getWidth(true) + AndroidUtilities.dp(32);
|
||||
|
@ -1450,7 +1446,7 @@ public class FilterTabsView extends FrameLayout {
|
|||
int idx1 = fromIndex - 1;
|
||||
int idx2 = toIndex - 1;
|
||||
int count = tabs.size() - 1;
|
||||
if (NekoConfig.hideAllTab) {
|
||||
if (!showAllChatsTab) {
|
||||
idx1++;
|
||||
idx2++;
|
||||
count++;
|
||||
|
@ -1517,7 +1513,7 @@ public class FilterTabsView extends FrameLayout {
|
|||
|
||||
@Override
|
||||
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
||||
if (!isEditing || (!NekoConfig.hideAllTab && viewHolder.getAdapterPosition() == 0)) {
|
||||
if (!isEditing || ((showAllChatsTab && viewHolder.getAdapterPosition() == 0) && !NekoConfig.pressTitleToOpenAllChats)) {
|
||||
return makeMovementFlags(0, 0);
|
||||
}
|
||||
return makeMovementFlags(ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT, 0);
|
||||
|
@ -1525,7 +1521,7 @@ public class FilterTabsView extends FrameLayout {
|
|||
|
||||
@Override
|
||||
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) {
|
||||
if (!NekoConfig.hideAllTab && (source.getAdapterPosition() == 0 || target.getAdapterPosition() == 0)) {
|
||||
if (showAllChatsTab && (source.getAdapterPosition() == 0 || target.getAdapterPosition() == 0)) {
|
||||
return false;
|
||||
}
|
||||
adapter.swapElements(source.getAdapterPosition(), target.getAdapterPosition());
|
||||
|
@ -1558,4 +1554,31 @@ public class FilterTabsView extends FrameLayout {
|
|||
public RecyclerListView getListView() {
|
||||
return listView;
|
||||
}
|
||||
|
||||
public boolean showAllChatsTab = false;
|
||||
|
||||
public void toggleAllTabs(boolean show) {
|
||||
if (show == showAllChatsTab)
|
||||
return;
|
||||
showAllChatsTab = show;
|
||||
removeTabs();
|
||||
if (showAllChatsTab)
|
||||
addTab(Integer.MAX_VALUE, 0, LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
|
||||
ArrayList<MessagesController.DialogFilter> filters = AccountInstance.getInstance(UserConfig.selectedAccount).getMessagesController().dialogFilters;
|
||||
for (int a = 0, N = filters.size(); a < N; a++) {
|
||||
MessagesController.DialogFilter dialogFilter = filters.get(a);
|
||||
switch (NekoConfig.tabsTitleType) {
|
||||
case NekoConfig.TITLE_TYPE_TEXT:
|
||||
addTab(a, filters.get(a).localId, dialogFilter.name);
|
||||
break;
|
||||
case NekoConfig.TITLE_TYPE_ICON:
|
||||
addTab(a, filters.get(a).localId, dialogFilter.emoticon != null ? dialogFilter.emoticon : "📂");
|
||||
break;
|
||||
case NekoConfig.TITLE_TYPE_MIX:
|
||||
addTab(a, filters.get(a).localId, dialogFilter.emoticon != null ? dialogFilter.emoticon + " " + dialogFilter.name : "📂 " + dialogFilter.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
finishAddingTabs(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,8 +73,6 @@ import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
|
||||
import org.telegram.messenger.AccountInstance;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
|
@ -84,7 +82,6 @@ import org.telegram.messenger.ContactsController;
|
|||
import org.telegram.messenger.DialogObject;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.ImageLoader;
|
||||
import org.telegram.messenger.ImageLocation;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MediaDataController;
|
||||
import org.telegram.messenger.MessageObject;
|
||||
|
@ -2113,6 +2110,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
actionBar.setTitle(LocaleController.getString("ArchivedChats", R.string.ArchivedChats));
|
||||
} else {
|
||||
actionBar.setTitle(LocaleController.getString("NekoX", R.string.NekoX));
|
||||
if (NekoConfig.hideAllTab) {
|
||||
actionBar.setOnLongClickListener(v -> {
|
||||
if (NekoConfig.pressTitleToOpenAllChats && filterTabsView != null && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE) {
|
||||
filterTabsView.toggleAllTabs(true);
|
||||
filterTabsView.selectFirstTab();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
if (folderId == 0) {
|
||||
actionBar.setSupportsHolidayImage(true);
|
||||
|
@ -3832,7 +3838,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
filterTabsView.resetTabId();
|
||||
}
|
||||
filterTabsView.removeTabs();
|
||||
if (!NekoConfig.hideAllTab)
|
||||
if (filterTabsView.showAllChatsTab)
|
||||
filterTabsView.addTab(Integer.MAX_VALUE, 0, LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
|
||||
for (int a = 0, N = filters.size(); a < N; a++) {
|
||||
MessagesController.DialogFilter dialogFilter = filters.get(a);
|
||||
|
@ -4123,9 +4129,18 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
hideActionMode(true);
|
||||
}
|
||||
return false;
|
||||
} else if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && !tabsAnimationInProgress && !filterTabsView.isAnimatingIndicator() && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE && !startedTracking) {
|
||||
filterTabsView.selectFirstTab();
|
||||
return false;
|
||||
} else if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && !tabsAnimationInProgress && !filterTabsView.isAnimatingIndicator()
|
||||
&& filterTabsView.getCurrentTabId() != Integer.MAX_VALUE && !startedTracking) {
|
||||
if(!NekoConfig.hideAllTab){
|
||||
filterTabsView.selectFirstTab();
|
||||
return false;
|
||||
}
|
||||
if(!NekoConfig.pressTitleToOpenAllChats){
|
||||
// not hideAllTab OR hideAllTab but not pressTitleToOpenAllChats
|
||||
filterTabsView.toggleAllTabs(true);
|
||||
filterTabsView.selectFirstTab();
|
||||
return false;
|
||||
}
|
||||
} else if (commentView != null && commentView.isPopupShowing()) {
|
||||
commentView.hidePopup(true);
|
||||
return false;
|
||||
|
|
|
@ -43,6 +43,7 @@ public class NekoConfig {
|
|||
public static boolean hideKeyboardOnChatScroll;
|
||||
public static boolean rearVideoMessages;
|
||||
public static boolean hideAllTab;
|
||||
public static boolean pressTitleToOpenAllChats;
|
||||
public static boolean confirmAVMessage;
|
||||
public static boolean askBeforeCall;
|
||||
public static boolean disableNumberRounding;
|
||||
|
@ -240,6 +241,7 @@ public class NekoConfig {
|
|||
showTabsOnForward = preferences.getBoolean("showTabsOnForward", false);
|
||||
rearVideoMessages = preferences.getBoolean("rearVideoMessages", false);
|
||||
hideAllTab = preferences.getBoolean("hideAllTab", false);
|
||||
pressTitleToOpenAllChats = preferences.getBoolean("pressTitleToOpenAllChats", false);
|
||||
|
||||
disableChatAction = preferences.getBoolean("disable_chat_action", false);
|
||||
sortByUnread = preferences.getBoolean("sort_by_unread", false);
|
||||
|
@ -579,6 +581,10 @@ public class NekoConfig {
|
|||
preferences.edit().putBoolean("hideAllTab", hideAllTab = !hideAllTab).apply();
|
||||
}
|
||||
|
||||
public static void togglePressTitleToOpenAllChats() {
|
||||
preferences.edit().putBoolean("pressTitleToOpenAllChats", pressTitleToOpenAllChats = !pressTitleToOpenAllChats).apply();
|
||||
}
|
||||
|
||||
public static void toggleSortByUnmuted() {
|
||||
preferences.edit().putBoolean("sort_by_unmuted", sortByUnmuted = !sortByUnmuted).apply();
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
|||
private int foldersRow;
|
||||
private int showTabsOnForwardRow;
|
||||
private int hideAllTabRow;
|
||||
private int pressTitleToOpenAllChatsRow;
|
||||
private int tabsTitleTypeRow;
|
||||
private int folders2Row;
|
||||
|
||||
|
@ -205,6 +206,11 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
|||
((TextCheckCell) view).setChecked(NekoConfig.hideAllTab);
|
||||
}
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated);
|
||||
} else if (position == pressTitleToOpenAllChatsRow) {
|
||||
NekoConfig.togglePressTitleToOpenAllChats();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoConfig.pressTitleToOpenAllChats);
|
||||
}
|
||||
} else if (position == tabsTitleTypeRow) {
|
||||
PopupBuilder builder = new PopupBuilder(view);
|
||||
|
||||
|
@ -322,6 +328,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
|||
foldersRow = rowCount++;
|
||||
showTabsOnForwardRow = rowCount++;
|
||||
hideAllTabRow = rowCount++;
|
||||
pressTitleToOpenAllChatsRow = rowCount++;
|
||||
tabsTitleTypeRow = rowCount++;
|
||||
folders2Row = rowCount++;
|
||||
|
||||
|
@ -651,6 +658,8 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
|||
textCell.setTextAndCheck(LocaleController.getString("RearVideoMessages", R.string.RearVideoMessages), NekoConfig.rearVideoMessages, true);
|
||||
} else if (position == hideAllTabRow) {
|
||||
textCell.setTextAndValueAndCheck(LocaleController.getString("HideAllTab", R.string.HideAllTab), LocaleController.getString("HideAllTabAbout", R.string.HideAllTabAbout), NekoConfig.hideAllTab, true, true);
|
||||
} else if(position == pressTitleToOpenAllChatsRow){
|
||||
textCell.setTextAndCheck(LocaleController.getString("pressTitleToOpenAllChats", R.string.pressTitleToOpenAllChats),NekoConfig.pressTitleToOpenAllChats, true);
|
||||
} else if (position == confirmAVRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("ConfirmAVMessage", R.string.ConfirmAVMessage), NekoConfig.confirmAVMessage, true);
|
||||
} else if (position == useChatAttachMediaMenuRow) {
|
||||
|
|
|
@ -109,5 +109,6 @@
|
|||
<string name="ProviderDeepLTranslate">DeepL Translate</string>
|
||||
<string name="ProviderMicrosoftTranslator">Microsoft Translator</string>
|
||||
<string name="ProviderYouDao">YouDao Translate</string>
|
||||
<string name="pressTitleToOpenAllChats">Press title to open \"All Chats\" tab</string>
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue