add neko settings
This commit is contained in:
parent
d78e9e4c52
commit
b2777eaca0
@ -119,6 +119,9 @@ import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
import tw.nekomimi.nekogram.NekoSettingsActivity;
|
||||
|
||||
public class SettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ImageUpdater.ImageUpdaterDelegate {
|
||||
|
||||
private RecyclerListView listView;
|
||||
@ -160,6 +163,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
private int privacyRow;
|
||||
private int dataRow;
|
||||
private int chatRow;
|
||||
private int nekoRow;
|
||||
private int helpRow;
|
||||
private int versionRow;
|
||||
private int rowCount;
|
||||
@ -217,7 +221,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
rowCount = 0;
|
||||
overscrollRow = rowCount++;
|
||||
numberSectionRow = rowCount++;
|
||||
numberRow = rowCount++;
|
||||
if(!NekoConfig.hidePhone){
|
||||
numberRow = rowCount++;
|
||||
}
|
||||
usernameRow = rowCount++;
|
||||
bioRow = rowCount++;
|
||||
settingsSectionRow = rowCount++;
|
||||
@ -226,6 +232,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
privacyRow = rowCount++;
|
||||
dataRow = rowCount++;
|
||||
chatRow = rowCount++;
|
||||
nekoRow = rowCount++;
|
||||
languageRow = rowCount++;
|
||||
helpRow = rowCount++;
|
||||
versionRow = rowCount++;
|
||||
@ -370,6 +377,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
presentFragment(new DataSettingsActivity());
|
||||
} else if (position == chatRow) {
|
||||
presentFragment(new ThemeActivity(ThemeActivity.THEME_TYPE_BASIC));
|
||||
} else if (position == nekoRow) {
|
||||
presentFragment(new NekoSettingsActivity());
|
||||
} else if (position == helpRow) {
|
||||
showHelpAlert();
|
||||
} else if (position == languageRow) {
|
||||
@ -1807,6 +1816,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
textCell.setTextAndIcon(LocaleController.getString("DataSettings", R.string.DataSettings), R.drawable.menu_data, true);
|
||||
} else if (position == chatRow) {
|
||||
textCell.setTextAndIcon(LocaleController.getString("ChatSettings", R.string.ChatSettings), R.drawable.menu_chats, true);
|
||||
} else if (position == nekoRow) {
|
||||
textCell.setTextAndIcon(LocaleController.getString("NekoSettings", R.string.NekoSettings), R.drawable.menu_settings, true);
|
||||
} else if (position == helpRow) {
|
||||
textCell.setTextAndIcon(LocaleController.getString("SettingsHelp", R.string.SettingsHelp), R.drawable.menu_help, false);
|
||||
}
|
||||
@ -1860,7 +1871,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
int position = holder.getAdapterPosition();
|
||||
return position == notificationRow || position == numberRow || position == privacyRow ||
|
||||
position == languageRow || position == usernameRow || position == bioRow ||
|
||||
position == versionRow || position == dataRow || position == chatRow ||
|
||||
position == versionRow || position == dataRow || position == chatRow || position == nekoRow ||
|
||||
position == helpRow;
|
||||
}
|
||||
|
||||
@ -1938,7 +1949,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
} else if (position == settingsSectionRow) {
|
||||
return 1;
|
||||
} else if (position == notificationRow || position == privacyRow || position == languageRow ||
|
||||
position == dataRow || position == chatRow || position == helpRow) {
|
||||
position == dataRow || position == chatRow || position == nekoRow || position == helpRow) {
|
||||
return 2;
|
||||
} else if (position == versionRow) {
|
||||
return 5;
|
||||
|
@ -0,0 +1,132 @@
|
||||
package tw.nekomimi.nekogram;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MessageHelper {
|
||||
|
||||
private static volatile MessageHelper[] Instance = new MessageHelper[UserConfig.MAX_ACCOUNT_COUNT];
|
||||
private int currentAccount;
|
||||
private int reqId;
|
||||
private int mergeReqId;
|
||||
private int lastReqId;
|
||||
private int[] messagesSearchCount = new int[]{0, 0};
|
||||
|
||||
public MessageHelper(int num) {
|
||||
currentAccount = num;
|
||||
}
|
||||
|
||||
public static MessageHelper getInstance(int num) {
|
||||
MessageHelper localInstance = Instance[num];
|
||||
if (localInstance == null) {
|
||||
synchronized (MessageHelper.class) {
|
||||
localInstance = Instance[num];
|
||||
if (localInstance == null) {
|
||||
Instance[num] = localInstance = new MessageHelper(num);
|
||||
}
|
||||
}
|
||||
}
|
||||
return localInstance;
|
||||
}
|
||||
|
||||
public void deleteUserChannelHistoryWithSearch(final long dialog_id, final TLRPC.User user) {
|
||||
deleteUserChannelHistoryWithSearch(dialog_id, user, false);
|
||||
}
|
||||
|
||||
public void deleteUserChannelHistoryWithSearch(final long dialog_id, final TLRPC.User user, final boolean internal) {
|
||||
boolean firstQuery = !internal;
|
||||
if (reqId != 0) {
|
||||
ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true);
|
||||
reqId = 0;
|
||||
}
|
||||
if (mergeReqId != 0) {
|
||||
ConnectionsManager.getInstance(currentAccount).cancelRequest(mergeReqId, true);
|
||||
mergeReqId = 0;
|
||||
}
|
||||
if (firstQuery) {
|
||||
TLRPC.InputPeer inputPeer = MessagesController.getInstance(currentAccount).getInputPeer((int) dialog_id);
|
||||
if (inputPeer == null) {
|
||||
return;
|
||||
}
|
||||
final TLRPC.TL_messages_search req = new TLRPC.TL_messages_search();
|
||||
req.peer = inputPeer;
|
||||
req.limit = 1;
|
||||
req.q = "";
|
||||
if (user != null) {
|
||||
req.from_id = MessagesController.getInstance(currentAccount).getInputUser(user);
|
||||
req.flags |= 1;
|
||||
}
|
||||
req.filter = new TLRPC.TL_inputMessagesFilterEmpty();
|
||||
mergeReqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
mergeReqId = 0;
|
||||
if (response != null) {
|
||||
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
|
||||
messagesSearchCount[0] = res.count;
|
||||
FileLog.d("total " + messagesSearchCount[0]);
|
||||
deleteUserChannelHistoryWithSearch(dialog_id, user, true);
|
||||
}
|
||||
}), ConnectionsManager.RequestFlagFailOnServerErrors);
|
||||
} else {
|
||||
final TLRPC.TL_messages_search req = new TLRPC.TL_messages_search();
|
||||
req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) dialog_id);
|
||||
if (req.peer == null) {
|
||||
return;
|
||||
}
|
||||
req.limit = 100;
|
||||
req.q = "";
|
||||
req.offset_id = 0;
|
||||
if (user != null) {
|
||||
req.from_id = MessagesController.getInstance(currentAccount).getInputUser(user);
|
||||
req.flags |= 1;
|
||||
}
|
||||
req.filter = new TLRPC.TL_inputMessagesFilterEmpty();
|
||||
final int currentReqId = ++lastReqId;
|
||||
reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (currentReqId == lastReqId) {
|
||||
reqId = 0;
|
||||
if (response != null) {
|
||||
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
|
||||
messagesSearchCount[1] = res.messages.size();
|
||||
for (int a = 0; a < res.messages.size(); a++) {
|
||||
TLRPC.Message message = res.messages.get(a);
|
||||
if (message instanceof TLRPC.TL_messageEmpty || message.action instanceof TLRPC.TL_messageActionHistoryClear || message instanceof TLRPC.TL_messageService) {
|
||||
res.messages.remove(a);
|
||||
a--;
|
||||
}
|
||||
}
|
||||
ArrayList<Integer> ids = new ArrayList<>();
|
||||
ArrayList<Long> random_ids = new ArrayList<>();
|
||||
int channelId = 0;
|
||||
for (int a = 0; a < res.messages.size(); a++) {
|
||||
TLRPC.Message message = res.messages.get(a);
|
||||
ids.add(message.id);
|
||||
if (message.random_id != 0) {
|
||||
random_ids.add(message.random_id);
|
||||
}
|
||||
channelId = message.to_id.channel_id;
|
||||
}
|
||||
MessagesController.getInstance(currentAccount).deleteMessages(ids, random_ids, null, channelId, true);
|
||||
messagesSearchCount[0] = messagesSearchCount[0] - messagesSearchCount[1];
|
||||
FileLog.d("found " + messagesSearchCount[1]);
|
||||
FileLog.d("after " + messagesSearchCount[0]);
|
||||
if (messagesSearchCount[0] > 0) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
deleteUserChannelHistoryWithSearch(dialog_id, user, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}), ConnectionsManager.RequestFlagFailOnServerErrors);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package tw.nekomimi.nekogram;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
|
||||
public class NekoConfig {
|
||||
|
||||
private static final Object sync = new Object();
|
||||
public static boolean useIPv6 = false;
|
||||
public static boolean hidePhone = true;
|
||||
public static boolean ignoreBlocked = false;
|
||||
public static boolean forceTablet = false;
|
||||
public static int nameOrder = 1;
|
||||
private static boolean configLoaded;
|
||||
|
||||
static {
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
|
||||
public static void saveConfig() {
|
||||
synchronized (sync) {
|
||||
try {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfing", Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("useIPv6", useIPv6);
|
||||
editor.putBoolean("hidePhone", hidePhone);
|
||||
editor.putBoolean("ignoreBlocked", ignoreBlocked);
|
||||
editor.putBoolean("forceTablet", forceTablet);
|
||||
editor.putInt("nameOrder", nameOrder);
|
||||
|
||||
editor.commit();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadConfig() {
|
||||
synchronized (sync) {
|
||||
if (configLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
useIPv6 = preferences.getBoolean("useIPv6", false);
|
||||
hidePhone = preferences.getBoolean("hidePhone", true);
|
||||
ignoreBlocked = preferences.getBoolean("ignoreBlocked", false);
|
||||
forceTablet = preferences.getBoolean("forceTablet", false);
|
||||
nameOrder = preferences.getInt("nameOrder", 1);
|
||||
configLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void toggleIPv6() {
|
||||
useIPv6 = !useIPv6;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("useIPv6", useIPv6);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public static void toggleHidePhone() {
|
||||
hidePhone = !hidePhone;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("hidePhone", hidePhone);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public static void toggleIgnoreBlocked() {
|
||||
ignoreBlocked = !ignoreBlocked;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("ignoreBlocked", ignoreBlocked);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public static void toggleForceTablet() {
|
||||
forceTablet = !forceTablet;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("forceTablet", forceTablet);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public static void setNameOrder(int order) {
|
||||
nameOrder = order;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("nameOrder", nameOrder);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,411 @@
|
||||
package tw.nekomimi.nekogram;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.SharedConfig;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.ActionBar.ThemeDescription;
|
||||
import org.telegram.ui.Cells.EmptyCell;
|
||||
import org.telegram.ui.Cells.HeaderCell;
|
||||
import org.telegram.ui.Cells.NotificationsCheckCell;
|
||||
import org.telegram.ui.Cells.ShadowSectionCell;
|
||||
import org.telegram.ui.Cells.TextCheckCell;
|
||||
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.RecyclerListView;
|
||||
|
||||
public class NekoSettingsActivity extends BaseFragment {
|
||||
|
||||
private RecyclerListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
|
||||
private int rowCount;
|
||||
|
||||
private int connectionRow;
|
||||
private int ipv6Row;
|
||||
private int connection2Row;
|
||||
|
||||
private int emojiRow;
|
||||
private int useSystemEmojiRow;
|
||||
private int singleBigEmojiRow;
|
||||
private int emoji2Row;
|
||||
|
||||
private int settingsRow;
|
||||
private int hidePhoneRow;
|
||||
private int inappCameraRow;
|
||||
private int ignoreBlockedRow;
|
||||
private int nameOrderRow;
|
||||
private int forceTabletRow;
|
||||
private int settings2Row;
|
||||
|
||||
private int debugRow;
|
||||
private int enableLogsRow;
|
||||
private int clearLogsRow;
|
||||
private int debug2Row;
|
||||
|
||||
private boolean showDebug = false;
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
super.onFragmentCreate();
|
||||
|
||||
updateRows(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public View createView(Context context) {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setTitle(LocaleController.getString("NekoSettings", R.string.NekoSettings));
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
actionBar.setOccupyStatusBar(false);
|
||||
}
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
listAdapter = new ListAdapter(context);
|
||||
|
||||
fragmentView = new FrameLayout(context);
|
||||
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
|
||||
FrameLayout frameLayout = (FrameLayout) fragmentView;
|
||||
|
||||
listView = new RecyclerListView(context);
|
||||
listView.setVerticalScrollBarEnabled(false);
|
||||
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) {
|
||||
@Override
|
||||
public boolean supportsPredictiveItemAnimations() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
listView.setGlowColor(Theme.getColor(Theme.key_avatar_backgroundActionBarBlue));
|
||||
listView.setAdapter(listAdapter);
|
||||
listView.setItemAnimator(null);
|
||||
listView.setLayoutAnimation(null);
|
||||
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
|
||||
listView.setOnItemClickListener((view, position, x, y) -> {
|
||||
if (position == ipv6Row) {
|
||||
NekoConfig.toggleIPv6();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoConfig.useIPv6);
|
||||
}
|
||||
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
|
||||
if (UserConfig.getInstance(a).isClientActivated()) {
|
||||
ConnectionsManager.native_setUseIpv6(a, NekoConfig.useIPv6);
|
||||
}
|
||||
}
|
||||
} else if (position == hidePhoneRow) {
|
||||
NekoConfig.toggleHidePhone();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoConfig.hidePhone);
|
||||
}
|
||||
} else if (position == inappCameraRow) {
|
||||
SharedConfig.toggleInappCamera();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(SharedConfig.inappCamera);
|
||||
}
|
||||
} else if (position == forceTabletRow) {
|
||||
NekoConfig.toggleForceTablet();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoConfig.forceTablet);
|
||||
}
|
||||
} else if (position == ignoreBlockedRow) {
|
||||
NekoConfig.toggleIgnoreBlocked();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoConfig.ignoreBlocked);
|
||||
}
|
||||
} else if (position == useSystemEmojiRow) {
|
||||
SharedConfig.useSystemEmoji = !SharedConfig.useSystemEmoji;
|
||||
SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit();
|
||||
editor.putBoolean("useSystemEmoji", SharedConfig.useSystemEmoji);
|
||||
editor.commit();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(SharedConfig.useSystemEmoji);
|
||||
}
|
||||
} else if (position == singleBigEmojiRow) {
|
||||
SharedConfig.allowBigEmoji = !SharedConfig.allowBigEmoji;
|
||||
SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit();
|
||||
editor.putBoolean("allowBigEmoji", SharedConfig.allowBigEmoji);
|
||||
editor.commit();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(SharedConfig.allowBigEmoji);
|
||||
}
|
||||
} else if (position == nameOrderRow) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("NameOrder", R.string.NameOrder));
|
||||
CharSequence[] items = new CharSequence[]{
|
||||
LocaleController.getString("FirstLast", R.string.FirstLast),
|
||||
LocaleController.getString("LastFirst", R.string.LastFirst),
|
||||
};
|
||||
builder.setItems(items, (dialog, which) -> {
|
||||
NekoConfig.setNameOrder(which + 1);
|
||||
listAdapter.notifyItemChanged(nameOrderRow);
|
||||
});
|
||||
showDialog(builder.create());
|
||||
} else if (position == enableLogsRow) {
|
||||
BuildVars.LOGS_ENABLED = !BuildVars.LOGS_ENABLED;
|
||||
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE);
|
||||
sharedPreferences.edit().putBoolean("logsEnabled", BuildVars.LOGS_ENABLED).commit();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(BuildVars.LOGS_ENABLED);
|
||||
}
|
||||
} else if (position == settings2Row) {
|
||||
showDebug = !showDebug;
|
||||
updateRows(true);
|
||||
} else if (position == clearLogsRow) {
|
||||
FileLog.cleanupLogs();
|
||||
}
|
||||
});
|
||||
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRows(boolean notify) {
|
||||
rowCount = 0;
|
||||
connectionRow = rowCount++;
|
||||
ipv6Row = rowCount++;
|
||||
connection2Row = rowCount++;
|
||||
emojiRow = rowCount++;
|
||||
useSystemEmojiRow = rowCount++;
|
||||
singleBigEmojiRow = rowCount++;
|
||||
emoji2Row = rowCount++;
|
||||
settingsRow = rowCount++;
|
||||
hidePhoneRow = rowCount++;
|
||||
inappCameraRow = rowCount++;
|
||||
ignoreBlockedRow = rowCount++;
|
||||
forceTabletRow = rowCount++;
|
||||
nameOrderRow = rowCount++;
|
||||
settings2Row = rowCount++;
|
||||
if (showDebug) {
|
||||
debugRow = rowCount++;
|
||||
enableLogsRow = rowCount++;
|
||||
clearLogsRow = rowCount++;
|
||||
debug2Row = rowCount++;
|
||||
} else {
|
||||
debugRow = -1;
|
||||
enableLogsRow = -1;
|
||||
clearLogsRow = -1;
|
||||
debug2Row = -1;
|
||||
}
|
||||
if (notify && listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThemeDescription[] getThemeDescriptions() {
|
||||
return new ThemeDescription[]{
|
||||
new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{EmptyCell.class, TextSettingsCell.class, TextCheckCell.class, HeaderCell.class, TextDetailSettingsCell.class, NotificationsCheckCell.class}, null, null, null, Theme.key_windowBackgroundWhite),
|
||||
new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray),
|
||||
|
||||
new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue),
|
||||
new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue),
|
||||
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_avatar_actionBarIconBlue),
|
||||
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle),
|
||||
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_avatar_actionBarSelectorBlue),
|
||||
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, null, Theme.key_actionBarDefaultSubmenuBackground),
|
||||
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, null, Theme.key_actionBarDefaultSubmenuItem),
|
||||
|
||||
new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector),
|
||||
|
||||
new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider),
|
||||
|
||||
new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow),
|
||||
|
||||
new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
|
||||
new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteValueText),
|
||||
|
||||
new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
|
||||
new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2),
|
||||
new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack),
|
||||
new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked),
|
||||
|
||||
new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
|
||||
new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2),
|
||||
new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack),
|
||||
new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked),
|
||||
|
||||
new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader),
|
||||
|
||||
new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
|
||||
new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2),
|
||||
};
|
||||
}
|
||||
|
||||
private class ListAdapter extends RecyclerListView.SelectionAdapter {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (holder.getItemViewType()) {
|
||||
case 1: {
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
|
||||
if (position == nameOrderRow) {
|
||||
String value;
|
||||
switch (NekoConfig.nameOrder) {
|
||||
case 2:
|
||||
value = LocaleController.getString("LastFirst", R.string.LastFirst);
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
value = LocaleController.getString("FirstLast", R.string.FirstLast);
|
||||
break;
|
||||
}
|
||||
textCell.setTextAndValue(LocaleController.getString("NameOrder", R.string.NameOrder), value, false);
|
||||
} else if (position == clearLogsRow) {
|
||||
textCell.setText(LocaleController.getString("DebugClearLogs", R.string.DebugClearLogs), false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
TextCheckCell textCell = (TextCheckCell) holder.itemView;
|
||||
if (position == ipv6Row) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("IPv6", R.string.IPv6), NekoConfig.useIPv6, false);
|
||||
} else if (position == hidePhoneRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("HidePhone", R.string.HidePhone), NekoConfig.hidePhone, true);
|
||||
} else if (position == inappCameraRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableCamera", R.string.DebugMenuEnableCamera), SharedConfig.inappCamera, true);
|
||||
} else if (position == useSystemEmojiRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("EmojiUseDefault", R.string.EmojiUseDefault), SharedConfig.useSystemEmoji, true);
|
||||
} else if (position == singleBigEmojiRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("EmojiBigSize", R.string.EmojiBigSize), SharedConfig.allowBigEmoji, false);
|
||||
} else if (position == ignoreBlockedRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("IgnoreBlocked", R.string.IgnoreBlocked), NekoConfig.ignoreBlocked, true);
|
||||
} else if (position == enableLogsRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableLogs", R.string.DebugMenuEnableLogs), BuildVars.LOGS_ENABLED, true);
|
||||
} else if (position == forceTabletRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("ForceTabletMode", R.string.ForceTabletMode), NekoConfig.forceTablet, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
HeaderCell headerCell = (HeaderCell) holder.itemView;
|
||||
if (position == settingsRow) {
|
||||
headerCell.setText(LocaleController.getString("Settings", R.string.Settings));
|
||||
} else if (position == emojiRow) {
|
||||
headerCell.setText(LocaleController.getString("Emoji", R.string.Emoji));
|
||||
} else if (position == connectionRow) {
|
||||
headerCell.setText(LocaleController.getString("Connection", R.string.Connection));
|
||||
} else if (position == debugRow) {
|
||||
headerCell.setText(LocaleController.getString("DebugMenu", R.string.DebugMenu));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
||||
int position = holder.getAdapterPosition();
|
||||
return position == hidePhoneRow || position == inappCameraRow || position == ignoreBlockedRow ||
|
||||
position == useSystemEmojiRow || position == singleBigEmojiRow || position == ipv6Row ||
|
||||
position == nameOrderRow || position == settings2Row || position == enableLogsRow ||
|
||||
position == clearLogsRow || position == forceTabletRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = null;
|
||||
switch (viewType) {
|
||||
case 1:
|
||||
view = new ShadowSectionCell(mContext);
|
||||
break;
|
||||
case 2:
|
||||
view = new TextSettingsCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case 3:
|
||||
view = new TextCheckCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case 4:
|
||||
view = new HeaderCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case 5:
|
||||
view = new NotificationsCheckCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case 6:
|
||||
view = new TextDetailSettingsCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
}
|
||||
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
|
||||
return new RecyclerListView.Holder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == settings2Row || position == emoji2Row || position == connection2Row ||
|
||||
position == debug2Row) {
|
||||
return 1;
|
||||
} else if (position == nameOrderRow || position == clearLogsRow) {
|
||||
return 2;
|
||||
} else if (position == ipv6Row || position == hidePhoneRow || position == inappCameraRow ||
|
||||
position == ignoreBlockedRow || position == useSystemEmojiRow || position == singleBigEmojiRow ||
|
||||
position == enableLogsRow || position == forceTabletRow) {
|
||||
return 3;
|
||||
} else if (position == settingsRow || position == connectionRow || position == emojiRow ||
|
||||
position == debugRow) {
|
||||
return 4;
|
||||
}
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
}
|
19
TMessagesProj/src/main/res/values/strings_neko.xml
Normal file
19
TMessagesProj/src/main/res/values/strings_neko.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="NekoSettings">Neko Settings</string>
|
||||
<string name="IPv6">Try connecting through IPv6</string>
|
||||
<string name="HidePhone">Hide phone number</string>
|
||||
<string name="Hide">Hide</string>
|
||||
<string name="DeleteAllFromSelf">Delete all from yourself</string>
|
||||
<string name="BotLogin">Bot Login</string>
|
||||
<string name="InvalidAccessToken">Invalid access token</string>
|
||||
<string name="IgnoreBlocked">Ignore blocked users in group</string>
|
||||
<string name="Connection">Connection</string>
|
||||
<string name="NameOrder">Name order</string>
|
||||
<string name="FirstLast">First Last</string>
|
||||
<string name="LastFirst">Last First</string>
|
||||
<string name="NoQuoteForward">NoQuote forward</string>
|
||||
<string name="Repeat">Repeat</string>
|
||||
<string name="CreateMention">Create Mention</string>
|
||||
<string name="ForceTabletMode">Force tablet mode</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user