| 1 | package tw.nekomimi.nekogram; |
| 2 | |
| 3 | import android.annotation.SuppressLint; |
| 4 | import android.content.Context; |
| 5 | import android.content.DialogInterface; |
| 6 | import android.content.SharedPreferences; |
| 7 | import android.os.Build; |
| 8 | import android.util.TypedValue; |
| 9 | import android.view.Gravity; |
| 10 | import android.view.View; |
| 11 | import android.view.ViewGroup; |
| 12 | import android.view.inputmethod.EditorInfo; |
| 13 | import android.widget.FrameLayout; |
| 14 | |
| 15 | import androidx.recyclerview.widget.LinearLayoutManager; |
| 16 | import androidx.recyclerview.widget.RecyclerView; |
| 17 | |
| 18 | import org.telegram.messenger.AndroidUtilities; |
| 19 | import org.telegram.messenger.ApplicationLoader; |
| 20 | import org.telegram.messenger.BuildVars; |
| 21 | import org.telegram.messenger.FileLog; |
| 22 | import org.telegram.messenger.LocaleController; |
| 23 | import org.telegram.messenger.MessagesController; |
| 24 | import org.telegram.messenger.R; |
| 25 | import org.telegram.messenger.SharedConfig; |
| 26 | import org.telegram.messenger.UserConfig; |
| 27 | import org.telegram.tgnet.ConnectionsManager; |
| 28 | import org.telegram.ui.ActionBar.ActionBar; |
| 29 | import org.telegram.ui.ActionBar.AlertDialog; |
| 30 | import org.telegram.ui.ActionBar.BaseFragment; |
| 31 | import org.telegram.ui.ActionBar.Theme; |
| 32 | import org.telegram.ui.ActionBar.ThemeDescription; |
| 33 | import org.telegram.ui.Cells.EmptyCell; |
| 34 | import org.telegram.ui.Cells.HeaderCell; |
| 35 | import org.telegram.ui.Cells.NotificationsCheckCell; |
| 36 | import org.telegram.ui.Cells.ShadowSectionCell; |
| 37 | import org.telegram.ui.Cells.TextCell; |
| 38 | import org.telegram.ui.Cells.TextCheckCell; |
| 39 | import org.telegram.ui.Cells.TextDetailSettingsCell; |
| 40 | import org.telegram.ui.Cells.TextSettingsCell; |
| 41 | import org.telegram.ui.Components.EditTextBoldCursor; |
| 42 | import org.telegram.ui.Components.LayoutHelper; |
| 43 | import org.telegram.ui.Components.RecyclerListView; |
| 44 | |
| 45 | public class NekoSettingsActivity extends BaseFragment { |
| 46 | |
| 47 | private RecyclerListView listView; |
| 48 | private ListAdapter listAdapter; |
| 49 | |
| 50 | private int rowCount; |
| 51 | |
| 52 | private int connectionRow; |
| 53 | private int ipv6Row; |
| 54 | private int connection2Row; |
| 55 | |
| 56 | private int emojiRow; |
| 57 | private int useSystemEmojiRow; |
| 58 | private int singleBigEmojiRow; |
| 59 | private int emoji2Row; |
| 60 | |
| 61 | private int chatRow; |
| 62 | private int ignoreBlockedRow; |
| 63 | private int chat2Row; |
| 64 | |
| 65 | private int settingsRow; |
| 66 | private int hidePhoneRow; |
| 67 | private int inappCameraRow; |
| 68 | private int nameOrderRow; |
| 69 | private int transparentStatusBarRow; |
| 70 | private int navigationBarTintRow; |
| 71 | private int navigationBarColorRow; |
| 72 | private int forceTabletRow; |
| 73 | private int settings2Row; |
| 74 | |
| 75 | @Override |
| 76 | public boolean onFragmentCreate() { |
| 77 | super.onFragmentCreate(); |
| 78 | |
| 79 | updateRows(false); |
| 80 | |
| 81 | return true; |
| 82 | } |
| 83 | |
| 84 | @SuppressLint("NewApi") |
| 85 | @Override |
| 86 | public View createView(Context context) { |
| 87 | actionBar.setBackButtonImage(R.drawable.ic_ab_back); |
| 88 | actionBar.setTitle(LocaleController.getString("NekoSettings", R.string.NekoSettings)); |
| 89 | |
| 90 | if (AndroidUtilities.isTablet()) { |
| 91 | actionBar.setOccupyStatusBar(false); |
| 92 | } |
| 93 | actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { |
| 94 | @Override |
| 95 | public void onItemClick(int id) { |
| 96 | if (id == -1) { |
| 97 | finishFragment(); |
| 98 | } |
| 99 | } |
| 100 | }); |
| 101 | |
| 102 | listAdapter = new ListAdapter(context); |
| 103 | |
| 104 | fragmentView = new FrameLayout(context); |
| 105 | fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray)); |
| 106 | FrameLayout frameLayout = (FrameLayout) fragmentView; |
| 107 | |
| 108 | listView = new RecyclerListView(context); |
| 109 | listView.setVerticalScrollBarEnabled(false); |
| 110 | listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) { |
| 111 | @Override |
| 112 | public boolean supportsPredictiveItemAnimations() { |
| 113 | return false; |
| 114 | } |
| 115 | }); |
| 116 | listView.setGlowColor(Theme.getColor(Theme.key_avatar_backgroundActionBarBlue)); |
| 117 | listView.setAdapter(listAdapter); |
| 118 | listView.setItemAnimator(null); |
| 119 | listView.setLayoutAnimation(null); |
| 120 | frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); |
| 121 | listView.setOnItemClickListener((view, position, x, y) -> { |
| 122 | if (position == ipv6Row) { |
| 123 | NekoConfig.toggleIPv6(); |
| 124 | if (view instanceof TextCheckCell) { |
| 125 | ((TextCheckCell) view).setChecked(NekoConfig.useIPv6); |
| 126 | } |
| 127 | for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { |
| 128 | if (UserConfig.getInstance(a).isClientActivated()) { |
| 129 | ConnectionsManager.native_setUseIpv6(a, NekoConfig.useIPv6); |
| 130 | } |
| 131 | } |
| 132 | } else if (position == hidePhoneRow) { |
| 133 | NekoConfig.toggleHidePhone(); |
| 134 | if (view instanceof TextCheckCell) { |
| 135 | ((TextCheckCell) view).setChecked(NekoConfig.hidePhone); |
| 136 | } |
| 137 | } else if (position == inappCameraRow) { |
| 138 | SharedConfig.toggleInappCamera(); |
| 139 | if (view instanceof TextCheckCell) { |
| 140 | ((TextCheckCell) view).setChecked(SharedConfig.inappCamera); |
| 141 | } |
| 142 | } else if (position == forceTabletRow) { |
| 143 | NekoConfig.toggleForceTablet(); |
| 144 | if (view instanceof TextCheckCell) { |
| 145 | ((TextCheckCell) view).setChecked(NekoConfig.forceTablet); |
| 146 | } |
| 147 | } else if (position == ignoreBlockedRow) { |
| 148 | NekoConfig.toggleIgnoreBlocked(); |
| 149 | if (view instanceof TextCheckCell) { |
| 150 | ((TextCheckCell) view).setChecked(NekoConfig.ignoreBlocked); |
| 151 | } |
| 152 | } else if (position == transparentStatusBarRow) { |
| 153 | if (!(NekoConfig.navigationBarTint || Build.VERSION.SDK_INT < Build.VERSION_CODES.O)) |
| 154 | return; |
| 155 | NekoConfig.toggleTransparentStatusBar(); |
| 156 | if (view instanceof TextCheckCell) { |
| 157 | ((TextCheckCell) view).setChecked(NekoConfig.transparentStatusBar); |
| 158 | } |
| 159 | UIHelper.updateStatusBarColor(getParentActivity()); |
| 160 | } else if (position == navigationBarTintRow) { |
| 161 | NekoConfig.toggleNavigationBarTint(); |
| 162 | if (view instanceof TextCheckCell) { |
| 163 | ((TextCheckCell) view).setChecked(NekoConfig.navigationBarTint); |
| 164 | } |
| 165 | updateRows(true); |
| 166 | UIHelper.updateStatusBarColor(getParentActivity()); |
| 167 | UIHelper.updateNavigationBarColor(getParentActivity()); |
| 168 | } else if (position == navigationBarColorRow) { |
| 169 | if (!NekoConfig.navigationBarTint) |
| 170 | return; |
| 171 | AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); |
| 172 | builder.setTitle(LocaleController.getString("NavigationBarColor", R.string.NavigationBarColor)); |
| 173 | CharSequence[] items = new CharSequence[]{ |
| 174 | LocaleController.getString("NavigationBarColorBlack", R.string.NavigationBarColorBlack), |
| 175 | LocaleController.getString("NavigationBarColorActionBar", R.string.NavigationBarColorActionBar), |
| 176 | LocaleController.getString("NavigationBarColorMessagePanel", R.string.NavigationBarColorMessagePanel), |
| 177 | }; |
| 178 | builder.setItems(items, (dialog, which) -> { |
| 179 | NekoConfig.setNavigationBarColor(which + 1); |
| 180 | listAdapter.notifyItemChanged(navigationBarColorRow); |
| 181 | UIHelper.updateNavigationBarColor(getParentActivity()); |
| 182 | }); |
| 183 | showDialog(builder.create()); |
| 184 | } else if (position == useSystemEmojiRow) { |
| 185 | SharedConfig.useSystemEmoji = !SharedConfig.useSystemEmoji; |
| 186 | SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit(); |
| 187 | editor.putBoolean("useSystemEmoji", SharedConfig.useSystemEmoji); |
| 188 | editor.commit(); |
| 189 | if (view instanceof TextCheckCell) { |
| 190 | ((TextCheckCell) view).setChecked(SharedConfig.useSystemEmoji); |
| 191 | } |
| 192 | } else if (position == singleBigEmojiRow) { |
| 193 | SharedConfig.allowBigEmoji = !SharedConfig.allowBigEmoji; |
| 194 | SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit(); |
| 195 | editor.putBoolean("allowBigEmoji", SharedConfig.allowBigEmoji); |
| 196 | editor.commit(); |
| 197 | if (view instanceof TextCheckCell) { |
| 198 | ((TextCheckCell) view).setChecked(SharedConfig.allowBigEmoji); |
| 199 | } |
| 200 | } else if (position == nameOrderRow) { |
| 201 | AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); |
| 202 | builder.setTitle(LocaleController.getString("NameOrder", R.string.NameOrder)); |
| 203 | CharSequence[] items = new CharSequence[]{ |
| 204 | LocaleController.getString("FirstLast", R.string.FirstLast), |
| 205 | LocaleController.getString("LastFirst", R.string.LastFirst), |
| 206 | }; |
| 207 | builder.setItems(items, (dialog, which) -> { |
| 208 | NekoConfig.setNameOrder(which + 1); |
| 209 | listAdapter.notifyItemChanged(nameOrderRow); |
| 210 | }); |
| 211 | showDialog(builder.create()); |
| 212 | } |
| 213 | }); |
| 214 | |
| 215 | return fragmentView; |
| 216 | } |
| 217 | |
| 218 | @Override |
| 219 | public void onResume() { |
| 220 | super.onResume(); |
| 221 | if (listAdapter != null) { |
| 222 | listAdapter.notifyDataSetChanged(); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | private void updateRows(boolean notify) { |
| 227 | rowCount = 0; |
| 228 | connectionRow = rowCount++; |
| 229 | ipv6Row = rowCount++; |
| 230 | connection2Row = rowCount++; |
| 231 | emojiRow = rowCount++; |
| 232 | useSystemEmojiRow = rowCount++; |
| 233 | singleBigEmojiRow = rowCount++; |
| 234 | emoji2Row = rowCount++; |
| 235 | chatRow = rowCount++; |
| 236 | ignoreBlockedRow = rowCount++; |
| 237 | chat2Row = rowCount++; |
| 238 | settingsRow = rowCount++; |
| 239 | hidePhoneRow = rowCount++; |
| 240 | inappCameraRow = rowCount++; |
| 241 | navigationBarTintRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? rowCount++ : -1; |
| 242 | transparentStatusBarRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? rowCount++ : -1; |
| 243 | navigationBarColorRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? rowCount++ : -1; |
| 244 | forceTabletRow = rowCount++; |
| 245 | nameOrderRow = rowCount++; |
| 246 | settings2Row = rowCount++; |
| 247 | if (notify && listAdapter != null) { |
| 248 | listAdapter.notifyDataSetChanged(); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | @Override |
| 253 | public ThemeDescription[] getThemeDescriptions() { |
| 254 | return new ThemeDescription[]{ |
| 255 | 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), |
| 256 | new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray), |
| 257 | |
| 258 | new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue), |
| 259 | new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue), |
| 260 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_avatar_actionBarIconBlue), |
| 261 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle), |
| 262 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_avatar_actionBarSelectorBlue), |
| 263 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, null, Theme.key_actionBarDefaultSubmenuBackground), |
| 264 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, null, Theme.key_actionBarDefaultSubmenuItem), |
| 265 | |
| 266 | new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector), |
| 267 | |
| 268 | new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider), |
| 269 | |
| 270 | new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow), |
| 271 | |
| 272 | new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 273 | new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteValueText), |
| 274 | |
| 275 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 276 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), |
| 277 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack), |
| 278 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked), |
| 279 | |
| 280 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 281 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), |
| 282 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack), |
| 283 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked), |
| 284 | |
| 285 | new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader), |
| 286 | |
| 287 | new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 288 | new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), |
| 289 | }; |
| 290 | } |
| 291 | |
| 292 | private class ListAdapter extends RecyclerListView.SelectionAdapter { |
| 293 | |
| 294 | private Context mContext; |
| 295 | |
| 296 | public ListAdapter(Context context) { |
| 297 | mContext = context; |
| 298 | } |
| 299 | |
| 300 | @Override |
| 301 | public int getItemCount() { |
| 302 | return rowCount; |
| 303 | } |
| 304 | |
| 305 | @Override |
| 306 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { |
| 307 | switch (holder.getItemViewType()) { |
| 308 | case 1: { |
| 309 | break; |
| 310 | } |
| 311 | case 2: { |
| 312 | TextSettingsCell textCell = (TextSettingsCell) holder.itemView; |
| 313 | if (position == nameOrderRow) { |
| 314 | String value; |
| 315 | switch (NekoConfig.nameOrder) { |
| 316 | case 2: |
| 317 | value = LocaleController.getString("LastFirst", R.string.LastFirst); |
| 318 | break; |
| 319 | case 1: |
| 320 | default: |
| 321 | value = LocaleController.getString("FirstLast", R.string.FirstLast); |
| 322 | break; |
| 323 | } |
| 324 | textCell.setTextAndValue(LocaleController.getString("NameOrder", R.string.NameOrder), value, false); |
| 325 | } else if (position == navigationBarColorRow) { |
| 326 | String value; |
| 327 | switch (NekoConfig.navigationBarColor) { |
| 328 | case 3: |
| 329 | value = LocaleController.getString("NavigationBarColorMessagePanel", R.string.NavigationBarColorMessagePanel); |
| 330 | break; |
| 331 | case 2: |
| 332 | value = LocaleController.getString("NavigationBarColorActionBar", R.string.NavigationBarColorActionBar); |
| 333 | break; |
| 334 | case 1: |
| 335 | default: |
| 336 | value = LocaleController.getString("NavigationBarColorBlack", R.string.NavigationBarColorBlack); |
| 337 | } |
| 338 | textCell.setTextAndValue(LocaleController.getString("NavigationBarColor", R.string.NavigationBarColor), value, true); |
| 339 | } |
| 340 | break; |
| 341 | } |
| 342 | case 3: { |
| 343 | TextCheckCell textCell = (TextCheckCell) holder.itemView; |
| 344 | if (position == ipv6Row) { |
| 345 | textCell.setTextAndCheck(LocaleController.getString("IPv6", R.string.IPv6), NekoConfig.useIPv6, false); |
| 346 | } else if (position == hidePhoneRow) { |
| 347 | textCell.setTextAndCheck(LocaleController.getString("HidePhone", R.string.HidePhone), NekoConfig.hidePhone, true); |
| 348 | } else if (position == inappCameraRow) { |
| 349 | textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableCamera", R.string.DebugMenuEnableCamera), SharedConfig.inappCamera, true); |
| 350 | } else if (position == transparentStatusBarRow) { |
| 351 | textCell.setTextAndCheck(LocaleController.getString("TransparentStatusBar", R.string.TransparentStatusBar), NekoConfig.transparentStatusBar, true); |
| 352 | } else if (position == navigationBarTintRow) { |
| 353 | textCell.setTextAndCheck(LocaleController.getString("NavigationBarTint", R.string.NavigationBarTint), NekoConfig.navigationBarTint, true); |
| 354 | } else if (position == useSystemEmojiRow) { |
| 355 | textCell.setTextAndCheck(LocaleController.getString("EmojiUseDefault", R.string.EmojiUseDefault), SharedConfig.useSystemEmoji, true); |
| 356 | } else if (position == singleBigEmojiRow) { |
| 357 | textCell.setTextAndCheck(LocaleController.getString("LargeEmoji", R.string.LargeEmoji), SharedConfig.allowBigEmoji, false); |
| 358 | } else if (position == ignoreBlockedRow) { |
| 359 | textCell.setTextAndCheck(LocaleController.getString("IgnoreBlocked", R.string.IgnoreBlocked), NekoConfig.ignoreBlocked, true); |
| 360 | } else if (position == forceTabletRow) { |
| 361 | textCell.setTextAndCheck(LocaleController.getString("ForceTabletMode", R.string.ForceTabletMode), NekoConfig.forceTablet, true); |
| 362 | } |
| 363 | break; |
| 364 | } |
| 365 | case 4: { |
| 366 | HeaderCell headerCell = (HeaderCell) holder.itemView; |
| 367 | if (position == settingsRow) { |
| 368 | headerCell.setText(LocaleController.getString("Settings", R.string.Settings)); |
| 369 | } else if (position == emojiRow) { |
| 370 | headerCell.setText(LocaleController.getString("Emoji", R.string.Emoji)); |
| 371 | } else if (position == connectionRow) { |
| 372 | headerCell.setText(LocaleController.getString("Connection", R.string.Connection)); |
| 373 | } else if (position == chatRow) { |
| 374 | headerCell.setText(LocaleController.getString("Chat", R.string.Chat)); |
| 375 | } |
| 376 | break; |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | @Override |
| 382 | public boolean isEnabled(RecyclerView.ViewHolder holder) { |
| 383 | int position = holder.getAdapterPosition(); |
| 384 | return position == hidePhoneRow || position == inappCameraRow || position == ignoreBlockedRow || position == navigationBarTintRow || |
| 385 | position == useSystemEmojiRow || position == singleBigEmojiRow || position == ipv6Row || |
| 386 | position == nameOrderRow || position == forceTabletRow || |
| 387 | (position == transparentStatusBarRow && (NekoConfig.navigationBarTint || Build.VERSION.SDK_INT < Build.VERSION_CODES.O)) || |
| 388 | (position == navigationBarColorRow && NekoConfig.navigationBarTint); |
| 389 | } |
| 390 | |
| 391 | @Override |
| 392 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
| 393 | View view = null; |
| 394 | switch (viewType) { |
| 395 | case 1: |
| 396 | view = new ShadowSectionCell(mContext); |
| 397 | break; |
| 398 | case 2: |
| 399 | view = new TextSettingsCell(mContext); |
| 400 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 401 | break; |
| 402 | case 3: |
| 403 | view = new TextCheckCell(mContext); |
| 404 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 405 | break; |
| 406 | case 4: |
| 407 | view = new HeaderCell(mContext); |
| 408 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 409 | break; |
| 410 | case 5: |
| 411 | view = new NotificationsCheckCell(mContext); |
| 412 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 413 | break; |
| 414 | case 6: |
| 415 | view = new TextDetailSettingsCell(mContext); |
| 416 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 417 | break; |
| 418 | } |
| 419 | view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT)); |
| 420 | return new RecyclerListView.Holder(view); |
| 421 | } |
| 422 | |
| 423 | @Override |
| 424 | public int getItemViewType(int position) { |
| 425 | if (position == settings2Row || position == emoji2Row || position == connection2Row || position == chat2Row) { |
| 426 | return 1; |
| 427 | } else if (position == nameOrderRow || position == navigationBarColorRow) { |
| 428 | return 2; |
| 429 | } else if (position == ipv6Row || position == hidePhoneRow || position == inappCameraRow || |
| 430 | position == transparentStatusBarRow || position == navigationBarTintRow || |
| 431 | position == ignoreBlockedRow || position == useSystemEmojiRow || position == singleBigEmojiRow || |
| 432 | position == forceTabletRow) { |
| 433 | return 3; |
| 434 | } else if (position == settingsRow || position == connectionRow || position == emojiRow || position == chatRow) { |
| 435 | return 4; |
| 436 | } |
| 437 | return 6; |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | |