Re-organize neko settings

This commit is contained in:
NekoInverter 2020-05-28 15:29:33 +08:00
parent a972f3f5e0
commit 76cb9ac206
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
17 changed files with 2198 additions and 1336 deletions

View File

@ -1535,7 +1535,7 @@ public class AndroidUtilities {
public static boolean isTablet() {
if (NekoConfig.forceTablet) {
isTablet = true;
return true;
} else if (isTablet == null) {
isTablet = ApplicationLoader.applicationContext.getResources().getBoolean(R.bool.isTablet);
}

View File

@ -36,6 +36,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import tw.nekomimi.nekogram.NekoConfig;
public class ContactsController extends BaseController {
private Account systemAccount;
@ -2586,7 +2588,7 @@ public class ContactsController extends BaseController {
lastName = lastName.trim();
}
StringBuilder result = new StringBuilder((firstName != null ? firstName.length() : 0) + (lastName != null ? lastName.length() : 0) + 1);
if (LocaleController.nameDisplayOrder == 1) {
if (NekoConfig.nameOrder == 1) {
if (firstName != null && firstName.length() > 0) {
result.append(firstName);
if (lastName != null && lastName.length() > 0) {

View File

@ -206,7 +206,7 @@ import org.telegram.ui.Components.voip.VoIPHelper;
import tw.nekomimi.nekogram.MessageDetailsActivity;
import tw.nekomimi.nekogram.MessageHelper;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoSettingsActivity;
import tw.nekomimi.nekogram.settings.NekoGeneralSettingsActivity;
import tw.nekomimi.nekogram.translator.Translator;
import tw.nekomimi.nekogram.translator.TranslateBottomSheet;
@ -3298,10 +3298,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatListView.setAdapter(chatAdapter = new ChatActivityAdapter(context));
chatListView.setClipToPadding(false);
chatListView.setPadding(0, AndroidUtilities.dp(4), 0, AndroidUtilities.dp(3));
if (!NekoConfig.chatMessageAnimation) {
chatListView.setItemAnimator(null);
chatListView.setLayoutAnimation(null);
}
chatListView.setItemAnimator(null);
chatListView.setLayoutAnimation(null);
chatLayoutManager = new GridLayoutManagerFixed(context, 1000, LinearLayoutManager.VERTICAL, true) {
@Override
@ -15331,7 +15329,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void onError() {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("TranslateFailed", R.string.TranslateFailed));
builder.setNeutralButton(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), (dialog, which) -> showDialog(NekoSettingsActivity.getTranslationProviderAlert(getParentActivity())));
builder.setNeutralButton(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), (dialog, which) -> showDialog(NekoGeneralSettingsActivity.getTranslationProviderAlert(getParentActivity())));
builder.setPositiveButton(LocaleController.getString("Retry", R.string.Retry), (dialog, which) -> processSelectedOption(option));
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
@ -15341,7 +15339,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void onUnsupported() {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("TranslateApiUnsupported", R.string.TranslateApiUnsupported));
builder.setPositiveButton(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), (dialog, which) -> showDialog(NekoSettingsActivity.getTranslationProviderAlert(getParentActivity())));
builder.setPositiveButton(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), (dialog, which) -> showDialog(NekoGeneralSettingsActivity.getTranslationProviderAlert(getParentActivity())));
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
}

View File

@ -87,6 +87,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import tw.nekomimi.nekogram.NekoConfig;
public class GroupCreateActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, View.OnClickListener {
private ScrollView scrollView;
@ -1128,7 +1130,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
firstName = chat.title;
lastName = "";
}
if (LocaleController.nameDisplayOrder == 1) {
if (NekoConfig.nameOrder == 1) {
if (!TextUtils.isEmpty(firstName)) {
return firstName.substring(0, 1).toUpperCase();
} else if (!TextUtils.isEmpty(lastName)) {

View File

@ -118,7 +118,7 @@ import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import tw.nekomimi.nekogram.NekoSettingsActivity;
import tw.nekomimi.nekogram.settings.NekoSettingsActivity;
public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate {

View File

@ -128,7 +128,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoSettingsActivity;
import tw.nekomimi.nekogram.settings.NekoSettingsActivity;
public class SettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ImageUpdater.ImageUpdaterDelegate {

View File

@ -11,7 +11,6 @@ import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.Toast;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
@ -41,6 +40,7 @@ import org.telegram.ui.Cells.TextDetailSettingsCell;
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 org.telegram.ui.ProfileActivity;
import java.io.File;
@ -78,6 +78,8 @@ public class MessageDetailsActivity extends BaseFragment {
private int exportRow;
private int endRow;
private UndoView copyTooltip;
public MessageDetailsActivity(MessageObject messageObject) {
this.messageObject = messageObject;
if (messageObject.messageOwner.to_id != null && messageObject.messageOwner.to_id.channel_id != 0) {
@ -158,23 +160,15 @@ public class MessageDetailsActivity extends BaseFragment {
listView = new RecyclerListView(context);
listView.setVerticalScrollBarEnabled(false);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) {
@Override
public boolean supportsPredictiveItemAnimations() {
return false;
}
});
listView.setGlowColor(Theme.getColor(Theme.key_avatar_backgroundActionBarBlue));
listView.setAdapter(listAdapter);
listView.setItemAnimator(null);
listView.setLayoutAnimation(null);
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 == exportRow) {
Gson gson = new Gson();
try {
AndroidUtilities.addToClipboard(gson.toJson(messageObject.messageOwner));
Toast.makeText(getParentActivity(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show();
copyTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
} catch (Exception e) {
FileLog.e(e);
}
@ -182,7 +176,7 @@ public class MessageDetailsActivity extends BaseFragment {
TextDetailSettingsCell textCell = (TextDetailSettingsCell) view;
try {
AndroidUtilities.addToClipboard(textCell.getValueTextView().getText());
Toast.makeText(getParentActivity(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show();
copyTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
} catch (Exception e) {
FileLog.e(e);
}
@ -225,6 +219,11 @@ public class MessageDetailsActivity extends BaseFragment {
}
return true;
});
copyTooltip = new UndoView(context);
copyTooltip.setInfoText(LocaleController.getString("TextCopied", R.string.TextCopied));
frameLayout.addView(copyTooltip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
return fragmentView;
}
@ -325,6 +324,11 @@ public class MessageDetailsActivity extends BaseFragment {
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
case 1: {
if (position == endRow) {
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: {
@ -364,13 +368,13 @@ public class MessageDetailsActivity extends BaseFragment {
}
textCell.setTextWithEmojiAnd21Value("From", builder.toString(), divider);
} else if (position == botRow) {
textCell.setTextWithEmojiAnd21Value("Bot", "Yes", divider);
textCell.setTextAndValue("Bot", "Yes", divider);
} else if (position == dateRow) {
long date = (long) messageObject.messageOwner.date * 1000;
textCell.setTextWithEmojiAnd21Value("Date", LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))), divider);
textCell.setTextAndValue("Date", LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))), divider);
} else if (position == editedRow) {
long date = (long) messageObject.messageOwner.date * 1000;
textCell.setTextWithEmojiAnd21Value("Edited", LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))), divider);
textCell.setTextAndValue("Edited", LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))), divider);
} else if (position == forwardRow) {
StringBuilder builder = new StringBuilder();
if (messageObject.messageOwner.fwd_from.channel_id != 0) {
@ -398,16 +402,16 @@ public class MessageDetailsActivity extends BaseFragment {
}
textCell.setTextWithEmojiAnd21Value("Forward from", builder.toString(), divider);
} else if (position == fileNameRow) {
textCell.setTextWithEmojiAnd21Value("File name", fileName, divider);
textCell.setTextAndValue("File name", fileName, divider);
} else if (position == filePathRow) {
textCell.setTextWithEmojiAnd21Value("File path", filePath, divider);
textCell.setTextAndValue("File path", filePath, divider);
} else if (position == fileSizeRow) {
textCell.setTextWithEmojiAnd21Value("File size", AndroidUtilities.formatFileSize(messageObject.getSize()), divider);
textCell.setTextAndValue("File size", AndroidUtilities.formatFileSize(messageObject.getSize()), divider);
} else if (position == dcRow) {
if (messageObject.messageOwner.media.photo != null && messageObject.messageOwner.media.photo.dc_id > 0) {
textCell.setTextWithEmojiAnd21Value("DC", String.valueOf(messageObject.messageOwner.media.photo.dc_id), divider);
textCell.setTextAndValue("DC", String.valueOf(messageObject.messageOwner.media.photo.dc_id), divider);
} else if (messageObject.messageOwner.media.document != null && messageObject.messageOwner.media.document.dc_id > 0) {
textCell.setTextWithEmojiAnd21Value("DC", String.valueOf(messageObject.messageOwner.media.document.dc_id), divider);
textCell.setTextAndValue("DC", String.valueOf(messageObject.messageOwner.media.document.dc_id), divider);
}
}
break;

View File

@ -16,6 +16,7 @@ import org.telegram.ui.Cells.ChatMessageCell;
import java.util.ArrayList;
import tw.nekomimi.nekogram.settings.NekoGeneralSettingsActivity;
import tw.nekomimi.nekogram.translator.TranslateBottomSheet;
import tw.nekomimi.nekogram.translator.Translator;
@ -72,7 +73,7 @@ public class MessageHelper extends BaseController {
}
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(LocaleController.getString("TranslateFailed", R.string.TranslateFailed));
builder.setNeutralButton(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), (dialog, which) -> NekoSettingsActivity.getTranslationProviderAlert(context).show());
builder.setNeutralButton(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), (dialog, which) -> NekoGeneralSettingsActivity.getTranslationProviderAlert(context).show());
builder.setPositiveButton(LocaleController.getString("Retry", R.string.Retry), (dialog, which) -> showTranslateDialog(context, query));
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.show();
@ -85,7 +86,7 @@ public class MessageHelper extends BaseController {
}
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(LocaleController.getString("TranslateApiUnsupported", R.string.TranslateApiUnsupported));
builder.setPositiveButton(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), (dialog, which) -> NekoSettingsActivity.getTranslationProviderAlert(context).show());
builder.setPositiveButton(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), (dialog, which) -> NekoGeneralSettingsActivity.getTranslationProviderAlert(context).show());
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.show();
}

