| 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.TextInfoPrivacyCell; |
| 41 | import org.telegram.ui.Cells.TextSettingsCell; |
| 42 | import org.telegram.ui.Components.EditTextBoldCursor; |
| 43 | import org.telegram.ui.Components.LayoutHelper; |
| 44 | import org.telegram.ui.Components.RecyclerListView; |
| 45 | |
| 46 | public class NekoSettingsActivity extends BaseFragment { |
| 47 | |
| 48 | private RecyclerListView listView; |
| 49 | private ListAdapter listAdapter; |
| 50 | |
| 51 | private int rowCount; |
| 52 | |
| 53 | private int connectionRow; |
| 54 | private int ipv6Row; |
| 55 | private int connection2Row; |
| 56 | |
| 57 | private int messageMenuRow; |
| 58 | private int showAddToSavedMessagesRow; |
| 59 | private int showReportRow; |
| 60 | private int showPrPrRow; |
| 61 | private int showAdminActionsRow; |
| 62 | private int showChangePermissionsRow; |
| 63 | private int messageMenu2Row; |
| 64 | |
| 65 | private int chatRow; |
| 66 | private int inappCameraRow; |
| 67 | private int useSystemEmojiRow; |
| 68 | private int ignoreBlockedRow; |
| 69 | private int mapPreviewRow; |
| 70 | private int chat2Row; |
| 71 | |
| 72 | private int settingsRow; |
| 73 | private int typefaceRow; |
| 74 | private int hidePhoneRow; |
| 75 | private int nameOrderRow; |
| 76 | private int transparentStatusBarRow; |
| 77 | private int navigationBarTintRow; |
| 78 | private int navigationBarColorRow; |
| 79 | private int forceTabletRow; |
| 80 | private int xmasRow; |
| 81 | private int newYearRow; |
| 82 | private int newYearEveRow; |
| 83 | private int fireworksRow; |
| 84 | private int needRestartRow; |
| 85 | |
| 86 | @Override |
| 87 | public boolean onFragmentCreate() { |
| 88 | super.onFragmentCreate(); |
| 89 | |
| 90 | updateRows(false); |
| 91 | |
| 92 | return true; |
| 93 | } |
| 94 | |
| 95 | @SuppressLint("NewApi") |
| 96 | @Override |
| 97 | public View createView(Context context) { |
| 98 | actionBar.setBackButtonImage(R.drawable.ic_ab_back); |
| 99 | actionBar.setTitle(LocaleController.getString("NekoSettings", R.string.NekoSettings)); |
| 100 | |
| 101 | if (AndroidUtilities.isTablet()) { |
| 102 | actionBar.setOccupyStatusBar(false); |
| 103 | } |
| 104 | actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { |
| 105 | @Override |
| 106 | public void onItemClick(int id) { |
| 107 | if (id == -1) { |
| 108 | finishFragment(); |
| 109 | } |
| 110 | } |
| 111 | }); |
| 112 | |
| 113 | listAdapter = new ListAdapter(context); |
| 114 | |
| 115 | fragmentView = new FrameLayout(context); |
| 116 | fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray)); |
| 117 | FrameLayout frameLayout = (FrameLayout) fragmentView; |
| 118 | |
| 119 | listView = new RecyclerListView(context); |
| 120 | listView.setVerticalScrollBarEnabled(false); |
| 121 | listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) { |
| 122 | @Override |
| 123 | public boolean supportsPredictiveItemAnimations() { |
| 124 | return false; |
| 125 | } |
| 126 | }); |
| 127 | listView.setGlowColor(Theme.getColor(Theme.key_avatar_backgroundActionBarBlue)); |
| 128 | listView.setAdapter(listAdapter); |
| 129 | listView.setItemAnimator(null); |
| 130 | listView.setLayoutAnimation(null); |
| 131 | frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); |
| 132 | listView.setOnItemClickListener((view, position, x, y) -> { |
| 133 | if (position == ipv6Row) { |
| 134 | NekoConfig.toggleIPv6(); |
| 135 | if (view instanceof TextCheckCell) { |
| 136 | ((TextCheckCell) view).setChecked(NekoConfig.useIPv6); |
| 137 | } |
| 138 | for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { |
| 139 | if (UserConfig.getInstance(a).isClientActivated()) { |
| 140 | ConnectionsManager.native_setUseIpv6(a, NekoConfig.useIPv6); |
| 141 | } |
| 142 | } |
| 143 | } else if (position == hidePhoneRow) { |
| 144 | NekoConfig.toggleHidePhone(); |
| 145 | if (view instanceof TextCheckCell) { |
| 146 | ((TextCheckCell) view).setChecked(NekoConfig.hidePhone); |
| 147 | } |
| 148 | } else if (position == inappCameraRow) { |
| 149 | SharedConfig.toggleInappCamera(); |
| 150 | if (view instanceof TextCheckCell) { |
| 151 | ((TextCheckCell) view).setChecked(SharedConfig.inappCamera); |
| 152 | } |
| 153 | } else if (position == showAddToSavedMessagesRow) { |
| 154 | NekoConfig.toggleShowAddToSavedMessages(); |
| 155 | if (view instanceof TextCheckCell) { |
| 156 | ((TextCheckCell) view).setChecked(NekoConfig.showAddToSavedMessages); |
| 157 | } |
| 158 | } else if (position == showAdminActionsRow) { |
| 159 | NekoConfig.toggleShowAdminActions(); |
| 160 | if (view instanceof TextCheckCell) { |
| 161 | ((TextCheckCell) view).setChecked(NekoConfig.showAdminActions); |
| 162 | } |
| 163 | } else if (position == showChangePermissionsRow) { |
| 164 | NekoConfig.toggleShowChangePermissions(); |
| 165 | if (view instanceof TextCheckCell) { |
| 166 | ((TextCheckCell) view).setChecked(NekoConfig.showChangePermissions); |
| 167 | } |
| 168 | } else if (position == showPrPrRow) { |
| 169 | NekoConfig.toggleShowPrPr(); |
| 170 | if (view instanceof TextCheckCell) { |
| 171 | ((TextCheckCell) view).setChecked(NekoConfig.showPrPr); |
| 172 | } |
| 173 | } else if (position == showReportRow) { |
| 174 | NekoConfig.toggleShowReport(); |
| 175 | if (view instanceof TextCheckCell) { |
| 176 | ((TextCheckCell) view).setChecked(NekoConfig.showReport); |
| 177 | } |
| 178 | } else if (position == forceTabletRow) { |
| 179 | NekoConfig.toggleForceTablet(); |
| 180 | if (view instanceof TextCheckCell) { |
| 181 | ((TextCheckCell) view).setChecked(NekoConfig.forceTablet); |
| 182 | } |
| 183 | } else if (position == ignoreBlockedRow) { |
| 184 | NekoConfig.toggleIgnoreBlocked(); |
| 185 | if (view instanceof TextCheckCell) { |
| 186 | ((TextCheckCell) view).setChecked(NekoConfig.ignoreBlocked); |
| 187 | } |
| 188 | } else if (position == transparentStatusBarRow) { |
| 189 | if (!(NekoConfig.navigationBarTint || Build.VERSION.SDK_INT < Build.VERSION_CODES.O)) |
| 190 | return; |
| 191 | NekoConfig.toggleTransparentStatusBar(); |
| 192 | if (view instanceof TextCheckCell) { |
| 193 | ((TextCheckCell) view).setChecked(NekoConfig.transparentStatusBar); |
| 194 | } |
| 195 | UIHelper.updateStatusBarColor(getParentActivity()); |
| 196 | } else if (position == navigationBarTintRow) { |
| 197 | NekoConfig.toggleNavigationBarTint(); |
| 198 | if (view instanceof TextCheckCell) { |
| 199 | ((TextCheckCell) view).setChecked(NekoConfig.navigationBarTint); |
| 200 | } |
| 201 | updateRows(true); |
| 202 | UIHelper.updateStatusBarColor(getParentActivity()); |
| 203 | UIHelper.updateNavigationBarColor(getParentActivity()); |
| 204 | } else if (position == navigationBarColorRow) { |
| 205 | if (!NekoConfig.navigationBarTint) |
| 206 | return; |
| 207 | AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); |
| 208 | builder.setTitle(LocaleController.getString("NavigationBarColor", R.string.NavigationBarColor)); |
| 209 | CharSequence[] items = new CharSequence[]{ |
| 210 | LocaleController.getString("NavigationBarColorBlack", R.string.NavigationBarColorBlack), |
| 211 | LocaleController.getString("NavigationBarColorActionBar", R.string.NavigationBarColorActionBar), |
| 212 | LocaleController.getString("NavigationBarColorMessagePanel", R.string.NavigationBarColorMessagePanel), |
| 213 | }; |
| 214 | builder.setItems(items, (dialog, which) -> { |
| 215 | NekoConfig.setNavigationBarColor(which + 1); |
| 216 | listAdapter.notifyItemChanged(navigationBarColorRow); |
| 217 | UIHelper.updateNavigationBarColor(getParentActivity()); |
| 218 | }); |
| 219 | showDialog(builder.create()); |
| 220 | } else if (position == useSystemEmojiRow) { |
| 221 | SharedConfig.useSystemEmoji = !SharedConfig.useSystemEmoji; |
| 222 | SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit(); |
| 223 | editor.putBoolean("useSystemEmoji", SharedConfig.useSystemEmoji); |
| 224 | editor.commit(); |
| 225 | if (view instanceof TextCheckCell) { |
| 226 | ((TextCheckCell) view).setChecked(SharedConfig.useSystemEmoji); |
| 227 | } |
| 228 | } else if (position == typefaceRow) { |
| 229 | NekoConfig.toggleTypeface(); |
| 230 | if (view instanceof TextCheckCell) { |
| 231 | ((TextCheckCell) view).setChecked(NekoConfig.typeface == 1); |
| 232 | } |
| 233 | } else if (position == mapPreviewRow) { |
| 234 | AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); |
| 235 | builder.setTitle(LocaleController.getString("MapPreviewProvider", R.string.MapPreviewProvider)); |
| 236 | CharSequence[] items = new CharSequence[]{ |
| 237 | LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram), |
| 238 | LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex), |
| 239 | LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody), |
| 240 | }; |
| 241 | builder.setItems(items, (dialog, which) -> { |
| 242 | NekoConfig.setMapPreviewProvider(which); |
| 243 | listAdapter.notifyItemChanged(mapPreviewRow); |
| 244 | }); |
| 245 | showDialog(builder.create()); |
| 246 | } else if (position == nameOrderRow) { |
| 247 | AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); |
| 248 | builder.setTitle(LocaleController.getString("NameOrder", R.string.NameOrder)); |
| 249 | CharSequence[] items = new CharSequence[]{ |
| 250 | LocaleController.getString("FirstLast", R.string.FirstLast), |
| 251 | LocaleController.getString("LastFirst", R.string.LastFirst), |
| 252 | }; |
| 253 | builder.setItems(items, (dialog, which) -> { |
| 254 | NekoConfig.setNameOrder(which + 1); |
| 255 | listAdapter.notifyItemChanged(nameOrderRow); |
| 256 | }); |
| 257 | showDialog(builder.create()); |
| 258 | } else if (position == xmasRow) { |
| 259 | NekoConfig.toggleXmas(); |
| 260 | if (view instanceof TextCheckCell) { |
| 261 | ((TextCheckCell) view).setChecked(NekoConfig.xmas); |
| 262 | } |
| 263 | } else if (position == newYearRow) { |
| 264 | NekoConfig.toggleNewYear(); |
| 265 | if (view instanceof TextCheckCell) { |
| 266 | ((TextCheckCell) view).setChecked(NekoConfig.newYear); |
| 267 | } |
| 268 | } else if (position == newYearEveRow) { |
| 269 | NekoConfig.toggleNewYearEve(); |
| 270 | if (view instanceof TextCheckCell) { |
| 271 | ((TextCheckCell) view).setChecked(NekoConfig.newYearEve); |
| 272 | } |
| 273 | } else if (position == fireworksRow) { |
| 274 | NekoConfig.toggleFireworks(); |
| 275 | if (view instanceof TextCheckCell) { |
| 276 | ((TextCheckCell) view).setChecked(NekoConfig.fireworks); |
| 277 | } |
| 278 | } |
| 279 | }); |
| 280 | |
| 281 | return fragmentView; |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public void onResume() { |
| 286 | super.onResume(); |
| 287 | if (listAdapter != null) { |
| 288 | listAdapter.notifyDataSetChanged(); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | private void updateRows(boolean notify) { |
| 293 | rowCount = 0; |
| 294 | connectionRow = rowCount++; |
| 295 | ipv6Row = rowCount++; |
| 296 | connection2Row = rowCount++; |
| 297 | chatRow = rowCount++; |
| 298 | inappCameraRow = rowCount++; |
| 299 | useSystemEmojiRow = rowCount++; |
| 300 | ignoreBlockedRow = rowCount++; |
| 301 | mapPreviewRow = rowCount++; |
| 302 | chat2Row = rowCount++; |
| 303 | messageMenuRow = rowCount++; |
| 304 | showAddToSavedMessagesRow = rowCount++; |
| 305 | showPrPrRow = rowCount++; |
| 306 | showReportRow = rowCount++; |
| 307 | showAdminActionsRow = rowCount++; |
| 308 | showChangePermissionsRow = rowCount++; |
| 309 | messageMenu2Row = rowCount++; |
| 310 | settingsRow = rowCount++; |
| 311 | hidePhoneRow = rowCount++; |
| 312 | typefaceRow = rowCount++; |
| 313 | navigationBarTintRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? rowCount++ : -1; |
| 314 | transparentStatusBarRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? rowCount++ : -1; |
| 315 | navigationBarColorRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? rowCount++ : -1; |
| 316 | forceTabletRow = rowCount++; |
| 317 | nameOrderRow = rowCount++; |
| 318 | xmasRow = rowCount++; |
| 319 | newYearRow = rowCount++; |
| 320 | newYearEveRow = rowCount++; |
| 321 | fireworksRow = rowCount++; |
| 322 | needRestartRow = rowCount++; |
| 323 | if (notify && listAdapter != null) { |
| 324 | listAdapter.notifyDataSetChanged(); |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | @Override |
| 329 | public ThemeDescription[] getThemeDescriptions() { |
| 330 | return new ThemeDescription[]{ |
| 331 | 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), |
| 332 | new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray), |
| 333 | |
| 334 | new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue), |
| 335 | new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue), |
| 336 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_avatar_actionBarIconBlue), |
| 337 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle), |
| 338 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_avatar_actionBarSelectorBlue), |
| 339 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, null, Theme.key_actionBarDefaultSubmenuBackground), |
| 340 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, null, Theme.key_actionBarDefaultSubmenuItem), |
| 341 | |
| 342 | new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector), |
| 343 | |
| 344 | new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider), |
| 345 | |
| 346 | new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow), |
| 347 | |
| 348 | new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 349 | new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteValueText), |
| 350 | |
| 351 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 352 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), |
| 353 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack), |
| 354 | new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked), |
| 355 | |
| 356 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 357 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), |
| 358 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack), |
| 359 | new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked), |
| 360 | |
| 361 | new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader), |
| 362 | |
| 363 | new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 364 | new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), |
| 365 | }; |
| 366 | } |
| 367 | |
| 368 | private class ListAdapter extends RecyclerListView.SelectionAdapter { |
| 369 | |
| 370 | private Context mContext; |
| 371 | |
| 372 | public ListAdapter(Context context) { |
| 373 | mContext = context; |
| 374 | } |
| 375 | |
| 376 | @Override |
| 377 | public int getItemCount() { |
| 378 | return rowCount; |
| 379 | } |
| 380 | |
| 381 | @Override |
| 382 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { |
| 383 | switch (holder.getItemViewType()) { |
| 384 | case 1: { |
| 385 | break; |
| 386 | } |
| 387 | case 2: { |
| 388 | TextSettingsCell textCell = (TextSettingsCell) holder.itemView; |
| 389 | if (position == nameOrderRow) { |
| 390 | String value; |
| 391 | switch (NekoConfig.nameOrder) { |
| 392 | case 2: |
| 393 | value = LocaleController.getString("LastFirst", R.string.LastFirst); |
| 394 | break; |
| 395 | case 1: |
| 396 | default: |
| 397 | value = LocaleController.getString("FirstLast", R.string.FirstLast); |
| 398 | break; |
| 399 | } |
| 400 | textCell.setTextAndValue(LocaleController.getString("NameOrder", R.string.NameOrder), value, true); |
| 401 | } else if (position == navigationBarColorRow) { |
| 402 | String value; |
| 403 | switch (NekoConfig.navigationBarColor) { |
| 404 | case 3: |
| 405 | value = LocaleController.getString("NavigationBarColorMessagePanel", R.string.NavigationBarColorMessagePanel); |
| 406 | break; |
| 407 | case 2: |
| 408 | value = LocaleController.getString("NavigationBarColorActionBar", R.string.NavigationBarColorActionBar); |
| 409 | break; |
| 410 | case 1: |
| 411 | default: |
| 412 | value = LocaleController.getString("NavigationBarColorBlack", R.string.NavigationBarColorBlack); |
| 413 | } |
| 414 | textCell.setTextAndValue(LocaleController.getString("NavigationBarColor", R.string.NavigationBarColor), value, true); |
| 415 | } else if (position == mapPreviewRow) { |
| 416 | String value; |
| 417 | switch (NekoConfig.mapPreviewProvider) { |
| 418 | case 0: |
| 419 | value = LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram); |
| 420 | break; |
| 421 | case 1: |
| 422 | value = LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex); |
| 423 | break; |
| 424 | case 2: |
| 425 | default: |
| 426 | value = LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody); |
| 427 | } |
| 428 | textCell.setTextAndValue(LocaleController.getString("MapPreviewProvider", R.string.MapPreviewProvider), value, false); |
| 429 | } |
| 430 | break; |
| 431 | } |
| 432 | case 3: { |
| 433 | TextCheckCell textCell = (TextCheckCell) holder.itemView; |
| 434 | if (position == ipv6Row) { |
| 435 | textCell.setTextAndCheck(LocaleController.getString("IPv6", R.string.IPv6), NekoConfig.useIPv6, false); |
| 436 | } else if (position == showAddToSavedMessagesRow) { |
| 437 | textCell.setTextAndCheck(LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages), NekoConfig.showAddToSavedMessages, true); |
| 438 | } else if (position == showPrPrRow) { |
| 439 | textCell.setTextAndCheck(LocaleController.getString("Prpr", R.string.Prpr), NekoConfig.showPrPr, true); |
| 440 | } else if (position == showReportRow) { |
| 441 | textCell.setTextAndCheck(LocaleController.getString("ReportChat", R.string.ReportChat), NekoConfig.showReport, true); |
| 442 | } else if (position == showAdminActionsRow) { |
| 443 | textCell.setTextAndCheck(LocaleController.getString("EditAdminRights", R.string.EditAdminRights), NekoConfig.showAdminActions, true); |
| 444 | } else if (position == showChangePermissionsRow) { |
| 445 | textCell.setTextAndCheck(LocaleController.getString("ChangePermissions", R.string.ChangePermissions), NekoConfig.showChangePermissions, false); |
| 446 | } else if (position == hidePhoneRow) { |
| 447 | textCell.setTextAndCheck(LocaleController.getString("HidePhone", R.string.HidePhone), NekoConfig.hidePhone, true); |
| 448 | } else if (position == inappCameraRow) { |
| 449 | textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableCamera", R.string.DebugMenuEnableCamera), SharedConfig.inappCamera, true); |
| 450 | } else if (position == transparentStatusBarRow) { |
| 451 | textCell.setTextAndCheck(LocaleController.getString("TransparentStatusBar", R.string.TransparentStatusBar), NekoConfig.transparentStatusBar, true); |
| 452 | } else if (position == navigationBarTintRow) { |
| 453 | textCell.setTextAndCheck(LocaleController.getString("NavigationBarTint", R.string.NavigationBarTint), NekoConfig.navigationBarTint, true); |
| 454 | } else if (position == useSystemEmojiRow) { |
| 455 | textCell.setTextAndCheck(LocaleController.getString("EmojiUseDefault", R.string.EmojiUseDefault), SharedConfig.useSystemEmoji, true); |
| 456 | } else if (position == typefaceRow) { |
| 457 | textCell.setTextAndCheck(LocaleController.getString("TypefaceUseDefault", R.string.TypefaceUseDefault), NekoConfig.typeface == 1, true); |
| 458 | } else if (position == ignoreBlockedRow) { |
| 459 | textCell.setTextAndCheck(LocaleController.getString("IgnoreBlocked", R.string.IgnoreBlocked), NekoConfig.ignoreBlocked, true); |
| 460 | } else if (position == forceTabletRow) { |
| 461 | textCell.setTextAndCheck(LocaleController.getString("ForceTabletMode", R.string.ForceTabletMode), NekoConfig.forceTablet, true); |
| 462 | } else if (position == xmasRow) { |
| 463 | textCell.setTextAndCheck(LocaleController.getString("ChristmasEveryday", R.string.ChristmasEveryday), NekoConfig.xmas, true); |
| 464 | } else if (position == newYearRow) { |
| 465 | textCell.setTextAndCheck(LocaleController.getString("NewYearEveryday", R.string.NewYearEveryday), NekoConfig.newYear, true); |
| 466 | } else if (position == newYearEveRow) { |
| 467 | textCell.setTextAndCheck(LocaleController.getString("HappyNewYearEveryday", R.string.HappyNewYearEveryday), NekoConfig.newYearEve, true); |
| 468 | } else if (position == fireworksRow) { |
| 469 | textCell.setTextAndCheck(LocaleController.getString("ShowFireworks", R.string.ShowFireworks), NekoConfig.fireworks, false); |
| 470 | } |
| 471 | break; |
| 472 | } |
| 473 | case 4: { |
| 474 | HeaderCell headerCell = (HeaderCell) holder.itemView; |
| 475 | if (position == settingsRow) { |
| 476 | headerCell.setText(LocaleController.getString("General", R.string.General)); |
| 477 | } else if (position == messageMenuRow) { |
| 478 | headerCell.setText(LocaleController.getString("MessageMenu", R.string.MessageMenu)); |
| 479 | } else if (position == connectionRow) { |
| 480 | headerCell.setText(LocaleController.getString("Connection", R.string.Connection)); |
| 481 | } else if (position == chatRow) { |
| 482 | headerCell.setText(LocaleController.getString("Chat", R.string.Chat)); |
| 483 | } |
| 484 | break; |
| 485 | } |
| 486 | case 7: { |
| 487 | TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView; |
| 488 | if (position == needRestartRow) { |
| 489 | cell.setText(LocaleController.getString("SomeItemsNeedRestart", R.string.SomeItemsNeedRestart)); |
| 490 | } |
| 491 | break; |
| 492 | } |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | @Override |
| 497 | public boolean isEnabled(RecyclerView.ViewHolder holder) { |
| 498 | int position = holder.getAdapterPosition(); |
| 499 | return position == hidePhoneRow || position == inappCameraRow || position == ignoreBlockedRow || position == navigationBarTintRow || |
| 500 | position == useSystemEmojiRow || position == ipv6Row || position == typefaceRow || |
| 501 | position == showChangePermissionsRow || position == showAdminActionsRow || position == showReportRow || |
| 502 | position == showPrPrRow || position == showAddToSavedMessagesRow || |
| 503 | position == nameOrderRow || position == forceTabletRow || position == mapPreviewRow || |
| 504 | position == xmasRow || position == newYearRow || position == newYearEveRow || position == fireworksRow || |
| 505 | (position == transparentStatusBarRow && (NekoConfig.navigationBarTint || Build.VERSION.SDK_INT < Build.VERSION_CODES.O)) || |
| 506 | (position == navigationBarColorRow && NekoConfig.navigationBarTint); |
| 507 | } |
| 508 | |
| 509 | @Override |
| 510 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
| 511 | View view = null; |
| 512 | switch (viewType) { |
| 513 | case 1: |
| 514 | view = new ShadowSectionCell(mContext); |
| 515 | break; |
| 516 | case 2: |
| 517 | view = new TextSettingsCell(mContext); |
| 518 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 519 | break; |
| 520 | case 3: |
| 521 | view = new TextCheckCell(mContext); |
| 522 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 523 | break; |
| 524 | case 4: |
| 525 | view = new HeaderCell(mContext); |
| 526 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 527 | break; |
| 528 | case 5: |
| 529 | view = new NotificationsCheckCell(mContext); |
| 530 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 531 | break; |
| 532 | case 6: |
| 533 | view = new TextDetailSettingsCell(mContext); |
| 534 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 535 | break; |
| 536 | case 7: |
| 537 | view = new TextInfoPrivacyCell(mContext); |
| 538 | view.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); |
| 539 | break; |
| 540 | } |
| 541 | view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT)); |
| 542 | return new RecyclerListView.Holder(view); |
| 543 | } |
| 544 | |
| 545 | @Override |
| 546 | public int getItemViewType(int position) { |
| 547 | if (position == messageMenu2Row || position == connection2Row || position == chat2Row) { |
| 548 | return 1; |
| 549 | } else if (position == nameOrderRow || position == navigationBarColorRow || position == mapPreviewRow) { |
| 550 | return 2; |
| 551 | } else if (position == ipv6Row || position == hidePhoneRow || position == inappCameraRow || |
| 552 | position == showAddToSavedMessagesRow || position == showPrPrRow || position == showReportRow || |
| 553 | position == showAdminActionsRow || position == showChangePermissionsRow || |
| 554 | position == transparentStatusBarRow || position == navigationBarTintRow || |
| 555 | position == ignoreBlockedRow || position == useSystemEmojiRow || position == typefaceRow || |
| 556 | position == forceTabletRow || position == xmasRow || position == newYearRow || position == newYearEveRow || |
| 557 | position == fireworksRow) { |
| 558 | return 3; |
| 559 | } else if (position == settingsRow || position == connectionRow || position == messageMenuRow || position == chatRow) { |
| 560 | return 4; |
| 561 | } else if (position == needRestartRow) { |
| 562 | return 7; |
| 563 | } |
| 564 | return 6; |
| 565 | } |
| 566 | } |
| 567 | } |
| 568 | |