mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-12-24 04:25:12 +01:00
Support filter emoticons
This commit is contained in:
parent
b511d66c3c
commit
0ed8a8afc2
@ -364,6 +364,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
||||
public ArrayList<Integer> neverShow = new ArrayList<>();
|
||||
public LongSparseArray<Integer> pinnedDialogs = new LongSparseArray<>();
|
||||
public ArrayList<TLRPC.Dialog> dialogs = new ArrayList<>();
|
||||
public String emoticon;
|
||||
}
|
||||
|
||||
private DialogFilter sortingDialogFilter;
|
||||
|
@ -302,7 +302,7 @@ public class MessagesStorage extends BaseController {
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS folder_id_idx_dialogs ON dialogs(folder_id);").stepThis().dispose();
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS flags_idx_dialogs ON dialogs(flags);").stepThis().dispose();
|
||||
|
||||
database.executeFast("CREATE TABLE dialog_filter(id INTEGER PRIMARY KEY, ord INTEGER, unread_count INTEGER, flags INTEGER, title TEXT)").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE dialog_filter_neko(id INTEGER PRIMARY KEY, ord INTEGER, unread_count INTEGER, flags INTEGER, title TEXT, emoticon TEXT)").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE dialog_filter_ep(id INTEGER, peer INTEGER, PRIMARY KEY (id, peer))").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE dialog_filter_pin_v2(id INTEGER, peer INTEGER, pin INTEGER, PRIMARY KEY (id, peer))").stepThis().dispose();
|
||||
|
||||
@ -418,6 +418,11 @@ public class MessagesStorage extends BaseController {
|
||||
FileLog.e(e2);
|
||||
}
|
||||
}
|
||||
try {
|
||||
database.executeFast("CREATE TABLE IF NOT EXISTS dialog_filter_neko(id INTEGER PRIMARY KEY, ord INTEGER, unread_count INTEGER, flags INTEGER, title TEXT, emoticon TEXT)").stepThis().dispose();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
if (version < LAST_DB_VERSION) {
|
||||
updateDbToLastVersion(version);
|
||||
}
|
||||
@ -1591,7 +1596,7 @@ public class MessagesStorage extends BaseController {
|
||||
|
||||
usersToLoad.add(getUserConfig().getClientUserId());
|
||||
|
||||
SQLiteCursor filtersCursor = database.queryFinalized("SELECT id, ord, unread_count, flags, title FROM dialog_filter WHERE 1");
|
||||
SQLiteCursor filtersCursor = database.queryFinalized("SELECT id, ord, unread_count, flags, title, emoticon FROM dialog_filter_neko WHERE 1");
|
||||
|
||||
boolean updateCounters = false;
|
||||
while (filtersCursor.next()) {
|
||||
@ -1601,6 +1606,7 @@ public class MessagesStorage extends BaseController {
|
||||
filter.pendingUnreadCount = filter.unreadCount = -1;//filtersCursor.intValue(2);
|
||||
filter.flags = filtersCursor.intValue(3);
|
||||
filter.name = filtersCursor.stringValue(4);
|
||||
filter.emoticon = filtersCursor.stringValue(5);
|
||||
dialogFilters.add(filter);
|
||||
dialogFiltersMap.put(filter.id, filter);
|
||||
filtersById.put(filter.id, filter);
|
||||
@ -2058,12 +2064,17 @@ public class MessagesStorage extends BaseController {
|
||||
dialogFiltersMap.put(filter.id, filter);
|
||||
}
|
||||
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO dialog_filter VALUES(?, ?, ?, ?, ?)");
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO dialog_filter_neko VALUES(?, ?, ?, ?, ?, ?)");
|
||||
state.bindInteger(1, filter.id);
|
||||
state.bindInteger(2, filter.order);
|
||||
state.bindInteger(3, filter.unreadCount);
|
||||
state.bindInteger(4, filter.flags);
|
||||
state.bindString(5, filter.name);
|
||||
if (filter.emoticon != null) {
|
||||
state.bindString(6, filter.emoticon);
|
||||
} else {
|
||||
state.bindNull(6);
|
||||
}
|
||||
state.step();
|
||||
state.dispose();
|
||||
if (peers) {
|
||||
@ -2164,6 +2175,10 @@ public class MessagesStorage extends BaseController {
|
||||
changed = true;
|
||||
filter.name = newFilter.title;
|
||||
}
|
||||
if (!TextUtils.equals(filter.emoticon, newFilter.emoticon)) {
|
||||
changed = true;
|
||||
filter.emoticon = newFilter.emoticon;
|
||||
}
|
||||
if (filter.flags != newFlags) {
|
||||
filter.flags = newFlags;
|
||||
changed = true;
|
||||
@ -2310,6 +2325,7 @@ public class MessagesStorage extends BaseController {
|
||||
filter.id = newFilter.id;
|
||||
filter.flags = newFlags;
|
||||
filter.name = newFilter.title;
|
||||
filter.emoticon = newFilter.emoticon;
|
||||
filter.pendingUnreadCount = -1;
|
||||
for (int c = 0; c < 2; c++) {
|
||||
if (c == 0) {
|
||||
@ -2472,7 +2488,7 @@ public class MessagesStorage extends BaseController {
|
||||
try {
|
||||
dialogFilters.remove(filter);
|
||||
dialogFiltersMap.remove(filter.id);
|
||||
database.executeFast("DELETE FROM dialog_filter WHERE id = " + filter.id).stepThis().dispose();
|
||||
database.executeFast("DELETE FROM dialog_filter_neko WHERE id = " + filter.id).stepThis().dispose();
|
||||
database.executeFast("DELETE FROM dialog_filter_ep WHERE id = " + filter.id).stepThis().dispose();
|
||||
database.executeFast("DELETE FROM dialog_filter_pin_v2 WHERE id = " + filter.id).stepThis().dispose();
|
||||
} catch (Exception e) {
|
||||
@ -2502,7 +2518,7 @@ public class MessagesStorage extends BaseController {
|
||||
|
||||
public void saveDialogFiltersOrderInternal() {
|
||||
try {
|
||||
SQLitePreparedStatement state = database.executeFast("UPDATE dialog_filter SET ord = ?, flags = ? WHERE id = ?");
|
||||
SQLitePreparedStatement state = database.executeFast("UPDATE dialog_filter_neko SET ord = ?, flags = ? WHERE id = ?");
|
||||
for (int a = 0, N = dialogFilters.size(); a < N ;a++) {
|
||||
MessagesController.DialogFilter filter = dialogFilters.get(a);
|
||||
state.requery();
|
||||
|
@ -2959,7 +2959,18 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
filterTabsView.removeTabs();
|
||||
if (!NekoConfig.hideAllTab) filterTabsView.addTab(Integer.MAX_VALUE, LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
|
||||
for (int a = 0, N = filters.size(); a < N; a++) {
|
||||
filterTabsView.addTab(a, filters.get(a).name);
|
||||
MessagesController.DialogFilter dialogFilter = filters.get(a);
|
||||
switch (NekoConfig.tabsTitleType) {
|
||||
case NekoConfig.TITLE_TYPE_TEXT:
|
||||
filterTabsView.addTab(a, dialogFilter.name);
|
||||
break;
|
||||
case NekoConfig.TITLE_TYPE_ICON:
|
||||
filterTabsView.addTab(a, dialogFilter.emoticon != null ? dialogFilter.emoticon : "📂");
|
||||
break;
|
||||
case NekoConfig.TITLE_TYPE_MIX:
|
||||
filterTabsView.addTab(a, dialogFilter.emoticon != null ? dialogFilter.emoticon + " " + dialogFilter.name : "📂 " + dialogFilter.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
id = filterTabsView.getCurrentTabId();
|
||||
if (id >= 0) {
|
||||
|
@ -15,6 +15,10 @@ import org.telegram.messenger.SharedConfig;
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public class NekoConfig {
|
||||
|
||||
public static final int TITLE_TYPE_TEXT = 0;
|
||||
public static final int TITLE_TYPE_ICON = 1;
|
||||
public static final int TITLE_TYPE_MIX = 2;
|
||||
|
||||
private static final Object sync = new Object();
|
||||
public static boolean useIPv6 = false;
|
||||
public static boolean showHiddenFeature = false;
|
||||
@ -31,6 +35,7 @@ public class NekoConfig {
|
||||
public static int mapPreviewProvider = 0;
|
||||
public static float stickerSize = 14.0f;
|
||||
public static int translationProvider = 1;
|
||||
public static int tabsTitleType = TITLE_TYPE_TEXT;
|
||||
|
||||
public static boolean showAddToSavedMessages = true;
|
||||
public static boolean showReport = false;
|
||||
@ -108,6 +113,7 @@ public class NekoConfig {
|
||||
editor.putInt("translationProvider", translationProvider);
|
||||
editor.putInt("eventType", eventType);
|
||||
editor.putInt("actionBarDecoration", actionBarDecoration);
|
||||
editor.putInt("tabsTitleType", tabsTitleType);
|
||||
editor.commit();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
@ -160,6 +166,7 @@ public class NekoConfig {
|
||||
chatMessageAnimation = preferences.getBoolean("chatMessageAnimation", false);
|
||||
rearVideoMessages = preferences.getBoolean("rearVideoMessages", false);
|
||||
hideAllTab = preferences.getBoolean("hideAllTab", false);
|
||||
tabsTitleType = preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT);
|
||||
configLoaded = true;
|
||||
}
|
||||
}
|
||||
@ -470,4 +477,12 @@ public class NekoConfig {
|
||||
editor.putBoolean("hideAllTab", hideAllTab);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public static void setTabsTitleType(int type) {
|
||||
tabsTitleType = type;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("tabsTitleType", tabsTitleType);
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
private int stickerSizeRow;
|
||||
private int translationProviderRow;
|
||||
private int messageMenuRow;
|
||||
private int tabsTitleTypeRow;
|
||||
private int chat2Row;
|
||||
|
||||
private int settingsRow;
|
||||
@ -537,6 +538,40 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
((TextCheckCell) view).setChecked(NekoConfig.hideAllTab);
|
||||
}
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated);
|
||||
} else if (position == tabsTitleTypeRow) {
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
ArrayList<Integer> types = new ArrayList<>();
|
||||
arrayList.add(LocaleController.getString("TabTitleTypeText", R.string.TabTitleTypeText));
|
||||
types.add(NekoConfig.TITLE_TYPE_TEXT);
|
||||
arrayList.add(LocaleController.getString("TabTitleTypeIcon", R.string.TabTitleTypeIcon));
|
||||
types.add(NekoConfig.TITLE_TYPE_ICON);
|
||||
arrayList.add(LocaleController.getString("TabTitleTypeMix", R.string.TabTitleTypeMix));
|
||||
types.add(NekoConfig.TITLE_TYPE_MIX);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(LocaleController.getString("TabTitleType", R.string.TabTitleType));
|
||||
builder.setMessage(LocaleController.getString("TabTitleTypeTip", R.string.TabTitleTypeTip));
|
||||
final LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
builder.setView(linearLayout);
|
||||
|
||||
for (int a = 0; a < arrayList.size(); a++) {
|
||||
RadioColorCell cell = new RadioColorCell(context);
|
||||
cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
|
||||
cell.setTag(a);
|
||||
cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
|
||||
cell.setTextAndValue(arrayList.get(a), NekoConfig.tabsTitleType == types.get(a));
|
||||
linearLayout.addView(cell);
|
||||
cell.setOnClickListener(v -> {
|
||||
Integer which = (Integer) v.getTag();
|
||||
NekoConfig.setTabsTitleType(types.get(which));
|
||||
listAdapter.notifyItemChanged(tabsTitleTypeRow);
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated);
|
||||
builder.getDismissRunnable().run();
|
||||
});
|
||||
}
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
|
||||
});
|
||||
@ -573,6 +608,7 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
stickerSizeRow = rowCount++;
|
||||
messageMenuRow = rowCount++;
|
||||
translationProviderRow = rowCount++;
|
||||
tabsTitleTypeRow = rowCount++;
|
||||
chat2Row = rowCount++;
|
||||
settingsRow = rowCount++;
|
||||
hidePhoneRow = rowCount++;
|
||||
@ -1027,7 +1063,21 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
value = LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud);
|
||||
break;
|
||||
}
|
||||
textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, false);
|
||||
textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, true);
|
||||
} else if (position == tabsTitleTypeRow) {
|
||||
String value;
|
||||
switch (NekoConfig.tabsTitleType) {
|
||||
case NekoConfig.TITLE_TYPE_TEXT:
|
||||
value = LocaleController.getString("TabTitleTypeText", R.string.TabTitleTypeText);
|
||||
break;
|
||||
case NekoConfig.TITLE_TYPE_ICON:
|
||||
value = LocaleController.getString("TabTitleTypeIcon", R.string.TabTitleTypeIcon);
|
||||
break;
|
||||
case NekoConfig.TITLE_TYPE_MIX:
|
||||
default:
|
||||
value = LocaleController.getString("TabTitleTypeMix", R.string.TabTitleTypeMix);
|
||||
}
|
||||
textCell.setTextAndValue(LocaleController.getString("TabTitleType", R.string.TabTitleType), value, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1123,7 +1173,7 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow ||
|
||||
position == experimentRow || position == hideKeyboardOnChatScrollRow || position == avatarAsDrawerBackgroundRow ||
|
||||
position == showTabsOnForwardRow || position == chatMessageAnimationRow || position == rearVideoMessagesRow ||
|
||||
position == hideAllTabRow;
|
||||
position == hideAllTabRow || position == tabsTitleTypeRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1168,7 +1218,8 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
if (position == connection2Row || position == chat2Row || position == experiment2Row) {
|
||||
return 1;
|
||||
} else if (position == nameOrderRow || position == mapPreviewRow || position == stickerSizeRow || position == messageMenuRow ||
|
||||
position == deleteAccountRow || position == translationProviderRow || position == eventTypeRow || position == actionBarDecorationRow) {
|
||||
position == deleteAccountRow || position == translationProviderRow || position == eventTypeRow || position == actionBarDecorationRow ||
|
||||
position == tabsTitleTypeRow) {
|
||||
return 2;
|
||||
} else if (position == ipv6Row || position == hidePhoneRow || position == inappCameraRow ||
|
||||
position == transparentStatusBarRow || position == hideProxySponsorChannelRow ||
|
||||
|
@ -61,7 +61,6 @@
|
||||
<string name="MessageDetails">Details</string>
|
||||
<string name="ExportAsJson">Export as JSON</string>
|
||||
<string name="Translate">Translate</string>
|
||||
<string name="ServiceByGoogle">Translation service is provided by Google</string>
|
||||
<string name="JoinedFormatted">joined %1$s</string>
|
||||
<string name="JoinedDateFormatted">joined on %1$s</string>
|
||||
<string name="DeleteAccount">Delete Telegram account</string>
|
||||
@ -72,7 +71,7 @@
|
||||
<string name="ProviderGoogleTranslateCN">Google Translate CN</string>
|
||||
<string name="ProviderGoogleTranslateCNWeb">Google Translate CN (Web)</string>
|
||||
<string name="ProviderBaiduFanyiWeb">Baidu Translate (Web)</string>
|
||||
<string name="TranslateApiUnsupported">The translation provider you selected don\'t support your language</string>
|
||||
<string name="TranslateApiUnsupported">The translation provider you selected don\'t support your language.</string>
|
||||
<string name="ProviderLingocloud">Lingocloud</string>
|
||||
<string name="UndoTranslate">Undo translate</string>
|
||||
<string name="CopyDetails">Copy Details</string>
|
||||
@ -91,5 +90,10 @@
|
||||
<string name="ChatMessageAnimation">Animate new messages</string>
|
||||
<string name="RearVideoMessages">Rear camera in Video Messages</string>
|
||||
<string name="HideAllTab">Hide \"All Chats\" tab</string>
|
||||
<string name="HideAllTabAbout">Press \"Back\" on home page to open it</string>
|
||||
<string name="HideAllTabAbout">Press \"Back\" on home page to open it.</string>
|
||||
<string name="TabTitleType">Show on tabs</string>
|
||||
<string name="TabTitleTypeTip">Emoticons are cloud-synced by Telegram.</string>
|
||||
<string name="TabTitleTypeText">Titles</string>
|
||||
<string name="TabTitleTypeIcon">Emoticons</string>
|
||||
<string name="TabTitleTypeMix">Emoticons with titles</string>
|
||||
</resources>
|
@ -6,7 +6,7 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.0.0-beta04'
|
||||
classpath 'com.android.tools.build:gradle:4.0.0-beta05'
|
||||
classpath 'com.google.gms:google-services:4.3.3'
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user