View File

@ -29,7 +29,6 @@ public class NekoConfig {
public static boolean saveCacheToPrivateDirectory = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
public static boolean disablePhotoSideAction = true;
public static boolean hideKeyboardOnChatScroll = false;
public static boolean chatMessageAnimation = false;
public static boolean rearVideoMessages = false;
public static boolean hideAllTab = false;
public static boolean confirmAVMessage = true;
@ -108,7 +107,6 @@ public class NekoConfig {
editor.putBoolean("avatarAsDrawerBackground", avatarAsDrawerBackground);
editor.putBoolean("useSystemEmoji", useSystemEmoji);
editor.putBoolean("showTabsOnForward", showTabsOnForward);
editor.putBoolean("chatMessageAnimation", chatMessageAnimation);
editor.putBoolean("rearVideoMessages", rearVideoMessages);
editor.putBoolean("hideAllTab", hideAllTab);
editor.putBoolean("confirmAVMessage", confirmAVMessage);
@ -172,7 +170,6 @@ public class NekoConfig {
avatarAsDrawerBackground = preferences.getBoolean("avatarAsDrawerBackground", false);
useSystemEmoji = preferences.getBoolean("useSystemEmoji", SharedConfig.useSystemEmoji);
showTabsOnForward = preferences.getBoolean("showTabsOnForward", false);
chatMessageAnimation = preferences.getBoolean("chatMessageAnimation", false);
rearVideoMessages = preferences.getBoolean("rearVideoMessages", false);
hideAllTab = preferences.getBoolean("hideAllTab", false);
tabsTitleType = preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT);
@ -467,14 +464,6 @@ public class NekoConfig {
editor.commit();
}
public static void toggleChatMessageAnimation() {
chatMessageAnimation = !chatMessageAnimation;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("chatMessageAnimation", chatMessageAnimation);
editor.commit();
}
public static void toggleRearVideoMessages() {
rearVideoMessages = !rearVideoMessages;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);

View File

@ -0,0 +1,653 @@
package tw.nekomimi.nekogram.settings;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.TextPaint;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
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.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.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.SeekBarView;
import java.util.ArrayList;
import tw.nekomimi.nekogram.NekoConfig;
@SuppressLint("RtlHardcoded")
public class NekoChatSettingsActivity extends BaseFragment {
private RecyclerListView listView;
private ListAdapter listAdapter;
private ActionBarMenuItem menuItem;
private StickerSizeCell stickerSizeCell;
private int rowCount;
private int stickerSizeHeaderRow;
private int stickerSizeRow;
private int stickerSize2Row;
private int chatRow;
private int ignoreBlockedRow;
private int disablePhotoSideActionRow;
private int hideKeyboardOnChatScrollRow;
private int rearVideoMessagesRow;
private int confirmAVRow;
private int mapPreviewRow;
private int messageMenuRow;
private int chat2Row;
private int foldersRow;
private int showTabsOnForwardRow;
private int hideAllTabRow;
private int tabsTitleTypeRow;
private int folders2Row;
@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("Chat", R.string.Chat));
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
}
ActionBarMenu menu = actionBar.createMenu();
menuItem = menu.addItem(0, R.drawable.ic_ab_other);
menuItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
menuItem.addSubItem(1, R.drawable.msg_reset, LocaleController.getString("ResetStickerSize", R.string.ResetStickerSize));
menuItem.setVisibility(NekoConfig.stickerSize != 14.0f ? View.VISIBLE : View.GONE);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == 1) {
NekoConfig.setStickerSize(14.0f);
menuItem.setVisibility(View.GONE);
stickerSizeCell.invalidate();
}
}
});
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 == ignoreBlockedRow) {
NekoConfig.toggleIgnoreBlocked();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.ignoreBlocked);
}
} 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 == messageMenuRow) {
showMessageMenuAlert();
} else if (position == disablePhotoSideActionRow) {
NekoConfig.toggleDisablePhotoSideAction();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.disablePhotoSideAction);
}
} else if (position == hideKeyboardOnChatScrollRow) {
NekoConfig.toggleHideKeyboardOnChatScroll();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.hideKeyboardOnChatScroll);
}
} else if (position == showTabsOnForwardRow) {
NekoConfig.toggleShowTabsOnForward();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.showTabsOnForward);
}
} 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());
} else if (position == confirmAVRow) {
NekoConfig.toggleConfirmAVMessage();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.confirmAVMessage);
}
}
});
return fragmentView;
}
@Override
public void onResume() {
super.onResume();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
private void updateRows() {
rowCount = 0;
stickerSizeHeaderRow = rowCount++;
stickerSizeRow = rowCount++;
stickerSize2Row = rowCount++;
chatRow = rowCount++;
ignoreBlockedRow = rowCount++;
disablePhotoSideActionRow = rowCount++;
hideKeyboardOnChatScrollRow = rowCount++;
rearVideoMessagesRow = rowCount++;
confirmAVRow = rowCount++;
mapPreviewRow = rowCount++;
messageMenuRow = rowCount++;
chat2Row = rowCount++;
foldersRow = rowCount++;
showTabsOnForwardRow = rowCount++;
hideAllTabRow = rowCount++;
tabsTitleTypeRow = rowCount++;
folders2Row = 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 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 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();
menuItem.setVisibility(View.VISIBLE);
}
@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();
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 == folders2Row) {
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 == 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 == 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), false);
} 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 == ignoreBlockedRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("IgnoreBlocked", R.string.IgnoreBlocked), LocaleController.getString("IgnoreBlockedAbout", R.string.IgnoreBlockedAbout), NekoConfig.ignoreBlocked, true, true);
} else if (position == disablePhotoSideActionRow) {
textCell.setTextAndCheck(LocaleController.getString("DisablePhotoViewerSideAction", R.string.DisablePhotoViewerSideAction), NekoConfig.disablePhotoSideAction, true);
} else if (position == hideKeyboardOnChatScrollRow) {
textCell.setTextAndCheck(LocaleController.getString("HideKeyboardOnChatScroll", R.string.HideKeyboardOnChatScroll), NekoConfig.hideKeyboardOnChatScroll, true);
} else if (position == showTabsOnForwardRow) {
textCell.setTextAndCheck(LocaleController.getString("ShowTabsOnForward", R.string.ShowTabsOnForward), NekoConfig.showTabsOnForward, 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);
} else if (position == confirmAVRow) {
textCell.setTextAndCheck(LocaleController.getString("ConfirmAVMessage", R.string.ConfirmAVMessage), NekoConfig.confirmAVMessage, true);
}
break;
}
case 4: {
HeaderCell headerCell = (HeaderCell) holder.itemView;
if (position == chatRow) {
headerCell.setText(LocaleController.getString("Chat", R.string.Chat));
} else if (position == foldersRow) {
headerCell.setText(LocaleController.getString("Folder", R.string.Folder));
} else if (position == stickerSizeHeaderRow) {
headerCell.setText(LocaleController.getString("StickerSize", R.string.StickerSize));
}
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;
case 8:
view = stickerSizeCell = new StickerSizeCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
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 == chat2Row || position == folders2Row || position == stickerSize2Row) {
return 1;
} else if (position == mapPreviewRow || position == messageMenuRow || position == tabsTitleTypeRow) {
return 2;
} else if (position == ignoreBlockedRow || position == disablePhotoSideActionRow || position == hideKeyboardOnChatScrollRow ||
position == showTabsOnForwardRow || position == rearVideoMessagesRow || position == hideAllTabRow || position == confirmAVRow) {
return 3;
} else if (position == chatRow || position == foldersRow || position == stickerSizeHeaderRow) {
return 4;
} else if (position == stickerSizeRow) {
return 8;
}
return 2;
}
}
}

