NekoX/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsAct...

514 lines
28 KiB
Java

package tw.nekomimi.nekogram.settings;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.EmptyCell;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.NotificationsCheckCell;
import org.telegram.ui.Cells.RadioColorCell;
import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.TextCheckCell;
import org.telegram.ui.Cells.TextDetailSettingsCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.Cells.TextSettingsCell;
import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.UndoView;
import java.util.ArrayList;
import tw.nekomimi.nekogram.MessageHelper;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.translator.Translator;
@SuppressLint("RtlHardcoded")
public class NekoExperimentalSettingsActivity extends BaseFragment {
private RecyclerListView listView;
private ListAdapter listAdapter;
private AnimatorSet animatorSet;
private boolean sensitiveCanChange = false;
private boolean sensitiveEnabled = false;
private int rowCount;
private int experimentRow;
private int smoothKeyboardRow;
private int saveCacheToPrivateDirectoryRow;
private int disableFilteringRow;
private int unlimitedFavedStickersRow;
private int unlimitedPinnedDialogsRow;
private int deleteAccountRow;
private int experiment2Row;
private int shouldNOTTrustMeRow;
private UndoView restartTooltip;
static public AlertDialog getTranslationProviderAlert(Context context) {
ArrayList<String> arrayList = new ArrayList<>();
ArrayList<Integer> types = new ArrayList<>();
arrayList.add(LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate));
types.add(Translator.PROVIDER_GOOGLE);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN));
types.add(Translator.PROVIDER_GOOGLE_CN);
arrayList.add(LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud));
types.add(Translator.PROVIDER_LINGO);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateWeb", R.string.ProviderGoogleTranslateWeb));
types.add(Translator.PROVIDER_GOOGLE_WEB);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCNWeb", R.string.ProviderGoogleTranslateCNWeb));
types.add(Translator.PROVIDER_GOOGLE_CN_WEB);
arrayList.add(LocaleController.getString("ProviderBaiduFanyiWeb", R.string.ProviderBaiduFanyiWeb));
types.add(Translator.PROVIDER_BAIDU_WEB);
arrayList.add(LocaleController.getString("ProviderDeepLWeb", R.string.ProviderDeepLWeb));
types.add(Translator.PROVIDER_DEEPL_WEB);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(LocaleController.getString("TranslationProvider", R.string.TranslationProvider));
final LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
builder.setView(linearLayout);
for (int a = 0; a < arrayList.size(); a++) {
RadioColorCell cell = new RadioColorCell(context);
cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
cell.setTag(a);
cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
cell.setTextAndValue(arrayList.get(a), NekoConfig.translationProvider == types.get(a));
linearLayout.addView(cell);
cell.setOnClickListener(v -> {
Integer which = (Integer) v.getTag();
NekoConfig.setTranslationProvider(types.get(which));
builder.getDismissRunnable().run();
});
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
return builder.create();
}
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
updateRows();
return true;
}
@SuppressLint("NewApi")
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setTitle(LocaleController.getString("Experiment", R.string.Experiment));
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
listAdapter = new ListAdapter(context);
fragmentView = new FrameLayout(context);
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
FrameLayout frameLayout = (FrameLayout) fragmentView;
listView = new RecyclerListView(context);
listView.setVerticalScrollBarEnabled(false);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
listView.setAdapter(listAdapter);
listView.setOnItemClickListener((view, position, x, y) -> {
if (position == saveCacheToPrivateDirectoryRow) {
NekoConfig.toggleSaveCacheToPrivateDirectory();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.saveCacheToPrivateDirectory);
}
restartTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
} else if (position == disableFilteringRow) {
sensitiveEnabled = !sensitiveEnabled;
TLRPC.TL_account_setContentSettings req = new TLRPC.TL_account_setContentSettings();
req.sensitive_enabled = sensitiveEnabled;
AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.show();
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
progressDialog.dismiss();
if (error == null) {
if (response instanceof TLRPC.TL_boolTrue && view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(sensitiveEnabled);
}
} else {
AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, this, req));
}
}));
} else if (position == unlimitedFavedStickersRow) {
NekoConfig.toggleUnlimitedFavedStickers();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.unlimitedFavedStickers);
}
} else if (position == deleteAccountRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("TosDeclineDeleteAccount", R.string.TosDeclineDeleteAccount));
builder.setTitle(LocaleController.getString("DeleteAccount", R.string.DeleteAccount));
builder.setPositiveButton(LocaleController.getString("Deactivate", R.string.Deactivate), (dialog, which) -> {
ArrayList<TLRPC.Dialog> dialogs = new ArrayList<>(getMessagesController().getAllDialogs());
for (TLRPC.Dialog TLdialog : dialogs) {
if (TLdialog instanceof TLRPC.TL_dialogFolder) {
continue;
}
TLRPC.Peer peer = getMessagesController().getPeer((int) TLdialog.id);
if (peer.channel_id != 0) {
TLRPC.Chat chat = getMessagesController().getChat(peer.channel_id);
if (!chat.broadcast) {
MessageHelper.getInstance(currentAccount).deleteUserChannelHistoryWithSearch(TLdialog.id, getMessagesController().getUser(getUserConfig().clientUserId));
}
}
if (peer.user_id != 0) {
getMessagesController().deleteDialog(TLdialog.id, 0, true);
}
}
AlertDialog.Builder builder12 = new AlertDialog.Builder(getParentActivity());
builder12.setMessage(LocaleController.getString("TosDeclineDeleteAccount", R.string.TosDeclineDeleteAccount));
builder12.setTitle(LocaleController.getString("DeleteAccount", R.string.DeleteAccount));
builder12.setPositiveButton(LocaleController.getString("Deactivate", R.string.Deactivate), (dialogInterface, i) -> {
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.setCanCacnel(false);
TLRPC.TL_account_deleteAccount req = new TLRPC.TL_account_deleteAccount();
req.reason = "Meow";
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
if (response instanceof TLRPC.TL_boolTrue) {
getMessagesController().performLogout(0);
} else if (error == null || error.code != -1000) {
String errorText = LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred);
if (error != null) {
errorText += "\n" + error.text;
}
AlertDialog.Builder builder1 = new AlertDialog.Builder(getParentActivity());
builder1.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder1.setMessage(errorText);
builder1.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder1.show();
}
}));
progressDialog.show();
});
builder12.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog dialog12 = builder12.create();
showDialog(dialog12);
TextView button = (TextView) dialog12.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.show();
AlertDialog dialog = builder.create();
showDialog(dialog);
TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
} else if (position == smoothKeyboardRow) {
SharedConfig.toggleSmoothKeyboard();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(SharedConfig.smoothKeyboard);
}
if (SharedConfig.smoothKeyboard && getParentActivity() != null) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
} else if (position == unlimitedPinnedDialogsRow) {
NekoConfig.toggleUnlimitedPinnedDialogs();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.unlimitedPinnedDialogs);
}
} else if (position == shouldNOTTrustMeRow) {
NekoConfig.toggleShouldNOTTrustMe();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.shouldNOTTrustMe);
}
}
});
restartTooltip = new UndoView(context);
restartTooltip.setInfoText(LocaleController.formatString("RestartAppToTakeEffect", R.string.RestartAppToTakeEffect));
frameLayout.addView(restartTooltip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
return fragmentView;
}
@Override
public void onResume() {
super.onResume();
if (listAdapter != null) {
checkSensitive();
listAdapter.notifyDataSetChanged();
}
}
private void updateRows() {
rowCount = 0;
experimentRow = rowCount++;
smoothKeyboardRow = !AndroidUtilities.isTablet() ? rowCount++ : -1;
saveCacheToPrivateDirectoryRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? rowCount++ : -1;
disableFilteringRow = rowCount++;
unlimitedFavedStickersRow = rowCount++;
unlimitedPinnedDialogsRow = rowCount++;
deleteAccountRow = NekoConfig.showHiddenFeature ? rowCount++ : -1;
experiment2Row = rowCount++;
shouldNOTTrustMeRow = BuildConfig.DEBUG ? rowCount++ : -1;
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
@Override
public ArrayList<ThemeDescription> getThemeDescriptions() {
ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{EmptyCell.class, TextSettingsCell.class, TextCheckCell.class, HeaderCell.class, TextDetailSettingsCell.class, NotificationsCheckCell.class}, null, null, null, Theme.key_windowBackgroundWhite));
themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_avatar_actionBarIconBlue));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_avatar_actionBarSelectorBlue));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, null, Theme.key_actionBarDefaultSubmenuBackground));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, null, Theme.key_actionBarDefaultSubmenuItem));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteValueText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
return themeDescriptions;
}
private void checkSensitive() {
TLRPC.TL_account_getContentSettings req = new TLRPC.TL_account_getContentSettings();
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (error == null) {
TLRPC.TL_account_contentSettings settings = (TLRPC.TL_account_contentSettings) response;
sensitiveEnabled = settings.sensitive_enabled;
sensitiveCanChange = settings.sensitive_can_change;
int count = listView.getChildCount();
ArrayList<Animator> animators = new ArrayList<>();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.getChildViewHolder(child);
int position = holder.getAdapterPosition();
if (position == disableFilteringRow) {
TextCheckCell checkCell = (TextCheckCell) holder.itemView;
checkCell.setChecked(sensitiveEnabled);
checkCell.setEnabled(sensitiveCanChange, animators);
if (sensitiveCanChange) {
if (!animators.isEmpty()) {
if (animatorSet != null) {
animatorSet.cancel();
}
animatorSet = new AnimatorSet();
animatorSet.playTogether(animators);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
if (animator.equals(animatorSet)) {
animatorSet = null;
}
}
});
animatorSet.setDuration(150);
animatorSet.start();
}
}
}
}
} else {
AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, this, req));
}
}));
}
private class ListAdapter extends RecyclerListView.SelectionAdapter {
private Context mContext;
public ListAdapter(Context context) {
mContext = context;
}
@Override
public int getItemCount() {
return rowCount;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
case 1: {
if (position == experiment2Row) {
holder.itemView.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
} else {
holder.itemView.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
}
break;
}
case 2: {
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
if (position == deleteAccountRow) {
textCell.setText(LocaleController.getString("DeleteAccount", R.string.DeleteAccount), false);
textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
}
break;
}
case 3: {
TextCheckCell textCell = (TextCheckCell) holder.itemView;
textCell.setEnabled(true, null);
if (position == saveCacheToPrivateDirectoryRow) {
textCell.setTextAndCheck(LocaleController.getString("SaveCacheToPrivateDirectory", R.string.SaveCacheToPrivateDirectory), NekoConfig.saveCacheToPrivateDirectory, true);
} else if (position == disableFilteringRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("SensitiveDisableFiltering", R.string.SensitiveDisableFiltering), LocaleController.getString("SensitiveAbout", R.string.SensitiveAbout), sensitiveEnabled, true, true);
textCell.setEnabled(sensitiveCanChange, null);
} else if (position == unlimitedFavedStickersRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedFavoredStickers", R.string.UnlimitedFavoredStickers), LocaleController.getString("UnlimitedFavoredStickersAbout", R.string.UnlimitedFavoredStickersAbout), NekoConfig.unlimitedFavedStickers, true, true);
} else if (position == smoothKeyboardRow) {
textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard), SharedConfig.smoothKeyboard, true);
} else if (position == unlimitedPinnedDialogsRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedPinnedDialogs", R.string.UnlimitedPinnedDialogs), LocaleController.getString("UnlimitedPinnedDialogsAbout", R.string.UnlimitedPinnedDialogsAbout), NekoConfig.unlimitedPinnedDialogs, true, deleteAccountRow != -1);
} else if (position == shouldNOTTrustMeRow) {
textCell.setTextAndCheck("Don't trust me", NekoConfig.shouldNOTTrustMe, false);
}
break;
}
case 4: {
HeaderCell headerCell = (HeaderCell) holder.itemView;
if (position == experimentRow) {
headerCell.setText(LocaleController.getString("Experiment", R.string.Experiment));
}
break;
}
}
}
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
int type = holder.getItemViewType();
return type == 2 || type == 3;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null;
switch (viewType) {
case 1:
view = new ShadowSectionCell(mContext);
break;
case 2:
view = new TextSettingsCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 3:
view = new TextCheckCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 4:
view = new HeaderCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 5:
view = new NotificationsCheckCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 6:
view = new TextDetailSettingsCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 7:
view = new TextInfoPrivacyCell(mContext);
view.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
break;
}
//noinspection ConstantConditions
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
return new RecyclerListView.Holder(view);
}
@Override
public int getItemViewType(int position) {
if (position == experiment2Row) {
return 1;
} else if (position == deleteAccountRow) {
return 2;
} else if (position == saveCacheToPrivateDirectoryRow || position == unlimitedFavedStickersRow || position == disableFilteringRow ||
position == smoothKeyboardRow || position == unlimitedPinnedDialogsRow || position == shouldNOTTrustMeRow) {
return 3;
} else if (position == experimentRow) {
return 4;
}
return 2;
}
}
}