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