View File

@ -0,0 +1,513 @@
package tw.nekomimi.nekogram.settings;
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.os.Build;
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.BuildConfig;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
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.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.UndoView;
import java.util.ArrayList;
import tw.nekomimi.nekogram.MessageHelper;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.translator.Translator;
@SuppressLint("RtlHardcoded")
public class NekoExperimentalSettingsActivity extends BaseFragment {
private RecyclerListView listView;
private ListAdapter listAdapter;
private AnimatorSet animatorSet;
private boolean sensitiveCanChange = false;
private boolean sensitiveEnabled = false;
private int rowCount;
private int experimentRow;
private int smoothKeyboardRow;
private int saveCacheToPrivateDirectoryRow;
private int disableFilteringRow;
private int unlimitedFavedStickersRow;
private int unlimitedPinnedDialogsRow;
private int deleteAccountRow;
private int experiment2Row;
private int shouldNOTTrustMeRow;
private UndoView restartTooltip;
static public AlertDialog getTranslationProviderAlert(Context context) {
ArrayList<String> arrayList = new ArrayList<>();
ArrayList<Integer> types = new ArrayList<>();
arrayList.add(LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate));
types.add(Translator.PROVIDER_GOOGLE);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN));
types.add(Translator.PROVIDER_GOOGLE_CN);
arrayList.add(LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud));
types.add(Translator.PROVIDER_LINGO);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateWeb", R.string.ProviderGoogleTranslateWeb));
types.add(Translator.PROVIDER_GOOGLE_WEB);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCNWeb", R.string.ProviderGoogleTranslateCNWeb));
types.add(Translator.PROVIDER_GOOGLE_CN_WEB);
arrayList.add(LocaleController.getString("ProviderBaiduFanyiWeb", R.string.ProviderBaiduFanyiWeb));
types.add(Translator.PROVIDER_BAIDU_WEB);
arrayList.add(LocaleController.getString("ProviderDeepLWeb", R.string.ProviderDeepLWeb));
types.add(Translator.PROVIDER_DEEPL_WEB);
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));
builder.getDismissRunnable().run();
});
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
return builder.create();
}
@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("Experiment", R.string.Experiment));
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 == saveCacheToPrivateDirectoryRow) {
NekoConfig.toggleSaveCacheToPrivateDirectory();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.saveCacheToPrivateDirectory);
}
restartTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
} 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 == unlimitedFavedStickersRow) {
NekoConfig.toggleUnlimitedFavedStickers();
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) {
((TextCheckCell) view).setChecked(SharedConfig.smoothKeyboard);
}
if (SharedConfig.smoothKeyboard && getParentActivity() != null) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
} else if (position == unlimitedPinnedDialogsRow) {
NekoConfig.toggleUnlimitedPinnedDialogs();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.unlimitedPinnedDialogs);
}
} else if (position == shouldNOTTrustMeRow) {
NekoConfig.toggleShouldNOTTrustMe();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.shouldNOTTrustMe);
}
}
});
restartTooltip = new UndoView(context);
restartTooltip.setInfoText(LocaleController.formatString("RestartAppToTakeEffect", R.string.RestartAppToTakeEffect));
frameLayout.addView(restartTooltip, 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) {
checkSensitive();
listAdapter.notifyDataSetChanged();
}
}
private void updateRows() {
rowCount = 0;
experimentRow = rowCount++;
smoothKeyboardRow = !AndroidUtilities.isTablet() ? rowCount++ : -1;
saveCacheToPrivateDirectoryRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? rowCount++ : -1;
disableFilteringRow = rowCount++;
unlimitedFavedStickersRow = rowCount++;
unlimitedPinnedDialogsRow = rowCount++;
deleteAccountRow = NekoConfig.showHiddenFeature ? rowCount++ : -1;
experiment2Row = rowCount++;
shouldNOTTrustMeRow = BuildConfig.DEBUG ? rowCount++ : -1;
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 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 == 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 == saveCacheToPrivateDirectoryRow) {
textCell.setTextAndCheck(LocaleController.getString("SaveCacheToPrivateDirectory", R.string.SaveCacheToPrivateDirectory), NekoConfig.saveCacheToPrivateDirectory, 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 == 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);
} else if (position == shouldNOTTrustMeRow) {
textCell.setTextAndCheck("Don't trust me", NekoConfig.shouldNOTTrustMe, false);
}
break;
}
case 4: {
HeaderCell headerCell = (HeaderCell) holder.itemView;
if (position == experimentRow) {
headerCell.setText(LocaleController.getString("Experiment", R.string.Experiment));
}
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 == experiment2Row) {
return 1;
} else if (position == deleteAccountRow) {
return 2;
} else if (position == saveCacheToPrivateDirectoryRow || position == unlimitedFavedStickersRow || position == disableFilteringRow ||
position == smoothKeyboardRow || position == unlimitedPinnedDialogsRow || position == shouldNOTTrustMeRow) {
return 3;
} else if (position == experimentRow) {
return 4;
}
return 2;
}
}
}

