| 1 | package tw.nekomimi.nekogram; |
| 2 | |
| 3 | import android.animation.Animator; |
| 4 | import android.animation.AnimatorListenerAdapter; |
| 5 | import android.animation.AnimatorSet; |
| 6 | import android.annotation.SuppressLint; |
| 7 | import android.content.Context; |
| 8 | import android.content.DialogInterface; |
| 9 | import android.graphics.Canvas; |
| 10 | import android.graphics.Paint; |
| 11 | import android.os.Build; |
| 12 | import android.text.TextPaint; |
| 13 | import android.view.Gravity; |
| 14 | import android.view.View; |
| 15 | import android.view.ViewGroup; |
| 16 | import android.view.WindowManager; |
| 17 | import android.widget.FrameLayout; |
| 18 | import android.widget.LinearLayout; |
| 19 | import android.widget.TextView; |
| 20 | |
| 21 | import androidx.recyclerview.widget.LinearLayoutManager; |
| 22 | import androidx.recyclerview.widget.RecyclerView; |
| 23 | |
| 24 | import org.telegram.messenger.AndroidUtilities; |
| 25 | import org.telegram.messenger.BuildConfig; |
| 26 | import org.telegram.messenger.FileLog; |
| 27 | import org.telegram.messenger.LocaleController; |
| 28 | import org.telegram.messenger.MessagesController; |
| 29 | import org.telegram.messenger.NotificationCenter; |
| 30 | import org.telegram.messenger.R; |
| 31 | import org.telegram.messenger.SharedConfig; |
| 32 | import org.telegram.messenger.UserConfig; |
| 33 | import org.telegram.tgnet.ConnectionsManager; |
| 34 | import org.telegram.tgnet.TLRPC; |
| 35 | import org.telegram.ui.ActionBar.ActionBar; |
| 36 | import org.telegram.ui.ActionBar.ActionBarMenuItem; |
| 37 | import org.telegram.ui.ActionBar.AlertDialog; |
| 38 | import org.telegram.ui.ActionBar.BaseFragment; |
| 39 | import org.telegram.ui.ActionBar.BottomSheet; |
| 40 | import org.telegram.ui.ActionBar.Theme; |
| 41 | import org.telegram.ui.ActionBar.ThemeDescription; |
| 42 | import org.telegram.ui.Cells.EmptyCell; |
| 43 | import org.telegram.ui.Cells.HeaderCell; |
| 44 | import org.telegram.ui.Cells.NotificationsCheckCell; |
| 45 | import org.telegram.ui.Cells.RadioColorCell; |
| 46 | import org.telegram.ui.Cells.ShadowSectionCell; |
| 47 | import org.telegram.ui.Cells.TextCheckCell; |
| 48 | import org.telegram.ui.Cells.TextDetailSettingsCell; |
| 49 | import org.telegram.ui.Cells.TextInfoPrivacyCell; |
| 50 | import org.telegram.ui.Cells.TextSettingsCell; |
| 51 | import org.telegram.ui.Components.AlertsCreator; |
| 52 | import org.telegram.ui.Components.LayoutHelper; |
| 53 | import org.telegram.ui.Components.RecyclerListView; |
| 54 | import org.telegram.ui.Components.SeekBarView; |
| 55 | |
| 56 | import java.util.ArrayList; |
| 57 | |
| 58 | import tw.nekomimi.nekogram.translator.Translator; |
| 59 | |
| 60 | @SuppressLint("RtlHardcoded") |
| 61 | public class NekoSettingsActivity extends BaseFragment { |
| 62 | |
| 63 | private RecyclerListView listView; |
| 64 | private ListAdapter listAdapter; |
| 65 | private AnimatorSet animatorSet; |
| 66 | |
| 67 | private boolean sensitiveCanChange = false; |
| 68 | private boolean sensitiveEnabled = false; |
| 69 | |
| 70 | private int rowCount; |
| 71 | |
| 72 | private int connectionRow; |
| 73 | private int ipv6Row; |
| 74 | private int connection2Row; |
| 75 | |
| 76 | private int chatRow; |
| 77 | private int inappCameraRow; |
| 78 | private int useSystemEmojiRow; |
| 79 | private int ignoreBlockedRow; |
| 80 | private int hideProxySponsorChannelRow; |
| 81 | private int pauseMusicOnRecordRow; |
| 82 | private int disablePhotoSideActionRow; |
| 83 | private int hideKeyboardOnChatScrollRow; |
| 84 | private int rearVideoMessagesRow; |
| 85 | private int hideAllTabRow; |
| 86 | private int confirmAVRow; |
| 87 | private int askBeforeCallRow; |
| 88 | private int disableNumberRoundingRow; |
| 89 | private int mapPreviewRow; |
| 90 | private int stickerSizeRow; |
| 91 | private int translationProviderRow; |
| 92 | private int messageMenuRow; |
| 93 | private int tabsTitleTypeRow; |
| 94 | private int chat2Row; |
| 95 | |
| 96 | private int settingsRow; |
| 97 | private int typefaceRow; |
| 98 | private int hidePhoneRow; |
| 99 | private int nameOrderRow; |
| 100 | private int transparentStatusBarRow; |
| 101 | private int forceTabletRow; |
| 102 | private int openArchiveOnPullRow; |
| 103 | private int avatarAsDrawerBackgroundRow; |
| 104 | private int showTabsOnForwardRow; |
| 105 | private int eventTypeRow; |
| 106 | private int newYearRow; |
| 107 | private int actionBarDecorationRow; |
| 108 | private int settings2Row; |
| 109 | |
| 110 | private int experimentRow; |
| 111 | private int smoothKeyboardRow; |
| 112 | private int chatMessageAnimationRow; |
| 113 | private int saveCacheToPrivateDirectoryRow; |
| 114 | private int disableFilteringRow; |
| 115 | private int unlimitedFavedStickersRow; |
| 116 | private int unlimitedPinnedDialogsRow; |
| 117 | private int deleteAccountRow; |
| 118 | private int needRestartRow; |
| 119 | |
| 120 | private int shouldNOTTrustMeRow; |
| 121 | |
| 122 | static public AlertDialog getTranslationProviderAlert(Context context) { |
| 123 | ArrayList<String> arrayList = new ArrayList<>(); |
| 124 | ArrayList<Integer> types = new ArrayList<>(); |
| 125 | arrayList.add(LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate)); |
| 126 | types.add(Translator.PROVIDER_GOOGLE); |
| 127 | arrayList.add(LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN)); |
| 128 | types.add(Translator.PROVIDER_GOOGLE_CN); |
| 129 | arrayList.add(LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud)); |
| 130 | types.add(Translator.PROVIDER_LINGO); |
| 131 | arrayList.add(LocaleController.getString("ProviderGoogleTranslateWeb", R.string.ProviderGoogleTranslateWeb)); |
| 132 | types.add(Translator.PROVIDER_GOOGLE_WEB); |
| 133 | arrayList.add(LocaleController.getString("ProviderGoogleTranslateCNWeb", R.string.ProviderGoogleTranslateCNWeb)); |
| 134 | types.add(Translator.PROVIDER_GOOGLE_CN_WEB); |
| 135 | arrayList.add(LocaleController.getString("ProviderBaiduFanyiWeb", R.string.ProviderBaiduFanyiWeb)); |
| 136 | types.add(Translator.PROVIDER_BAIDU_WEB); |
| 137 | arrayList.add(LocaleController.getString("ProviderDeepLWeb", R.string.ProviderDeepLWeb)); |
| 138 | types.add(Translator.PROVIDER_DEEPL_WEB); |
| 139 | |
| 140 | AlertDialog.Builder builder = new AlertDialog.Builder(context); |
| 141 | builder.setTitle(LocaleController.getString("TranslationProvider", R.string.TranslationProvider)); |
| 142 | final LinearLayout linearLayout = new LinearLayout(context); |
| 143 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 144 | builder.setView(linearLayout); |
| 145 | |
| 146 | for (int a = 0; a < arrayList.size(); a++) { |
| 147 | RadioColorCell cell = new RadioColorCell(context); |
| 148 | cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); |
| 149 | cell.setTag(a); |
| 150 | cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); |
| 151 | cell.setTextAndValue(arrayList.get(a), NekoConfig.translationProvider == types.get(a)); |
| 152 | linearLayout.addView(cell); |
| 153 | cell.setOnClickListener(v -> { |
| 154 | Integer which = (Integer) v.getTag(); |
| 155 | NekoConfig.setTranslationProvider(types.get(which)); |
| 156 | builder.getDismissRunnable().run(); |
| 157 | }); |
| 158 | } |
| 159 | builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); |
| 160 | return builder.create(); |
| 161 | } |
| 162 | |
| 163 | @Override |
| 164 | public boolean onFragmentCreate() { |
| 165 | super.onFragmentCreate(); |
| 166 | |
| 167 | updateRows(); |
| 168 | |
| 169 | return true; |
| 170 | } |
| 171 | |
| 172 | @SuppressLint("NewApi") |
| 173 | @Override |
| 174 | public View createView(Context context) { |
| 175 | actionBar.setBackButtonImage(R.drawable.ic_ab_back); |
| 176 | actionBar.setTitle(LocaleController.getString("NekoSettings", R.string.NekoSettings)); |
| 177 | |
| 178 | if (AndroidUtilities.isTablet()) { |
| 179 | actionBar.setOccupyStatusBar(false); |
| 180 | } |
| 181 | actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { |
| 182 | @Override |
| 183 | public void onItemClick(int id) { |
| 184 | if (id == -1) { |
| 185 | finishFragment(); |
| 186 | } |
| 187 | } |
| 188 | }); |
| 189 | |
| 190 | listAdapter = new ListAdapter(context); |
| 191 | |
| 192 | fragmentView = new FrameLayout(context); |
| 193 | fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray)); |
| 194 | FrameLayout frameLayout = (FrameLayout) fragmentView; |
| 195 | |
| 196 | listView = new RecyclerListView(context); |
| 197 | listView.setVerticalScrollBarEnabled(false); |
| 198 | listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); |
| 199 | frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); |
| 200 | listView.setAdapter(listAdapter); |
| 201 | listView.setOnItemClickListener((view, position, x, y) -> { |
| 202 | if (position == ipv6Row) { |
| 203 | NekoConfig.toggleIPv6(); |
| 204 | if (view instanceof TextCheckCell) { |
| 205 | ((TextCheckCell) view).setChecked(NekoConfig.useIPv6); |
| 206 | } |
| 207 | for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { |
| 208 | if (UserConfig.getInstance(a).isClientActivated()) { |
| 209 | ConnectionsManager.native_setUseIpv6(a, NekoConfig.useIPv6); |
| 210 | } |
| 211 | } |
| 212 | } else if (position == hidePhoneRow) { |
| 213 | NekoConfig.toggleHidePhone(); |
| 214 | if (view instanceof TextCheckCell) { |
| 215 | ((TextCheckCell) view).setChecked(NekoConfig.hidePhone); |
| 216 | } |
| 217 | } else if (position == inappCameraRow) { |
| 218 | SharedConfig.toggleInappCamera(); |
| 219 | if (view instanceof TextCheckCell) { |
| 220 | ((TextCheckCell) view).setChecked(SharedConfig.inappCamera); |
| 221 | } |
| 222 | } else if (position == forceTabletRow) { |
| 223 | NekoConfig.toggleForceTablet(); |
| 224 | if (view instanceof TextCheckCell) { |
| 225 | ((TextCheckCell) view).setChecked(NekoConfig.forceTablet); |
| 226 | } |
| 227 | } else if (position == ignoreBlockedRow) { |
| 228 | NekoConfig.toggleIgnoreBlocked(); |
| 229 | if (view instanceof TextCheckCell) { |
| 230 | ((TextCheckCell) view).setChecked(NekoConfig.ignoreBlocked); |
| 231 | } |
| 232 | } else if (position == transparentStatusBarRow) { |
| 233 | NekoConfig.toggleTransparentStatusBar(); |
| 234 | if (view instanceof TextCheckCell) { |
| 235 | ((TextCheckCell) view).setChecked(NekoConfig.transparentStatusBar); |
| 236 | } |
| 237 | AndroidUtilities.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewTheme, false)); |
| 238 | } else if (position == hideProxySponsorChannelRow) { |
| 239 | NekoConfig.toggleHideProxySponsorChannel(); |
| 240 | if (view instanceof TextCheckCell) { |
| 241 | ((TextCheckCell) view).setChecked(NekoConfig.hideProxySponsorChannel); |
| 242 | } |
| 243 | for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { |
| 244 | if (UserConfig.getInstance(a).isClientActivated()) { |
| 245 | MessagesController.getInstance(a).checkPromoInfo(true); |
| 246 | } |
| 247 | } |
| 248 | } else if (position == saveCacheToPrivateDirectoryRow) { |
| 249 | NekoConfig.toggleSaveCacheToPrivateDirectory(); |
| 250 | if (view instanceof TextCheckCell) { |
| 251 | ((TextCheckCell) view).setChecked(NekoConfig.saveCacheToPrivateDirectory); |
| 252 | } |
| 253 | } else if (position == useSystemEmojiRow) { |
| 254 | NekoConfig.toggleUseSystemEmoji(); |
| 255 | if (view instanceof TextCheckCell) { |
| 256 | ((TextCheckCell) view).setChecked(NekoConfig.useSystemEmoji); |
| 257 | } |
| 258 | } else if (position == typefaceRow) { |
| 259 | NekoConfig.toggleTypeface(); |
| 260 | if (view instanceof TextCheckCell) { |
| 261 | ((TextCheckCell) view).setChecked(NekoConfig.typeface == 1); |
| 262 | } |
| 263 | } else if (position == mapPreviewRow) { |
| 264 | ArrayList<String> arrayList = new ArrayList<>(); |
| 265 | ArrayList<Integer> types = new ArrayList<>(); |
| 266 | arrayList.add(LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram)); |
| 267 | types.add(0); |
| 268 | arrayList.add(LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex)); |
| 269 | types.add(1); |
| 270 | arrayList.add(LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody)); |
| 271 | types.add(2); |
| 272 | |
| 273 | AlertDialog.Builder builder = new AlertDialog.Builder(context); |
| 274 | builder.setTitle(LocaleController.getString("MapPreviewProviderTitle", R.string.MapPreviewProviderTitle)); |
| 275 | final LinearLayout linearLayout = new LinearLayout(context); |
| 276 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 277 | builder.setView(linearLayout); |
| 278 | |
| 279 | for (int a = 0; a < arrayList.size(); a++) { |
| 280 | RadioColorCell cell = new RadioColorCell(context); |
| 281 | cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); |
| 282 | cell.setTag(a); |
| 283 | cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); |
| 284 | cell.setTextAndValue(arrayList.get(a), NekoConfig.mapPreviewProvider == types.get(a)); |
| 285 | linearLayout.addView(cell); |
| 286 | cell.setOnClickListener(v -> { |
| 287 | Integer which = (Integer) v.getTag(); |
| 288 | NekoConfig.setMapPreviewProvider(types.get(which)); |
| 289 | listAdapter.notifyItemChanged(mapPreviewRow); |
| 290 | builder.getDismissRunnable().run(); |
| 291 | }); |
| 292 | } |
| 293 | builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); |
| 294 | showDialog(builder.create()); |
| 295 | } else if (position == nameOrderRow) { |
| 296 | ArrayList<String> arrayList = new ArrayList<>(); |
| 297 | ArrayList<Integer> types = new ArrayList<>(); |
| 298 | arrayList.add(LocaleController.getString("FirstLast", R.string.FirstLast)); |
| 299 | types.add(1); |
| 300 | arrayList.add(LocaleController.getString("LastFirst", R.string.LastFirst)); |
| 301 | types.add(2); |
| 302 | |
| 303 | AlertDialog.Builder builder = new AlertDialog.Builder(context); |
| 304 | builder.setTitle(LocaleController.getString("NameOrder", R.string.NameOrder)); |
| 305 | final LinearLayout linearLayout = new LinearLayout(context); |
| 306 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 307 | builder.setView(linearLayout); |
| 308 | |
| 309 | for (int a = 0; a < arrayList.size(); a++) { |
| 310 | RadioColorCell cell = new RadioColorCell(context); |
| 311 | cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); |
| 312 | cell.setTag(a); |
| 313 | cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); |
| 314 | cell.setTextAndValue(arrayList.get(a), NekoConfig.nameOrder == types.get(a)); |
| 315 | linearLayout.addView(cell); |
| 316 | cell.setOnClickListener(v -> { |
| 317 | Integer which = (Integer) v.getTag(); |
| 318 | NekoConfig.setNameOrder(types.get(which)); |
| 319 | listAdapter.notifyItemChanged(nameOrderRow); |
| 320 | builder.getDismissRunnable().run(); |
| 321 | }); |
| 322 | } |
| 323 | builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); |
| 324 | showDialog(builder.create()); |
| 325 | } else if (position == eventTypeRow) { |
| 326 | ArrayList<String> arrayList = new ArrayList<>(); |
| 327 | ArrayList<Integer> types = new ArrayList<>(); |
| 328 | arrayList.add(LocaleController.getString("DependsOnDate", R.string.DependsOnDate)); |
| 329 | types.add(0); |
| 330 | arrayList.add(LocaleController.getString("Christmas", R.string.Christmas)); |
| 331 | types.add(1); |
| 332 | arrayList.add(LocaleController.getString("Valentine", R.string.Valentine)); |
| 333 | types.add(2); |
| 334 | |
| 335 | AlertDialog.Builder builder = new AlertDialog.Builder(context); |
| 336 | builder.setTitle(LocaleController.getString("EventType", R.string.EventType)); |
| 337 | final LinearLayout linearLayout = new LinearLayout(context); |
| 338 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 339 | builder.setView(linearLayout); |
| 340 | |
| 341 | for (int a = 0; a < arrayList.size(); a++) { |
| 342 | RadioColorCell cell = new RadioColorCell(context); |
| 343 | cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); |
| 344 | cell.setTag(a); |
| 345 | cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); |
| 346 | cell.setTextAndValue(arrayList.get(a), NekoConfig.eventType == types.get(a)); |
| 347 | linearLayout.addView(cell); |
| 348 | cell.setOnClickListener(v -> { |
| 349 | Integer which = (Integer) v.getTag(); |
| 350 | NekoConfig.setEventType(types.get(which)); |
| 351 | listAdapter.notifyItemChanged(eventTypeRow); |
| 352 | builder.getDismissRunnable().run(); |
| 353 | }); |
| 354 | } |
| 355 | builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); |
| 356 | showDialog(builder.create()); |
| 357 | } else if (position == actionBarDecorationRow) { |
| 358 | ArrayList<String> arrayList = new ArrayList<>(); |
| 359 | ArrayList<Integer> types = new ArrayList<>(); |
| 360 | arrayList.add(LocaleController.getString("DependsOnDate", R.string.DependsOnDate)); |
| 361 | types.add(0); |
| 362 | arrayList.add(LocaleController.getString("Snowflakes", R.string.Snowflakes)); |
| 363 | types.add(1); |
| 364 | arrayList.add(LocaleController.getString("Fireworks", R.string.Fireworks)); |
| 365 | types.add(2); |
| 366 | |
| 367 | AlertDialog.Builder builder = new AlertDialog.Builder(context); |
| 368 | builder.setTitle(LocaleController.getString("ActionBarDecoration", R.string.ActionBarDecoration)); |
| 369 | final LinearLayout linearLayout = new LinearLayout(context); |
| 370 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 371 | builder.setView(linearLayout); |
| 372 | |
| 373 | for (int a = 0; a < arrayList.size(); a++) { |
| 374 | RadioColorCell cell = new RadioColorCell(context); |
| 375 | cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); |
| 376 | cell.setTag(a); |
| 377 | cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); |
| 378 | cell.setTextAndValue(arrayList.get(a), NekoConfig.actionBarDecoration == types.get(a)); |
| 379 | linearLayout.addView(cell); |
| 380 | cell.setOnClickListener(v -> { |
| 381 | Integer which = (Integer) v.getTag(); |
| 382 | NekoConfig.setActionBarDecoration(types.get(which)); |
| 383 | listAdapter.notifyItemChanged(actionBarDecorationRow); |
| 384 | builder.getDismissRunnable().run(); |
| 385 | }); |
| 386 | } |
| 387 | builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); |
| 388 | showDialog(builder.create()); |
| 389 | } else if (position == newYearRow) { |
| 390 | NekoConfig.toggleNewYear(); |
| 391 | if (view instanceof TextCheckCell) { |
| 392 | ((TextCheckCell) view).setChecked(NekoConfig.newYear); |
| 393 | } |
| 394 | } else if (position == disableFilteringRow) { |
| 395 | sensitiveEnabled = !sensitiveEnabled; |
| 396 | TLRPC.TL_account_setContentSettings req = new TLRPC.TL_account_setContentSettings(); |
| 397 | req.sensitive_enabled = sensitiveEnabled; |
| 398 | AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3); |
| 399 | progressDialog.show(); |
| 400 | getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { |
| 401 | progressDialog.dismiss(); |
| 402 | if (error == null) { |
| 403 | if (response instanceof TLRPC.TL_boolTrue && view instanceof TextCheckCell) { |
| 404 | ((TextCheckCell) view).setChecked(sensitiveEnabled); |
| 405 | } |
| 406 | } else { |
| 407 | AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, this, req)); |
| 408 | } |
| 409 | })); |
| 410 | } else if (position == stickerSizeRow) { |
| 411 | showStickerSizeAlert(); |
| 412 | } else if (position == unlimitedFavedStickersRow) { |
| 413 | NekoConfig.toggleUnlimitedFavedStickers(); |
| 414 | if (view instanceof TextCheckCell) { |
| 415 | ((TextCheckCell) view).setChecked(NekoConfig.unlimitedFavedStickers); |
| 416 | } |
| 417 | } else if (position == messageMenuRow) { |
| 418 | showMessageMenuAlert(); |
| 419 | } else if (position == deleteAccountRow) { |
| 420 | AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); |
| 421 | builder.setMessage(LocaleController.getString("TosDeclineDeleteAccount", R.string.TosDeclineDeleteAccount)); |
| 422 | builder.setTitle(LocaleController.getString("DeleteAccount", R.string.DeleteAccount)); |
| 423 | builder.setPositiveButton(LocaleController.getString("Deactivate", R.string.Deactivate), (dialog, which) -> { |
| 424 | ArrayList<TLRPC.Dialog> dialogs = new ArrayList<>(getMessagesController().getAllDialogs()); |
| 425 | for (TLRPC.Dialog TLdialog : dialogs) { |
| 426 | if (TLdialog instanceof TLRPC.TL_dialogFolder) { |
| 427 | continue; |
| 428 | } |
| 429 | TLRPC.Peer peer = getMessagesController().getPeer((int) TLdialog.id); |
| 430 | if (peer.channel_id != 0) { |
| 431 | TLRPC.Chat chat = getMessagesController().getChat(peer.channel_id); |
| 432 | if (!chat.broadcast) { |
| 433 | MessageHelper.getInstance(currentAccount).deleteUserChannelHistoryWithSearch(TLdialog.id, getMessagesController().getUser(getUserConfig().clientUserId)); |
| 434 | } |
| 435 | } |
| 436 | if (peer.user_id != 0) { |
| 437 | getMessagesController().deleteDialog(TLdialog.id, 0, true); |
| 438 | } |
| 439 | } |
| 440 | AlertDialog.Builder builder12 = new AlertDialog.Builder(getParentActivity()); |
| 441 | builder12.setMessage(LocaleController.getString("TosDeclineDeleteAccount", R.string.TosDeclineDeleteAccount)); |
| 442 | builder12.setTitle(LocaleController.getString("DeleteAccount", R.string.DeleteAccount)); |
| 443 | builder12.setPositiveButton(LocaleController.getString("Deactivate", R.string.Deactivate), (dialogInterface, i) -> { |
| 444 | final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3); |
| 445 | progressDialog.setCanCacnel(false); |
| 446 | |
| 447 | TLRPC.TL_account_deleteAccount req = new TLRPC.TL_account_deleteAccount(); |
| 448 | req.reason = "Meow"; |
| 449 | getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { |
| 450 | try { |
| 451 | progressDialog.dismiss(); |
| 452 | } catch (Exception e) { |
| 453 | FileLog.e(e); |
| 454 | } |
| 455 | if (response instanceof TLRPC.TL_boolTrue) { |
| 456 | getMessagesController().performLogout(0); |
| 457 | } else if (error == null || error.code != -1000) { |
| 458 | String errorText = LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred); |
| 459 | if (error != null) { |
| 460 | errorText += "\n" + error.text; |
| 461 | } |
| 462 | AlertDialog.Builder builder1 = new AlertDialog.Builder(getParentActivity()); |
| 463 | builder1.setTitle(LocaleController.getString("AppName", R.string.AppName)); |
| 464 | builder1.setMessage(errorText); |
| 465 | builder1.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); |
| 466 | builder1.show(); |
| 467 | } |
| 468 | })); |
| 469 | progressDialog.show(); |
| 470 | }); |
| 471 | builder12.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); |
| 472 | AlertDialog dialog12 = builder12.create(); |
| 473 | showDialog(dialog12); |
| 474 | TextView button = (TextView) dialog12.getButton(DialogInterface.BUTTON_POSITIVE); |
| 475 | if (button != null) { |
| 476 | button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2)); |
| 477 | } |
| 478 | }); |
| 479 | builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); |
| 480 | builder.show(); |
| 481 | AlertDialog dialog = builder.create(); |
| 482 | showDialog(dialog); |
| 483 | TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE); |
| 484 | if (button != null) { |
| 485 | button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2)); |
| 486 | } |
| 487 | } else if (position == translationProviderRow) { |
| 488 | AlertDialog dialog = getTranslationProviderAlert(context); |
| 489 | dialog.setOnDismissListener(dialog1 -> listAdapter.notifyItemChanged(translationProviderRow)); |
| 490 | showDialog(dialog); |
| 491 | } else if (position == pauseMusicOnRecordRow) { |
| 492 | SharedConfig.togglePauseMusicOnRecord(); |
| 493 | if (view instanceof TextCheckCell) { |
| 494 | ((TextCheckCell) view).setChecked(SharedConfig.pauseMusicOnRecord); |
| 495 | } |
| 496 | } else if (position == smoothKeyboardRow) { |
| 497 | SharedConfig.toggleSmoothKeyboard(); |
| 498 | if (view instanceof TextCheckCell) { |
| 499 | ((TextCheckCell) view).setChecked(SharedConfig.smoothKeyboard); |
| 500 | } |
| 501 | if (SharedConfig.smoothKeyboard && getParentActivity() != null) { |
| 502 | getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); |
| 503 | } |
| 504 | } else if (position == disablePhotoSideActionRow) { |
| 505 | NekoConfig.toggleDisablePhotoSideAction(); |
| 506 | if (view instanceof TextCheckCell) { |
| 507 | ((TextCheckCell) view).setChecked(NekoConfig.disablePhotoSideAction); |
| 508 | } |
| 509 | } else if (position == unlimitedPinnedDialogsRow) { |
| 510 | NekoConfig.toggleUnlimitedPinnedDialogs(); |
| 511 | if (view instanceof TextCheckCell) { |
| 512 | ((TextCheckCell) view).setChecked(NekoConfig.unlimitedPinnedDialogs); |
| 513 | } |
| 514 | } else if (position == openArchiveOnPullRow) { |
| 515 | NekoConfig.toggleOpenArchiveOnPull(); |
| 516 | if (view instanceof TextCheckCell) { |
| 517 | ((TextCheckCell) view).setChecked(NekoConfig.openArchiveOnPull); |
| 518 | } |
| 519 | } else if (position == experimentRow) { |
| 520 | NekoConfig.toggleShowHiddenFeature(); |
| 521 | updateRows(); |
| 522 | } else if (position == hideKeyboardOnChatScrollRow) { |
| 523 | NekoConfig.toggleHideKeyboardOnChatScroll(); |
| 524 | if (view instanceof TextCheckCell) { |
| 525 | ((TextCheckCell) view).setChecked(NekoConfig.hideKeyboardOnChatScroll); |
| 526 | } |
| 527 | } else if (position == avatarAsDrawerBackgroundRow) { |
| 528 | NekoConfig.toggleAvatarAsDrawerBackground(); |
| 529 | getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged); |
| 530 | if (view instanceof TextCheckCell) { |
| 531 | ((TextCheckCell) view).setChecked(NekoConfig.avatarAsDrawerBackground); |
| 532 | } |
| 533 | } else if (position == showTabsOnForwardRow) { |
| 534 | NekoConfig.toggleShowTabsOnForward(); |
| 535 | if (view instanceof TextCheckCell) { |
| 536 | ((TextCheckCell) view).setChecked(NekoConfig.showTabsOnForward); |
| 537 | } |
| 538 | } else if (position == chatMessageAnimationRow) { |
| 539 | NekoConfig.toggleChatMessageAnimation(); |
| 540 | if (view instanceof TextCheckCell) { |
| 541 | ((TextCheckCell) view).setChecked(NekoConfig.chatMessageAnimation); |
| 542 | } |
| 543 | } else if (position == rearVideoMessagesRow) { |
| 544 | NekoConfig.toggleRearVideoMessages(); |
| 545 | if (view instanceof TextCheckCell) { |
| 546 | ((TextCheckCell) view).setChecked(NekoConfig.rearVideoMessages); |
| 547 | } |
| 548 | } else if (position == hideAllTabRow) { |
| 549 | NekoConfig.toggleHideAllTab(); |
| 550 | if (view instanceof TextCheckCell) { |
| 551 | ((TextCheckCell) view).setChecked(NekoConfig.hideAllTab); |
| 552 | } |
| 553 | getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated); |
| 554 | } else if (position == tabsTitleTypeRow) { |
| 555 | ArrayList<String> arrayList = new ArrayList<>(); |
| 556 | ArrayList<Integer> types = new ArrayList<>(); |
| 557 | arrayList.add(LocaleController.getString("TabTitleTypeText", R.string.TabTitleTypeText)); |
| 558 | types.add(NekoConfig.TITLE_TYPE_TEXT); |
| 559 | arrayList.add(LocaleController.getString("TabTitleTypeIcon", R.string.TabTitleTypeIcon)); |
| 560 | types.add(NekoConfig.TITLE_TYPE_ICON); |
| 561 | arrayList.add(LocaleController.getString("TabTitleTypeMix", R.string.TabTitleTypeMix)); |
| 562 | types.add(NekoConfig.TITLE_TYPE_MIX); |
| 563 | |
| 564 | AlertDialog.Builder builder = new AlertDialog.Builder(context); |
| 565 | builder.setTitle(LocaleController.getString("TabTitleType", R.string.TabTitleType)); |
| 566 | builder.setMessage(LocaleController.getString("TabTitleTypeTip", R.string.TabTitleTypeTip)); |
| 567 | final LinearLayout linearLayout = new LinearLayout(context); |
| 568 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 569 | builder.setView(linearLayout); |
| 570 | |
| 571 | for (int a = 0; a < arrayList.size(); a++) { |
| 572 | RadioColorCell cell = new RadioColorCell(context); |
| 573 | cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); |
| 574 | cell.setTag(a); |
| 575 | cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); |
| 576 | cell.setTextAndValue(arrayList.get(a), NekoConfig.tabsTitleType == types.get(a)); |
| 577 | linearLayout.addView(cell); |
| 578 | cell.setOnClickListener(v -> { |
| 579 | Integer which = (Integer) v.getTag(); |
| 580 | NekoConfig.setTabsTitleType(types.get(which)); |
| 581 | listAdapter.notifyItemChanged(tabsTitleTypeRow); |
| 582 | getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated); |
| 583 | builder.getDismissRunnable().run(); |
| 584 | }); |
| 585 | } |
| 586 | builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); |
| 587 | showDialog(builder.create()); |
| 588 | } else if (position == confirmAVRow) { |
| 589 | NekoConfig.toggleConfirmAVMessage(); |
| 590 | if (view instanceof TextCheckCell) { |
| 591 | ((TextCheckCell) view).setChecked(NekoConfig.confirmAVMessage); |
| 592 | } |
| 593 | } else if (position == askBeforeCallRow) { |
| 594 | NekoConfig.toggleAskBeforeCall(); |
| 595 | if (view instanceof TextCheckCell) { |
| 596 | ((TextCheckCell) view).setChecked(NekoConfig.askBeforeCall); |
| 597 | } |
| 598 | } else if (position == shouldNOTTrustMeRow) { |
| 599 | NekoConfig.toggleShouldNOTTrustMe(); |
| 600 | if (view instanceof TextCheckCell) { |
| 601 | ((TextCheckCell) view).setChecked(NekoConfig.shouldNOTTrustMe); |
| 602 | } |
| 603 | } else if (position == disableNumberRoundingRow) { |
| 604 | NekoConfig.toggleDisableNumberRounding(); |
| 605 | if (view instanceof TextCheckCell) { |
| 606 | ((TextCheckCell) view).setChecked(NekoConfig.disableNumberRounding); |
| 607 | } |
| 608 | } |
| 609 | }); |
| 610 | |
| 611 | return fragmentView; |
| 612 | } |
| 613 | |
| 614 | @Override |
| 615 | public void onResume() { |
| 616 | super.onResume(); |
| 617 | if (listAdapter != null) { |
| 618 | checkSensitive(); |
| 619 | listAdapter.notifyDataSetChanged(); |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | private void updateRows() { |
| 624 | rowCount = 0; |
| 625 | connectionRow = rowCount++; |
| 626 | ipv6Row = rowCount++; |
| 627 | connection2Row = rowCount++; |
| 628 | chatRow = rowCount++; |
| 629 | inappCameraRow = rowCount++; |
| 630 | useSystemEmojiRow = rowCount++; |
| 631 | ignoreBlockedRow = rowCount++; |
| 632 | hideProxySponsorChannelRow = rowCount++; |
| 633 | pauseMusicOnRecordRow = rowCount++; |
| 634 | disablePhotoSideActionRow = rowCount++; |
| 635 | hideKeyboardOnChatScrollRow = rowCount++; |
| 636 | rearVideoMessagesRow = rowCount++; |
| 637 | hideAllTabRow = rowCount++; |
| 638 | confirmAVRow = rowCount++; |
| 639 | askBeforeCallRow = rowCount++; |
| 640 | disableNumberRoundingRow = rowCount++; |
| 641 | mapPreviewRow = rowCount++; |
| 642 | stickerSizeRow = rowCount++; |
| 643 | messageMenuRow = rowCount++; |
| 644 | translationProviderRow = rowCount++; |
| 645 | tabsTitleTypeRow = rowCount++; |
| 646 | chat2Row = rowCount++; |
| 647 | settingsRow = rowCount++; |
| 648 | hidePhoneRow = rowCount++; |
| 649 | typefaceRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? rowCount++ : -1; |
| 650 | transparentStatusBarRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? rowCount++ : -1; |
| 651 | forceTabletRow = rowCount++; |
| 652 | openArchiveOnPullRow = rowCount++; |
| 653 | avatarAsDrawerBackgroundRow = rowCount++; |
| 654 | showTabsOnForwardRow = rowCount++; |
| 655 | nameOrderRow = rowCount++; |
| 656 | eventTypeRow = NekoConfig.showHiddenFeature ? rowCount++ : -1; |
| 657 | newYearRow = NekoConfig.showHiddenFeature ? rowCount++ : -1; |
| 658 | actionBarDecorationRow = NekoConfig.showHiddenFeature ? rowCount++ : -1; |
| 659 | settings2Row = rowCount++; |
| 660 | experimentRow = rowCount++; |
| 661 | smoothKeyboardRow = !AndroidUtilities.isTablet() ? rowCount++ : -1; |
| 662 | chatMessageAnimationRow = NekoConfig.showHiddenFeature ? rowCount++ : -1; |
| 663 | saveCacheToPrivateDirectoryRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? rowCount++ : -1; |
| 664 | disableFilteringRow = rowCount++; |
| 665 | unlimitedFavedStickersRow = rowCount++; |
| 666 | unlimitedPinnedDialogsRow = rowCount++; |
| 667 | deleteAccountRow = NekoConfig.showHiddenFeature ? rowCount++ : -1; |
| 668 | needRestartRow = rowCount++; |
| 669 | shouldNOTTrustMeRow = BuildConfig.DEBUG ? rowCount++ : -1; |
| 670 | if (listAdapter != null) { |
| 671 | listAdapter.notifyDataSetChanged(); |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | @Override |
| 676 | public ArrayList<ThemeDescription> getThemeDescriptions() { |
| 677 | ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>(); |
| 678 | 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)); |
| 679 | themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray)); |
| 680 | |
| 681 | themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue)); |
| 682 | themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue)); |
| 683 | themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_avatar_actionBarIconBlue)); |
| 684 | themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle)); |
| 685 | themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_avatar_actionBarSelectorBlue)); |
| 686 | themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, null, Theme.key_actionBarDefaultSubmenuBackground)); |
| 687 | themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, null, Theme.key_actionBarDefaultSubmenuItem)); |
| 688 | |
| 689 | themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector)); |
| 690 | |
| 691 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider)); |
| 692 | |
| 693 | themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow)); |
| 694 | |
| 695 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText)); |
| 696 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteValueText)); |
| 697 | |
| 698 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText)); |
| 699 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2)); |
| 700 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack)); |
| 701 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked)); |
| 702 | |
| 703 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText)); |
| 704 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2)); |
| 705 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack)); |
| 706 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked)); |
| 707 | |
| 708 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader)); |
| 709 | |
| 710 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText)); |
| 711 | themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2)); |
| 712 | |
| 713 | return themeDescriptions; |
| 714 | } |
| 715 | |
| 716 | private void checkSensitive() { |
| 717 | TLRPC.TL_account_getContentSettings req = new TLRPC.TL_account_getContentSettings(); |
| 718 | getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { |
| 719 | if (error == null) { |
| 720 | TLRPC.TL_account_contentSettings settings = (TLRPC.TL_account_contentSettings) response; |
| 721 | sensitiveEnabled = settings.sensitive_enabled; |
| 722 | sensitiveCanChange = settings.sensitive_can_change; |
| 723 | int count = listView.getChildCount(); |
| 724 | ArrayList<Animator> animators = new ArrayList<>(); |
| 725 | for (int a = 0; a < count; a++) { |
| 726 | View child = listView.getChildAt(a); |
| 727 | RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.getChildViewHolder(child); |
| 728 | int position = holder.getAdapterPosition(); |
| 729 | if (position == disableFilteringRow) { |
| 730 | TextCheckCell checkCell = (TextCheckCell) holder.itemView; |
| 731 | checkCell.setChecked(sensitiveEnabled); |
| 732 | checkCell.setEnabled(sensitiveCanChange, animators); |
| 733 | if (sensitiveCanChange) { |
| 734 | if (!animators.isEmpty()) { |
| 735 | if (animatorSet != null) { |
| 736 | animatorSet.cancel(); |
| 737 | } |
| 738 | animatorSet = new AnimatorSet(); |
| 739 | animatorSet.playTogether(animators); |
| 740 | animatorSet.addListener(new AnimatorListenerAdapter() { |
| 741 | @Override |
| 742 | public void onAnimationEnd(Animator animator) { |
| 743 | if (animator.equals(animatorSet)) { |
| 744 | animatorSet = null; |
| 745 | } |
| 746 | } |
| 747 | }); |
| 748 | animatorSet.setDuration(150); |
| 749 | animatorSet.start(); |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | } |
| 754 | } |
| 755 | } else { |
| 756 | AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, this, req)); |
| 757 | } |
| 758 | })); |
| 759 | } |
| 760 | |
| 761 | private void showMessageMenuAlert() { |
| 762 | if (getParentActivity() == null) { |
| 763 | return; |
| 764 | } |
| 765 | Context context = getParentActivity(); |
| 766 | AlertDialog.Builder builder = new AlertDialog.Builder(context); |
| 767 | builder.setTitle(LocaleController.getString("MessageMenu", R.string.MessageMenu)); |
| 768 | |
| 769 | LinearLayout linearLayout = new LinearLayout(context); |
| 770 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 771 | |
| 772 | LinearLayout linearLayoutInviteContainer = new LinearLayout(context); |
| 773 | linearLayoutInviteContainer.setOrientation(LinearLayout.VERTICAL); |
| 774 | linearLayout.addView(linearLayoutInviteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); |
| 775 | |
| 776 | int count = 10; |
| 777 | for (int a = 0; a < count; a++) { |
| 778 | TextCheckCell textCell = new TextCheckCell(context); |
| 779 | switch (a) { |
| 780 | case 0: { |
| 781 | textCell.setTextAndCheck(LocaleController.getString("DeleteDownloadedFile", R.string.DeleteDownloadedFile), NekoConfig.showDeleteDownloadedFile, false); |
| 782 | break; |
| 783 | } |
| 784 | case 1: { |
| 785 | textCell.setTextAndCheck(LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages), NekoConfig.showAddToSavedMessages, false); |
| 786 | break; |
| 787 | } |
| 788 | case 2: { |
| 789 | textCell.setTextAndCheck(LocaleController.getString("Repeat", R.string.Repeat), NekoConfig.showRepeat, false); |
| 790 | break; |
| 791 | } |
| 792 | case 3: { |
| 793 | textCell.setTextAndCheck(LocaleController.getString("Prpr", R.string.Prpr), NekoConfig.showPrPr, false); |
| 794 | break; |
| 795 | } |
| 796 | case 4: { |
| 797 | textCell.setTextAndCheck(LocaleController.getString("ViewHistory", R.string.ViewHistory), NekoConfig.showViewHistory, false); |
| 798 | break; |
| 799 | } |
| 800 | case 5: { |
| 801 | textCell.setTextAndCheck(LocaleController.getString("Translate", R.string.Translate), NekoConfig.showTranslate, false); |
| 802 | break; |
| 803 | } |
| 804 | case 6: { |
| 805 | textCell.setTextAndCheck(LocaleController.getString("ReportChat", R.string.ReportChat), NekoConfig.showReport, false); |
| 806 | break; |
| 807 | } |
| 808 | case 7: { |
| 809 | textCell.setTextAndCheck(LocaleController.getString("EditAdminRights", R.string.EditAdminRights), NekoConfig.showAdminActions, false); |
| 810 | break; |
| 811 | } |
| 812 | case 8: { |
| 813 | textCell.setTextAndCheck(LocaleController.getString("ChangePermissions", R.string.ChangePermissions), NekoConfig.showChangePermissions, false); |
| 814 | break; |
| 815 | } |
| 816 | case 9: { |
| 817 | textCell.setTextAndCheck(LocaleController.getString("MessageDetails", R.string.MessageDetails), NekoConfig.showMessageDetails, false); |
| 818 | break; |
| 819 | } |
| 820 | } |
| 821 | textCell.setTag(a); |
| 822 | textCell.setBackground(Theme.getSelectorDrawable(false)); |
| 823 | linearLayoutInviteContainer.addView(textCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); |
| 824 | textCell.setOnClickListener(v2 -> { |
| 825 | Integer tag = (Integer) v2.getTag(); |
| 826 | switch (tag) { |
| 827 | case 0: { |
| 828 | NekoConfig.toggleShowDeleteDownloadedFile(); |
| 829 | textCell.setChecked(NekoConfig.showDeleteDownloadedFile); |
| 830 | break; |
| 831 | } |
| 832 | case 1: { |
| 833 | NekoConfig.toggleShowAddToSavedMessages(); |
| 834 | textCell.setChecked(NekoConfig.showAddToSavedMessages); |
| 835 | break; |
| 836 | } |
| 837 | case 2: { |
| 838 | NekoConfig.toggleShowRepeat(); |
| 839 | textCell.setChecked(NekoConfig.showRepeat); |
| 840 | break; |
| 841 | } |
| 842 | case 3: { |
| 843 | NekoConfig.toggleShowPrPr(); |
| 844 | textCell.setChecked(NekoConfig.showPrPr); |
| 845 | break; |
| 846 | } |
| 847 | case 4: { |
| 848 | NekoConfig.toggleShowViewHistory(); |
| 849 | textCell.setChecked(NekoConfig.showViewHistory); |
| 850 | break; |
| 851 | } |
| 852 | case 5: { |
| 853 | NekoConfig.toggleShowTranslate(); |
| 854 | textCell.setChecked(NekoConfig.showTranslate); |
| 855 | break; |
| 856 | } |
| 857 | case 6: { |
| 858 | NekoConfig.toggleShowReport(); |
| 859 | textCell.setChecked(NekoConfig.showReport); |
| 860 | break; |
| 861 | } |
| 862 | case 7: { |
| 863 | NekoConfig.toggleShowAdminActions(); |
| 864 | textCell.setChecked(NekoConfig.showAdminActions); |
| 865 | break; |
| 866 | } |
| 867 | case 8: { |
| 868 | NekoConfig.toggleShowChangePermissions(); |
| 869 | textCell.setChecked(NekoConfig.showChangePermissions); |
| 870 | break; |
| 871 | } |
| 872 | case 9: { |
| 873 | NekoConfig.toggleShowMessageDetails(); |
| 874 | textCell.setChecked(NekoConfig.showMessageDetails); |
| 875 | break; |
| 876 | } |
| 877 | } |
| 878 | }); |
| 879 | } |
| 880 | builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); |
| 881 | builder.setView(linearLayout); |
| 882 | showDialog(builder.create()); |
| 883 | } |
| 884 | |
| 885 | private void showStickerSizeAlert() { |
| 886 | if (getParentActivity() == null) { |
| 887 | return; |
| 888 | } |
| 889 | Context context = getParentActivity(); |
| 890 | BottomSheet.Builder builder = new BottomSheet.Builder(context); |
| 891 | builder.setApplyTopPadding(false); |
| 892 | builder.setApplyBottomPadding(false); |
| 893 | |
| 894 | LinearLayout linearLayout = new LinearLayout(context); |
| 895 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 896 | |
| 897 | FrameLayout titleLayout = new FrameLayout(context); |
| 898 | linearLayout.addView(titleLayout); |
| 899 | |
| 900 | HeaderCell headerCell = new HeaderCell(context, Theme.key_windowBackgroundWhiteBlueHeader, 23, 15, false); |
| 901 | headerCell.setHeight(47); |
| 902 | headerCell.setText(LocaleController.getString("StickerSize", R.string.StickerSize)); |
| 903 | titleLayout.addView(headerCell); |
| 904 | |
| 905 | ActionBarMenuItem optionsButton = new ActionBarMenuItem(context, null, 0, Theme.getColor(Theme.key_sheet_other)); |
| 906 | optionsButton.setLongClickEnabled(false); |
| 907 | optionsButton.setSubMenuOpenSide(2); |
| 908 | optionsButton.setIcon(R.drawable.ic_ab_other); |
| 909 | optionsButton.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_player_actionBarSelector), 1)); |
| 910 | optionsButton.addSubItem(1, R.drawable.msg_reset, LocaleController.getString("Reset", R.string.Reset)); |
| 911 | optionsButton.setOnClickListener(v -> optionsButton.toggleSubMenu()); |
| 912 | optionsButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions)); |
| 913 | titleLayout.addView(optionsButton, LayoutHelper.createFrame(40, 40, Gravity.TOP | Gravity.RIGHT, 0, 8, 5, 0)); |
| 914 | |
| 915 | LinearLayout linearLayoutInviteContainer = new LinearLayout(context); |
| 916 | linearLayoutInviteContainer.setOrientation(LinearLayout.VERTICAL); |
| 917 | linearLayout.addView(linearLayoutInviteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); |
| 918 | StickerSizeCell stickerSizeCell = new StickerSizeCell(context); |
| 919 | optionsButton.setDelegate(id -> { |
| 920 | if (id == 1) { |
| 921 | NekoConfig.setStickerSize(14.0f); |
| 922 | stickerSizeCell.invalidate(); |
| 923 | } |
| 924 | }); |
| 925 | linearLayoutInviteContainer.addView(stickerSizeCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); |
| 926 | builder.setCustomView(linearLayout); |
| 927 | showDialog(builder.create()); |
| 928 | } |
| 929 | |
| 930 | private class StickerSizeCell extends FrameLayout { |
| 931 | |
| 932 | private StickerSizePreviewMessagesCell messagesCell; |
| 933 | private SeekBarView sizeBar; |
| 934 | private int startStickerSize = 2; |
| 935 | private int endStickerSize = 20; |
| 936 | |
| 937 | private TextPaint textPaint; |
| 938 | |
| 939 | public StickerSizeCell(Context context) { |
| 940 | super(context); |
| 941 | |
| 942 | setWillNotDraw(false); |
| 943 | |
| 944 | textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); |
| 945 | textPaint.setTextSize(AndroidUtilities.dp(16)); |
| 946 | |
| 947 | sizeBar = new SeekBarView(context); |
| 948 | sizeBar.setReportChanges(true); |
| 949 | sizeBar.setDelegate(new SeekBarView.SeekBarViewDelegate() { |
| 950 | @Override |
| 951 | public void onSeekBarDrag(boolean stop, float progress) { |
| 952 | NekoConfig.setStickerSize(startStickerSize + (endStickerSize - startStickerSize) * progress); |
| 953 | StickerSizeCell.this.invalidate(); |
| 954 | } |
| 955 | |
| 956 | @Override |
| 957 | public void onSeekBarPressed(boolean pressed) { |
| 958 | |
| 959 | } |
| 960 | }); |
| 961 | addView(sizeBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.LEFT | Gravity.TOP, 9, 5, 43, 11)); |
| 962 | |
| 963 | messagesCell = new StickerSizePreviewMessagesCell(context, parentLayout); |
| 964 | addView(messagesCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 53, 0, 0)); |
| 965 | } |
| 966 | |
| 967 | @Override |
| 968 | protected void onDraw(Canvas canvas) { |
| 969 | textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText)); |
| 970 | canvas.drawText("" + Math.round(NekoConfig.stickerSize), getMeasuredWidth() - AndroidUtilities.dp(39), AndroidUtilities.dp(28), textPaint); |
| 971 | } |
| 972 | |
| 973 | @Override |
| 974 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 975 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 976 | sizeBar.setProgress((NekoConfig.stickerSize - startStickerSize) / (float) (endStickerSize - startStickerSize)); |
| 977 | } |
| 978 | |
| 979 | @Override |
| 980 | public void invalidate() { |
| 981 | super.invalidate(); |
| 982 | listAdapter.notifyItemChanged(stickerSizeRow); |
| 983 | messagesCell.invalidate(); |
| 984 | sizeBar.invalidate(); |
| 985 | } |
| 986 | } |
| 987 | |
| 988 | private class ListAdapter extends RecyclerListView.SelectionAdapter { |
| 989 | |
| 990 | private Context mContext; |
| 991 | |
| 992 | public ListAdapter(Context context) { |
| 993 | mContext = context; |
| 994 | } |
| 995 | |
| 996 | @Override |
| 997 | public int getItemCount() { |
| 998 | return rowCount; |
| 999 | } |
| 1000 | |
| 1001 | @Override |
| 1002 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { |
| 1003 | switch (holder.getItemViewType()) { |
| 1004 | case 2: { |
| 1005 | TextSettingsCell textCell = (TextSettingsCell) holder.itemView; |
| 1006 | textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); |
| 1007 | if (position == nameOrderRow) { |
| 1008 | String value; |
| 1009 | switch (NekoConfig.nameOrder) { |
| 1010 | case 2: |
| 1011 | value = LocaleController.getString("LastFirst", R.string.LastFirst); |
| 1012 | break; |
| 1013 | case 1: |
| 1014 | default: |
| 1015 | value = LocaleController.getString("FirstLast", R.string.FirstLast); |
| 1016 | break; |
| 1017 | } |
| 1018 | textCell.setTextAndValue(LocaleController.getString("NameOrder", R.string.NameOrder), value, eventTypeRow != -1); |
| 1019 | } else if (position == mapPreviewRow) { |
| 1020 | String value; |
| 1021 | switch (NekoConfig.mapPreviewProvider) { |
| 1022 | case 0: |
| 1023 | value = LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram); |
| 1024 | break; |
| 1025 | case 1: |
| 1026 | value = LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex); |
| 1027 | break; |
| 1028 | case 2: |
| 1029 | default: |
| 1030 | value = LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody); |
| 1031 | } |
| 1032 | textCell.setTextAndValue(LocaleController.getString("MapPreviewProvider", R.string.MapPreviewProvider), value, true); |
| 1033 | } else if (position == eventTypeRow) { |
| 1034 | String value; |
| 1035 | switch (NekoConfig.eventType) { |
| 1036 | case 1: |
| 1037 | value = LocaleController.getString("Christmas", R.string.Christmas); |
| 1038 | break; |
| 1039 | case 2: |
| 1040 | value = LocaleController.getString("Valentine", R.string.Valentine); |
| 1041 | break; |
| 1042 | case 0: |
| 1043 | default: |
| 1044 | value = LocaleController.getString("DependsOnDate", R.string.DependsOnDate); |
| 1045 | } |
| 1046 | textCell.setTextAndValue(LocaleController.getString("EventType", R.string.EventType), value, true); |
| 1047 | } else if (position == actionBarDecorationRow) { |
| 1048 | String value; |
| 1049 | switch (NekoConfig.actionBarDecoration) { |
| 1050 | case 1: |
| 1051 | value = LocaleController.getString("Snowflakes", R.string.Snowflakes); |
| 1052 | break; |
| 1053 | case 2: |
| 1054 | value = LocaleController.getString("Fireworks", R.string.Fireworks); |
| 1055 | break; |
| 1056 | case 0: |
| 1057 | default: |
| 1058 | value = LocaleController.getString("DependsOnDate", R.string.DependsOnDate); |
| 1059 | } |
| 1060 | textCell.setTextAndValue(LocaleController.getString("ActionBarDecoration", R.string.ActionBarDecoration), value, false); |
| 1061 | } else if (position == stickerSizeRow) { |
| 1062 | textCell.setTextAndValue(LocaleController.getString("StickerSize", R.string.StickerSize), String.valueOf(Math.round(NekoConfig.stickerSize)), true); |
| 1063 | } else if (position == messageMenuRow) { |
| 1064 | textCell.setText(LocaleController.getString("MessageMenu", R.string.MessageMenu), true); |
| 1065 | } else if (position == deleteAccountRow) { |
| 1066 | textCell.setText(LocaleController.getString("DeleteAccount", R.string.DeleteAccount), false); |
| 1067 | textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText)); |
| 1068 | } else if (position == translationProviderRow) { |
| 1069 | String value; |
| 1070 | switch (NekoConfig.translationProvider) { |
| 1071 | case Translator.PROVIDER_GOOGLE: |
| 1072 | value = LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate); |
| 1073 | break; |
| 1074 | case Translator.PROVIDER_GOOGLE_WEB: |
| 1075 | value = LocaleController.getString("ProviderGoogleTranslateWeb", R.string.ProviderGoogleTranslateWeb); |
| 1076 | break; |
| 1077 | case Translator.PROVIDER_GOOGLE_CN: |
| 1078 | value = LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN); |
| 1079 | break; |
| 1080 | case Translator.PROVIDER_GOOGLE_CN_WEB: |
| 1081 | value = LocaleController.getString("ProviderGoogleTranslateCNWeb", R.string.ProviderGoogleTranslateCNWeb); |
| 1082 | break; |
| 1083 | case Translator.PROVIDER_BAIDU_WEB: |
| 1084 | value = LocaleController.getString("ProviderBaiduFanyiWeb", R.string.ProviderBaiduFanyiWeb); |
| 1085 | break; |
| 1086 | case Translator.PROVIDER_DEEPL_WEB: |
| 1087 | value = LocaleController.getString("ProviderDeepLWeb", R.string.ProviderDeepLWeb); |
| 1088 | break; |
| 1089 | case Translator.PROVIDER_LINGO: |
| 1090 | default: |
| 1091 | value = LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud); |
| 1092 | break; |
| 1093 | } |
| 1094 | textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, true); |
| 1095 | } else if (position == tabsTitleTypeRow) { |
| 1096 | String value; |
| 1097 | switch (NekoConfig.tabsTitleType) { |
| 1098 | case NekoConfig.TITLE_TYPE_TEXT: |
| 1099 | value = LocaleController.getString("TabTitleTypeText", R.string.TabTitleTypeText); |
| 1100 | break; |
| 1101 | case NekoConfig.TITLE_TYPE_ICON: |
| 1102 | value = LocaleController.getString("TabTitleTypeIcon", R.string.TabTitleTypeIcon); |
| 1103 | break; |
| 1104 | case NekoConfig.TITLE_TYPE_MIX: |
| 1105 | default: |
| 1106 | value = LocaleController.getString("TabTitleTypeMix", R.string.TabTitleTypeMix); |
| 1107 | } |
| 1108 | textCell.setTextAndValue(LocaleController.getString("TabTitleType", R.string.TabTitleType), value, false); |
| 1109 | } |
| 1110 | break; |
| 1111 | } |
| 1112 | case 3: { |
| 1113 | TextCheckCell textCell = (TextCheckCell) holder.itemView; |
| 1114 | textCell.setEnabled(true, null); |
| 1115 | if (position == ipv6Row) { |
| 1116 | textCell.setTextAndCheck(LocaleController.getString("IPv6", R.string.IPv6), NekoConfig.useIPv6, false); |
| 1117 | } else if (position == hidePhoneRow) { |
| 1118 | textCell.setTextAndCheck(LocaleController.getString("HidePhone", R.string.HidePhone), NekoConfig.hidePhone, true); |
| 1119 | } else if (position == inappCameraRow) { |
| 1120 | textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableCamera", R.string.DebugMenuEnableCamera), SharedConfig.inappCamera, true); |
| 1121 | } else if (position == transparentStatusBarRow) { |
| 1122 | textCell.setTextAndCheck(LocaleController.getString("TransparentStatusBar", R.string.TransparentStatusBar), NekoConfig.transparentStatusBar, true); |
| 1123 | } else if (position == hideProxySponsorChannelRow) { |
| 1124 | textCell.setTextAndCheck(LocaleController.getString("HideProxySponsorChannel", R.string.HideProxySponsorChannel), NekoConfig.hideProxySponsorChannel, true); |
| 1125 | } else if (position == saveCacheToPrivateDirectoryRow) { |
| 1126 | textCell.setTextAndCheck(LocaleController.getString("SaveCacheToPrivateDirectory", R.string.SaveCacheToPrivateDirectory), NekoConfig.saveCacheToPrivateDirectory, true); |
| 1127 | } else if (position == useSystemEmojiRow) { |
| 1128 | textCell.setTextAndCheck(LocaleController.getString("EmojiUseDefault", R.string.EmojiUseDefault), NekoConfig.useSystemEmoji, true); |
| 1129 | } else if (position == typefaceRow) { |
| 1130 | textCell.setTextAndCheck(LocaleController.getString("TypefaceUseDefault", R.string.TypefaceUseDefault), NekoConfig.typeface == 1, true); |
| 1131 | } else if (position == ignoreBlockedRow) { |
| 1132 | textCell.setTextAndCheck(LocaleController.getString("IgnoreBlocked", R.string.IgnoreBlocked), NekoConfig.ignoreBlocked, true); |
| 1133 | } else if (position == forceTabletRow) { |
| 1134 | textCell.setTextAndCheck(LocaleController.getString("ForceTabletMode", R.string.ForceTabletMode), NekoConfig.forceTablet, true); |
| 1135 | } else if (position == newYearRow) { |
| 1136 | textCell.setTextAndCheck(LocaleController.getString("ChristmasHat", R.string.ChristmasHat), NekoConfig.newYear, true); |
| 1137 | } else if (position == disableFilteringRow) { |
| 1138 | textCell.setTextAndValueAndCheck(LocaleController.getString("SensitiveDisableFiltering", R.string.SensitiveDisableFiltering), LocaleController.getString("SensitiveAbout", R.string.SensitiveAbout), sensitiveEnabled, true, true); |
| 1139 | textCell.setEnabled(sensitiveCanChange, null); |
| 1140 | } else if (position == unlimitedFavedStickersRow) { |
| 1141 | textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedFavoredStickers", R.string.UnlimitedFavoredStickers), LocaleController.getString("UnlimitedFavoredStickersAbout", R.string.UnlimitedFavoredStickersAbout), NekoConfig.unlimitedFavedStickers, true, true); |
| 1142 | } else if (position == pauseMusicOnRecordRow) { |
| 1143 | textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnablePauseMusic", R.string.DebugMenuEnablePauseMusic), SharedConfig.pauseMusicOnRecord, true); |
| 1144 | } else if (position == smoothKeyboardRow) { |
| 1145 | textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard), SharedConfig.smoothKeyboard, true); |
| 1146 | } else if (position == disablePhotoSideActionRow) { |
| 1147 | textCell.setTextAndCheck(LocaleController.getString("DisablePhotoViewerSideAction", R.string.DisablePhotoViewerSideAction), NekoConfig.disablePhotoSideAction, true); |
| 1148 | } else if (position == unlimitedPinnedDialogsRow) { |
| 1149 | textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedPinnedDialogs", R.string.UnlimitedPinnedDialogs), LocaleController.getString("UnlimitedPinnedDialogsAbout", R.string.UnlimitedPinnedDialogsAbout), NekoConfig.unlimitedPinnedDialogs, true, deleteAccountRow != -1); |
| 1150 | } else if (position == openArchiveOnPullRow) { |
| 1151 | textCell.setTextAndCheck(LocaleController.getString("OpenArchiveOnPull", R.string.OpenArchiveOnPull), NekoConfig.openArchiveOnPull, true); |
| 1152 | } else if (position == hideKeyboardOnChatScrollRow) { |
| 1153 | textCell.setTextAndCheck(LocaleController.getString("HideKeyboardOnChatScroll", R.string.HideKeyboardOnChatScroll), NekoConfig.hideKeyboardOnChatScroll, true); |
| 1154 | } else if (position == avatarAsDrawerBackgroundRow) { |
| 1155 | textCell.setTextAndCheck(LocaleController.getString("UseAvatarAsDrawerBackground", R.string.UseAvatarAsDrawerBackground), NekoConfig.avatarAsDrawerBackground, true); |
| 1156 | } else if (position == showTabsOnForwardRow) { |
| 1157 | textCell.setTextAndCheck(LocaleController.getString("ShowTabsOnForward", R.string.ShowTabsOnForward), NekoConfig.showTabsOnForward, true); |
| 1158 | } else if (position == chatMessageAnimationRow) { |
| 1159 | textCell.setTextAndCheck(LocaleController.getString("ChatMessageAnimation", R.string.ChatMessageAnimation), NekoConfig.chatMessageAnimation, true); |
| 1160 | } else if (position == rearVideoMessagesRow) { |
| 1161 | textCell.setTextAndCheck(LocaleController.getString("RearVideoMessages", R.string.RearVideoMessages), NekoConfig.rearVideoMessages, true); |
| 1162 | } else if (position == hideAllTabRow) { |
| 1163 | textCell.setTextAndValueAndCheck(LocaleController.getString("HideAllTab", R.string.HideAllTab), LocaleController.getString("HideAllTabAbout", R.string.HideAllTabAbout), NekoConfig.hideAllTab, true, true); |
| 1164 | } else if (position == confirmAVRow) { |
| 1165 | textCell.setTextAndCheck(LocaleController.getString("ConfirmAVMessage", R.string.ConfirmAVMessage), NekoConfig.confirmAVMessage, true); |
| 1166 | } else if (position == askBeforeCallRow) { |
| 1167 | textCell.setTextAndCheck(LocaleController.getString("AskBeforeCalling", R.string.AskBeforeCalling), NekoConfig.askBeforeCall, true); |
| 1168 | } else if (position == shouldNOTTrustMeRow) { |
| 1169 | textCell.setTextAndCheck("Don't trust me", NekoConfig.shouldNOTTrustMe, false); |
| 1170 | } else if (position == disableNumberRoundingRow) { |
| 1171 | textCell.setTextAndValueAndCheck(LocaleController.getString("DisableNumberRounding", R.string.DisableNumberRounding), "4.8K -> 4777", NekoConfig.disableNumberRounding, true, true); |
| 1172 | } |
| 1173 | break; |
| 1174 | } |
| 1175 | case 4: { |
| 1176 | HeaderCell headerCell = (HeaderCell) holder.itemView; |
| 1177 | if (position == settingsRow) { |
| 1178 | headerCell.setText(LocaleController.getString("General", R.string.General)); |
| 1179 | } else if (position == connectionRow) { |
| 1180 | headerCell.setText(LocaleController.getString("Connection", R.string.Connection)); |
| 1181 | } else if (position == chatRow) { |
| 1182 | headerCell.setText(LocaleController.getString("Chat", R.string.Chat)); |
| 1183 | } else if (position == experimentRow) { |
| 1184 | headerCell.setText(LocaleController.getString("Experiment", R.string.Experiment)); |
| 1185 | } |
| 1186 | break; |
| 1187 | } |
| 1188 | case 7: { |
| 1189 | TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView; |
| 1190 | if (position == needRestartRow) { |
| 1191 | cell.setText(LocaleController.getString("SomeItemsNeedRestart", R.string.SomeItemsNeedRestart)); |
| 1192 | } |
| 1193 | break; |
| 1194 | } |
| 1195 | } |
| 1196 | } |
| 1197 | |
| 1198 | @Override |
| 1199 | public boolean isEnabled(RecyclerView.ViewHolder holder) { |
| 1200 | int position = holder.getAdapterPosition(); |
| 1201 | return position == hidePhoneRow || position == inappCameraRow || position == ignoreBlockedRow || |
| 1202 | position == useSystemEmojiRow || position == ipv6Row || position == typefaceRow || position == nameOrderRow || |
| 1203 | position == forceTabletRow || position == mapPreviewRow || position == newYearRow || |
| 1204 | position == actionBarDecorationRow || position == eventTypeRow || position == transparentStatusBarRow || |
| 1205 | position == hideProxySponsorChannelRow || position == saveCacheToPrivateDirectoryRow || |
| 1206 | position == disableFilteringRow || position == stickerSizeRow || |
| 1207 | position == unlimitedFavedStickersRow || position == messageMenuRow || position == deleteAccountRow || |
| 1208 | position == translationProviderRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow || |
| 1209 | position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow || |
| 1210 | position == experimentRow || position == hideKeyboardOnChatScrollRow || position == avatarAsDrawerBackgroundRow || |
| 1211 | position == showTabsOnForwardRow || position == chatMessageAnimationRow || position == rearVideoMessagesRow || |
| 1212 | position == hideAllTabRow || position == tabsTitleTypeRow || position == confirmAVRow || position == askBeforeCallRow || |
| 1213 | position == shouldNOTTrustMeRow || position == disableNumberRoundingRow; |
| 1214 | } |
| 1215 | |
| 1216 | @Override |
| 1217 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
| 1218 | View view = null; |
| 1219 | switch (viewType) { |
| 1220 | case 1: |
| 1221 | view = new ShadowSectionCell(mContext); |
| 1222 | break; |
| 1223 | case 2: |
| 1224 | view = new TextSettingsCell(mContext); |
| 1225 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 1226 | break; |
| 1227 | case 3: |
| 1228 | view = new TextCheckCell(mContext); |
| 1229 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 1230 | break; |
| 1231 | case 4: |
| 1232 | view = new HeaderCell(mContext); |
| 1233 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 1234 | break; |
| 1235 | case 5: |
| 1236 | view = new NotificationsCheckCell(mContext); |
| 1237 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 1238 | break; |
| 1239 | case 6: |
| 1240 | view = new TextDetailSettingsCell(mContext); |
| 1241 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 1242 | break; |
| 1243 | case 7: |
| 1244 | view = new TextInfoPrivacyCell(mContext); |
| 1245 | view.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); |
| 1246 | break; |
| 1247 | } |
| 1248 | //noinspection ConstantConditions |
| 1249 | view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT)); |
| 1250 | return new RecyclerListView.Holder(view); |
| 1251 | } |
| 1252 | |
| 1253 | @Override |
| 1254 | public int getItemViewType(int position) { |
| 1255 | if (position == connection2Row || position == chat2Row || position == settings2Row) { |
| 1256 | return 1; |
| 1257 | } else if (position == nameOrderRow || position == mapPreviewRow || position == stickerSizeRow || position == messageMenuRow || |
| 1258 | position == deleteAccountRow || position == translationProviderRow || position == eventTypeRow || position == actionBarDecorationRow || |
| 1259 | position == tabsTitleTypeRow) { |
| 1260 | return 2; |
| 1261 | } else if (position == ipv6Row || position == hidePhoneRow || position == inappCameraRow || |
| 1262 | position == transparentStatusBarRow || position == hideProxySponsorChannelRow || |
| 1263 | position == ignoreBlockedRow || position == useSystemEmojiRow || position == typefaceRow || |
| 1264 | position == forceTabletRow || position == newYearRow || |
| 1265 | position == saveCacheToPrivateDirectoryRow || position == unlimitedFavedStickersRow || |
| 1266 | position == disableFilteringRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow || |
| 1267 | position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow || |
| 1268 | position == hideKeyboardOnChatScrollRow || position == avatarAsDrawerBackgroundRow || position == showTabsOnForwardRow || |
| 1269 | position == chatMessageAnimationRow || position == rearVideoMessagesRow || position == hideAllTabRow || position == confirmAVRow || |
| 1270 | position == askBeforeCallRow || position == shouldNOTTrustMeRow || position == disableNumberRoundingRow) { |
| 1271 | return 3; |
| 1272 | } else if (position == settingsRow || position == connectionRow || position == chatRow || position == experimentRow) { |
| 1273 | return 4; |
| 1274 | } else if (position == needRestartRow) { |
| 1275 | return 7; |
| 1276 | } |
| 1277 | return 6; |
| 1278 | } |
| 1279 | } |
| 1280 | } |
| 1281 | |