| 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.SharedPreferences; |
| 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.widget.FrameLayout; |
| 17 | import android.widget.LinearLayout; |
| 18 | |
| 19 | import androidx.recyclerview.widget.LinearLayoutManager; |
| 20 | import androidx.recyclerview.widget.RecyclerView; |
| 21 | |
| 22 | import org.telegram.messenger.AndroidUtilities; |
| 23 | import org.telegram.messenger.LocaleController; |
| 24 | import org.telegram.messenger.MessagesController; |
| 25 | import org.telegram.messenger.NotificationCenter; |
| 26 | import org.telegram.messenger.R; |
| 27 | import org.telegram.messenger.SharedConfig; |
| 28 | import org.telegram.messenger.UserConfig; |
| 29 | import org.telegram.tgnet.ConnectionsManager; |
| 30 | import org.telegram.tgnet.TLRPC; |
| 31 | import org.telegram.ui.ActionBar.ActionBar; |
| 32 | import org.telegram.ui.ActionBar.ActionBarMenuItem; |
| 33 | import org.telegram.ui.ActionBar.AlertDialog; |
| 34 | import org.telegram.ui.ActionBar.BaseFragment; |
| 35 | import org.telegram.ui.ActionBar.BottomSheet; |
| 36 | import org.telegram.ui.ActionBar.Theme; |
| 37 | import org.telegram.ui.ActionBar.ThemeDescription; |
| 38 | import org.telegram.ui.Cells.EmptyCell; |
| 39 | import org.telegram.ui.Cells.HeaderCell; |
| 40 | import org.telegram.ui.Cells.NotificationsCheckCell; |
| 41 | import org.telegram.ui.Cells.RadioColorCell; |
| 42 | import org.telegram.ui.Cells.ShadowSectionCell; |
| 43 | import org.telegram.ui.Cells.TextCheckCell; |
| 44 | import org.telegram.ui.Cells.TextDetailSettingsCell; |
| 45 | import org.telegram.ui.Cells.TextInfoPrivacyCell; |
| 46 | import org.telegram.ui.Cells.TextSettingsCell; |
| 47 | import org.telegram.ui.Components.AlertsCreator; |
| 48 | import org.telegram.ui.Components.LayoutHelper; |
| 49 | import org.telegram.ui.Components.RecyclerListView; |
| 50 | import org.telegram.ui.Components.SeekBarView; |
| 51 | |
| 52 | import java.util.ArrayList; |
| 53 | |
| 54 | public class NekoSettingsActivity extends BaseFragment { |
| 55 | |
| 56 | private RecyclerListView listView; |
| 57 | private ListAdapter listAdapter; |
| 58 | private AnimatorSet animatorSet; |
| 59 | |
| 60 | private boolean sensitiveCanChange = false; |
| 61 | private boolean sensitiveEnabled = false; |
| 62 | |
| 63 | private int rowCount; |
| 64 | |
| 65 | private int connectionRow; |
| 66 | private int ipv6Row; |
| 67 | private int connection2Row; |
| 68 | |
| 69 | |
| 70 | private int chatRow; |
| 71 | private int inappCameraRow; |
| 72 | private int useSystemEmojiRow; |
| 73 | private int ignoreBlockedRow; |
| 74 | private int showJoinDateRow; |
| 75 | private int mapPreviewRow; |
| 76 | private int stickerSizeRow; |
| 77 | private int messageMenuRow; |
| 78 | private int chat2Row; |
| 79 | |
| 80 | private int settingsRow; |
| 81 | private int typefaceRow; |
| 82 | private int hidePhoneRow; |
| 83 | private int nameOrderRow; |
| 84 | private int transparentStatusBarRow; |
| 85 | private int hideProxySponsorChannelRow; |
| 86 | private int saveCacheToPrivateDirectoryRow; |
| 87 | private int forceTabletRow; |
| 88 | private int xmasRow; |
| 89 | private int newYearRow; |
| 90 | private int newYearEveRow; |
| 91 | private int fireworksRow; |
| 92 | private int needRestartRow; |
| 93 | |
| 94 | private int experimentRow; |
| 95 | private int disableFilteringRow; |
| 96 | private int unlimitedFavedStickersRow; |
| 97 | private int experiment2Row; |
| 98 | |
| 99 | @Override |
| 100 | public boolean onFragmentCreate() { |
| 101 | super.onFragmentCreate(); |
| 102 | |
| 103 | updateRows(false); |
| 104 | |
| 105 | return true; |
| 106 | } |
| 107 | |
| 108 | @SuppressLint("NewApi") |
| 109 | @Override |
| 110 | public View createView(Context context) { |
| 111 | actionBar.setBackButtonImage(R.drawable.ic_ab_back); |
| 112 | actionBar.setTitle(LocaleController.getString("NekoSettings", R.string.NekoSettings)); |
| 113 | |
| 114 | if (AndroidUtilities.isTablet()) { |
| 115 | actionBar.setOccupyStatusBar(false); |
| 116 | } |
| 117 | actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { |
| 118 | @Override |
| 119 | public void onItemClick(int id) { |
| 120 | if (id == -1) { |
| 121 | finishFragment(); |
| 122 | } |
| 123 | } |
| 124 | }); |
| 125 | |
| 126 | listAdapter = new ListAdapter(context); |
| 127 | |
| 128 | fragmentView = new FrameLayout(context); |
| 129 | fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray)); |
| 130 | FrameLayout frameLayout = (FrameLayout) fragmentView; |
| 131 | |
| 132 | listView = new RecyclerListView(context); |
| 133 | listView.setVerticalScrollBarEnabled(false); |
| 134 | listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) { |
| 135 | @Override |
| 136 | public boolean supportsPredictiveItemAnimations() { |
| 137 | return false; |
| 138 | } |
| 139 | }); |
| 140 | listView.setGlowColor(Theme.getColor(Theme.key_avatar_backgroundActionBarBlue)); |
| 141 | listView.setAdapter(listAdapter); |
| 142 | listView.setItemAnimator(null); |
| 143 | listView.setLayoutAnimation(null); |
| 144 | frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); |
| 145 | listView.setOnItemClickListener((view, position, x, y) -> { |
| 146 | if (position == ipv6Row) { |
| 147 | NekoConfig.toggleIPv6(); |
| 148 | if (view instanceof TextCheckCell) { |
| 149 | ((TextCheckCell) view).setChecked(NekoConfig.useIPv6); |
| 150 | } |
| 151 | for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { |
| 152 | if (UserConfig.getInstance(a).isClientActivated()) { |
| 153 | ConnectionsManager.native_setUseIpv6(a, NekoConfig.useIPv6); |
| 154 | } |
| 155 | } |
| 156 | } else if (position == hidePhoneRow) { |
| 157 | NekoConfig.toggleHidePhone(); |
| 158 | if (view instanceof TextCheckCell) { |
| 159 | ((TextCheckCell) view).setChecked(NekoConfig.hidePhone); |
| 160 | } |
| 161 | } else if (position == inappCameraRow) { |
| 162 | SharedConfig.toggleInappCamera(); |
| 163 | if (view instanceof TextCheckCell) { |
| 164 | ((TextCheckCell) view).setChecked(SharedConfig.inappCamera); |
| 165 | } |
| 166 | } else if (position == forceTabletRow) { |
| 167 | NekoConfig.toggleForceTablet(); |
| 168 | if (view instanceof TextCheckCell) { |
| 169 | ((TextCheckCell) view).setChecked(NekoConfig.forceTablet); |
| 170 | } |
| 171 | } else if (position == ignoreBlockedRow) { |
| 172 | NekoConfig.toggleIgnoreBlocked(); |
| 173 | if (view instanceof TextCheckCell) { |
| 174 | ((TextCheckCell) view).setChecked(NekoConfig.ignoreBlocked); |
| 175 | } |
| 176 | } else if (position == showJoinDateRow) { |
| 177 | NekoConfig.toggleShowJoinDate(); |
| 178 | if (view instanceof TextCheckCell) { |
| 179 | ((TextCheckCell) view).setChecked(NekoConfig.showJoinDate); |
| 180 | } |
| 181 | } else if (position == transparentStatusBarRow) { |
| 182 | NekoConfig.toggleTransparentStatusBar(); |
| 183 | if (view instanceof TextCheckCell) { |
| 184 | ((TextCheckCell) view).setChecked(NekoConfig.transparentStatusBar); |
| 185 | } |
| 186 | AndroidUtilities.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewTheme, false)); |
| 187 | } else if (position == hideProxySponsorChannelRow) { |
| 188 | NekoConfig.toggleHideProxySponsorChannel(); |
| 189 | if (view instanceof TextCheckCell) { |
| 190 | ((TextCheckCell) view).setChecked(NekoConfig.hideProxySponsorChannel); |
| 191 | } |
| 192 | for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { |
| 193 | if (UserConfig.getInstance(a).isClientActivated()) { |
| 194 | MessagesController.getInstance(a).checkProxyInfo(true); |
| 195 | } |
| 196 | } |
| 197 | } else if (position == saveCacheToPrivateDirectoryRow) { |
| 198 | NekoConfig.toggleSaveCacheToPrivateDirectory(); |
| 199 | if (view instanceof TextCheckCell) { |
| 200 | ((TextCheckCell) view).setChecked(NekoConfig.saveCacheToPrivateDirectory); |
| 201 | } |
| 202 | } else if (position == useSystemEmojiRow) { |
| 203 | SharedConfig.useSystemEmoji = !SharedConfig.useSystemEmoji; |
| 204 | SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit(); |
| 205 | editor.putBoolean("useSystemEmoji", SharedConfig.useSystemEmoji); |
| 206 | editor.commit(); |
| 207 | if (view instanceof TextCheckCell) { |
| 208 | ((TextCheckCell) view).setChecked(SharedConfig.useSystemEmoji); |
| 209 | } |
| 210 | } else if (position == typefaceRow) { |
| 211 | NekoConfig.toggleTypeface(); |
| 212 | if (view instanceof TextCheckCell) { |
| 213 | ((TextCheckCell) view).setChecked(NekoConfig.typeface == 1); |
| 214 | } |
| 215 | } else if (position == mapPreviewRow) { |
| 216 | ArrayList<String> arrayList = new ArrayList<>(); |
| 217 | ArrayList<Integer> types = new ArrayList<>(); |
| 218 | arrayList.add(LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram)); |
| 219 | types.add(0); |
| 220 | arrayList.add(LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex)); |
| 221 | types.add(1); |
| 222 | arrayList.add(LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody)); |
| 223 | types.add(2); |
| 224 | |
| 225 | AlertDialog.Builder builder = new AlertDialog.Builder(context); |
| 226 | builder.setTitle(LocaleController.getString("MapPreviewProviderTitle", R.string.MapPreviewProviderTitle)); |
| 227 | final LinearLayout linearLayout = new LinearLayout(context); |
| 228 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 229 | builder.setView(linearLayout); |
| 230 | |
| 231 | for (int a = 0; a < arrayList.size(); a++) { |
| 232 | RadioColorCell cell = new RadioColorCell(context); |
| 233 | cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); |
| 234 | cell.setTag(a); |
| 235 | cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); |
| 236 | cell.setTextAndValue(arrayList.get(a), NekoConfig.mapPreviewProvider == types.get(a)); |
| 237 | linearLayout.addView(cell); |
| 238 | cell.setOnClickListener(v -> { |
| 239 | Integer which = (Integer) v.getTag(); |
| 240 | NekoConfig.setMapPreviewProvider(types.get(which)); |
| 241 | listAdapter.notifyItemChanged(mapPreviewRow); |
| 242 | builder.getDismissRunnable().run(); |
| 243 | }); |
| 244 | } |
| 245 | builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); |
| 246 | showDialog(builder.create()); |
| 247 | } else if (position == nameOrderRow) { |
| 248 | ArrayList<String> arrayList = new ArrayList<>(); |
| 249 | ArrayList<Integer> types = new ArrayList<>(); |
| 250 | arrayList.add(LocaleController.getString("FirstLast", R.string.FirstLast)); |
| 251 | types.add(1); |
| 252 | arrayList.add(LocaleController.getString("LastFirst", R.string.LastFirst)); |
| 253 | types.add(2); |
| 254 | |
| 255 | AlertDialog.Builder builder = new AlertDialog.Builder(context); |
| 256 | builder.setTitle(LocaleController.getString("NameOrder", R.string.NameOrder)); |
| 257 | final LinearLayout linearLayout = new LinearLayout(context); |
| 258 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 259 | builder.setView(linearLayout); |
| 260 | |
| 261 | for (int a = 0; a < arrayList.size(); a++) { |
| 262 | RadioColorCell cell = new RadioColorCell(context); |
| 263 | cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); |
| 264 | cell.setTag(a); |
| 265 | cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); |
| 266 | cell.setTextAndValue(arrayList.get(a), NekoConfig.nameOrder == types.get(a)); |
| 267 | linearLayout.addView(cell); |
| 268 | cell.setOnClickListener(v -> { |
| 269 | Integer which = (Integer) v.getTag(); |
| 270 | NekoConfig.setNameOrder(types.get(which)); |
| 271 | listAdapter.notifyItemChanged(nameOrderRow); |
| 272 | builder.getDismissRunnable().run(); |
| 273 | }); |
| 274 | } |
| 275 | builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); |
| 276 | showDialog(builder.create()); |
| 277 | } else if (position == xmasRow) { |
| 278 | NekoConfig.toggleXmas(); |
| 279 | if (view instanceof TextCheckCell) { |
| 280 | ((TextCheckCell) view).setChecked(NekoConfig.xmas); |
| 281 | } |
| 282 | } else if (position == newYearRow) { |
| 283 | NekoConfig.toggleNewYear(); |
| 284 | if (view instanceof TextCheckCell) { |
| 285 | ((TextCheckCell) view).setChecked(NekoConfig.newYear); |
| 286 | } |
| 287 | } else if (position == newYearEveRow) { |
| 288 | NekoConfig.toggleNewYearEve(); |
| 289 | if (view instanceof TextCheckCell) { |
| 290 | ((TextCheckCell) view).setChecked(NekoConfig.newYearEve); |
| 291 | } |
| 292 | } else if (position == fireworksRow) { |
| 293 | NekoConfig.toggleFireworks(); |
| 294 | if (view instanceof TextCheckCell) { |
| 295 | ((TextCheckCell) view).setChecked(NekoConfig.fireworks); |
| 296 | } |
| 297 | } else if (position == disableFilteringRow) { |
| 298 | sensitiveEnabled = !sensitiveEnabled; |
| 299 | TLRPC.TL_account_setContentSettings req = new TLRPC.TL_account_setContentSettings(); |
| 300 | req.sensitive_enabled = sensitiveEnabled; |
| 301 | AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3); |
| 302 | progressDialog.show(); |
| 303 | getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { |
| 304 | progressDialog.dismiss(); |
| 305 | if (error == null) { |
| 306 | if (response instanceof TLRPC.TL_boolTrue && view instanceof TextCheckCell) { |
| 307 | ((TextCheckCell) view).setChecked(sensitiveEnabled); |
| 308 | } |
| 309 | } else { |
| 310 | AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, this, req)); |
| 311 | } |
| 312 | })); |
| 313 | } else if (position == stickerSizeRow) { |
| 314 | showStickerSizeAlert(); |
| 315 | } else if (position == unlimitedFavedStickersRow) { |
| 316 | NekoConfig.toggleUnlimitedFavedStickers(); |
| 317 | if (view instanceof TextCheckCell) { |
| 318 | ((TextCheckCell) view).setChecked(NekoConfig.unlimitedFavedStickers); |
| 319 | } |
| 320 | } else if (position == messageMenuRow) { |
| 321 | showMessageMenuAlert(); |
| 322 | } |
| 323 | }); |
| 324 | |
| 325 | return fragmentView; |
| 326 | } |
| 327 | |
| 328 | @Override |
| 329 | public void onResume() { |
| 330 | super.onResume(); |
| 331 | if (listAdapter != null) { |
| 332 | checkSensitive(); |
| 333 | listAdapter.notifyDataSetChanged(); |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | private void updateRows(boolean notify) { |
| 338 | rowCount = 0; |
| 339 | connectionRow = rowCount++; |
| 340 | ipv6Row = rowCount++; |
| 341 | connection2Row = rowCount++; |
| 342 | chatRow = rowCount++; |
| 343 | inappCameraRow = rowCount++; |
| 344 | useSystemEmojiRow = rowCount++; |
| 345 | ignoreBlockedRow = rowCount++; |
| 346 | showJoinDateRow = rowCount++; |
| 347 | hideProxySponsorChannelRow = rowCount++; |
| 348 | saveCacheToPrivateDirectoryRow = Build.VERSION.SDK_INT >= 24 ? rowCount++ : -1; |
| 349 | mapPreviewRow = rowCount++; |
| 350 | stickerSizeRow = rowCount++; |
| 351 | messageMenuRow = rowCount++; |
| 352 | chat2Row = rowCount++; |
| 353 | settingsRow = rowCount++; |
| 354 | hidePhoneRow = rowCount++; |
| 355 | typefaceRow = rowCount++; |
| 356 | transparentStatusBarRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? rowCount++ : -1; |
| 357 | forceTabletRow = rowCount++; |
| 358 | nameOrderRow = rowCount++; |
| 359 | xmasRow = rowCount++; |
| 360 | newYearRow = rowCount++; |
| 361 | newYearEveRow = rowCount++; |
| 362 | fireworksRow = rowCount++; |
| 363 | needRestartRow = rowCount++; |
| 364 | experimentRow = rowCount++; |
| 365 | disableFilteringRow = rowCount++; |
| 366 | unlimitedFavedStickersRow = rowCount++; |
| 367 | experiment2Row = rowCount++; |
| 368 | if (notify && listAdapter != null) { |
| 369 | listAdapter.notifyDataSetChanged(); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | @Override |
| 374 | public ThemeDescription[] getThemeDescriptions() { |
| 375 | return new ThemeDescription[]{ |
| 376 | 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), |
| 377 | new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray), |
| 378 | |
| 379 | new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue), |
| 380 | new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue), |
| 381 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_avatar_actionBarIconBlue), |
| 382 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle), |
| 383 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_avatar_actionBarSelectorBlue), |
| 384 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, null, Theme.key_actionBarDefaultSubmenuBackground), |
| 385 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, null, Theme.key_actionBarDefaultSubmenuItem), |
| 386 | |
| 387 | new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector), |
| 388 | |
| 389 | new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider), |
| 390 | |
| 391 | new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow), |
| 392 | |
| 393 | new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 394 | new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteValueText), |
| 395 | |
| 396 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 397 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), |
| 398 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack), |
| 399 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked), |
| 400 | |
| 401 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 402 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), |
| 403 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack), |
| 404 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked), |
| 405 | |
| 406 | new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader), |
| 407 | |
| 408 | new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 409 | new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), |
| 410 | }; |
| 411 | } |
| 412 | |
| 413 | private void checkSensitive() { |
| 414 | TLRPC.TL_account_getContentSettings req = new TLRPC.TL_account_getContentSettings(); |
| 415 | getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { |
| 416 | if (error == null) { |
| 417 | TLRPC.TL_account_contentSettings settings = (TLRPC.TL_account_contentSettings) response; |
| 418 | sensitiveEnabled = settings.sensitive_enabled; |
| 419 | sensitiveCanChange = settings.sensitive_can_change; |
| 420 | int count = listView.getChildCount(); |
| 421 | ArrayList<Animator> animators = new ArrayList<>(); |
| 422 | for (int a = 0; a < count; a++) { |
| 423 | View child = listView.getChildAt(a); |
| 424 | RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.getChildViewHolder(child); |
| 425 | int position = holder.getAdapterPosition(); |
| 426 | if (position == disableFilteringRow) { |
| 427 | TextCheckCell checkCell = (TextCheckCell) holder.itemView; |
| 428 | checkCell.setChecked(sensitiveEnabled); |
| 429 | checkCell.setEnabled(sensitiveCanChange, animators); |
| 430 | if (sensitiveCanChange) { |
| 431 | if (!animators.isEmpty()) { |
| 432 | if (animatorSet != null) { |
| 433 | animatorSet.cancel(); |
| 434 | } |
| 435 | animatorSet = new AnimatorSet(); |
| 436 | animatorSet.playTogether(animators); |
| 437 | animatorSet.addListener(new AnimatorListenerAdapter() { |
| 438 | @Override |
| 439 | public void onAnimationEnd(Animator animator) { |
| 440 | if (animator.equals(animatorSet)) { |
| 441 | animatorSet = null; |
| 442 | } |
| 443 | } |
| 444 | }); |
| 445 | animatorSet.setDuration(150); |
| 446 | animatorSet.start(); |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | } |
| 451 | } |
| 452 | } else { |
| 453 | AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, this, req)); |
| 454 | } |
| 455 | })); |
| 456 | } |
| 457 | |
| 458 | private void showMessageMenuAlert() { |
| 459 | if (getParentActivity() == null) { |
| 460 | return; |
| 461 | } |
| 462 | Context context = getParentActivity(); |
| 463 | AlertDialog.Builder builder = new AlertDialog.Builder(context); |
| 464 | builder.setTitle(LocaleController.getString("MessageMenu", R.string.MessageMenu)); |
| 465 | |
| 466 | LinearLayout linearLayout = new LinearLayout(context); |
| 467 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 468 | |
| 469 | LinearLayout linearLayoutInviteContainer = new LinearLayout(context); |
| 470 | linearLayoutInviteContainer.setOrientation(LinearLayout.VERTICAL); |
| 471 | linearLayout.addView(linearLayoutInviteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); |
| 472 | |
| 473 | int count = 9; |
| 474 | for (int a = 0; a < count; a++) { |
| 475 | TextCheckCell textCell = new TextCheckCell(context); |
| 476 | switch (a) { |
| 477 | case 0: { |
| 478 | textCell.setTextAndCheck(LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages), NekoConfig.showAddToSavedMessages, false); |
| 479 | break; |
| 480 | } |
| 481 | case 1: { |
| 482 | textCell.setTextAndCheck(LocaleController.getString("Prpr", R.string.Prpr), NekoConfig.showPrPr, false); |
| 483 | break; |
| 484 | } |
| 485 | case 2: { |
| 486 | textCell.setTextAndCheck(LocaleController.getString("ViewHistory", R.string.ViewHistory), NekoConfig.showViewHistory, false); |
| 487 | break; |
| 488 | } |
| 489 | case 3: { |
| 490 | textCell.setTextAndCheck(LocaleController.getString("ReportChat", R.string.ReportChat), NekoConfig.showReport, false); |
| 491 | break; |
| 492 | } |
| 493 | case 4: { |
| 494 | textCell.setTextAndCheck(LocaleController.getString("EditAdminRights", R.string.EditAdminRights), NekoConfig.showAdminActions, false); |
| 495 | break; |
| 496 | } |
| 497 | case 5: { |
| 498 | textCell.setTextAndCheck(LocaleController.getString("ChangePermissions", R.string.ChangePermissions), NekoConfig.showChangePermissions, false); |
| 499 | break; |
| 500 | } |
| 501 | case 6: { |
| 502 | textCell.setTextAndCheck(LocaleController.getString("DeleteDownloadedFile", R.string.DeleteDownloadedFile), NekoConfig.showDeleteDownloadedFile, false); |
| 503 | break; |
| 504 | } |
| 505 | case 7: { |
| 506 | textCell.setTextAndCheck(LocaleController.getString("MessageDetails", R.string.MessageDetails), NekoConfig.showMessageDetails, false); |
| 507 | break; |
| 508 | } |
| 509 | case 8: { |
| 510 | textCell.setTextAndValueAndCheck(LocaleController.getString("Translate", R.string.Translate), LocaleController.getString("ServiceByGoogle", R.string.ServiceByGoogle), NekoConfig.showTranslate, false, false); |
| 511 | break; |
| 512 | } |
| 513 | } |
| 514 | textCell.setTag(a); |
| 515 | textCell.setBackgroundDrawable(Theme.getSelectorDrawable(false)); |
| 516 | linearLayoutInviteContainer.addView(textCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); |
| 517 | textCell.setOnClickListener(v2 -> { |
| 518 | Integer tag = (Integer) v2.getTag(); |
| 519 | switch (tag) { |
| 520 | case 0: { |
| 521 | NekoConfig.toggleShowAddToSavedMessages(); |
| 522 | textCell.setChecked(NekoConfig.showAddToSavedMessages); |
| 523 | break; |
| 524 | } |
| 525 | case 1: { |
| 526 | NekoConfig.toggleShowPrPr(); |
| 527 | textCell.setChecked(NekoConfig.showPrPr); |
| 528 | break; |
| 529 | } |
| 530 | case 2: { |
| 531 | NekoConfig.toggleShowViewHistory(); |
| 532 | textCell.setChecked(NekoConfig.showViewHistory); |
| 533 | break; |
| 534 | } |
| 535 | case 3: { |
| 536 | NekoConfig.toggleShowReport(); |
| 537 | textCell.setChecked(NekoConfig.showReport); |
| 538 | break; |
| 539 | } |
| 540 | case 4: { |
| 541 | NekoConfig.toggleShowAdminActions(); |
| 542 | textCell.setChecked(NekoConfig.showAdminActions); |
| 543 | break; |
| 544 | } |
| 545 | case 5: { |
| 546 | NekoConfig.toggleShowChangePermissions(); |
| 547 | textCell.setChecked(NekoConfig.showChangePermissions); |
| 548 | break; |
| 549 | } |
| 550 | case 6: { |
| 551 | NekoConfig.toggleShowDeleteDownloadedFile(); |
| 552 | textCell.setChecked(NekoConfig.showDeleteDownloadedFile); |
| 553 | break; |
| 554 | } |
| 555 | case 7: { |
| 556 | NekoConfig.toggleShowMessageDetails(); |
| 557 | textCell.setChecked(NekoConfig.showMessageDetails); |
| 558 | break; |
| 559 | } |
| 560 | case 8: { |
| 561 | NekoConfig.toggleShowTranslate(); |
| 562 | textCell.setChecked(NekoConfig.showTranslate); |
| 563 | break; |
| 564 | } |
| 565 | } |
| 566 | }); |
| 567 | } |
| 568 | builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); |
| 569 | builder.setView(linearLayout); |
| 570 | showDialog(builder.create()); |
| 571 | } |
| 572 | |
| 573 | private void showStickerSizeAlert() { |
| 574 | if (getParentActivity() == null) { |
| 575 | return; |
| 576 | } |
| 577 | Context context = getParentActivity(); |
| 578 | BottomSheet.Builder builder = new BottomSheet.Builder(context); |
| 579 | builder.setApplyTopPadding(false); |
| 580 | builder.setApplyBottomPadding(false); |
| 581 | |
| 582 | LinearLayout linearLayout = new LinearLayout(context); |
| 583 | linearLayout.setOrientation(LinearLayout.VERTICAL); |
| 584 | |
| 585 | FrameLayout titleLayout = new FrameLayout(context); |
| 586 | linearLayout.addView(titleLayout); |
| 587 | |
| 588 | HeaderCell headerCell = new HeaderCell(context, true, 23, 15, false); |
| 589 | headerCell.setHeight(47); |
| 590 | headerCell.setText(LocaleController.getString("StickerSize", R.string.StickerSize)); |
| 591 | titleLayout.addView(headerCell); |
| 592 | |
| 593 | ActionBarMenuItem optionsButton = new ActionBarMenuItem(context, null, 0, Theme.getColor(Theme.key_sheet_other)); |
| 594 | optionsButton.setLongClickEnabled(false); |
| 595 | optionsButton.setSubMenuOpenSide(2); |
| 596 | optionsButton.setIcon(R.drawable.ic_ab_other); |
| 597 | optionsButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_player_actionBarSelector), 1)); |
| 598 | optionsButton.addSubItem(1, R.drawable.msg_reset, LocaleController.getString("Reset", R.string.Reset)); |
| 599 | optionsButton.setOnClickListener(v -> optionsButton.toggleSubMenu()); |
| 600 | optionsButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions)); |
| 601 | titleLayout.addView(optionsButton, LayoutHelper.createFrame(40, 40, Gravity.TOP | Gravity.RIGHT, 0, 8, 5, 0)); |
| 602 | |
| 603 | LinearLayout linearLayoutInviteContainer = new LinearLayout(context); |
| 604 | linearLayoutInviteContainer.setOrientation(LinearLayout.VERTICAL); |
| 605 | linearLayout.addView(linearLayoutInviteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); |
| 606 | StickerSizeCell stickerSizeCell = new StickerSizeCell(context); |
| 607 | optionsButton.setDelegate(id -> { |
| 608 | if (id == 1) { |
| 609 | NekoConfig.setStickerSize(14.0f); |
| 610 | stickerSizeCell.invalidate(); |
| 611 | } |
| 612 | }); |
| 613 | linearLayoutInviteContainer.addView(stickerSizeCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); |
| 614 | builder.setCustomView(linearLayout); |
| 615 | showDialog(builder.create()); |
| 616 | } |
| 617 | |
| 618 | private class StickerSizeCell extends FrameLayout { |
| 619 | |
| 620 | private StickerSizePreviewMessagesCell messagesCell; |
| 621 | private SeekBarView sizeBar; |
| 622 | private int startStickerSize = 2; |
| 623 | private int endStickerSize = 20; |
| 624 | |
| 625 | private TextPaint textPaint; |
| 626 | |
| 627 | public StickerSizeCell(Context context) { |
| 628 | super(context); |
| 629 | |
| 630 | setWillNotDraw(false); |
| 631 | |
| 632 | textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); |
| 633 | textPaint.setTextSize(AndroidUtilities.dp(16)); |
| 634 | |
| 635 | sizeBar = new SeekBarView(context); |
| 636 | sizeBar.setReportChanges(true); |
| 637 | sizeBar.setDelegate(new SeekBarView.SeekBarViewDelegate() { |
| 638 | @Override |
| 639 | public void onSeekBarDrag(boolean stop, float progress) { |
| 640 | NekoConfig.setStickerSize(startStickerSize + (endStickerSize - startStickerSize) * progress); |
| 641 | StickerSizeCell.this.invalidate(); |
| 642 | } |
| 643 | |
| 644 | @Override |
| 645 | public void onSeekBarPressed(boolean pressed) { |
| 646 | |
| 647 | } |
| 648 | }); |
| 649 | addView(sizeBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.LEFT | Gravity.TOP, 9, 5, 43, 11)); |
| 650 | |
| 651 | messagesCell = new StickerSizePreviewMessagesCell(context, parentLayout); |
| 652 | addView(messagesCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 53, 0, 0)); |
| 653 | } |
| 654 | |
| 655 | @Override |
| 656 | protected void onDraw(Canvas canvas) { |
| 657 | textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText)); |
| 658 | canvas.drawText("" + Math.round(NekoConfig.stickerSize), getMeasuredWidth() - AndroidUtilities.dp(39), AndroidUtilities.dp(28), textPaint); |
| 659 | } |
| 660 | |
| 661 | @Override |
| 662 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 663 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 664 | sizeBar.setProgress((NekoConfig.stickerSize - startStickerSize) / (float) (endStickerSize - startStickerSize)); |
| 665 | } |
| 666 | |
| 667 | @Override |
| 668 | public void invalidate() { |
| 669 | super.invalidate(); |
| 670 | listAdapter.notifyItemChanged(stickerSizeRow); |
| 671 | messagesCell.invalidate(); |
| 672 | sizeBar.invalidate(); |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | private class ListAdapter extends RecyclerListView.SelectionAdapter { |
| 677 | |
| 678 | private Context mContext; |
| 679 | |
| 680 | public ListAdapter(Context context) { |
| 681 | mContext = context; |
| 682 | } |
| 683 | |
| 684 | @Override |
| 685 | public int getItemCount() { |
| 686 | return rowCount; |
| 687 | } |
| 688 | |
| 689 | @Override |
| 690 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { |
| 691 | switch (holder.getItemViewType()) { |
| 692 | case 1: { |
| 693 | if (position == experiment2Row) { |
| 694 | holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); |
| 695 | } else { |
| 696 | holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); |
| 697 | } |
| 698 | break; |
| 699 | } |
| 700 | case 2: { |
| 701 | TextSettingsCell textCell = (TextSettingsCell) holder.itemView; |
| 702 | if (position == nameOrderRow) { |
| 703 | String value; |
| 704 | switch (NekoConfig.nameOrder) { |
| 705 | case 2: |
| 706 | value = LocaleController.getString("LastFirst", R.string.LastFirst); |
| 707 | break; |
| 708 | case 1: |
| 709 | default: |
| 710 | value = LocaleController.getString("FirstLast", R.string.FirstLast); |
| 711 | break; |
| 712 | } |
| 713 | textCell.setTextAndValue(LocaleController.getString("NameOrder", R.string.NameOrder), value, true); |
| 714 | } else if (position == mapPreviewRow) { |
| 715 | String value; |
| 716 | switch (NekoConfig.mapPreviewProvider) { |
| 717 | case 0: |
| 718 | value = LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram); |
| 719 | break; |
| 720 | case 1: |
| 721 | value = LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex); |
| 722 | break; |
| 723 | case 2: |
| 724 | default: |
| 725 | value = LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody); |
| 726 | } |
| 727 | textCell.setTextAndValue(LocaleController.getString("MapPreviewProvider", R.string.MapPreviewProvider), value, true); |
| 728 | } else if (position == stickerSizeRow) { |
| 729 | textCell.setTextAndValue(LocaleController.getString("StickerSize", R.string.StickerSize), String.valueOf(Math.round(NekoConfig.stickerSize)), true); |
| 730 | } else if (position == messageMenuRow) { |
| 731 | textCell.setText(LocaleController.getString("MessageMenu", R.string.MessageMenu), false); |
| 732 | } |
| 733 | break; |
| 734 | } |
| 735 | case 3: { |
| 736 | TextCheckCell textCell = (TextCheckCell) holder.itemView; |
| 737 | if (position == ipv6Row) { |
| 738 | textCell.setTextAndCheck(LocaleController.getString("IPv6", R.string.IPv6), NekoConfig.useIPv6, false); |
| 739 | } else if (position == hidePhoneRow) { |
| 740 | textCell.setTextAndCheck(LocaleController.getString("HidePhone", R.string.HidePhone), NekoConfig.hidePhone, true); |
| 741 | } else if (position == inappCameraRow) { |
| 742 | textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableCamera", R.string.DebugMenuEnableCamera), SharedConfig.inappCamera, true); |
| 743 | } else if (position == transparentStatusBarRow) { |
| 744 | textCell.setTextAndCheck(LocaleController.getString("TransparentStatusBar", R.string.TransparentStatusBar), NekoConfig.transparentStatusBar, true); |
| 745 | } else if (position == hideProxySponsorChannelRow) { |
| 746 | textCell.setTextAndCheck(LocaleController.getString("HideProxySponsorChannel", R.string.HideProxySponsorChannel), NekoConfig.hideProxySponsorChannel, true); |
| 747 | } else if (position == saveCacheToPrivateDirectoryRow) { |
| 748 | textCell.setTextAndCheck(LocaleController.getString("SaveCacheToPrivateDirectory", R.string.SaveCacheToPrivateDirectory), NekoConfig.saveCacheToPrivateDirectory, true); |
| 749 | } else if (position == useSystemEmojiRow) { |
| 750 | textCell.setTextAndCheck(LocaleController.getString("EmojiUseDefault", R.string.EmojiUseDefault), SharedConfig.useSystemEmoji, true); |
| 751 | } else if (position == typefaceRow) { |
| 752 | textCell.setTextAndCheck(LocaleController.getString("TypefaceUseDefault", R.string.TypefaceUseDefault), NekoConfig.typeface == 1, true); |
| 753 | } else if (position == ignoreBlockedRow) { |
| 754 | textCell.setTextAndCheck(LocaleController.getString("IgnoreBlocked", R.string.IgnoreBlocked), NekoConfig.ignoreBlocked, true); |
| 755 | } else if (position == showJoinDateRow) { |
| 756 | textCell.setTextAndCheck(LocaleController.getString("ShowJoinDate", R.string.ShowJoinDate), NekoConfig.showJoinDate, true); |
| 757 | } else if (position == forceTabletRow) { |
| 758 | textCell.setTextAndCheck(LocaleController.getString("ForceTabletMode", R.string.ForceTabletMode), NekoConfig.forceTablet, true); |
| 759 | } else if (position == xmasRow) { |
| 760 | textCell.setTextAndCheck(LocaleController.getString("ChristmasEveryday", R.string.ChristmasEveryday), NekoConfig.xmas, true); |
| 761 | } else if (position == newYearRow) { |
| 762 | textCell.setTextAndCheck(LocaleController.getString("NewYearEveryday", R.string.NewYearEveryday), NekoConfig.newYear, true); |
| 763 | } else if (position == newYearEveRow) { |
| 764 | textCell.setTextAndCheck(LocaleController.getString("HappyNewYearEveryday", R.string.HappyNewYearEveryday), NekoConfig.newYearEve, true); |
| 765 | } else if (position == fireworksRow) { |
| 766 | textCell.setTextAndCheck(LocaleController.getString("ShowFireworks", R.string.ShowFireworks), NekoConfig.fireworks, false); |
| 767 | } else if (position == disableFilteringRow) { |
| 768 | textCell.setTextAndValueAndCheck(LocaleController.getString("SensitiveDisableFiltering", R.string.SensitiveDisableFiltering), LocaleController.getString("SensitiveAbout", R.string.SensitiveAbout), sensitiveEnabled, true, true); |
| 769 | textCell.setEnabled(sensitiveCanChange, null); |
| 770 | } else if (position == unlimitedFavedStickersRow) { |
| 771 | textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedFavoredStickers", R.string.UnlimitedFavoredStickers), LocaleController.getString("UnlimitedFavoredStickersAbout", R.string.UnlimitedFavoredStickersAbout), NekoConfig.unlimitedFavedStickers, true, false); |
| 772 | } |
| 773 | break; |
| 774 | } |
| 775 | case 4: { |
| 776 | HeaderCell headerCell = (HeaderCell) holder.itemView; |
| 777 | if (position == settingsRow) { |
| 778 | headerCell.setText(LocaleController.getString("General", R.string.General)); |
| 779 | } else if (position == connectionRow) { |
| 780 | headerCell.setText(LocaleController.getString("Connection", R.string.Connection)); |
| 781 | } else if (position == chatRow) { |
| 782 | headerCell.setText(LocaleController.getString("Chat", R.string.Chat)); |
| 783 | } else if (position == experimentRow) { |
| 784 | headerCell.setText(LocaleController.getString("Experiment", R.string.Experiment)); |
| 785 | } |
| 786 | break; |
| 787 | } |
| 788 | case 7: { |
| 789 | TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView; |
| 790 | if (position == needRestartRow) { |
| 791 | cell.setText(LocaleController.getString("SomeItemsNeedRestart", R.string.SomeItemsNeedRestart)); |
| 792 | } |
| 793 | break; |
| 794 | } |
| 795 | } |
| 796 | } |
| 797 | |
| 798 | @Override |
| 799 | public boolean isEnabled(RecyclerView.ViewHolder holder) { |
| 800 | int position = holder.getAdapterPosition(); |
| 801 | return position == hidePhoneRow || position == inappCameraRow || position == ignoreBlockedRow || position == showJoinDateRow || |
| 802 | position == useSystemEmojiRow || position == ipv6Row || position == typefaceRow || position == nameOrderRow || |
| 803 | position == forceTabletRow || position == mapPreviewRow || position == xmasRow || position == newYearRow || |
| 804 | position == newYearEveRow || position == fireworksRow || position == transparentStatusBarRow || |
| 805 | position == hideProxySponsorChannelRow || position == saveCacheToPrivateDirectoryRow || |
| 806 | (position == disableFilteringRow && sensitiveCanChange) || position == stickerSizeRow || |
| 807 | position == unlimitedFavedStickersRow || position == messageMenuRow; |
| 808 | } |
| 809 | |
| 810 | @Override |
| 811 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
| 812 | View view = null; |
| 813 | switch (viewType) { |
| 814 | case 1: |
| 815 | view = new ShadowSectionCell(mContext); |
| 816 | break; |
| 817 | case 2: |
| 818 | view = new TextSettingsCell(mContext); |
| 819 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 820 | break; |
| 821 | case 3: |
| 822 | view = new TextCheckCell(mContext); |
| 823 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 824 | break; |
| 825 | case 4: |
| 826 | view = new HeaderCell(mContext); |
| 827 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 828 | break; |
| 829 | case 5: |
| 830 | view = new NotificationsCheckCell(mContext); |
| 831 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 832 | break; |
| 833 | case 6: |
| 834 | view = new TextDetailSettingsCell(mContext); |
| 835 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 836 | break; |
| 837 | case 7: |
| 838 | view = new TextInfoPrivacyCell(mContext); |
| 839 | view.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); |
| 840 | break; |
| 841 | } |
| 842 | view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT)); |
| 843 | return new RecyclerListView.Holder(view); |
| 844 | } |
| 845 | |
| 846 | @Override |
| 847 | public int getItemViewType(int position) { |
| 848 | if (position == connection2Row || position == chat2Row || position == experiment2Row) { |
| 849 | return 1; |
| 850 | } else if (position == nameOrderRow || position == mapPreviewRow || position == stickerSizeRow || position == messageMenuRow) { |
| 851 | return 2; |
| 852 | } else if (position == ipv6Row || position == hidePhoneRow || position == inappCameraRow || |
| 853 | position == transparentStatusBarRow || position == hideProxySponsorChannelRow || |
| 854 | position == ignoreBlockedRow || position == showJoinDateRow || position == useSystemEmojiRow || position == typefaceRow || |
| 855 | position == forceTabletRow || position == xmasRow || position == newYearRow || position == newYearEveRow || |
| 856 | position == fireworksRow || position == saveCacheToPrivateDirectoryRow || position == unlimitedFavedStickersRow || |
| 857 | position == disableFilteringRow) { |
| 858 | return 3; |
| 859 | } else if (position == settingsRow || position == connectionRow || position == chatRow || position == experimentRow) { |
| 860 | return 4; |
| 861 | } else if (position == needRestartRow) { |
| 862 | return 7; |
| 863 | } |
| 864 | return 6; |
| 865 | } |
| 866 | } |
| 867 | } |
| 868 | |