View File

@ -0,0 +1,640 @@
package tw.nekomimi.nekogram.settings;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
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.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.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.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.UndoView;
import java.util.ArrayList;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.translator.Translator;
@SuppressLint("RtlHardcoded")
public class NekoGeneralSettingsActivity extends BaseFragment {
private RecyclerListView listView;
private ListAdapter listAdapter;
private int rowCount;
private int connectionRow;
private int ipv6Row;
private int connection2Row;
private int appearanceRow;
private int typefaceRow;
private int useSystemEmojiRow;
private int transparentStatusBarRow;
private int forceTabletRow;
private int avatarAsDrawerBackgroundRow;
private int eventTypeRow;
private int newYearRow;
private int actionBarDecorationRow;
private int appearance2Row;
private int generalRow;
private int hidePhoneRow;
private int inappCameraRow;
private int hideProxySponsorChannelRow;
private int askBeforeCallRow;
private int disableNumberRoundingRow;
private int openArchiveOnPullRow;
private int translationProviderRow;
private int nameOrderRow;
private int general2Row;
private UndoView restartTooltip;
static public AlertDialog getTranslationProviderAlert(Context context) {
ArrayList<String> arrayList = new ArrayList<>();
ArrayList<Integer> types = new ArrayList<>();
arrayList.add(LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate));
types.add(Translator.PROVIDER_GOOGLE);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN));
types.add(Translator.PROVIDER_GOOGLE_CN);
arrayList.add(LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud));
types.add(Translator.PROVIDER_LINGO);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateWeb", R.string.ProviderGoogleTranslateWeb));
types.add(Translator.PROVIDER_GOOGLE_WEB);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCNWeb", R.string.ProviderGoogleTranslateCNWeb));
types.add(Translator.PROVIDER_GOOGLE_CN_WEB);
arrayList.add(LocaleController.getString("ProviderBaiduFanyiWeb", R.string.ProviderBaiduFanyiWeb));
types.add(Translator.PROVIDER_BAIDU_WEB);
arrayList.add(LocaleController.getString("ProviderDeepLWeb", R.string.ProviderDeepLWeb));
types.add(Translator.PROVIDER_DEEPL_WEB);
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));
builder.getDismissRunnable().run();
});
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
return builder.create();
}
@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("General", R.string.General));
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);
}
restartTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
} 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).checkPromoInfo(true);
}
}
} 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);
}
parentLayout.rebuildAllFragmentViews(true, true);
} 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();
parentLayout.rebuildAllFragmentViews(false, false);
});
}
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();
restartTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
});
}
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();
restartTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
});
}
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);
}
restartTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
} else if (position == translationProviderRow) {
AlertDialog dialog = getTranslationProviderAlert(context);
dialog.setOnDismissListener(dialog1 -> listAdapter.notifyItemChanged(translationProviderRow));
showDialog(dialog);
} else if (position == openArchiveOnPullRow) {
NekoConfig.toggleOpenArchiveOnPull();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.openArchiveOnPull);
}
} else if (position == avatarAsDrawerBackgroundRow) {
NekoConfig.toggleAvatarAsDrawerBackground();
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.avatarAsDrawerBackground);
}
} else if (position == askBeforeCallRow) {
NekoConfig.toggleAskBeforeCall();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.askBeforeCall);
}
} else if (position == disableNumberRoundingRow) {
NekoConfig.toggleDisableNumberRounding();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.disableNumberRounding);
}
}
});
restartTooltip = new UndoView(context);
restartTooltip.setInfoText(LocaleController.formatString("RestartAppToTakeEffect", R.string.RestartAppToTakeEffect));
frameLayout.addView(restartTooltip, 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;
connectionRow = rowCount++;
ipv6Row = rowCount++;
connection2Row = rowCount++;
appearanceRow = rowCount++;
typefaceRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? rowCount++ : -1;
useSystemEmojiRow = rowCount++;
transparentStatusBarRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? rowCount++ : -1;
forceTabletRow = rowCount++;
avatarAsDrawerBackgroundRow = rowCount++;
eventTypeRow = NekoConfig.showHiddenFeature ? rowCount++ : -1;
newYearRow = NekoConfig.showHiddenFeature ? rowCount++ : -1;
actionBarDecorationRow = NekoConfig.showHiddenFeature ? rowCount++ : -1;
appearance2Row = rowCount++;
generalRow = rowCount++;
hidePhoneRow = rowCount++;
inappCameraRow = rowCount++;
hideProxySponsorChannelRow = rowCount++;
askBeforeCallRow = rowCount++;
disableNumberRoundingRow = rowCount++;
openArchiveOnPullRow = rowCount++;
translationProviderRow = rowCount++;
nameOrderRow = rowCount++;
general2Row = 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 == general2Row) {
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, false);
} 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 == translationProviderRow) {
String value;
switch (NekoConfig.translationProvider) {
case Translator.PROVIDER_GOOGLE:
value = LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate);
break;
case Translator.PROVIDER_GOOGLE_WEB:
value = LocaleController.getString("ProviderGoogleTranslateWeb", R.string.ProviderGoogleTranslateWeb);
break;
case Translator.PROVIDER_GOOGLE_CN:
value = LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN);
break;
case Translator.PROVIDER_GOOGLE_CN_WEB:
value = LocaleController.getString("ProviderGoogleTranslateCNWeb", R.string.ProviderGoogleTranslateCNWeb);
break;
case Translator.PROVIDER_BAIDU_WEB:
value = LocaleController.getString("ProviderBaiduFanyiWeb", R.string.ProviderBaiduFanyiWeb);
break;
case Translator.PROVIDER_DEEPL_WEB:
value = LocaleController.getString("ProviderDeepLWeb", R.string.ProviderDeepLWeb);
break;
case Translator.PROVIDER_LINGO:
default:
value = LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud);
break;
}
textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, true);
}
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 == 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 == 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 == openArchiveOnPullRow) {
textCell.setTextAndCheck(LocaleController.getString("OpenArchiveOnPull", R.string.OpenArchiveOnPull), NekoConfig.openArchiveOnPull, true);
} else if (position == avatarAsDrawerBackgroundRow) {
textCell.setTextAndCheck(LocaleController.getString("UseAvatarAsDrawerBackground", R.string.UseAvatarAsDrawerBackground), NekoConfig.avatarAsDrawerBackground, eventTypeRow != -1);
} else if (position == askBeforeCallRow) {
textCell.setTextAndCheck(LocaleController.getString("AskBeforeCalling", R.string.AskBeforeCalling), NekoConfig.askBeforeCall, true);
} else if (position == disableNumberRoundingRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("DisableNumberRounding", R.string.DisableNumberRounding), "4.8K -> 4777", NekoConfig.disableNumberRounding, true, true);
}
break;
}
case 4: {
HeaderCell headerCell = (HeaderCell) holder.itemView;
if (position == generalRow) {
headerCell.setText(LocaleController.getString("General", R.string.General));
} else if (position == connectionRow) {
headerCell.setText(LocaleController.getString("Connection", R.string.Connection));
} else if (position == appearanceRow) {
headerCell.setText(LocaleController.getString("Appearance", R.string.Appearance));
}
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 == connection2Row || position == appearance2Row || position == general2Row) {
return 1;
} else if (position == nameOrderRow || position == translationProviderRow || position == eventTypeRow || position == actionBarDecorationRow) {
return 2;
} else if (position == ipv6Row || position == hidePhoneRow || position == inappCameraRow || position == transparentStatusBarRow ||
position == hideProxySponsorChannelRow || position == useSystemEmojiRow || position == typefaceRow || position == forceTabletRow ||
position == newYearRow || position == openArchiveOnPullRow || position == avatarAsDrawerBackgroundRow || position == askBeforeCallRow ||
position == disableNumberRoundingRow) {
return 3;
} else if (position == generalRow || position == connectionRow || position == appearanceRow) {
return 4;
}
return 2;
}
}
}

View File

@ -0,0 +1,325 @@
package tw.nekomimi.nekogram.settings;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.browser.Browser;
import org.telegram.ui.ActionBar.ActionBar;
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.TextCell;
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 java.util.ArrayList;
import tw.nekomimi.nekogram.NekoConfig;
@SuppressLint("RtlHardcoded")
public class NekoSettingsActivity extends BaseFragment {
private RecyclerListView listView;
private ListAdapter listAdapter;
private int rowCount;
private int categoriesRow;
private int generalRow;
private int chatRow;
private int experimentRow;
private int categories2Row;
private int aboutRow;
private int channelRow;
private int googlePlayRow;
private int sourceCodeRow;
private int translationRow;
private int donateRow;
private int about2Row;
@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 == chatRow) {
presentFragment(new NekoChatSettingsActivity());
} else if (position == generalRow) {
presentFragment(new NekoGeneralSettingsActivity());
} else if (position == experimentRow) {
presentFragment(new NekoExperimentalSettingsActivity());
} else if (position == channelRow) {
MessagesController.getInstance(currentAccount).openByUserName(LocaleController.getString("OfficialChannelUsername", R.string.OfficialChannelUsername), this, 1);
} else if (position == donateRow) {
Browser.openUrl(getParentActivity(), "https://nekogram.github.io/donation.html");
} else if (position == translationRow) {
Browser.openUrl(getParentActivity(), "https://neko.crowdin.com/nekogram");
} else if (position == googlePlayRow) {
Browser.openUrl(getParentActivity(), "https://play.google.com/store/apps/details?id=tw.nekomimi.nekogram");
} else if (position == sourceCodeRow) {
Browser.openUrl(getParentActivity(), "https://github.com/Nekogram/Nekogram");
}
});
listView.setOnItemLongClickListener((view, position) -> {
if (position == experimentRow) {
NekoConfig.toggleShowHiddenFeature();
listView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
return true;
}
return false;
});
return fragmentView;
}
@Override
public void onResume() {
super.onResume();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
private void updateRows() {
rowCount = 0;
categoriesRow = rowCount++;
generalRow = rowCount++;
chatRow = rowCount++;
experimentRow = rowCount++;
categories2Row = rowCount++;
aboutRow = rowCount++;
channelRow = rowCount++;
googlePlayRow = -1;
sourceCodeRow = rowCount++;
translationRow = rowCount++;
donateRow = rowCount++;
about2Row = 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 == about2Row) {
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: {
TextCell textCell = (TextCell) holder.itemView;
if (position == chatRow) {
textCell.setTextAndIcon(LocaleController.getString("Chat", R.string.Chat), R.drawable.menu_chats, true);
} else if (position == generalRow) {
textCell.setTextAndIcon(LocaleController.getString("General", R.string.General), R.drawable.msg_theme, true);
} else if (position == experimentRow) {
textCell.setTextAndIcon(LocaleController.getString("Experiment", R.string.Experiment), R.drawable.msg_fave, false);
}
break;
}
case 3: {
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
if (position == channelRow) {
textCell.setTextAndValue(LocaleController.getString("OfficialChannel", R.string.OfficialChannel), "@" + LocaleController.getString("OfficialChannelUsername", R.string.OfficialChannelUsername), true);
} else if (position == googlePlayRow) {
textCell.setText(LocaleController.getString("GooglePlay", R.string.GooglePlay), true);
} else if (position == sourceCodeRow) {
textCell.setText(LocaleController.getString("SourceCode", R.string.SourceCode), true);
}
break;
}
case 4: {
HeaderCell headerCell = (HeaderCell) holder.itemView;
if (position == categoriesRow) {
headerCell.setText(LocaleController.getString("Categories", R.string.Categories));
} else if (position == aboutRow) {
headerCell.setText(LocaleController.getString("About", R.string.About));
}
break;
}
case 6: {
TextDetailSettingsCell textCell = (TextDetailSettingsCell) holder.itemView;
if (position == translationRow) {
textCell.setTextAndValue(LocaleController.getString("Translation", R.string.Translation), LocaleController.getString("TranslationAbout", R.string.TranslationAbout), true);
} else if (position == donateRow) {
textCell.setTextAndValue(LocaleController.getString("Donate", R.string.Donate), LocaleController.getString("DonateAbout", R.string.DonateAbout), false);
}
break;
}
}
}
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
int type = holder.getItemViewType();
return type == 2 || type == 3 || type == 6;
}
@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 TextCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 3:
view = new TextSettingsCell(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 == categories2Row || position == about2Row) {
return 1;
} else if (position == chatRow || position == generalRow || position == experimentRow) {
return 2;
} else if (position == googlePlayRow || position == channelRow || position == sourceCodeRow) {
return 3;
} else if (position == categoriesRow || position == aboutRow) {
return 4;
} else if (position == translationRow || position == donateRow) {
return 6;
}
return 2;
}
}
}

