mirror of https://github.com/NekoX-Dev/NekoX.git
1243 lines
71 KiB
Java
1243 lines
71 KiB
Java
package tw.nekomimi.nekogram;
|
|
|
|
import android.animation.Animator;
|
|
import android.animation.AnimatorListenerAdapter;
|
|
import android.animation.AnimatorSet;
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Paint;
|
|
import android.os.Build;
|
|
import android.text.TextPaint;
|
|
import android.view.Gravity;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.WindowManager;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.LinearLayout;
|
|
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.MessagesController;
|
|
import org.telegram.messenger.NotificationCenter;
|
|
import org.telegram.messenger.R;
|
|
import org.telegram.messenger.SharedConfig;
|
|
import org.telegram.messenger.UserConfig;
|
|
import org.telegram.tgnet.ConnectionsManager;
|
|
import org.telegram.tgnet.TLRPC;
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
|
import org.telegram.ui.ActionBar.AlertDialog;
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
|
import org.telegram.ui.ActionBar.BottomSheet;
|
|
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.RadioColorCell;
|
|
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.AlertsCreator;
|
|
import org.telegram.ui.Components.LayoutHelper;
|
|
import org.telegram.ui.Components.RecyclerListView;
|
|
import org.telegram.ui.Components.SeekBarView;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@SuppressLint("RtlHardcoded")
|
|
public class NekoSettingsActivity extends BaseFragment {
|
|
|
|
private RecyclerListView listView;
|
|
private ListAdapter listAdapter;
|
|
private AnimatorSet animatorSet;
|
|
|
|
private boolean sensitiveCanChange = false;
|
|
private boolean sensitiveEnabled = false;
|
|
|
|
private int rowCount;
|
|
|
|
private int connectionRow;
|
|
private int ipv6Row;
|
|
private int connection2Row;
|
|
|
|
private int chatRow;
|
|
private int inappCameraRow;
|
|
private int useSystemEmojiRow;
|
|
private int ignoreBlockedRow;
|
|
private int hideProxySponsorChannelRow;
|
|
private int saveCacheToPrivateDirectoryRow;
|
|
private int pauseMusicOnRecordRow;
|
|
private int disablePhotoSideActionRow;
|
|
private int hideKeyboardOnChatScrollRow;
|
|
private int rearVideoMessagesRow;
|
|
private int hideAllTabRow;
|
|
private int mapPreviewRow;
|
|
private int stickerSizeRow;
|
|
private int translationProviderRow;
|
|
private int messageMenuRow;
|
|
private int tabsTitleTypeRow;
|
|
private int chat2Row;
|
|
|
|
private int settingsRow;
|
|
private int typefaceRow;
|
|
private int hidePhoneRow;
|
|
private int nameOrderRow;
|
|
private int transparentStatusBarRow;
|
|
private int forceTabletRow;
|
|
private int openArchiveOnPullRow;
|
|
private int avatarAsDrawerBackgroundRow;
|
|
private int showTabsOnForwardRow;
|
|
private int eventTypeRow;
|
|
private int newYearRow;
|
|
private int actionBarDecorationRow;
|
|
private int needRestartRow;
|
|
|
|
private int experimentRow;
|
|
private int smoothKeyboardRow;
|
|
private int chatMessageAnimationRow;
|
|
private int disableFilteringRow;
|
|
private int unlimitedFavedStickersRow;
|
|
private int unlimitedPinnedDialogsRow;
|
|
private int deleteAccountRow;
|
|
private int experiment2Row;
|
|
|
|
@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("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));
|
|
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 == 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 == transparentStatusBarRow) {
|
|
NekoConfig.toggleTransparentStatusBar();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.transparentStatusBar);
|
|
}
|
|
AndroidUtilities.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewTheme, false));
|
|
} else if (position == hideProxySponsorChannelRow) {
|
|
NekoConfig.toggleHideProxySponsorChannel();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.hideProxySponsorChannel);
|
|
}
|
|
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
|
|
if (UserConfig.getInstance(a).isClientActivated()) {
|
|
MessagesController.getInstance(a).checkProxyInfo(true);
|
|
}
|
|
}
|
|
} else if (position == saveCacheToPrivateDirectoryRow) {
|
|
NekoConfig.toggleSaveCacheToPrivateDirectory();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.saveCacheToPrivateDirectory);
|
|
}
|
|
} else if (position == useSystemEmojiRow) {
|
|
NekoConfig.toggleUseSystemEmoji();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.useSystemEmoji);
|
|
}
|
|
} else if (position == typefaceRow) {
|
|
NekoConfig.toggleTypeface();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.typeface == 1);
|
|
}
|
|
} else if (position == mapPreviewRow) {
|
|
ArrayList<String> arrayList = new ArrayList<>();
|
|
ArrayList<Integer> types = new ArrayList<>();
|
|
arrayList.add(LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram));
|
|
types.add(0);
|
|
arrayList.add(LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex));
|
|
types.add(1);
|
|
arrayList.add(LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody));
|
|
types.add(2);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
builder.setTitle(LocaleController.getString("MapPreviewProviderTitle", R.string.MapPreviewProviderTitle));
|
|
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.mapPreviewProvider == types.get(a));
|
|
linearLayout.addView(cell);
|
|
cell.setOnClickListener(v -> {
|
|
Integer which = (Integer) v.getTag();
|
|
NekoConfig.setMapPreviewProvider(types.get(which));
|
|
listAdapter.notifyItemChanged(mapPreviewRow);
|
|
builder.getDismissRunnable().run();
|
|
});
|
|
}
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
showDialog(builder.create());
|
|
} else if (position == nameOrderRow) {
|
|
ArrayList<String> arrayList = new ArrayList<>();
|
|
ArrayList<Integer> types = new ArrayList<>();
|
|
arrayList.add(LocaleController.getString("FirstLast", R.string.FirstLast));
|
|
types.add(1);
|
|
arrayList.add(LocaleController.getString("LastFirst", R.string.LastFirst));
|
|
types.add(2);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
builder.setTitle(LocaleController.getString("NameOrder", R.string.NameOrder));
|
|
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.nameOrder == types.get(a));
|
|
linearLayout.addView(cell);
|
|
cell.setOnClickListener(v -> {
|
|
Integer which = (Integer) v.getTag();
|
|
NekoConfig.setNameOrder(types.get(which));
|
|
listAdapter.notifyItemChanged(nameOrderRow);
|
|
builder.getDismissRunnable().run();
|
|
});
|
|
}
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
showDialog(builder.create());
|
|
} else if (position == eventTypeRow) {
|
|
ArrayList<String> arrayList = new ArrayList<>();
|
|
ArrayList<Integer> types = new ArrayList<>();
|
|
arrayList.add(LocaleController.getString("DependsOnDate", R.string.DependsOnDate));
|
|
types.add(0);
|
|
arrayList.add(LocaleController.getString("Christmas", R.string.Christmas));
|
|
types.add(1);
|
|
arrayList.add(LocaleController.getString("Valentine", R.string.Valentine));
|
|
types.add(2);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
builder.setTitle(LocaleController.getString("EventType", R.string.EventType));
|
|
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.eventType == types.get(a));
|
|
linearLayout.addView(cell);
|
|
cell.setOnClickListener(v -> {
|
|
Integer which = (Integer) v.getTag();
|
|
NekoConfig.setEventType(types.get(which));
|
|
listAdapter.notifyItemChanged(eventTypeRow);
|
|
builder.getDismissRunnable().run();
|
|
});
|
|
}
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
showDialog(builder.create());
|
|
} else if (position == actionBarDecorationRow) {
|
|
ArrayList<String> arrayList = new ArrayList<>();
|
|
ArrayList<Integer> types = new ArrayList<>();
|
|
arrayList.add(LocaleController.getString("DependsOnDate", R.string.DependsOnDate));
|
|
types.add(0);
|
|
arrayList.add(LocaleController.getString("Snowflakes", R.string.Snowflakes));
|
|
types.add(1);
|
|
arrayList.add(LocaleController.getString("Fireworks", R.string.Fireworks));
|
|
types.add(2);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
builder.setTitle(LocaleController.getString("ActionBarDecoration", R.string.ActionBarDecoration));
|
|
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.actionBarDecoration == types.get(a));
|
|
linearLayout.addView(cell);
|
|
cell.setOnClickListener(v -> {
|
|
Integer which = (Integer) v.getTag();
|
|
NekoConfig.setActionBarDecoration(types.get(which));
|
|
listAdapter.notifyItemChanged(actionBarDecorationRow);
|
|
builder.getDismissRunnable().run();
|
|
});
|
|
}
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
showDialog(builder.create());
|
|
} else if (position == newYearRow) {
|
|
NekoConfig.toggleNewYear();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.newYear);
|
|
}
|
|
} else if (position == disableFilteringRow) {
|
|
sensitiveEnabled = !sensitiveEnabled;
|
|
TLRPC.TL_account_setContentSettings req = new TLRPC.TL_account_setContentSettings();
|
|
req.sensitive_enabled = sensitiveEnabled;
|
|
AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
|
|
progressDialog.show();
|
|
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
|
progressDialog.dismiss();
|
|
if (error == null) {
|
|
if (response instanceof TLRPC.TL_boolTrue && view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(sensitiveEnabled);
|
|
}
|
|
} else {
|
|
AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, this, req));
|
|
}
|
|
}));
|
|
} else if (position == stickerSizeRow) {
|
|
showStickerSizeAlert();
|
|
} else if (position == unlimitedFavedStickersRow) {
|
|
NekoConfig.toggleUnlimitedFavedStickers();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.unlimitedFavedStickers);
|
|
}
|
|
} else if (position == messageMenuRow) {
|
|
showMessageMenuAlert();
|
|
} 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 == translationProviderRow) {
|
|
ArrayList<String> arrayList = new ArrayList<>();
|
|
ArrayList<Integer> types = new ArrayList<>();
|
|
arrayList.add(LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate));
|
|
types.add(1);
|
|
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN));
|
|
types.add(2);
|
|
arrayList.add(LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud));
|
|
types.add(3);
|
|
arrayList.add(LocaleController.getString("ProviderGoogleTranslateWeb", R.string.ProviderGoogleTranslateWeb));
|
|
types.add(-1);
|
|
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCNWeb", R.string.ProviderGoogleTranslateCNWeb));
|
|
types.add(-2);
|
|
arrayList.add(LocaleController.getString("ProviderBaiduFanyiWeb", R.string.ProviderBaiduFanyiWeb));
|
|
types.add(-3);
|
|
arrayList.add(LocaleController.getString("ProviderDeepLWeb", R.string.ProviderDeepLWeb));
|
|
types.add(-4);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
builder.setTitle(LocaleController.getString("TranslationProvider", R.string.TranslationProvider));
|
|
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.translationProvider == types.get(a));
|
|
linearLayout.addView(cell);
|
|
cell.setOnClickListener(v -> {
|
|
Integer which = (Integer) v.getTag();
|
|
NekoConfig.setTranslationProvider(types.get(which));
|
|
listAdapter.notifyItemChanged(translationProviderRow);
|
|
builder.getDismissRunnable().run();
|
|
});
|
|
}
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
showDialog(builder.create());
|
|
} else if (position == pauseMusicOnRecordRow) {
|
|
SharedConfig.togglePauseMusicOnRecord();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(SharedConfig.pauseMusicOnRecord);
|
|
}
|
|
} else if (position == smoothKeyboardRow) {
|
|
SharedConfig.toggleSmoothKeyboard();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(SharedConfig.smoothKeyboard);
|
|
}
|
|
if (SharedConfig.smoothKeyboard && getParentActivity() != null) {
|
|
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
|
}
|
|
} else if (position == disablePhotoSideActionRow) {
|
|
NekoConfig.toggleDisablePhotoSideAction();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.disablePhotoSideAction);
|
|
}
|
|
} else if (position == unlimitedPinnedDialogsRow) {
|
|
NekoConfig.toggleUnlimitedPinnedDialogs();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.unlimitedPinnedDialogs);
|
|
}
|
|
} else if (position == openArchiveOnPullRow) {
|
|
NekoConfig.toggleOpenArchiveOnPull();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.openArchiveOnPull);
|
|
}
|
|
} else if (position == experimentRow) {
|
|
NekoConfig.toggleShowHiddenFeature();
|
|
updateRows();
|
|
} else if (position == hideKeyboardOnChatScrollRow) {
|
|
NekoConfig.toggleHideKeyboardOnChatScroll();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.hideKeyboardOnChatScroll);
|
|
}
|
|
} else if (position == avatarAsDrawerBackgroundRow) {
|
|
NekoConfig.toggleAvatarAsDrawerBackground();
|
|
NotificationCenter.getInstance(UserConfig.selectedAccount).postNotificationName(NotificationCenter.mainUserInfoChanged);
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.avatarAsDrawerBackground);
|
|
}
|
|
} else if (position == showTabsOnForwardRow) {
|
|
NekoConfig.toggleShowTabsOnForward();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.showTabsOnForward);
|
|
}
|
|
} else if (position == chatMessageAnimationRow) {
|
|
NekoConfig.toggleChatMessageAnimation();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.chatMessageAnimation);
|
|
}
|
|
} else if (position == rearVideoMessagesRow) {
|
|
NekoConfig.toggleRearVideoMessages();
|
|
if (view instanceof TextCheckCell) {
|
|
((TextCheckCell) view).setChecked(NekoConfig.rearVideoMessages);
|
|
}
|
|
} else if (position == hideAllTabRow) {
|
|
NekoConfig.toggleHideAllTab();
|
|
if (view instanceof TextCheckCell) {
|
|
((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());
|
|
}
|
|
|
|
});
|
|
|
|
return fragmentView;
|
|
}
|
|
|
|
@Override
|
|
public void onResume() {
|
|
super.onResume();
|
|
if (listAdapter != null) {
|
|
checkSensitive();
|
|
listAdapter.notifyDataSetChanged();
|
|
}
|
|
}
|
|
|
|
private void updateRows() {
|
|
rowCount = 0;
|
|
connectionRow = rowCount++;
|
|
ipv6Row = rowCount++;
|
|
connection2Row = rowCount++;
|
|
chatRow = rowCount++;
|
|
inappCameraRow = rowCount++;
|
|
useSystemEmojiRow = rowCount++;
|
|
ignoreBlockedRow = rowCount++;
|
|
hideProxySponsorChannelRow = rowCount++;
|
|
saveCacheToPrivateDirectoryRow = NekoConfig.showHiddenFeature && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? rowCount++ : -1;
|
|
pauseMusicOnRecordRow = rowCount++;
|
|
disablePhotoSideActionRow = rowCount++;
|
|
hideKeyboardOnChatScrollRow = rowCount++;
|
|
rearVideoMessagesRow = rowCount++;
|
|
hideAllTabRow = rowCount++;
|
|
mapPreviewRow = rowCount++;
|
|
stickerSizeRow = rowCount++;
|
|
messageMenuRow = rowCount++;
|
|
translationProviderRow = rowCount++;
|
|
tabsTitleTypeRow = rowCount++;
|
|
chat2Row = rowCount++;
|
|
settingsRow = rowCount++;
|
|
hidePhoneRow = rowCount++;
|
|
typefaceRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? rowCount++ : -1;
|
|
transparentStatusBarRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? rowCount++ : -1;
|
|
forceTabletRow = rowCount++;
|
|
openArchiveOnPullRow = rowCount++;
|
|
avatarAsDrawerBackgroundRow = rowCount++;
|
|
showTabsOnForwardRow = rowCount++;
|
|
nameOrderRow = rowCount++;
|
|
eventTypeRow = NekoConfig.showHiddenFeature ? rowCount++ : -1;
|
|
newYearRow = NekoConfig.showHiddenFeature ? rowCount++ : -1;
|
|
actionBarDecorationRow = NekoConfig.showHiddenFeature ? rowCount++ : -1;
|
|
needRestartRow = rowCount++;
|
|
experimentRow = rowCount++;
|
|
smoothKeyboardRow = !AndroidUtilities.isTablet() ? rowCount++ : -1;
|
|
chatMessageAnimationRow = rowCount++;
|
|
disableFilteringRow = rowCount++;
|
|
unlimitedFavedStickersRow = rowCount++;
|
|
unlimitedPinnedDialogsRow = rowCount++;
|
|
deleteAccountRow = NekoConfig.showHiddenFeature ? rowCount++ : -1;
|
|
experiment2Row = 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 void checkSensitive() {
|
|
TLRPC.TL_account_getContentSettings req = new TLRPC.TL_account_getContentSettings();
|
|
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
|
if (error == null) {
|
|
TLRPC.TL_account_contentSettings settings = (TLRPC.TL_account_contentSettings) response;
|
|
sensitiveEnabled = settings.sensitive_enabled;
|
|
sensitiveCanChange = settings.sensitive_can_change;
|
|
int count = listView.getChildCount();
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
for (int a = 0; a < count; a++) {
|
|
View child = listView.getChildAt(a);
|
|
RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.getChildViewHolder(child);
|
|
int position = holder.getAdapterPosition();
|
|
if (position == disableFilteringRow) {
|
|
TextCheckCell checkCell = (TextCheckCell) holder.itemView;
|
|
checkCell.setChecked(sensitiveEnabled);
|
|
checkCell.setEnabled(sensitiveCanChange, animators);
|
|
if (sensitiveCanChange) {
|
|
if (!animators.isEmpty()) {
|
|
if (animatorSet != null) {
|
|
animatorSet.cancel();
|
|
}
|
|
animatorSet = new AnimatorSet();
|
|
animatorSet.playTogether(animators);
|
|
animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
@Override
|
|
public void onAnimationEnd(Animator animator) {
|
|
if (animator.equals(animatorSet)) {
|
|
animatorSet = null;
|
|
}
|
|
}
|
|
});
|
|
animatorSet.setDuration(150);
|
|
animatorSet.start();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
} else {
|
|
AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, this, req));
|
|
}
|
|
}));
|
|
}
|
|
|
|
private void showMessageMenuAlert() {
|
|
if (getParentActivity() == null) {
|
|
return;
|
|
}
|
|
Context context = getParentActivity();
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
builder.setTitle(LocaleController.getString("MessageMenu", R.string.MessageMenu));
|
|
|
|
LinearLayout linearLayout = new LinearLayout(context);
|
|
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
LinearLayout linearLayoutInviteContainer = new LinearLayout(context);
|
|
linearLayoutInviteContainer.setOrientation(LinearLayout.VERTICAL);
|
|
linearLayout.addView(linearLayoutInviteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
|
|
|
int count = 10;
|
|
for (int a = 0; a < count; a++) {
|
|
TextCheckCell textCell = new TextCheckCell(context);
|
|
switch (a) {
|
|
case 0: {
|
|
textCell.setTextAndCheck(LocaleController.getString("DeleteDownloadedFile", R.string.DeleteDownloadedFile), NekoConfig.showDeleteDownloadedFile, false);
|
|
break;
|
|
}
|
|
case 1: {
|
|
textCell.setTextAndCheck(LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages), NekoConfig.showAddToSavedMessages, false);
|
|
break;
|
|
}
|
|
case 2: {
|
|
textCell.setTextAndCheck(LocaleController.getString("Repeat", R.string.Repeat), NekoConfig.showRepeat, false);
|
|
break;
|
|
}
|
|
case 3: {
|
|
textCell.setTextAndCheck(LocaleController.getString("Prpr", R.string.Prpr), NekoConfig.showPrPr, false);
|
|
break;
|
|
}
|
|
case 4: {
|
|
textCell.setTextAndCheck(LocaleController.getString("ViewHistory", R.string.ViewHistory), NekoConfig.showViewHistory, false);
|
|
break;
|
|
}
|
|
case 5: {
|
|
textCell.setTextAndCheck(LocaleController.getString("Translate", R.string.Translate), NekoConfig.showTranslate, false);
|
|
break;
|
|
}
|
|
case 6: {
|
|
textCell.setTextAndCheck(LocaleController.getString("ReportChat", R.string.ReportChat), NekoConfig.showReport, false);
|
|
break;
|
|
}
|
|
case 7: {
|
|
textCell.setTextAndCheck(LocaleController.getString("EditAdminRights", R.string.EditAdminRights), NekoConfig.showAdminActions, false);
|
|
break;
|
|
}
|
|
case 8: {
|
|
textCell.setTextAndCheck(LocaleController.getString("ChangePermissions", R.string.ChangePermissions), NekoConfig.showChangePermissions, false);
|
|
break;
|
|
}
|
|
case 9: {
|
|
textCell.setTextAndCheck(LocaleController.getString("MessageDetails", R.string.MessageDetails), NekoConfig.showMessageDetails, false);
|
|
break;
|
|
}
|
|
}
|
|
textCell.setTag(a);
|
|
textCell.setBackground(Theme.getSelectorDrawable(false));
|
|
linearLayoutInviteContainer.addView(textCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
|
textCell.setOnClickListener(v2 -> {
|
|
Integer tag = (Integer) v2.getTag();
|
|
switch (tag) {
|
|
case 0: {
|
|
NekoConfig.toggleShowDeleteDownloadedFile();
|
|
textCell.setChecked(NekoConfig.showDeleteDownloadedFile);
|
|
break;
|
|
}
|
|
case 1: {
|
|
NekoConfig.toggleShowAddToSavedMessages();
|
|
textCell.setChecked(NekoConfig.showAddToSavedMessages);
|
|
break;
|
|
}
|
|
case 2: {
|
|
NekoConfig.toggleShowRepeat();
|
|
textCell.setChecked(NekoConfig.showRepeat);
|
|
break;
|
|
}
|
|
case 3: {
|
|
NekoConfig.toggleShowPrPr();
|
|
textCell.setChecked(NekoConfig.showPrPr);
|
|
break;
|
|
}
|
|
case 4: {
|
|
NekoConfig.toggleShowViewHistory();
|
|
textCell.setChecked(NekoConfig.showViewHistory);
|
|
break;
|
|
}
|
|
case 5: {
|
|
NekoConfig.toggleShowTranslate();
|
|
textCell.setChecked(NekoConfig.showTranslate);
|
|
break;
|
|
}
|
|
case 6: {
|
|
NekoConfig.toggleShowReport();
|
|
textCell.setChecked(NekoConfig.showReport);
|
|
break;
|
|
}
|
|
case 7: {
|
|
NekoConfig.toggleShowAdminActions();
|
|
textCell.setChecked(NekoConfig.showAdminActions);
|
|
break;
|
|
}
|
|
case 8: {
|
|
NekoConfig.toggleShowChangePermissions();
|
|
textCell.setChecked(NekoConfig.showChangePermissions);
|
|
break;
|
|
}
|
|
case 9: {
|
|
NekoConfig.toggleShowMessageDetails();
|
|
textCell.setChecked(NekoConfig.showMessageDetails);
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
|
builder.setView(linearLayout);
|
|
showDialog(builder.create());
|
|
}
|
|
|
|
private void showStickerSizeAlert() {
|
|
if (getParentActivity() == null) {
|
|
return;
|
|
}
|
|
Context context = getParentActivity();
|
|
BottomSheet.Builder builder = new BottomSheet.Builder(context);
|
|
builder.setApplyTopPadding(false);
|
|
builder.setApplyBottomPadding(false);
|
|
|
|
LinearLayout linearLayout = new LinearLayout(context);
|
|
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
FrameLayout titleLayout = new FrameLayout(context);
|
|
linearLayout.addView(titleLayout);
|
|
|
|
HeaderCell headerCell = new HeaderCell(context, Theme.key_windowBackgroundWhiteBlueHeader, 23, 15, false);
|
|
headerCell.setHeight(47);
|
|
headerCell.setText(LocaleController.getString("StickerSize", R.string.StickerSize));
|
|
titleLayout.addView(headerCell);
|
|
|
|
ActionBarMenuItem optionsButton = new ActionBarMenuItem(context, null, 0, Theme.getColor(Theme.key_sheet_other));
|
|
optionsButton.setLongClickEnabled(false);
|
|
optionsButton.setSubMenuOpenSide(2);
|
|
optionsButton.setIcon(R.drawable.ic_ab_other);
|
|
optionsButton.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_player_actionBarSelector), 1));
|
|
optionsButton.addSubItem(1, R.drawable.msg_reset, LocaleController.getString("Reset", R.string.Reset));
|
|
optionsButton.setOnClickListener(v -> optionsButton.toggleSubMenu());
|
|
optionsButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
|
|
titleLayout.addView(optionsButton, LayoutHelper.createFrame(40, 40, Gravity.TOP | Gravity.RIGHT, 0, 8, 5, 0));
|
|
|
|
LinearLayout linearLayoutInviteContainer = new LinearLayout(context);
|
|
linearLayoutInviteContainer.setOrientation(LinearLayout.VERTICAL);
|
|
linearLayout.addView(linearLayoutInviteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
|
StickerSizeCell stickerSizeCell = new StickerSizeCell(context);
|
|
optionsButton.setDelegate(id -> {
|
|
if (id == 1) {
|
|
NekoConfig.setStickerSize(14.0f);
|
|
stickerSizeCell.invalidate();
|
|
}
|
|
});
|
|
linearLayoutInviteContainer.addView(stickerSizeCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
|
builder.setCustomView(linearLayout);
|
|
showDialog(builder.create());
|
|
}
|
|
|
|
private class StickerSizeCell extends FrameLayout {
|
|
|
|
private StickerSizePreviewMessagesCell messagesCell;
|
|
private SeekBarView sizeBar;
|
|
private int startStickerSize = 2;
|
|
private int endStickerSize = 20;
|
|
|
|
private TextPaint textPaint;
|
|
|
|
public StickerSizeCell(Context context) {
|
|
super(context);
|
|
|
|
setWillNotDraw(false);
|
|
|
|
textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
|
textPaint.setTextSize(AndroidUtilities.dp(16));
|
|
|
|
sizeBar = new SeekBarView(context);
|
|
sizeBar.setReportChanges(true);
|
|
sizeBar.setDelegate(new SeekBarView.SeekBarViewDelegate() {
|
|
@Override
|
|
public void onSeekBarDrag(boolean stop, float progress) {
|
|
NekoConfig.setStickerSize(startStickerSize + (endStickerSize - startStickerSize) * progress);
|
|
StickerSizeCell.this.invalidate();
|
|
}
|
|
|
|
@Override
|
|
public void onSeekBarPressed(boolean pressed) {
|
|
|
|
}
|
|
});
|
|
addView(sizeBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.LEFT | Gravity.TOP, 9, 5, 43, 11));
|
|
|
|
messagesCell = new StickerSizePreviewMessagesCell(context, parentLayout);
|
|
addView(messagesCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 53, 0, 0));
|
|
}
|
|
|
|
@Override
|
|
protected void onDraw(Canvas canvas) {
|
|
textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText));
|
|
canvas.drawText("" + Math.round(NekoConfig.stickerSize), getMeasuredWidth() - AndroidUtilities.dp(39), AndroidUtilities.dp(28), textPaint);
|
|
}
|
|
|
|
@Override
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
sizeBar.setProgress((NekoConfig.stickerSize - startStickerSize) / (float) (endStickerSize - startStickerSize));
|
|
}
|
|
|
|
@Override
|
|
public void invalidate() {
|
|
super.invalidate();
|
|
listAdapter.notifyItemChanged(stickerSizeRow);
|
|
messagesCell.invalidate();
|
|
sizeBar.invalidate();
|
|
}
|
|
}
|
|
|
|
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 == experiment2Row) {
|
|
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 == 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, eventTypeRow != -1);
|
|
} else if (position == mapPreviewRow) {
|
|
String value;
|
|
switch (NekoConfig.mapPreviewProvider) {
|
|
case 0:
|
|
value = LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram);
|
|
break;
|
|
case 1:
|
|
value = LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex);
|
|
break;
|
|
case 2:
|
|
default:
|
|
value = LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody);
|
|
}
|
|
textCell.setTextAndValue(LocaleController.getString("MapPreviewProvider", R.string.MapPreviewProvider), value, true);
|
|
} else if (position == eventTypeRow) {
|
|
String value;
|
|
switch (NekoConfig.eventType) {
|
|
case 1:
|
|
value = LocaleController.getString("Christmas", R.string.Christmas);
|
|
break;
|
|
case 2:
|
|
value = LocaleController.getString("Valentine", R.string.Valentine);
|
|
break;
|
|
case 0:
|
|
default:
|
|
value = LocaleController.getString("DependsOnDate", R.string.DependsOnDate);
|
|
}
|
|
textCell.setTextAndValue(LocaleController.getString("EventType", R.string.EventType), value, true);
|
|
} else if (position == actionBarDecorationRow) {
|
|
String value;
|
|
switch (NekoConfig.actionBarDecoration) {
|
|
case 1:
|
|
value = LocaleController.getString("Snowflakes", R.string.Snowflakes);
|
|
break;
|
|
case 2:
|
|
value = LocaleController.getString("Fireworks", R.string.Fireworks);
|
|
break;
|
|
case 0:
|
|
default:
|
|
value = LocaleController.getString("DependsOnDate", R.string.DependsOnDate);
|
|
}
|
|
textCell.setTextAndValue(LocaleController.getString("ActionBarDecoration", R.string.ActionBarDecoration), value, false);
|
|
} else if (position == stickerSizeRow) {
|
|
textCell.setTextAndValue(LocaleController.getString("StickerSize", R.string.StickerSize), String.valueOf(Math.round(NekoConfig.stickerSize)), true);
|
|
} else if (position == messageMenuRow) {
|
|
textCell.setText(LocaleController.getString("MessageMenu", R.string.MessageMenu), true);
|
|
} else if (position == deleteAccountRow) {
|
|
textCell.setText(LocaleController.getString("DeleteAccount", R.string.DeleteAccount), false);
|
|
textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
|
|
} else if (position == translationProviderRow) {
|
|
String value;
|
|
switch (NekoConfig.translationProvider) {
|
|
case 1:
|
|
value = LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate);
|
|
break;
|
|
case -1:
|
|
value = LocaleController.getString("ProviderGoogleTranslateWeb", R.string.ProviderGoogleTranslateWeb);
|
|
break;
|
|
case 2:
|
|
value = LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN);
|
|
break;
|
|
case -2:
|
|
value = LocaleController.getString("ProviderGoogleTranslateCNWeb", R.string.ProviderGoogleTranslateCNWeb);
|
|
break;
|
|
case -3:
|
|
value = LocaleController.getString("ProviderBaiduFanyiWeb", R.string.ProviderBaiduFanyiWeb);
|
|
break;
|
|
case -4:
|
|
value = LocaleController.getString("ProviderDeepLWeb", R.string.ProviderDeepLWeb);
|
|
break;
|
|
case 3:
|
|
default:
|
|
value = LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud);
|
|
break;
|
|
}
|
|
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;
|
|
}
|
|
case 3: {
|
|
TextCheckCell textCell = (TextCheckCell) holder.itemView;
|
|
textCell.setEnabled(true, null);
|
|
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 == transparentStatusBarRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("TransparentStatusBar", R.string.TransparentStatusBar), NekoConfig.transparentStatusBar, true);
|
|
} else if (position == hideProxySponsorChannelRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("HideProxySponsorChannel", R.string.HideProxySponsorChannel), NekoConfig.hideProxySponsorChannel, true);
|
|
} else if (position == saveCacheToPrivateDirectoryRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("SaveCacheToPrivateDirectory", R.string.SaveCacheToPrivateDirectory), NekoConfig.saveCacheToPrivateDirectory, true);
|
|
} else if (position == useSystemEmojiRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("EmojiUseDefault", R.string.EmojiUseDefault), NekoConfig.useSystemEmoji, true);
|
|
} else if (position == typefaceRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("TypefaceUseDefault", R.string.TypefaceUseDefault), NekoConfig.typeface == 1, true);
|
|
} else if (position == ignoreBlockedRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("IgnoreBlocked", R.string.IgnoreBlocked), NekoConfig.ignoreBlocked, true);
|
|
} else if (position == forceTabletRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("ForceTabletMode", R.string.ForceTabletMode), NekoConfig.forceTablet, true);
|
|
} else if (position == newYearRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("ChristmasHat", R.string.ChristmasHat), NekoConfig.newYear, true);
|
|
} else if (position == disableFilteringRow) {
|
|
textCell.setTextAndValueAndCheck(LocaleController.getString("SensitiveDisableFiltering", R.string.SensitiveDisableFiltering), LocaleController.getString("SensitiveAbout", R.string.SensitiveAbout), sensitiveEnabled, true, true);
|
|
textCell.setEnabled(sensitiveCanChange, null);
|
|
} else if (position == unlimitedFavedStickersRow) {
|
|
textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedFavoredStickers", R.string.UnlimitedFavoredStickers), LocaleController.getString("UnlimitedFavoredStickersAbout", R.string.UnlimitedFavoredStickersAbout), NekoConfig.unlimitedFavedStickers, true, true);
|
|
} else if (position == pauseMusicOnRecordRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnablePauseMusic", R.string.DebugMenuEnablePauseMusic), SharedConfig.pauseMusicOnRecord, true);
|
|
} else if (position == smoothKeyboardRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard), SharedConfig.smoothKeyboard, true);
|
|
} else if (position == disablePhotoSideActionRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("DisablePhotoViewerSideAction", R.string.DisablePhotoViewerSideAction), NekoConfig.disablePhotoSideAction, true);
|
|
} else if (position == unlimitedPinnedDialogsRow) {
|
|
textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedPinnedDialogs", R.string.UnlimitedPinnedDialogs), LocaleController.getString("UnlimitedPinnedDialogsAbout", R.string.UnlimitedPinnedDialogsAbout), NekoConfig.unlimitedPinnedDialogs, true, deleteAccountRow != -1);
|
|
} else if (position == openArchiveOnPullRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("OpenArchiveOnPull", R.string.OpenArchiveOnPull), NekoConfig.openArchiveOnPull, true);
|
|
} else if (position == hideKeyboardOnChatScrollRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("HideKeyboardOnChatScroll", R.string.HideKeyboardOnChatScroll), NekoConfig.hideKeyboardOnChatScroll, true);
|
|
} else if (position == avatarAsDrawerBackgroundRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("UseAvatarAsDrawerBackground", R.string.UseAvatarAsDrawerBackground), NekoConfig.avatarAsDrawerBackground, true);
|
|
} else if (position == showTabsOnForwardRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("ShowTabsOnForward", R.string.ShowTabsOnForward), NekoConfig.showTabsOnForward, true);
|
|
} else if (position == chatMessageAnimationRow) {
|
|
textCell.setTextAndCheck(LocaleController.getString("ChatMessageAnimation", R.string.ChatMessageAnimation), NekoConfig.chatMessageAnimation, true);
|
|
} else if (position == rearVideoMessagesRow) {
|
|
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);
|
|
}
|
|
break;
|
|
}
|
|
case 4: {
|
|
HeaderCell headerCell = (HeaderCell) holder.itemView;
|
|
if (position == settingsRow) {
|
|
headerCell.setText(LocaleController.getString("General", R.string.General));
|
|
} else if (position == connectionRow) {
|
|
headerCell.setText(LocaleController.getString("Connection", R.string.Connection));
|
|
} else if (position == chatRow) {
|
|
headerCell.setText(LocaleController.getString("Chat", R.string.Chat));
|
|
} else if (position == experimentRow) {
|
|
headerCell.setText(LocaleController.getString("Experiment", R.string.Experiment));
|
|
}
|
|
break;
|
|
}
|
|
case 7: {
|
|
TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
|
|
if (position == needRestartRow) {
|
|
cell.setText(LocaleController.getString("SomeItemsNeedRestart", R.string.SomeItemsNeedRestart));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
|
int position = holder.getAdapterPosition();
|
|
return position == hidePhoneRow || position == inappCameraRow || position == ignoreBlockedRow ||
|
|
position == useSystemEmojiRow || position == ipv6Row || position == typefaceRow || position == nameOrderRow ||
|
|
position == forceTabletRow || position == mapPreviewRow || position == newYearRow ||
|
|
position == actionBarDecorationRow || position == eventTypeRow || position == transparentStatusBarRow ||
|
|
position == hideProxySponsorChannelRow || position == saveCacheToPrivateDirectoryRow ||
|
|
position == disableFilteringRow || position == stickerSizeRow ||
|
|
position == unlimitedFavedStickersRow || position == messageMenuRow || position == deleteAccountRow ||
|
|
position == translationProviderRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow ||
|
|
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow ||
|
|
position == experimentRow || position == hideKeyboardOnChatScrollRow || position == avatarAsDrawerBackgroundRow ||
|
|
position == showTabsOnForwardRow || position == chatMessageAnimationRow || position == rearVideoMessagesRow ||
|
|
position == hideAllTabRow || position == tabsTitleTypeRow;
|
|
}
|
|
|
|
@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 == 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 == tabsTitleTypeRow) {
|
|
return 2;
|
|
} else if (position == ipv6Row || position == hidePhoneRow || position == inappCameraRow ||
|
|
position == transparentStatusBarRow || position == hideProxySponsorChannelRow ||
|
|
position == ignoreBlockedRow || position == useSystemEmojiRow || position == typefaceRow ||
|
|
position == forceTabletRow || position == newYearRow ||
|
|
position == saveCacheToPrivateDirectoryRow || position == unlimitedFavedStickersRow ||
|
|
position == disableFilteringRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow ||
|
|
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow ||
|
|
position == hideKeyboardOnChatScrollRow || position == avatarAsDrawerBackgroundRow || position == showTabsOnForwardRow ||
|
|
position == chatMessageAnimationRow || position == rearVideoMessagesRow || position == hideAllTabRow) {
|
|
return 3;
|
|
} else if (position == settingsRow || position == connectionRow || position == chatRow || position == experimentRow) {
|
|
return 4;
|
|
} else if (position == needRestartRow) {
|
|
return 7;
|
|
}
|
|
return 6;
|
|
}
|
|
}
|
|
}
|