2020-05-28 09:29:33 +02:00
|
|
|
package tw.nekomimi.nekogram.settings;
|
|
|
|
|
2021-01-12 03:37:29 +01:00
|
|
|
import android.animation.ValueAnimator;
|
2020-05-28 09:29:33 +02:00
|
|
|
import android.annotation.SuppressLint;
|
2020-07-19 09:44:11 +02:00
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.PendingIntent;
|
2020-05-28 09:29:33 +02:00
|
|
|
import android.content.Context;
|
2020-07-19 09:44:11 +02:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.IntentSender;
|
|
|
|
import android.content.pm.ResolveInfo;
|
2022-03-15 10:22:27 +01:00
|
|
|
import android.graphics.Canvas;
|
|
|
|
import android.graphics.Paint;
|
|
|
|
import android.text.TextPaint;
|
2021-01-12 03:37:29 +01:00
|
|
|
import android.transition.TransitionManager;
|
2020-07-19 09:44:11 +02:00
|
|
|
import android.util.Log;
|
2020-05-28 09:29:33 +02:00
|
|
|
import android.view.Gravity;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2020-06-25 17:25:38 +02:00
|
|
|
import android.widget.EditText;
|
2020-05-28 09:29:33 +02:00
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
2021-01-12 03:37:29 +01:00
|
|
|
import androidx.recyclerview.widget.DefaultItemAnimator;
|
2020-05-28 09:29:33 +02:00
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
2020-07-19 09:44:11 +02:00
|
|
|
import org.openintents.openpgp.OpenPgpError;
|
|
|
|
import org.openintents.openpgp.util.OpenPgpApi;
|
2020-05-28 09:29:33 +02:00
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
2020-06-25 17:25:38 +02:00
|
|
|
import org.telegram.messenger.ContactsController;
|
2020-05-28 09:29:33 +02:00
|
|
|
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;
|
2020-05-30 12:36:45 +02:00
|
|
|
import org.telegram.ui.ActionBar.ActionBarLayout;
|
2020-05-28 09:29:33 +02:00
|
|
|
import org.telegram.ui.ActionBar.AlertDialog;
|
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
|
|
|
import org.telegram.ui.ActionBar.ThemeDescription;
|
|
|
|
import org.telegram.ui.Cells.EmptyCell;
|
|
|
|
import org.telegram.ui.Cells.HeaderCell;
|
|
|
|
import org.telegram.ui.Cells.NotificationsCheckCell;
|
|
|
|
import org.telegram.ui.Cells.ShadowSectionCell;
|
|
|
|
import org.telegram.ui.Cells.TextCheckCell;
|
|
|
|
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
|
|
|
import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
|
|
|
import org.telegram.ui.Cells.TextSettingsCell;
|
|
|
|
import org.telegram.ui.Components.LayoutHelper;
|
|
|
|
import org.telegram.ui.Components.RecyclerListView;
|
2022-03-15 10:22:27 +01:00
|
|
|
import org.telegram.ui.Components.SeekBarView;
|
2020-05-28 09:29:33 +02:00
|
|
|
import org.telegram.ui.Components.UndoView;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2020-07-19 09:44:11 +02:00
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
2020-05-28 09:29:33 +02:00
|
|
|
|
2020-06-25 17:25:38 +02:00
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import kotlin.Unit;
|
2022-01-17 08:45:37 +01:00
|
|
|
import tw.nekomimi.nekogram.ui.BottomBuilder;
|
2022-01-16 07:58:45 +01:00
|
|
|
import tw.nekomimi.nekogram.NekoXConfig;
|
2022-01-17 08:45:37 +01:00
|
|
|
import tw.nekomimi.nekogram.ui.PopupBuilder;
|
2020-06-25 17:25:38 +02:00
|
|
|
import tw.nekomimi.nekogram.transtale.Translator;
|
|
|
|
import tw.nekomimi.nekogram.transtale.TranslatorKt;
|
2020-07-19 09:44:11 +02:00
|
|
|
import tw.nekomimi.nekogram.utils.AlertUtil;
|
|
|
|
import tw.nekomimi.nekogram.utils.PGPUtil;
|
2020-05-28 09:29:33 +02:00
|
|
|
|
2022-01-17 08:45:37 +01:00
|
|
|
import tw.nekomimi.nekogram.config.ConfigItem;
|
|
|
|
import tw.nekomimi.nekogram.NekoConfig;
|
|
|
|
import tw.nekomimi.nekogram.config.CellGroup;
|
|
|
|
import tw.nekomimi.nekogram.config.cell.AbstractConfigCell;
|
|
|
|
import tw.nekomimi.nekogram.config.cell.*;
|
2021-10-29 07:52:52 +02:00
|
|
|
|
2020-05-28 09:29:33 +02:00
|
|
|
@SuppressLint("RtlHardcoded")
|
|
|
|
public class NekoGeneralSettingsActivity extends BaseFragment {
|
|
|
|
|
|
|
|
private RecyclerListView listView;
|
|
|
|
private ListAdapter listAdapter;
|
2021-01-12 03:37:29 +01:00
|
|
|
private ValueAnimator statusBarColorAnimator;
|
|
|
|
private DrawerProfilePreviewCell profilePreviewCell;
|
2020-05-28 09:29:33 +02:00
|
|
|
|
2021-11-10 18:24:03 +01:00
|
|
|
private final CellGroup cellGroup = new CellGroup(this);
|
|
|
|
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell profilePreviewRow = cellGroup.appendCell(new ConfigCellDrawerProfilePreview());
|
|
|
|
private final AbstractConfigCell largeAvatarInDrawerRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.largeAvatarInDrawer, LocaleController.getString("valuesLargeAvatarInDrawer"), null));
|
|
|
|
private final AbstractConfigCell avatarBackgroundBlurRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.avatarBackgroundBlur));
|
|
|
|
private final AbstractConfigCell avatarBackgroundDarkenRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.avatarBackgroundDarken));
|
|
|
|
private final AbstractConfigCell hidePhoneRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hidePhone));
|
|
|
|
private final AbstractConfigCell divider0 = cellGroup.appendCell(new ConfigCellDivider());
|
|
|
|
|
|
|
|
private final AbstractConfigCell header1 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Connection")));
|
|
|
|
private final AbstractConfigCell useIPv6Row = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useIPv6));
|
|
|
|
private final AbstractConfigCell useProxyItemRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useProxyItem));
|
|
|
|
private final AbstractConfigCell hideProxyByDefaultRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideProxyByDefault));
|
|
|
|
private final AbstractConfigCell autoUpdateSubInfoRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.autoUpdateSubInfo));
|
|
|
|
private final AbstractConfigCell useSystemDNSRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useSystemDNS));
|
|
|
|
private final AbstractConfigCell customDoHRow = cellGroup.appendCell(new ConfigCellTextInput(null, NekoConfig.customDoH, "https://1.0.0.1/dns-query", null));
|
|
|
|
private final AbstractConfigCell customPublicProxyIPRow = cellGroup.appendCell(new ConfigCellTextDetail(NekoConfig.customPublicProxyIP, (view, position) -> {
|
|
|
|
customDialog_BottomInputString(position, NekoConfig.customPublicProxyIP, LocaleController.getString("customPublicProxyIPNotice"), "IP");
|
2021-10-31 16:45:24 +01:00
|
|
|
}, LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty)));
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell divider1 = cellGroup.appendCell(new ConfigCellDivider());
|
|
|
|
|
|
|
|
private final AbstractConfigCell header2 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Translate")));
|
|
|
|
private final AbstractConfigCell translationProviderRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
|
|
|
private final AbstractConfigCell translateToLangRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
|
|
|
private final AbstractConfigCell translateInputToLangRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
|
|
|
private final AbstractConfigCell googleCloudTranslateKeyRow = cellGroup.appendCell(new ConfigCellTextDetail(NekoConfig.googleCloudTranslateKey, (view, position) -> {
|
|
|
|
customDialog_BottomInputString(position, NekoConfig.googleCloudTranslateKey, LocaleController.getString("GoogleCloudTransKeyNotice"), "Key");
|
2021-10-30 05:25:05 +02:00
|
|
|
}, LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty)));
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell divider2 = cellGroup.appendCell(new ConfigCellDivider());
|
2021-10-29 07:52:52 +02:00
|
|
|
|
2022-07-12 17:55:25 +02:00
|
|
|
private final AbstractConfigCell headerFolder = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Folder")));
|
|
|
|
private final AbstractConfigCell showTabsOnForwardRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.showTabsOnForward));
|
|
|
|
private final AbstractConfigCell hideAllTabRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideAllTab, LocaleController.getString("HideAllTabAbout")));
|
|
|
|
private final AbstractConfigCell openArchiveOnPullRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.openArchiveOnPull));
|
|
|
|
private final AbstractConfigCell ignoreMutedCountRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.ignoreMutedCount));
|
|
|
|
private final AbstractConfigCell tabsTitleTypeRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.tabsTitleType,
|
|
|
|
new String[]{
|
|
|
|
LocaleController.getString("TabTitleTypeText", R.string.TabTitleTypeText),
|
|
|
|
LocaleController.getString("TabTitleTypeIcon", R.string.TabTitleTypeIcon),
|
|
|
|
LocaleController.getString("TabTitleTypeMix", R.string.TabTitleTypeMix)
|
|
|
|
}, null));
|
|
|
|
private final AbstractConfigCell dividerFolder = cellGroup.appendCell(new ConfigCellDivider());
|
|
|
|
|
2022-01-20 16:07:24 +01:00
|
|
|
private final AbstractConfigCell header_notification = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("NekoGeneralNotification")));
|
|
|
|
private final AbstractConfigCell disableNotificationBubblesRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableNotificationBubbles));
|
|
|
|
private final AbstractConfigCell divider_notification = cellGroup.appendCell(new ConfigCellDivider());
|
|
|
|
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell header3 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("OpenKayChain")));
|
|
|
|
private final AbstractConfigCell pgpAppRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
|
|
|
private final AbstractConfigCell keyRow = cellGroup.appendCell(new ConfigCellTextDetail(NekoConfig.openPGPKeyId, (view, position) -> {
|
2021-10-29 07:52:52 +02:00
|
|
|
requestKey(new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID));
|
2021-10-30 05:25:05 +02:00
|
|
|
}, "0"));
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell divider3 = cellGroup.appendCell(new ConfigCellDivider());
|
2021-10-29 07:52:52 +02:00
|
|
|
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell header4 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("DialogsSettings")));
|
|
|
|
private final AbstractConfigCell sortMenuRow = cellGroup.appendCell(new ConfigCellSelectBox(LocaleController.getString("SortMenu"), null, null, () -> {
|
2021-10-29 07:52:52 +02:00
|
|
|
showSortMenuAlert();
|
|
|
|
}));
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell divider4 = cellGroup.appendCell(new ConfigCellDivider());
|
|
|
|
|
|
|
|
private final AbstractConfigCell header5 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Appearance")));
|
|
|
|
private final AbstractConfigCell typefaceRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.typeface));
|
|
|
|
private final AbstractConfigCell transparentStatusBarRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.transparentStatusBar));
|
|
|
|
private final AbstractConfigCell appBarShadowRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableAppBarShadow));
|
|
|
|
private final AbstractConfigCell newYearRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.newYear));
|
|
|
|
private final AbstractConfigCell actionBarDecorationRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.actionBarDecoration, new String[]{
|
2021-10-29 07:52:52 +02:00
|
|
|
LocaleController.getString("DependsOnDate", R.string.DependsOnDate),
|
|
|
|
LocaleController.getString("Snowflakes", R.string.Snowflakes),
|
|
|
|
LocaleController.getString("Fireworks", R.string.Fireworks)
|
|
|
|
}, null));
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell tabletModeRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.tabletMode, new String[]{
|
2021-10-29 07:52:52 +02:00
|
|
|
LocaleController.getString("TabletModeDefault", R.string.TabletModeDefault),
|
|
|
|
LocaleController.getString("Enable", R.string.Enable),
|
|
|
|
LocaleController.getString("Disable", R.string.Disable)
|
|
|
|
}, null));
|
2022-03-15 10:22:27 +01:00
|
|
|
|
|
|
|
private final AbstractConfigCell forceBlurInChatRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.forceBlurInChat));
|
|
|
|
private final AbstractConfigCell header_chatblur = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("ChatBlurAlphaValue")));
|
|
|
|
private final AbstractConfigCell chatBlurAlphaValueRow = cellGroup.appendCell(new ConfigCellCustom(ConfigCellCustom.CUSTOM_ITEM_CharBlurAlpha, NekoConfig.forceBlurInChat.Bool()));
|
|
|
|
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell divider5 = cellGroup.appendCell(new ConfigCellDivider());
|
|
|
|
|
|
|
|
private final AbstractConfigCell header6 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("PrivacyTitle")));
|
|
|
|
private final AbstractConfigCell disableSystemAccountRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableSystemAccount));
|
|
|
|
private final AbstractConfigCell divider6 = cellGroup.appendCell(new ConfigCellDivider());
|
|
|
|
|
|
|
|
private final AbstractConfigCell header7 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("General")));
|
2022-01-21 10:17:27 +01:00
|
|
|
private final AbstractConfigCell customSavePathRow = cellGroup.appendCell(new ConfigCellTextInput(null, NekoConfig.customSavePath,
|
|
|
|
LocaleController.getString("customSavePathHint", R.string.customSavePathHint), null,
|
|
|
|
(input) -> input.matches("^[A-za-z0-9.]{1,255}$") || input.isEmpty() ? input : (String) NekoConfig.customSavePath.defaultValue));
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell disableUndoRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableUndo));
|
|
|
|
private final AbstractConfigCell showIdAndDcRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.showIdAndDc));
|
|
|
|
private final AbstractConfigCell inappCameraRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.inappCamera));
|
|
|
|
private final AbstractConfigCell hideProxySponsorChannelRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideProxySponsorChannel));
|
|
|
|
private final AbstractConfigCell hideSponsoredMessageRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideSponsoredMessage));
|
|
|
|
private final AbstractConfigCell autoPauseVideoRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.autoPauseVideo, LocaleController.getString("AutoPauseVideoAbout")));
|
|
|
|
private final AbstractConfigCell disableNumberRoundingRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableNumberRounding, "4.8K -> 4777"));
|
|
|
|
private final AbstractConfigCell nameOrderRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.nameOrder, new String[]{
|
2021-11-01 03:51:37 +01:00
|
|
|
LocaleController.getString("LastFirst", R.string.LastFirst),
|
|
|
|
LocaleController.getString("FirstLast", R.string.FirstLast)
|
2021-10-29 07:52:52 +02:00
|
|
|
}, null));
|
2022-01-17 08:45:37 +01:00
|
|
|
private final AbstractConfigCell usePersianCalendarRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.usePersianCalendar, LocaleController.getString("UsePersiancalendarInfo")));
|
|
|
|
private final AbstractConfigCell displayPersianCalendarByLatinRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.displayPersianCalendarByLatin));
|
|
|
|
private final AbstractConfigCell divider7 = cellGroup.appendCell(new ConfigCellDivider());
|
2021-10-29 07:52:52 +02:00
|
|
|
|
2022-07-12 17:55:25 +02:00
|
|
|
private final AbstractConfigCell headerAutoDownload = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("AutoDownload")));
|
|
|
|
private final AbstractConfigCell win32Row = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableAutoDownloadingWin32Executable));
|
|
|
|
private final AbstractConfigCell archiveRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableAutoDownloadingArchive));
|
|
|
|
private final AbstractConfigCell dividerAutoDownload = cellGroup.appendCell(new ConfigCellDivider());
|
|
|
|
|
2022-03-15 10:22:27 +01:00
|
|
|
private ChatBlurAlphaSeekBar chatBlurAlphaSeekbar;
|
2020-05-28 09:29:33 +02:00
|
|
|
private UndoView restartTooltip;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onFragmentCreate() {
|
|
|
|
super.onFragmentCreate();
|
|
|
|
|
2021-01-12 03:37:29 +01:00
|
|
|
updateRows(true);
|
2020-05-28 09:29:33 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2021-11-03 08:01:01 +01:00
|
|
|
// Before listAdapter
|
|
|
|
setCanNotChange();
|
|
|
|
|
2020-05-28 09:29:33 +02:00
|
|
|
listView = new RecyclerListView(context);
|
|
|
|
listView.setVerticalScrollBarEnabled(false);
|
|
|
|
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
|
2021-01-12 03:37:29 +01:00
|
|
|
if (listView.getItemAnimator() != null) {
|
|
|
|
((DefaultItemAnimator) listView.getItemAnimator()).setSupportsChangeAnimations(false);
|
|
|
|
}
|
2020-05-28 09:29:33 +02:00
|
|
|
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
|
|
|
|
listView.setAdapter(listAdapter);
|
2021-10-29 07:52:52 +02:00
|
|
|
|
|
|
|
// Fragment: Set OnClick Callbacks
|
2020-05-28 09:29:33 +02:00
|
|
|
listView.setOnItemClickListener((view, position, x, y) -> {
|
2022-01-17 08:45:37 +01:00
|
|
|
AbstractConfigCell a = cellGroup.rows.get(position);
|
|
|
|
if (a instanceof ConfigCellTextCheck) {
|
|
|
|
((ConfigCellTextCheck) a).onClick((TextCheckCell) view);
|
|
|
|
} else if (a instanceof ConfigCellSelectBox) {
|
|
|
|
((ConfigCellSelectBox) a).onClick(view);
|
|
|
|
} else if (a instanceof ConfigCellTextInput) {
|
|
|
|
((ConfigCellTextInput) a).onClick();
|
|
|
|
} else if (a instanceof ConfigCellTextDetail) {
|
|
|
|
RecyclerListView.OnItemClickListener o = ((ConfigCellTextDetail) a).onItemClickListener;
|
2021-10-29 07:52:52 +02:00
|
|
|
if (o != null) {
|
|
|
|
try {
|
|
|
|
o.onItemClick(view, position);
|
|
|
|
} catch (Exception e) {
|
2020-05-28 09:29:33 +02:00
|
|
|
}
|
|
|
|
}
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (a instanceof ConfigCellCustom) { // Custom OnClick
|
2021-11-10 18:24:03 +01:00
|
|
|
if (position == cellGroup.rows.indexOf(pgpAppRow)) {
|
2021-10-29 07:52:52 +02:00
|
|
|
PopupBuilder builder = new PopupBuilder(view);
|
2021-01-11 12:22:07 +01:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
builder.addSubItem(0, LocaleController.getString("None", R.string.None));
|
2021-01-11 12:22:07 +01:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
LinkedList<String> appsMap = new LinkedList<>();
|
|
|
|
appsMap.add("");
|
2021-01-11 12:22:07 +01:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT_2);
|
|
|
|
List<ResolveInfo> resInfo = getParentActivity().getPackageManager().queryIntentServices(intent, 0);
|
2021-01-11 12:22:07 +01:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
if (resInfo != null) {
|
|
|
|
for (ResolveInfo resolveInfo : resInfo) {
|
|
|
|
if (resolveInfo.serviceInfo == null) {
|
|
|
|
continue;
|
|
|
|
}
|
2021-01-11 12:22:07 +01:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
String packageName = resolveInfo.serviceInfo.packageName;
|
|
|
|
String simpleName = String.valueOf(resolveInfo.serviceInfo.loadLabel(getParentActivity().getPackageManager()));
|
2021-01-11 12:22:07 +01:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
builder.addSubItem(appsMap.size(), simpleName);
|
|
|
|
appsMap.add(packageName);
|
2021-01-11 12:22:07 +01:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
}
|
|
|
|
}
|
2020-06-25 17:25:38 +02:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
builder.setDelegate((i) -> {
|
2022-01-17 08:45:37 +01:00
|
|
|
NekoConfig.openPGPApp.setConfigString(appsMap.get(i));
|
|
|
|
NekoConfig.openPGPKeyId.setConfigLong(0L);
|
2021-11-10 18:24:03 +01:00
|
|
|
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(pgpAppRow));
|
|
|
|
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(keyRow));
|
2020-06-25 17:25:38 +02:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
if (i > 0) PGPUtil.recreateConnection();
|
|
|
|
});
|
2020-06-25 17:25:38 +02:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
builder.show();
|
2021-11-10 18:24:03 +01:00
|
|
|
} else if (position == cellGroup.rows.indexOf(translationProviderRow)) {
|
2021-10-29 07:52:52 +02:00
|
|
|
PopupBuilder builder = new PopupBuilder(view);
|
2020-06-25 17:25:38 +02:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
builder.setItems(new String[]{
|
|
|
|
LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate),
|
|
|
|
LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN),
|
|
|
|
LocaleController.getString("ProviderYandexTranslate", R.string.ProviderYandexTranslate),
|
|
|
|
LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud),
|
|
|
|
LocaleController.getString("ProviderMicrosoftTranslator", R.string.ProviderMicrosoftTranslator),
|
|
|
|
LocaleController.getString("ProviderMicrosoftTranslator", R.string.ProviderYouDao),
|
|
|
|
LocaleController.getString("ProviderMicrosoftTranslator", R.string.ProviderDeepLTranslate)
|
|
|
|
}, (i, __) -> {
|
2022-01-17 08:45:37 +01:00
|
|
|
boolean needReset = NekoConfig.translationProvider.Int() - 1 != i && (NekoConfig.translationProvider.Int() == 1 || i == 0);
|
|
|
|
NekoConfig.translationProvider.setConfigInt(i + 1);
|
2021-10-29 07:52:52 +02:00
|
|
|
if (needReset) {
|
|
|
|
updateRows(true);
|
|
|
|
} else {
|
|
|
|
listAdapter.notifyItemChanged(position);
|
|
|
|
}
|
|
|
|
return Unit.INSTANCE;
|
|
|
|
});
|
|
|
|
builder.show();
|
2021-11-10 18:24:03 +01:00
|
|
|
} else if (position == cellGroup.rows.indexOf(translateToLangRow) || position == cellGroup.rows.indexOf(translateInputToLangRow)) {
|
|
|
|
Translator.showTargetLangSelect(view, position == cellGroup.rows.indexOf(translateInputToLangRow), (locale) -> {
|
|
|
|
if (position == cellGroup.rows.indexOf(translateToLangRow)) {
|
2022-01-17 08:45:37 +01:00
|
|
|
NekoConfig.translateToLang.setConfigString(TranslatorKt.getLocale2code(locale));
|
2021-10-29 07:52:52 +02:00
|
|
|
} else {
|
2022-01-17 08:45:37 +01:00
|
|
|
NekoConfig.translateInputLang.setConfigString(TranslatorKt.getLocale2code(locale));
|
2021-10-29 07:52:52 +02:00
|
|
|
}
|
|
|
|
listAdapter.notifyItemChanged(position);
|
|
|
|
return Unit.INSTANCE;
|
|
|
|
});
|
2021-11-10 18:24:03 +01:00
|
|
|
} else if (position == cellGroup.rows.indexOf(nameOrderRow)) {
|
2021-10-30 08:05:57 +02:00
|
|
|
LocaleController.getInstance().recreateFormatters();
|
2021-10-29 07:52:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-06-25 17:25:38 +02:00
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
// Cells: Set OnSettingChanged Callbacks
|
2021-11-10 18:24:03 +01:00
|
|
|
cellGroup.callBackSettingsChanged = (key, newValue) -> {
|
2022-01-17 08:45:37 +01:00
|
|
|
if (key.equals(NekoConfig.useIPv6.getKey())) {
|
2021-10-29 07:52:52 +02:00
|
|
|
for (int a : SharedConfig.activeAccounts) {
|
|
|
|
if (UserConfig.getInstance(a).isClientActivated()) {
|
|
|
|
ConnectionsManager.native_setIpStrategy(a, ConnectionsManager.getIpStrategy());
|
2020-06-25 17:25:38 +02:00
|
|
|
}
|
|
|
|
}
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.inappCamera.getKey())) {
|
2021-11-12 05:38:06 +01:00
|
|
|
SharedConfig.setInappCamera((boolean) newValue);
|
2021-11-18 15:59:41 +01:00
|
|
|
restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.hidePhone.getKey())) {
|
2021-10-29 07:52:52 +02:00
|
|
|
parentLayout.rebuildAllFragmentViews(false, false);
|
|
|
|
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
|
2021-11-10 18:24:03 +01:00
|
|
|
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(profilePreviewRow));
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.transparentStatusBar.getKey())) {
|
2021-11-12 05:38:06 +01:00
|
|
|
restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.hideProxySponsorChannel.getKey())) {
|
2021-10-29 07:52:52 +02:00
|
|
|
for (int a : SharedConfig.activeAccounts) {
|
|
|
|
if (UserConfig.getInstance(a).isClientActivated()) {
|
|
|
|
MessagesController.getInstance(a).checkPromoInfo(true);
|
|
|
|
}
|
2020-05-28 09:29:33 +02:00
|
|
|
}
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.actionBarDecoration.getKey())) {
|
2021-10-29 07:52:52 +02:00
|
|
|
restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.tabletMode.getKey())) {
|
2021-10-29 07:52:52 +02:00
|
|
|
restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.newYear.getKey())) {
|
2021-10-29 07:52:52 +02:00
|
|
|
restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.usePersianCalendar.getKey())) {
|
2021-11-05 15:12:07 +01:00
|
|
|
restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.displayPersianCalendarByLatin.getKey())) {
|
2021-11-05 15:12:07 +01:00
|
|
|
restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.disableSystemAccount.getKey())) {
|
2021-11-12 05:38:06 +01:00
|
|
|
if ((boolean) newValue) {
|
2020-06-25 17:25:38 +02:00
|
|
|
getContactsController().deleteUnknownAppAccounts();
|
|
|
|
} else {
|
2021-03-12 13:37:39 +01:00
|
|
|
for (int a : SharedConfig.activeAccounts) {
|
2020-06-25 17:25:38 +02:00
|
|
|
ContactsController.getInstance(a).checkAppAccount();
|
|
|
|
}
|
|
|
|
}
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.largeAvatarInDrawer.getKey())) {
|
2021-01-12 03:37:29 +01:00
|
|
|
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
|
|
|
|
TransitionManager.beginDelayedTransition(profilePreviewCell);
|
2021-11-03 08:01:01 +01:00
|
|
|
setCanNotChange();
|
|
|
|
listAdapter.notifyDataSetChanged();
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.avatarBackgroundBlur.getKey())) {
|
2021-01-12 03:37:29 +01:00
|
|
|
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
|
2021-11-10 18:24:03 +01:00
|
|
|
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(profilePreviewRow));
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.avatarBackgroundDarken.getKey())) {
|
2021-01-12 03:37:29 +01:00
|
|
|
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
|
2021-11-10 18:24:03 +01:00
|
|
|
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(profilePreviewRow));
|
2022-01-17 08:45:37 +01:00
|
|
|
} else if (key.equals(NekoConfig.disableAppBarShadow.getKey())) {
|
2021-10-29 07:52:52 +02:00
|
|
|
ActionBarLayout.headerShadowDrawable = (boolean) newValue ? null : parentLayout.getResources().getDrawable(R.drawable.header_shadow).mutate();
|
2020-05-30 12:36:45 +02:00
|
|
|
parentLayout.rebuildAllFragmentViews(true, true);
|
2022-03-15 10:22:27 +01:00
|
|
|
} else if (NekoConfig.forceBlurInChat.getKey().equals(key)) {
|
|
|
|
boolean enabled = (Boolean) newValue;
|
|
|
|
if (chatBlurAlphaSeekbar != null)
|
|
|
|
chatBlurAlphaSeekbar.setEnabled(enabled);
|
|
|
|
((ConfigCellCustom) chatBlurAlphaValueRow).enabled = enabled;
|
2020-05-28 09:29:33 +02:00
|
|
|
}
|
2021-10-29 07:52:52 +02:00
|
|
|
};
|
2020-05-28 09:29:33 +02:00
|
|
|
|
2021-10-30 04:29:17 +02:00
|
|
|
//Cells: Set ListAdapter
|
2021-11-10 18:24:03 +01:00
|
|
|
cellGroup.setListAdapter(listView, listAdapter);
|
2021-10-30 04:29:17 +02:00
|
|
|
|
2020-05-28 09:29:33 +02:00
|
|
|
restartTooltip = new UndoView(context);
|
|
|
|
frameLayout.addView(restartTooltip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
|
|
|
|
|
|
|
|
return fragmentView;
|
|
|
|
}
|
|
|
|
|
2022-01-17 08:45:37 +01:00
|
|
|
private class ConfigCellDrawerProfilePreview extends AbstractConfigCell {
|
2021-10-29 07:52:52 +02:00
|
|
|
public int getType() {
|
2022-03-15 10:22:27 +01:00
|
|
|
return ConfigCellCustom.CUSTOM_ITEM_ProfilePreview;
|
2021-10-29 07:52:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isEnabled() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
|
|
|
DrawerProfilePreviewCell cell = (DrawerProfilePreviewCell) holder.itemView;
|
|
|
|
cell.setUser(getUserConfig().getCurrentUser(), false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-19 09:44:11 +02:00
|
|
|
private void requestKey(Intent data) {
|
|
|
|
|
|
|
|
PGPUtil.post(() -> PGPUtil.api.executeApiAsync(data, null, null, result -> {
|
|
|
|
|
|
|
|
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
|
|
|
|
|
|
|
|
case OpenPgpApi.RESULT_CODE_SUCCESS: {
|
|
|
|
|
|
|
|
long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0L);
|
2022-01-17 08:45:37 +01:00
|
|
|
NekoConfig.openPGPKeyId.setConfigLong(keyId);
|
2020-07-19 09:44:11 +02:00
|
|
|
|
2021-11-10 18:24:03 +01:00
|
|
|
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(keyRow));
|
2020-07-19 09:44:11 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
|
|
|
|
|
|
|
|
PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
|
|
|
|
try {
|
|
|
|
Activity act = (Activity) getParentActivity();
|
|
|
|
act.startIntentSenderFromChild(
|
|
|
|
act, pi.getIntentSender(),
|
|
|
|
114, null, 0, 0, 0);
|
|
|
|
} catch (IntentSender.SendIntentException e) {
|
|
|
|
Log.e(OpenPgpApi.TAG, "SendIntentException", e);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OpenPgpApi.RESULT_CODE_ERROR: {
|
|
|
|
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
|
|
|
|
AlertUtil.showToast(error.getMessage());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
|
|
|
if (requestCode == 114 && resultCode == Activity.RESULT_OK) {
|
|
|
|
requestKey(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static class OpenPgpProviderEntry {
|
|
|
|
private String packageName;
|
|
|
|
private String simpleName;
|
|
|
|
private Intent intent;
|
|
|
|
|
|
|
|
OpenPgpProviderEntry(String packageName, String simpleName) {
|
|
|
|
this.packageName = packageName;
|
|
|
|
this.simpleName = simpleName;
|
|
|
|
}
|
|
|
|
|
|
|
|
OpenPgpProviderEntry(String packageName, String simpleName, Intent intent) {
|
|
|
|
this(packageName, simpleName);
|
|
|
|
this.intent = intent;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return simpleName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-25 17:25:38 +02:00
|
|
|
private void showSortMenuAlert() {
|
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Context context = getParentActivity();
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
|
|
builder.setTitle(LocaleController.getString("SortMenu", R.string.SortMenu));
|
|
|
|
|
|
|
|
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 = 4;
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
TextCheckCell textCell = new TextCheckCell(context);
|
|
|
|
switch (a) {
|
|
|
|
case 0: {
|
2022-01-17 08:45:37 +01:00
|
|
|
textCell.setTextAndCheck(LocaleController.getString("SortByUnread", R.string.SortByUnread), NekoConfig.sortByUnread.Bool(), false);
|
2020-06-25 17:25:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: {
|
2022-01-17 08:45:37 +01:00
|
|
|
textCell.setTextAndCheck(LocaleController.getString("SortByUnmuted", R.string.SortByUnmuted), NekoConfig.sortByUnmuted.Bool(), false);
|
2020-06-25 17:25:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
2022-01-17 08:45:37 +01:00
|
|
|
textCell.setTextAndCheck(LocaleController.getString("SortByUser", R.string.SortByUser), NekoConfig.sortByUser.Bool(), false);
|
2020-06-25 17:25:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: {
|
2022-01-17 08:45:37 +01:00
|
|
|
textCell.setTextAndCheck(LocaleController.getString("SortByContacts", R.string.SortByContacts), NekoConfig.sortByContacts.Bool(), false);
|
2020-06-25 17:25:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
textCell.setTag(a);
|
|
|
|
textCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
|
|
|
linearLayoutInviteContainer.addView(textCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
|
|
|
textCell.setOnClickListener(view -> {
|
|
|
|
Integer tag = (Integer) view.getTag();
|
|
|
|
switch (tag) {
|
|
|
|
case 0: {
|
2022-01-17 08:45:37 +01:00
|
|
|
NekoConfig.sortByUnread.toggleConfigBool();
|
2020-06-25 17:25:38 +02:00
|
|
|
if (view instanceof TextCheckCell) {
|
2022-01-17 08:45:37 +01:00
|
|
|
((TextCheckCell) view).setChecked(NekoConfig.sortByUnread.Bool());
|
2020-06-25 17:25:38 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: {
|
2022-01-17 08:45:37 +01:00
|
|
|
NekoConfig.sortByUnmuted.toggleConfigBool();
|
2020-06-25 17:25:38 +02:00
|
|
|
if (view instanceof TextCheckCell) {
|
2022-01-17 08:45:37 +01:00
|
|
|
((TextCheckCell) view).setChecked(NekoConfig.sortByUnmuted.Bool());
|
2020-06-25 17:25:38 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
2022-01-17 08:45:37 +01:00
|
|
|
NekoConfig.sortByUser.toggleConfigBool();
|
2020-06-25 17:25:38 +02:00
|
|
|
if (view instanceof TextCheckCell) {
|
2022-01-17 08:45:37 +01:00
|
|
|
((TextCheckCell) view).setChecked(NekoConfig.sortByUser.Bool());
|
2020-06-25 17:25:38 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: {
|
2022-01-17 08:45:37 +01:00
|
|
|
NekoConfig.sortByContacts.toggleConfigBool();
|
2020-06-25 17:25:38 +02:00
|
|
|
if (view instanceof TextCheckCell) {
|
2022-01-17 08:45:37 +01:00
|
|
|
((TextCheckCell) view).setChecked(NekoConfig.sortByContacts.Bool());
|
2020-06-25 17:25:38 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
builder.setView(linearLayout);
|
|
|
|
showDialog(builder.create());
|
|
|
|
}
|
|
|
|
|
2020-05-28 09:29:33 +02:00
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
if (listAdapter != null) {
|
|
|
|
listAdapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-12 03:37:29 +01:00
|
|
|
private void updateRows(boolean notify) {
|
|
|
|
if (notify && listAdapter != null) {
|
2020-05-28 09:29:33 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
//impl ListAdapter
|
2020-05-28 09:29:33 +02:00
|
|
|
private class ListAdapter extends RecyclerListView.SelectionAdapter {
|
|
|
|
|
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
public ListAdapter(Context context) {
|
|
|
|
mContext = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
2021-11-10 18:24:03 +01:00
|
|
|
return cellGroup.rows.size();
|
2021-10-29 07:52:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
|
|
|
int position = holder.getAdapterPosition();
|
2022-01-17 08:45:37 +01:00
|
|
|
AbstractConfigCell a = cellGroup.rows.get(position);
|
2021-10-29 07:52:52 +02:00
|
|
|
if (a != null) {
|
|
|
|
return a.isEnabled();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemViewType(int position) {
|
2022-01-17 08:45:37 +01:00
|
|
|
AbstractConfigCell a = cellGroup.rows.get(position);
|
2021-10-29 07:52:52 +02:00
|
|
|
if (a != null) {
|
|
|
|
return a.getType();
|
|
|
|
}
|
2021-11-10 18:24:03 +01:00
|
|
|
return CellGroup.ITEM_TYPE_TEXT_DETAIL;
|
2020-05-28 09:29:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
2022-01-17 08:45:37 +01:00
|
|
|
AbstractConfigCell a = cellGroup.rows.get(position);
|
2021-10-29 07:52:52 +02:00
|
|
|
if (a != null) {
|
2022-01-17 08:45:37 +01:00
|
|
|
if (a instanceof ConfigCellCustom) {
|
2021-10-29 07:52:52 +02:00
|
|
|
// Custom binds
|
|
|
|
if (holder.itemView instanceof TextSettingsCell) {
|
|
|
|
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
|
2021-11-10 18:24:03 +01:00
|
|
|
if (position == cellGroup.rows.indexOf(translationProviderRow)) {
|
2021-10-29 07:52:52 +02:00
|
|
|
String value;
|
2022-01-17 08:45:37 +01:00
|
|
|
switch (NekoConfig.translationProvider.Int()) {
|
2021-10-29 07:52:52 +02:00
|
|
|
case 1:
|
|
|
|
value = LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
value = LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
value = LocaleController.getString("ProviderYandexTranslate", R.string.ProviderYandexTranslate);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
value = LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
value = LocaleController.getString("ProviderMicrosoftTranslator", R.string.ProviderMicrosoftTranslator);
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
value = LocaleController.getString("ProviderYouDao", R.string.ProviderYouDao);
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
value = LocaleController.getString("ProviderDeepLTranslate", R.string.ProviderDeepLTranslate);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
value = "Unknown";
|
|
|
|
}
|
|
|
|
textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, true);
|
2021-11-10 18:24:03 +01:00
|
|
|
} else if (position == cellGroup.rows.indexOf(pgpAppRow)) {
|
2022-01-17 08:45:37 +01:00
|
|
|
textCell.setTextAndValue(LocaleController.getString("OpenPGPApp", R.string.OpenPGPApp), NekoXConfig.getOpenPGPAppName(), true);
|
2021-11-10 18:24:03 +01:00
|
|
|
} else if (position == cellGroup.rows.indexOf(translateToLangRow)) {
|
2022-01-17 08:45:37 +01:00
|
|
|
textCell.setTextAndValue(LocaleController.getString("TransToLang", R.string.TransToLang), NekoXConfig.formatLang(NekoConfig.translateToLang.String()), true);
|
2021-11-10 18:24:03 +01:00
|
|
|
} else if (position == cellGroup.rows.indexOf(translateInputToLangRow)) {
|
2022-01-17 08:45:37 +01:00
|
|
|
textCell.setTextAndValue(LocaleController.getString("TransInputToLang", R.string.TransInputToLang), NekoXConfig.formatLang(NekoConfig.translateInputLang.String()), true);
|
2020-05-28 09:29:33 +02:00
|
|
|
}
|
|
|
|
}
|
2021-10-29 07:52:52 +02:00
|
|
|
} else {
|
|
|
|
// Default binds
|
|
|
|
a.onBindViewHolder(holder);
|
2021-01-12 03:37:29 +01:00
|
|
|
}
|
2021-10-31 13:58:14 +01:00
|
|
|
// Other things
|
2020-05-28 09:29:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
|
|
|
View view = null;
|
|
|
|
switch (viewType) {
|
2021-11-10 18:24:03 +01:00
|
|
|
case CellGroup.ITEM_TYPE_DIVIDER:
|
2020-05-28 09:29:33 +02:00
|
|
|
view = new ShadowSectionCell(mContext);
|
|
|
|
break;
|
2021-11-10 18:24:03 +01:00
|
|
|
case CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL:
|
2020-05-28 09:29:33 +02:00
|
|
|
view = new TextSettingsCell(mContext);
|
|
|
|
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
|
|
|
break;
|
2021-11-10 18:24:03 +01:00
|
|
|
case CellGroup.ITEM_TYPE_TEXT_CHECK:
|
2020-05-28 09:29:33 +02:00
|
|
|
view = new TextCheckCell(mContext);
|
|
|
|
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
|
|
|
break;
|
2021-11-10 18:24:03 +01:00
|
|
|
case CellGroup.ITEM_TYPE_HEADER:
|
2020-05-28 09:29:33 +02:00
|
|
|
view = new HeaderCell(mContext);
|
|
|
|
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
|
|
|
break;
|
2021-11-10 18:24:03 +01:00
|
|
|
case CellGroup.ITEM_TYPE_TEXT_DETAIL:
|
2020-05-28 09:29:33 +02:00
|
|
|
view = new TextDetailSettingsCell(mContext);
|
|
|
|
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
|
|
|
break;
|
2021-11-10 18:24:03 +01:00
|
|
|
case CellGroup.ITEM_TYPE_TEXT:
|
2020-05-28 09:29:33 +02:00
|
|
|
view = new TextInfoPrivacyCell(mContext);
|
2021-10-29 07:52:52 +02:00
|
|
|
// view.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
|
2020-05-28 09:29:33 +02:00
|
|
|
break;
|
2022-03-15 10:22:27 +01:00
|
|
|
case ConfigCellCustom.CUSTOM_ITEM_ProfilePreview:
|
2021-01-12 03:37:29 +01:00
|
|
|
view = profilePreviewCell = new DrawerProfilePreviewCell(mContext);
|
|
|
|
view.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
|
|
|
|
break;
|
2022-03-15 10:22:27 +01:00
|
|
|
case ConfigCellCustom.CUSTOM_ITEM_CharBlurAlpha:
|
|
|
|
view = chatBlurAlphaSeekbar = new ChatBlurAlphaSeekBar(mContext);
|
|
|
|
chatBlurAlphaSeekbar.setEnabled(NekoConfig.forceBlurInChat.Bool());
|
|
|
|
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
|
|
|
break;
|
2020-05-28 09:29:33 +02:00
|
|
|
}
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
|
|
|
|
return new RecyclerListView.Holder(view);
|
|
|
|
}
|
2021-10-29 07:52:52 +02:00
|
|
|
}
|
|
|
|
|
2021-11-03 08:01:01 +01:00
|
|
|
private void setCanNotChange() {
|
2022-01-20 08:41:31 +01:00
|
|
|
if (!NekoXConfig.isDeveloper())
|
2021-11-11 07:56:48 +01:00
|
|
|
cellGroup.rows.remove(hideSponsoredMessageRow);
|
|
|
|
|
2021-11-03 08:01:01 +01:00
|
|
|
boolean enabled;
|
|
|
|
|
2022-01-17 08:45:37 +01:00
|
|
|
enabled = NekoConfig.largeAvatarInDrawer.Int() > 0;
|
|
|
|
((ConfigCellTextCheck) avatarBackgroundBlurRow).enabled = enabled;
|
|
|
|
((ConfigCellTextCheck) avatarBackgroundDarkenRow).enabled = enabled;
|
2021-11-03 08:01:01 +01:00
|
|
|
}
|
|
|
|
|
2021-10-29 07:52:52 +02:00
|
|
|
//Custom dialogs
|
|
|
|
|
2021-11-10 18:24:03 +01:00
|
|
|
private void customDialog_BottomInputString(int position, ConfigItem bind, String subtitle, String hint) {
|
2021-10-29 07:52:52 +02:00
|
|
|
BottomBuilder builder = new BottomBuilder(getParentActivity());
|
|
|
|
|
|
|
|
builder.addTitle(
|
2021-10-31 16:45:24 +01:00
|
|
|
LocaleController.getString(bind.getKey()),
|
|
|
|
subtitle
|
2021-10-29 07:52:52 +02:00
|
|
|
);
|
|
|
|
|
2021-10-31 16:45:24 +01:00
|
|
|
EditText keyField = builder.addEditText(hint);
|
2020-05-28 09:29:33 +02:00
|
|
|
|
2021-10-31 16:45:24 +01:00
|
|
|
if (StrUtil.isNotBlank(bind.String())) {
|
|
|
|
keyField.setText(bind.String());
|
2020-05-28 09:29:33 +02:00
|
|
|
}
|
2021-10-29 07:52:52 +02:00
|
|
|
|
|
|
|
builder.addCancelButton();
|
|
|
|
|
|
|
|
builder.addOkButton((it) -> {
|
|
|
|
|
|
|
|
String key = keyField.getText().toString();
|
|
|
|
|
|
|
|
if (StrUtil.isBlank(key)) key = null;
|
|
|
|
|
2021-10-31 16:45:24 +01:00
|
|
|
bind.setConfigString(key);
|
2021-10-29 07:52:52 +02:00
|
|
|
|
|
|
|
listAdapter.notifyItemChanged(position);
|
|
|
|
|
|
|
|
return Unit.INSTANCE;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
builder.show();
|
|
|
|
|
|
|
|
keyField.requestFocus();
|
|
|
|
AndroidUtilities.showKeyboard(keyField);
|
2020-05-28 09:29:33 +02:00
|
|
|
}
|
2022-03-15 10:22:27 +01:00
|
|
|
|
|
|
|
private class ChatBlurAlphaSeekBar extends FrameLayout {
|
|
|
|
|
|
|
|
private final SeekBarView sizeBar;
|
|
|
|
private final TextPaint textPaint;
|
|
|
|
private boolean enabled = true;
|
|
|
|
|
|
|
|
public ChatBlurAlphaSeekBar(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.chatBlueAlphaValue.setConfigInt(Math.min(255, (int) (255 * progress)));
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSeekBarPressed(boolean pressed) {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
sizeBar.setOnTouchListener((v, event) -> !enabled);
|
|
|
|
sizeBar.setProgress(NekoConfig.chatBlueAlphaValue.Int());
|
|
|
|
addView(sizeBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.LEFT | Gravity.TOP, 9, 5, 43, 11));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
|
|
|
textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText));
|
|
|
|
canvas.drawText(String.valueOf(NekoConfig.chatBlueAlphaValue.Int()), getMeasuredWidth() - AndroidUtilities.dp(39), AndroidUtilities.dp(28), textPaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
sizeBar.setProgress((NekoConfig.chatBlueAlphaValue.Int() / 255.0f));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void invalidate() {
|
|
|
|
super.invalidate();
|
|
|
|
sizeBar.invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setEnabled(boolean enabled) {
|
|
|
|
super.setEnabled(enabled);
|
|
|
|
this.enabled = enabled;
|
|
|
|
sizeBar.setAlpha(enabled ? 1.0f : 0.5f);
|
|
|
|
textPaint.setAlpha((int) ((enabled ? 1.0f : 0.3f) * 255));
|
|
|
|
this.invalidate();
|
|
|
|
}
|
|
|
|
}
|
2021-11-03 08:01:01 +01:00
|
|
|
}
|