1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-02 10:33:36 +00:00

Allow hide device info

This commit is contained in:
世界 2021-02-06 19:40:35 +08:00
parent e85a773906
commit 1a2569bad4
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
11 changed files with 443 additions and 127 deletions

View File

@ -54,6 +54,7 @@ NekoX is an **free and open source** third-party Telegram client, based on Teleg
- Allow create group without invite
- Option to upgrade group to supergroup
- Mark dialogs as read using tab menu
- Option to hide device info
- Improved session dialog
- Improved link long click menu
- Text replacer

View File

@ -1,8 +1,8 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
def verName = "7.4.2-rc02"
def verCode = 178
def verName = "7.4.2-rc03"
def verCode = 180
def officialVer = "7.4.2"
def officialCode = 2227

View File

@ -67,6 +67,7 @@ public class UserConfig extends BaseController {
public long autoDownloadConfigLoadTime;
public boolean isBot;
public boolean official;
public boolean deviceInfo;
public volatile byte[] savedPasswordHash;
public volatile byte[] savedSaltedPassword;
@ -153,6 +154,7 @@ public class UserConfig extends BaseController {
editor.putInt("lastMyLocationShareTime", lastMyLocationShareTime);
editor.putBoolean("isBot", isBot);
editor.putBoolean("official", official);
editor.putBoolean("deviceInfo", deviceInfo);
editor.putBoolean("filtersLoaded", filtersLoaded);
if (tonEncryptedData != null) {
@ -305,8 +307,10 @@ public class UserConfig extends BaseController {
notificationsSignUpSettingsLoaded = preferences.getBoolean("notificationsSignUpSettingsLoaded", false);
autoDownloadConfigLoadTime = preferences.getLong("autoDownloadConfigLoadTime", 0);
hasValidDialogLoadIds = preferences.contains("2dialogsLoadOffsetId") || preferences.getBoolean("hasValidDialogLoadIds", false);
isBot = preferences.getBoolean("isBot",false);
isBot = preferences.getBoolean("isBot", false);
official = preferences.getBoolean("official", false);
deviceInfo = preferences.getBoolean("deviceInfo", true);
tonEncryptedData = preferences.getString("tonEncryptedData", null);
tonPublicKey = preferences.getString("tonPublicKey", null);
tonKeyName = preferences.getString("tonKeyName", "walletKey" + currentAccount);

View File

@ -164,20 +164,25 @@ public class ConnectionsManager extends BaseController {
}
String configPath = config.toString();
boolean enablePushConnection = isPushConnectionEnabled();
getUserConfig().loadConfig();
try {
systemLangCode = LocaleController.getSystemLocaleStringIso639().toLowerCase();
langCode = LocaleController.getLocaleStringIso639().toLowerCase();
deviceModel = Build.MANUFACTURER + Build.MODEL;
systemVersion = "SDK " + Build.VERSION.SDK_INT;
} catch (Exception e) {
systemLangCode = "en";
if (getUserConfig().deviceInfo) {
deviceModel = Build.MANUFACTURER + Build.MODEL;
systemVersion = "SDK " + Build.VERSION.SDK_INT;
} else {
deviceModel = "";
systemVersion = "";
}
} catch (Exception ignored) {
systemLangCode = "";
langCode = "";
deviceModel = "Android unknown";
systemVersion = "SDK " + Build.VERSION.SDK_INT;
deviceModel = "";
systemVersion = "";
}
getUserConfig().loadConfig();
int version;
int appId;
String fingerprint;
@ -200,13 +205,10 @@ public class ConnectionsManager extends BaseController {
systemLangCode = "en";
}
if (deviceModel.trim().length() == 0) {
deviceModel = "Android unknown";
}
if (appVersion.trim().length() == 0) {
appVersion = "App version unknown";
deviceModel = "Unknown";
}
if (systemVersion.trim().length() == 0) {
systemVersion = "SDK Unknown";
systemVersion = "Unknown";
}
String pushString = SharedConfig.pushString;
if (TextUtils.isEmpty(pushString) && !TextUtils.isEmpty(SharedConfig.pushStringStatus)) {

View File

@ -18,6 +18,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
@ -164,7 +165,7 @@ public class SessionCell extends FrameLayout {
}
}
if (!session.official_app) {
if (!session.official_app && session.api_id != BuildConfig.APP_ID) {
if (stringBuilder.length() != 0) {
stringBuilder.append(", ");
}

View File

@ -102,15 +102,15 @@ import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CombinedDrawable;
import org.telegram.ui.Components.ContextProgressView;
import org.telegram.ui.Components.EditTextBoldCursor;
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.VerticalPositionAutoAnimator;
import org.telegram.ui.Components.HintEditText;
import org.telegram.ui.Components.ImageUpdater;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.ProxyDrawable;
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.RadialProgressView;
import org.telegram.ui.Components.SlideView;
import org.telegram.ui.Components.VerticalPositionAutoAnimator;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@ -1553,6 +1553,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
UserConfig.getInstance(currentAccount).clearConfig();
MessagesController.getInstance(currentAccount).cleanup();
UserConfig.getInstance(currentAccount).official = NekoXConfig.currentAppId() == BuildVars.OFFICAL_APP_ID;
UserConfig.getInstance(currentAccount).deviceInfo = uploadDeviceInfo;
UserConfig.getInstance(currentAccount).syncContacts = syncContacts;
UserConfig.getInstance(currentAccount).setCurrentUser(res.user);
UserConfig.getInstance(currentAccount).saveConfig(true);
@ -1633,7 +1634,8 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
private TLRPC.TL_help_termsOfService currentTermsOfService;
private boolean allowFlashCall;
private boolean allowFlashCall = false;
private boolean uploadDeviceInfo = true;
public class PhoneView extends SlideView implements AdapterView.OnItemSelectedListener {
@ -1643,7 +1645,9 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
private View view;
private TextView textView;
private TextView textView2;
private CheckBoxCell checkBoxCell;
private CheckBoxCell syncCell;
private CheckBoxCell infoCell;
private int countryState = 0;
@ -1921,10 +1925,40 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
textView2.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
addView(textView2, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 28, 0, 10));
checkBoxCell = new CheckBoxCell(context, 2);
checkBoxCell.setText(LocaleController.getString("SyncContacts", R.string.SyncContacts), "", syncContacts, false);
addView(checkBoxCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
checkBoxCell.setOnClickListener(new OnClickListener() {
infoCell = new CheckBoxCell(context, 2);
infoCell.setText(LocaleController.getString("UploadDeviceInfo", R.string.UploadDeviceInfo), "", uploadDeviceInfo, false);
addView(infoCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
infoCell.setOnClickListener(new OnClickListener() {
private Toast visibleToast;
@Override
public void onClick(View v) {
if (getParentActivity() == null) {
return;
}
infoCell.setChecked(uploadDeviceInfo = !uploadDeviceInfo, true);
try {
if (visibleToast != null) {
visibleToast.cancel();
}
} catch (Exception e) {
FileLog.e(e);
}
if (uploadDeviceInfo) {
visibleToast = Toast.makeText(getParentActivity(), LocaleController.getString("UploadDeviceInfoOn", R.string.UploadDeviceInfoOn), Toast.LENGTH_SHORT);
visibleToast.show();
} else {
visibleToast = Toast.makeText(getParentActivity(), LocaleController.getString("UploadDeviceInfoOff", R.string.UploadDeviceInfoOff), Toast.LENGTH_SHORT);
visibleToast.show();
}
}
});
syncCell = new CheckBoxCell(context, 2);
syncCell.setText(LocaleController.getString("SyncContacts", R.string.SyncContacts), "", syncContacts, false);
addView(syncCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
syncCell.setOnClickListener(new OnClickListener() {
private Toast visibleToast;
@ -2324,8 +2358,8 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
public void onShow() {
super.onShow();
fillNumber();
if (checkBoxCell != null) {
checkBoxCell.setChecked(syncContacts, false);
if (syncCell != null) {
syncCell.setChecked(syncContacts, false);
}
AndroidUtilities.runOnUIThread(() -> {
if (phoneField != null) {

View File

@ -25,18 +25,22 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment;
@ -55,9 +59,6 @@ import org.telegram.ui.Components.UndoView;
import java.util.ArrayList;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import kotlin.Unit;
import tw.nekomimi.nekogram.BottomBuilder;
import tw.nekomimi.nekogram.utils.AlertUtil;
@ -310,11 +311,17 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
BottomBuilder builder = new BottomBuilder(getParentActivity());
String title = authorization.app_name + " " + authorization.app_version + "\n";
title += authorization.device_model + ", " + authorization.system_version + "\n";
title += authorization.device_model + ", " + authorization.platform + " " + authorization.system_version + "\n";
title += "Login: " + LocaleController.getInstance().chatFullDate.format(authorization.date_created * 1000L) + "\n";
title += "Active: " + LocaleController.getInstance().chatFullDate.format(authorization.date_active * 1000L) + "\n";
if (!authorization.official_app) {
title += "Unofficial application " + authorization.api_id + "\n";
title += "Unofficial application ";
if (authorization.api_id == BuildConfig.APP_ID) {
title += "Nekogram X";
} else {
title += authorization.api_id;
}
title += "\n";
}
title += authorization.ip + " - " + authorization.region + " " + authorization.country;

View File

@ -0,0 +1,347 @@
package tw.nekomimi.nekogram.settings;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import org.telegram.tgnet.TLRPC;
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.TextInfoPrivacyCell;
import org.telegram.ui.Cells.TextSettingsCell;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.UndoView;
import java.util.ArrayList;
import tw.nekomimi.nekogram.MessageHelper;
@SuppressLint("RtlHardcoded")
public class NekoAccountSettingsActivity extends BaseFragment {
private RecyclerListView listView;
private ListAdapter listAdapter;
private int rowCount;
private int accountRow;
private int uploadDeviceInfoRow;
private int deleteAccountRow;
private int account2Row;
private UndoView tooltip;
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
updateRows();
return true;
}
@SuppressLint("NewApi")
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setTitle(LocaleController.getString("Account", R.string.Account));
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));
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
listView.setAdapter(listAdapter);
listView.setOnItemClickListener((view, position, x, y) -> {
if (position == uploadDeviceInfoRow) {
getUserConfig().deviceInfo = !getUserConfig().deviceInfo;
getUserConfig().saveConfig(true);
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(getUserConfig().deviceInfo);
}
tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
} else if (position == deleteAccountRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("TosDeclineDeleteAccount", R.string.TosDeclineDeleteAccount));
builder.setTitle(LocaleController.getString("DeleteAccount", R.string.DeleteAccount));
builder.setPositiveButton(LocaleController.getString("Deactivate", R.string.Deactivate), (dialog, which) -> {
ArrayList<TLRPC.Dialog> dialogs = new ArrayList<>(getMessagesController().getAllDialogs());
for (TLRPC.Dialog TLdialog : dialogs) {
if (TLdialog instanceof TLRPC.TL_dialogFolder) {
continue;
}
TLRPC.Peer peer = getMessagesController().getPeer((int) TLdialog.id);
if (peer.channel_id != 0) {
TLRPC.Chat chat = getMessagesController().getChat(peer.channel_id);
if (!chat.broadcast) {
MessageHelper.getInstance(currentAccount).deleteUserChannelHistoryWithSearch(TLdialog.id, getMessagesController().getUser(getUserConfig().clientUserId));
}
}
if (peer.user_id != 0) {
getMessagesController().deleteDialog(TLdialog.id, 0, true);
}
}
AlertDialog.Builder builder12 = new AlertDialog.Builder(getParentActivity());
builder12.setMessage(LocaleController.getString("TosDeclineDeleteAccount", R.string.TosDeclineDeleteAccount));
builder12.setTitle(LocaleController.getString("DeleteAccount", R.string.DeleteAccount));
builder12.setPositiveButton(LocaleController.getString("Deactivate", R.string.Deactivate), (dialogInterface, i) -> {
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.setCanCacnel(false);
TLRPC.TL_account_deleteAccount req = new TLRPC.TL_account_deleteAccount();
req.reason = "Meow";
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
if (response instanceof TLRPC.TL_boolTrue) {
getMessagesController().performLogout(0);
} else if (error == null || error.code != -1000) {
String errorText = LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred);
if (error != null) {
errorText += "\n" + error.text;
}
AlertDialog.Builder builder1 = new AlertDialog.Builder(getParentActivity());
builder1.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder1.setMessage(errorText);
builder1.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder1.show();
}
}));
progressDialog.show();
});
builder12.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog dialog12 = builder12.create();
showDialog(dialog12);
TextView button = (TextView) dialog12.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.show();
AlertDialog dialog = builder.create();
showDialog(dialog);
TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
}
});
tooltip = new UndoView(context);
frameLayout.addView(tooltip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
return fragmentView;
}
@Override
public void onResume() {
super.onResume();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
private void updateRows() {
rowCount = 0;
accountRow = rowCount++;
uploadDeviceInfoRow = rowCount++;
deleteAccountRow = rowCount++;
account2Row = rowCount++;
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
@Override
public ArrayList<ThemeDescription> getThemeDescriptions() {
ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
themeDescriptions.add(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));
themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_avatar_actionBarIconBlue));
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_avatar_actionBarSelectorBlue));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, null, Theme.key_actionBarDefaultSubmenuBackground));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, null, Theme.key_actionBarDefaultSubmenuItem));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteValueText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
return themeDescriptions;
}
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: {
if (position == account2Row) {
holder.itemView.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
} else {
holder.itemView.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
}
break;
}
case 2: {
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
if (position == deleteAccountRow) {
textCell.setText(LocaleController.getString("DeleteAccount", R.string.DeleteAccount), false);
textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
}
break;
}
case 3: {
TextCheckCell textCell = (TextCheckCell) holder.itemView;
textCell.setEnabled(true, null);
if (position == uploadDeviceInfoRow) {
textCell.setTextAndCheck(LocaleController.getString("UploadDeviceInfo", R.string.UploadDeviceInfo), getUserConfig().deviceInfo, true);
}
break;
}
case 4: {
HeaderCell headerCell = (HeaderCell) holder.itemView;
if (position == accountRow) {
headerCell.setText(LocaleController.getString("Account", R.string.Account));
}
break;
}
}
}
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
int type = holder.getItemViewType();
return type == 2 || type == 3;
}
@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;
case 7:
view = new TextInfoPrivacyCell(mContext);
view.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
break;
}
//noinspection ConstantConditions
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 == account2Row) {
return 1;
} else if (position == deleteAccountRow) {
return 2;
} else if (position == accountRow) {
return 4;
}
return 3;
}
}
}