View File

@ -1,4 +1,4 @@
package tw.nekomimi.nekogram;
package tw.nekomimi.nekogram.settings;
import android.annotation.SuppressLint;
import android.content.Context;
@ -25,6 +25,8 @@ import org.telegram.ui.Cells.ChatMessageCell;
import org.telegram.ui.Components.BackgroundGradientDrawable;
import org.telegram.ui.Components.LayoutHelper;
import tw.nekomimi.nekogram.NekoConfig;
@SuppressLint("ViewConstructor")
public class StickerSizePreviewMessagesCell extends LinearLayout {

View File

@ -17,29 +17,28 @@
<string name="IgnoreBlocked">Ignore blocked users in group</string>
<string name="Connection">Connection</string>
<string name="Chat">Chat</string>
<string name="NameOrder">Name order*</string>
<string name="NameOrder">Name order</string>
<string name="FirstLast">First Last</string>
<string name="LastFirst">Last First</string>
<string name="TypefaceUseDefault">Use system default font*</string>
<string name="TypefaceUseDefault">Use system default font</string>
<string name="NoQuoteForward">NoQuote forward</string>
<string name="Repeat">Repeat</string>
<string name="AddToSavedMessages">Save message</string>
<string name="CreateMention">Create Mention</string>
<string name="ForceTabletMode">Force tablet mode*</string>
<string name="ForceTabletMode">Force tablet mode</string>
<string name="Prpr">Peropero</string>
<string name="TransparentStatusBar">Transparent status bar</string>
<string name="EnableResidentNotification">Show a resident notification</string>
<string name="DisableResidentNotification">Disable resident notification</string>
<string name="NekogramRunning">Nekogram is running</string>
<string name="EventType">Sidebar icon set*</string>
<string name="ChristmasHat">Show christmas hat everyday*</string>
<string name="ActionBarDecoration">Title bar decoration*</string>
<string name="EventType">Sidebar icon set</string>
<string name="ChristmasHat">Show christmas hat everyday</string>
<string name="ActionBarDecoration">Title bar decoration</string>
<string name="DependsOnDate">Depends on date</string>
<string name="Christmas">Christmas</string>
<string name="Valentine">Valentine\'s day</string>
<string name="Snowflakes">Snowflakes</string>
<string name="Fireworks">Fireworks</string>
<string name="SomeItemsNeedRestart">Options with * may need restart to take effect.</string>
<string name="DeleteDownloadedFile">Delete downloaded file</string>
<string name="TestBackend">Test Backend</string>
<string name="TestBackendOn">This account will connect to the test backend.</string>
@ -47,7 +46,7 @@
<string name="HideProxySponsorChannel">Hide proxy sponsor channel</string>
<string name="ViewHistory">View history</string>
<string name="Nya">Meow!</string>
<string name="SaveCacheToPrivateDirectory">Save cache to private directory*</string>
<string name="SaveCacheToPrivateDirectory">Save cache to private directory</string>
<string name="SensitiveDisableFiltering">Disable sensitive content filtering</string>
<string name="SensitiveAbout">Display sensitive media in public channels on all your devices.</string>
<string name="StickerSize">Sticker size</string>
@ -102,4 +101,18 @@
<string name="CallTo">Call to **%1$s**?</string>
<string name="SetAsCurrent">Set as current</string>
<string name="DisableNumberRounding">Disable number rounding</string>
<string name="Categories">Categories</string>
<string name="OfficialChannel">Official channel</string>
<string name="About">About</string>
<string name="IgnoreBlockedAbout">You\'ll no longer see messages from blocked users in groups.</string>
<string name="Donate">Donate</string>
<string name="DonateAbout">Support our development.</string>
<string name="TranslationAbout">Help us to translate Nekogram to your language.</string>
<string name="Translation">Translate Nekogram</string>
<string name="GooglePlay">Google Play</string>
<string name="SourceCode">Source code on Github</string>
<string name="ResetStickerSize">Reset sticker size</string>
<string name="OfficialChannelUsername">nekoupdates</string>
<string name="RestartAppToTakeEffect">Restart the app to take effect.</string>
<string name="Restart">RESTART</string>
</resources>

View File

@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0-rc01'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.google.gms:google-services:4.3.3'
}
}