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