View File

@ -5,20 +5,17 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
@ -43,7 +40,6 @@ import org.telegram.ui.Components.UndoView;
import java.util.ArrayList;
import tw.nekomimi.nekogram.MessageHelper;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
@ -68,7 +64,6 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
private int ignoreContentRestrictionsRow;
private int unlimitedFavedStickersRow;
private int unlimitedPinnedDialogsRow;
private int deleteAccountRow;
private int experiment2Row;
private UndoView tooltip;
@ -138,74 +133,6 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.unlimitedFavedStickers);
}
} else if (position == deleteAccountRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("TosDeclineDeleteAccount", R.string.TosDeclineDeleteAccount));
builder.setTitle(LocaleController.getString("DeleteAccount", R.string.DeleteAccount));
builder.setPositiveButton(LocaleController.getString("Deactivate", R.string.Deactivate), (dialog, which) -> {
ArrayList<TLRPC.Dialog> dialogs = new ArrayList<>(getMessagesController().getAllDialogs());
for (TLRPC.Dialog TLdialog : dialogs) {
if (TLdialog instanceof TLRPC.TL_dialogFolder) {
continue;
}
TLRPC.Peer peer = getMessagesController().getPeer((int) TLdialog.id);
if (peer.channel_id != 0) {
TLRPC.Chat chat = getMessagesController().getChat(peer.channel_id);
if (!chat.broadcast) {
MessageHelper.getInstance(currentAccount).deleteUserChannelHistoryWithSearch(TLdialog.id, getMessagesController().getUser(getUserConfig().clientUserId));
}
}
if (peer.user_id != 0) {
getMessagesController().deleteDialog(TLdialog.id, 0, true);
}
}
AlertDialog.Builder builder12 = new AlertDialog.Builder(getParentActivity());
builder12.setMessage(LocaleController.getString("TosDeclineDeleteAccount", R.string.TosDeclineDeleteAccount));
builder12.setTitle(LocaleController.getString("DeleteAccount", R.string.DeleteAccount));
builder12.setPositiveButton(LocaleController.getString("Deactivate", R.string.Deactivate), (dialogInterface, i) -> {
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.setCanCacnel(false);
TLRPC.TL_account_deleteAccount req = new TLRPC.TL_account_deleteAccount();
req.reason = "Meow";
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
if (response instanceof TLRPC.TL_boolTrue) {
getMessagesController().performLogout(0);
} else if (error == null || error.code != -1000) {
String errorText = LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred);
if (error != null) {
errorText += "\n" + error.text;
}
AlertDialog.Builder builder1 = new AlertDialog.Builder(getParentActivity());
builder1.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder1.setMessage(errorText);
builder1.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder1.show();
}
}));
progressDialog.show();
});
builder12.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog dialog12 = builder12.create();
showDialog(dialog12);
TextView button = (TextView) dialog12.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.show();
AlertDialog dialog = builder.create();
showDialog(dialog);
TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
} else if (position == smoothKeyboardRow) {
SharedConfig.toggleSmoothKeyboard();
if (view instanceof TextCheckCell) {
@ -273,7 +200,6 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
ignoreContentRestrictionsRow = !BuildConfig.VERSION_NAME.contains("play") || NekoXConfig.developerMode ? rowCount++ : -1;
unlimitedFavedStickersRow = rowCount++;
unlimitedPinnedDialogsRow = rowCount++;
deleteAccountRow = rowCount++;
experiment2Row = rowCount++;
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
@ -390,15 +316,6 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
}
break;
}
case 2: {
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
if (position == deleteAccountRow) {
textCell.setText(LocaleController.getString("DeleteAccount", R.string.DeleteAccount), false);
textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
}
break;
}
case 3: {
TextCheckCell textCell = (TextCheckCell) holder.itemView;
textCell.setEnabled(true, null);
@ -412,7 +329,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
} else if (position == smoothKeyboardRow) {
textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard), SharedConfig.smoothKeyboard, true);
} else if (position == unlimitedPinnedDialogsRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedPinnedDialogs", R.string.UnlimitedPinnedDialogs), LocaleController.getString("UnlimitedPinnedDialogsAbout", R.string.UnlimitedPinnedDialogsAbout), NekoConfig.unlimitedPinnedDialogs, true, deleteAccountRow != -1);
textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedPinnedDialogs", R.string.UnlimitedPinnedDialogs), LocaleController.getString("UnlimitedPinnedDialogsAbout", R.string.UnlimitedPinnedDialogsAbout), NekoConfig.unlimitedPinnedDialogs, true, false);
} else if (position == mediaPreviewRow) {
textCell.setTextAndCheck(LocaleController.getString("MediaPreview", R.string.MediaPreview), NekoConfig.mediaPreview, true);
} else if (position == proxyAutoSwitchRow) {
@ -435,7 +352,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
int type = holder.getItemViewType();
return type == 2 || type == 3;
return type == 3;
}
@Override
@ -445,10 +362,6 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
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));
@ -479,8 +392,6 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
public int getItemViewType(int position) {
if (position == experiment2Row) {
return 1;
} else if (position == deleteAccountRow) {
return 2;
} else if (position == experimentRow) {
return 4;
}

View File

@ -11,7 +11,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.R;
@ -45,6 +44,7 @@ public class NekoSettingsActivity extends BaseFragment {
private int categoriesRow;
private int generalRow;
private int accountRow;
private int chatRow;
private int experimentRow;
private int categories2Row;
@ -99,6 +99,8 @@ public class NekoSettingsActivity extends BaseFragment {
presentFragment(new NekoChatSettingsActivity());
} else if (position == generalRow) {
presentFragment(new NekoGeneralSettingsActivity());
} else if (position == accountRow) {
presentFragment(new NekoAccountSettingsActivity());
} else if (position == experimentRow) {
presentFragment(new NekoExperimentalSettingsActivity());
} else if (position == channelRow) {
@ -127,6 +129,7 @@ public class NekoSettingsActivity extends BaseFragment {
rowCount = 0;
categoriesRow = rowCount++;
generalRow = rowCount++;
accountRow = rowCount++;
chatRow = rowCount++;
experimentRow = rowCount++;
categories2Row = rowCount++;
@ -220,6 +223,8 @@ public class NekoSettingsActivity extends BaseFragment {
textCell.setTextAndIcon(LocaleController.getString("General", R.string.General), R.drawable.baseline_palette_24, true);
} else if (position == experimentRow) {
textCell.setTextAndIcon(LocaleController.getString("Experiment", R.string.Experiment), R.drawable.baseline_star_24, false);
} else if (position == accountRow) {
textCell.setTextAndIcon(LocaleController.getString("Account", R.string.Account), R.drawable.baseline_person_24, true);
}
break;
}

View File

@ -275,5 +275,9 @@
<string name="TextReplace">Replace</string>
<string name="ReplaceRegex">Use regex</string>
<string name="DisableTrending">Disable Trending</string>
<string name="UploadDeviceInfo">Upload device info</string>
<string name="UploadDeviceInfoOn">Device info will be uploaded the second time after logging in.</string>
<string name="UploadDeviceInfoOff">You can change this in the settings later.</string>
</resources>