Search in sources :

Example 1 with TextCheckCell

use of org.telegram.ui.Cells.TextCheckCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class NotificationsCustomSettingsActivity method checkRowsEnabled.

private void checkRowsEnabled() {
    if (!exceptions.isEmpty()) {
        return;
    }
    int count = listView.getChildCount();
    ArrayList<Animator> animators = new ArrayList<>();
    boolean enabled = getNotificationsController().isGlobalNotificationsEnabled(currentType);
    for (int a = 0; a < count; a++) {
        View child = listView.getChildAt(a);
        RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.getChildViewHolder(child);
        switch(holder.getItemViewType()) {
            case 0:
                {
                    HeaderCell headerCell = (HeaderCell) holder.itemView;
                    if (holder.getAdapterPosition() == messageSectionRow) {
                        headerCell.setEnabled(enabled, animators);
                    }
                    break;
                }
            case 1:
                {
                    TextCheckCell textCell = (TextCheckCell) holder.itemView;
                    textCell.setEnabled(enabled, animators);
                    break;
                }
            case 3:
                {
                    TextColorCell textCell = (TextColorCell) holder.itemView;
                    textCell.setEnabled(enabled, animators);
                    break;
                }
            case 5:
                {
                    TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
                    textCell.setEnabled(enabled, animators);
                    break;
                }
        }
    }
    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();
    }
}
Also used : TextCheckCell(org.telegram.ui.Cells.TextCheckCell) HeaderCell(org.telegram.ui.Cells.HeaderCell) ArrayList(java.util.ArrayList) AnimatorSet(android.animation.AnimatorSet) RecyclerListView(org.telegram.ui.Components.RecyclerListView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) EmptyTextProgressView(org.telegram.ui.Components.EmptyTextProgressView) TextView(android.widget.TextView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) Animator(android.animation.Animator) TextColorCell(org.telegram.ui.Cells.TextColorCell) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 2 with TextCheckCell

use of org.telegram.ui.Cells.TextCheckCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class NotificationsSettingsActivity method createView.

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });
    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
    listView = new RecyclerListView(context);
    listView.setItemAnimator(null);
    listView.setLayoutAnimation(null);
    listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) {

        @Override
        public boolean supportsPredictiveItemAnimations() {
            return false;
        }
    });
    listView.setVerticalScrollBarEnabled(false);
    frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(adapter = new ListAdapter(context));
    listView.setOnItemClickListener((view, position, x, y) -> {
        boolean enabled = false;
        if (getParentActivity() == null) {
            return;
        }
        if (position == privateRow || position == groupRow || position == channelsRow) {
            int type;
            ArrayList<NotificationException> exceptions;
            if (position == privateRow) {
                type = NotificationsController.TYPE_PRIVATE;
                exceptions = exceptionUsers;
            } else if (position == groupRow) {
                type = NotificationsController.TYPE_GROUP;
                exceptions = exceptionChats;
            } else {
                type = NotificationsController.TYPE_CHANNEL;
                exceptions = exceptionChannels;
            }
            if (exceptions == null) {
                return;
            }
            NotificationsCheckCell checkCell = (NotificationsCheckCell) view;
            enabled = getNotificationsController().isGlobalNotificationsEnabled(type);
            if (LocaleController.isRTL && x <= AndroidUtilities.dp(76) || !LocaleController.isRTL && x >= view.getMeasuredWidth() - AndroidUtilities.dp(76)) {
                getNotificationsController().setGlobalNotificationsEnabled(type, !enabled ? 0 : Integer.MAX_VALUE);
                showExceptionsAlert(position);
                checkCell.setChecked(!enabled, 0);
                adapter.notifyItemChanged(position);
            } else {
                presentFragment(new NotificationsCustomSettingsActivity(type, exceptions));
            }
        } else if (position == callsRingtoneRow) {
            try {
                SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
                Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
                tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE);
                tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
                tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
                tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));
                Uri currentSound = null;
                String defaultPath = null;
                Uri defaultUri = Settings.System.DEFAULT_RINGTONE_URI;
                if (defaultUri != null) {
                    defaultPath = defaultUri.getPath();
                }
                String path = preferences.getString("CallsRingtonePath", defaultPath);
                if (path != null && !path.equals("NoSound")) {
                    if (path.equals(defaultPath)) {
                        currentSound = defaultUri;
                    } else {
                        currentSound = Uri.parse(path);
                    }
                }
                tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
                startActivityForResult(tmpIntent, position);
            } catch (Exception e) {
                FileLog.e(e);
            }
        } else if (position == resetNotificationsRow) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("ResetNotificationsAlertTitle", R.string.ResetNotificationsAlertTitle));
            builder.setMessage(LocaleController.getString("ResetNotificationsAlert", R.string.ResetNotificationsAlert));
            builder.setPositiveButton(LocaleController.getString("Reset", R.string.Reset), (dialogInterface, i) -> {
                if (reseting) {
                    return;
                }
                reseting = true;
                TLRPC.TL_account_resetNotifySettings req = new TLRPC.TL_account_resetNotifySettings();
                ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                    getMessagesController().enableJoined = true;
                    reseting = false;
                    SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
                    SharedPreferences.Editor editor = preferences.edit();
                    editor.clear();
                    editor.commit();
                    exceptionChats.clear();
                    exceptionUsers.clear();
                    adapter.notifyDataSetChanged();
                    if (getParentActivity() != null) {
                        Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("ResetNotificationsText", R.string.ResetNotificationsText), Toast.LENGTH_SHORT);
                        toast.show();
                    }
                    getMessagesStorage().updateMutedDialogsFiltersCounters();
                }));
            });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            AlertDialog alertDialog = builder.create();
            showDialog(alertDialog);
            TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
            if (button != null) {
                button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
            }
        } else if (position == inappSoundRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = preferences.getBoolean("EnableInAppSounds", true);
            editor.putBoolean("EnableInAppSounds", !enabled);
            editor.commit();
        } else if (position == inappVibrateRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = preferences.getBoolean("EnableInAppVibrate", true);
            editor.putBoolean("EnableInAppVibrate", !enabled);
            editor.commit();
        } else if (position == inappPreviewRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = preferences.getBoolean("EnableInAppPreview", true);
            editor.putBoolean("EnableInAppPreview", !enabled);
            editor.commit();
        } else if (position == inchatSoundRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = preferences.getBoolean("EnableInChatSound", true);
            editor.putBoolean("EnableInChatSound", !enabled);
            editor.commit();
            getNotificationsController().setInChatSoundEnabled(!enabled);
        } else if (position == inappPriorityRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = preferences.getBoolean("EnableInAppPriority", false);
            editor.putBoolean("EnableInAppPriority", !enabled);
            editor.commit();
        } else if (position == contactJoinedRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = preferences.getBoolean("EnableContactJoined", true);
            MessagesController.getInstance(currentAccount).enableJoined = !enabled;
            editor.putBoolean("EnableContactJoined", !enabled);
            editor.commit();
            TLRPC.TL_account_setContactSignUpNotification req = new TLRPC.TL_account_setContactSignUpNotification();
            req.silent = enabled;
            ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
            });
        } else if (position == pinnedMessageRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = preferences.getBoolean("PinnedMessages", true);
            editor.putBoolean("PinnedMessages", !enabled);
            editor.commit();
        } else if (position == androidAutoAlertRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = preferences.getBoolean("EnableAutoNotifications", false);
            editor.putBoolean("EnableAutoNotifications", !enabled);
            editor.commit();
        } else if (position == badgeNumberShowRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = getNotificationsController().showBadgeNumber;
            getNotificationsController().showBadgeNumber = !enabled;
            editor.putBoolean("badgeNumber", getNotificationsController().showBadgeNumber);
            editor.commit();
            getNotificationsController().updateBadge();
        } else if (position == badgeNumberMutedRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = getNotificationsController().showBadgeMuted;
            getNotificationsController().showBadgeMuted = !enabled;
            editor.putBoolean("badgeNumberMuted", getNotificationsController().showBadgeMuted);
            editor.commit();
            getNotificationsController().updateBadge();
            getMessagesStorage().updateMutedDialogsFiltersCounters();
        } else if (position == badgeNumberMessagesRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            SharedPreferences.Editor editor = preferences.edit();
            enabled = getNotificationsController().showBadgeMessages;
            getNotificationsController().showBadgeMessages = !enabled;
            editor.putBoolean("badgeNumberMessages", getNotificationsController().showBadgeMessages);
            editor.commit();
            getNotificationsController().updateBadge();
        } else if (position == notificationsServiceConnectionRow) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            enabled = preferences.getBoolean("pushConnection", getMessagesController().backgroundConnection);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putBoolean("pushConnection", !enabled);
            enabled = preferences.getBoolean("pushService", getMessagesController().keepAliveService);
            editor.putBoolean("pushService", !enabled);
            editor.commit();
            if (!enabled) {
                ConnectionsManager.getInstance(currentAccount).setPushConnectionEnabled(true);
            } else {
                ConnectionsManager.getInstance(currentAccount).setPushConnectionEnabled(false);
            }
            ApplicationLoader.startPushService();
        } else if (position == accountsAllRow) {
            SharedPreferences preferences = MessagesController.getGlobalNotificationsSettings();
            enabled = preferences.getBoolean("AllAccounts", true);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putBoolean("AllAccounts", !enabled);
            editor.commit();
            SharedConfig.showNotificationsForAllAccounts = !enabled;
            for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
                if (SharedConfig.showNotificationsForAllAccounts) {
                    NotificationsController.getInstance(a).showNotifications();
                } else {
                    if (a == currentAccount) {
                        NotificationsController.getInstance(a).showNotifications();
                    } else {
                        NotificationsController.getInstance(a).hideNotifications();
                    }
                }
            }
        } else if (position == callsVibrateRow) {
            if (getParentActivity() == null) {
                return;
            }
            String key = null;
            if (position == callsVibrateRow) {
                key = "vibrate_calls";
            }
            showDialog(AlertsCreator.createVibrationSelectDialog(getParentActivity(), 0, key, () -> adapter.notifyItemChanged(position)));
        } else if (position == repeatRow) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications));
            builder.setItems(new CharSequence[] { LocaleController.getString("RepeatDisabled", R.string.RepeatDisabled), LocaleController.formatPluralString("Minutes", 5), LocaleController.formatPluralString("Minutes", 10), LocaleController.formatPluralString("Minutes", 30), LocaleController.formatPluralString("Hours", 1), LocaleController.formatPluralString("Hours", 2), LocaleController.formatPluralString("Hours", 4) }, (dialog, which) -> {
                int minutes = 0;
                if (which == 1) {
                    minutes = 5;
                } else if (which == 2) {
                    minutes = 10;
                } else if (which == 3) {
                    minutes = 30;
                } else if (which == 4) {
                    minutes = 60;
                } else if (which == 5) {
                    minutes = 60 * 2;
                } else if (which == 6) {
                    minutes = 60 * 4;
                }
                SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
                preferences.edit().putInt("repeat_messages", minutes).commit();
                adapter.notifyItemChanged(position);
            });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
        }
        if (view instanceof TextCheckCell) {
            ((TextCheckCell) view).setChecked(!enabled);
        }
    });
    return fragmentView;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Ringtone(android.media.Ringtone) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) AndroidUtilities(org.telegram.messenger.AndroidUtilities) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) ApplicationLoader(org.telegram.messenger.ApplicationLoader) Map(java.util.Map) NotificationsCheckCell(org.telegram.ui.Cells.NotificationsCheckCell) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NotificationsController(org.telegram.messenger.NotificationsController) Utilities(org.telegram.messenger.Utilities) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) ViewGroup(android.view.ViewGroup) NotificationCenter(org.telegram.messenger.NotificationCenter) UserConfig(org.telegram.messenger.UserConfig) TextView(android.widget.TextView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) LongSparseArray(android.util.LongSparseArray) Context(android.content.Context) Theme(org.telegram.ui.ActionBar.Theme) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HeaderCell(org.telegram.ui.Cells.HeaderCell) AlertsCreator(org.telegram.ui.Components.AlertsCreator) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) ArrayList(java.util.ArrayList) TextDetailSettingsCell(org.telegram.ui.Cells.TextDetailSettingsCell) TLRPC(org.telegram.tgnet.TLRPC) Toast(android.widget.Toast) ActionBar(org.telegram.ui.ActionBar.ActionBar) Settings(android.provider.Settings) SharedConfig(org.telegram.messenger.SharedConfig) Build(android.os.Build) DialogInterface(android.content.DialogInterface) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) DialogObject(org.telegram.messenger.DialogObject) R(org.telegram.messenger.R) TextUtils(android.text.TextUtils) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileLog(org.telegram.messenger.FileLog) MessagesController(org.telegram.messenger.MessagesController) SharedPreferences(android.content.SharedPreferences) MessagesStorage(org.telegram.messenger.MessagesStorage) RingtoneManager(android.media.RingtoneManager) TextCheckCell(org.telegram.ui.Cells.TextCheckCell) Activity(android.app.Activity) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextCheckCell(org.telegram.ui.Cells.TextCheckCell) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Uri(android.net.Uri) TLRPC(org.telegram.tgnet.TLRPC) Toast(android.widget.Toast) TextView(android.widget.TextView) ActionBar(org.telegram.ui.ActionBar.ActionBar) SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) NotificationsCheckCell(org.telegram.ui.Cells.NotificationsCheckCell) FrameLayout(android.widget.FrameLayout)

Example 3 with TextCheckCell

use of org.telegram.ui.Cells.TextCheckCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class PasscodeActivity method createView.

@Override
public View createView(Context context) {
    if (type != 3) {
        actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    }
    actionBar.setAllowOverlayTitle(false);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                if (passcodeSetStep == 0) {
                    processNext();
                } else if (passcodeSetStep == 1) {
                    processDone();
                }
            } else if (id == pin_item) {
                currentPasswordType = 0;
                updateDropDownTextView();
            } else if (id == password_item) {
                currentPasswordType = 1;
                updateDropDownTextView();
            }
        }
    });
    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    if (type != 0) {
        ActionBarMenu menu = actionBar.createMenu();
        menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done));
        titleTextView = new TextView(context);
        titleTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
        if (type == 1) {
            if (SharedConfig.passcodeHash.length() != 0) {
                titleTextView.setText(LocaleController.getString("EnterNewPasscode", R.string.EnterNewPasscode));
            } else {
                titleTextView.setText(LocaleController.getString("EnterNewFirstPasscode", R.string.EnterNewFirstPasscode));
            }
        } else {
            titleTextView.setText(LocaleController.getString("EnterCurrentPasscode", R.string.EnterCurrentPasscode));
        }
        titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        titleTextView.setGravity(Gravity.CENTER_HORIZONTAL);
        frameLayout.addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 38, 0, 0));
        passwordEditText = new EditTextBoldCursor(context);
        passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
        passwordEditText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        passwordEditText.setBackgroundDrawable(Theme.createEditTextDrawable(context, false));
        passwordEditText.setMaxLines(1);
        passwordEditText.setLines(1);
        passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL);
        passwordEditText.setSingleLine(true);
        if (type == 1) {
            passcodeSetStep = 0;
            passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        } else {
            passcodeSetStep = 1;
            passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
        }
        passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
        passwordEditText.setTypeface(Typeface.DEFAULT);
        passwordEditText.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        passwordEditText.setCursorSize(AndroidUtilities.dp(20));
        passwordEditText.setCursorWidth(1.5f);
        frameLayout.addView(passwordEditText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.TOP | Gravity.LEFT, 40, 90, 40, 0));
        passwordEditText.setOnEditorActionListener((textView, i, keyEvent) -> {
            if (passcodeSetStep == 0) {
                processNext();
                return true;
            } else if (passcodeSetStep == 1) {
                processDone();
                return true;
            }
            return false;
        });
        passwordEditText.addTextChangedListener(new TextWatcher() {

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (passwordEditText.length() == 4) {
                    if (type == 2 && SharedConfig.passcodeType == 0) {
                        processDone();
                    } else if (type == 1 && currentPasswordType == 0) {
                        if (passcodeSetStep == 0) {
                            processNext();
                        } else if (passcodeSetStep == 1) {
                            processDone();
                        }
                    }
                }
            }
        });
        passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {

            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public void onDestroyActionMode(ActionMode mode) {
            }

            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }
        });
        if (type == 1) {
            frameLayout.setTag(Theme.key_windowBackgroundWhite);
            dropDownContainer = new ActionBarMenuItem(context, menu, 0, 0);
            dropDownContainer.setSubMenuOpenSide(1);
            dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", R.string.PasscodePIN));
            dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword));
            actionBar.addView(dropDownContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, AndroidUtilities.isTablet() ? 64 : 56, 0, 40, 0));
            dropDownContainer.setOnClickListener(view -> dropDownContainer.toggleSubMenu());
            dropDown = new TextView(context);
            dropDown.setGravity(Gravity.LEFT);
            dropDown.setSingleLine(true);
            dropDown.setLines(1);
            dropDown.setMaxLines(1);
            dropDown.setEllipsize(TextUtils.TruncateAt.END);
            dropDown.setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle));
            dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
            dropDownDrawable = context.getResources().getDrawable(R.drawable.ic_arrow_drop_down).mutate();
            dropDownDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultTitle), PorterDuff.Mode.MULTIPLY));
            dropDown.setCompoundDrawablesWithIntrinsicBounds(null, null, dropDownDrawable, null);
            dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4));
            dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0);
            dropDownContainer.addView(dropDown, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 16, 0, 0, 1));
        } else {
            actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode));
        }
        updateDropDownTextView();
    } else {
        actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode));
        frameLayout.setTag(Theme.key_windowBackgroundGray);
        frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
        listView = new RecyclerListView(context);
        listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) {

            @Override
            public boolean supportsPredictiveItemAnimations() {
                return false;
            }
        });
        listView.setVerticalScrollBarEnabled(false);
        listView.setItemAnimator(null);
        listView.setLayoutAnimation(null);
        frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
        listView.setAdapter(listAdapter = new ListAdapter(context));
        listView.setOnItemClickListener((view, position) -> {
            if (!view.isEnabled()) {
                return;
            }
            if (position == changePasscodeRow) {
                presentFragment(new PasscodeActivity(1));
            } else if (position == passcodeRow) {
                TextCheckCell cell = (TextCheckCell) view;
                if (SharedConfig.passcodeHash.length() != 0) {
                    SharedConfig.passcodeHash = "";
                    SharedConfig.appLocked = false;
                    SharedConfig.saveConfig();
                    getMediaDataController().buildShortcuts();
                    int count = listView.getChildCount();
                    for (int a = 0; a < count; a++) {
                        View child = listView.getChildAt(a);
                        if (child instanceof TextSettingsCell) {
                            TextSettingsCell textCell = (TextSettingsCell) child;
                            textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText7));
                            break;
                        }
                    }
                    cell.setChecked(SharedConfig.passcodeHash.length() != 0);
                    NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetPasscode);
                } else {
                    presentFragment(new PasscodeActivity(1));
                }
            } else if (position == autoLockRow) {
                if (getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock));
                final NumberPicker numberPicker = new NumberPicker(getParentActivity());
                numberPicker.setMinValue(0);
                numberPicker.setMaxValue(4);
                if (SharedConfig.autoLockIn == 0) {
                    numberPicker.setValue(0);
                } else if (SharedConfig.autoLockIn == 60) {
                    numberPicker.setValue(1);
                } else if (SharedConfig.autoLockIn == 60 * 5) {
                    numberPicker.setValue(2);
                } else if (SharedConfig.autoLockIn == 60 * 60) {
                    numberPicker.setValue(3);
                } else if (SharedConfig.autoLockIn == 60 * 60 * 5) {
                    numberPicker.setValue(4);
                }
                numberPicker.setFormatter(value -> {
                    if (value == 0) {
                        return LocaleController.getString("AutoLockDisabled", R.string.AutoLockDisabled);
                    } else if (value == 1) {
                        return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 1));
                    } else if (value == 2) {
                        return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 5));
                    } else if (value == 3) {
                        return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 1));
                    } else if (value == 4) {
                        return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 5));
                    }
                    return "";
                });
                builder.setView(numberPicker);
                builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), (dialog, which) -> {
                    which = numberPicker.getValue();
                    if (which == 0) {
                        SharedConfig.autoLockIn = 0;
                    } else if (which == 1) {
                        SharedConfig.autoLockIn = 60;
                    } else if (which == 2) {
                        SharedConfig.autoLockIn = 60 * 5;
                    } else if (which == 3) {
                        SharedConfig.autoLockIn = 60 * 60;
                    } else if (which == 4) {
                        SharedConfig.autoLockIn = 60 * 60 * 5;
                    }
                    listAdapter.notifyItemChanged(position);
                    UserConfig.getInstance(currentAccount).saveConfig(false);
                });
                showDialog(builder.create());
            } else if (position == fingerprintRow) {
                SharedConfig.useFingerprint = !SharedConfig.useFingerprint;
                UserConfig.getInstance(currentAccount).saveConfig(false);
                ((TextCheckCell) view).setChecked(SharedConfig.useFingerprint);
            } else if (position == captureRow) {
                SharedConfig.allowScreenCapture = !SharedConfig.allowScreenCapture;
                UserConfig.getInstance(currentAccount).saveConfig(false);
                ((TextCheckCell) view).setChecked(SharedConfig.allowScreenCapture);
                NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetPasscode);
                if (!SharedConfig.allowScreenCapture) {
                    AlertsCreator.showSimpleAlert(PasscodeActivity.this, LocaleController.getString("ScreenCaptureAlert", R.string.ScreenCaptureAlert));
                }
            }
        });
    }
    return fragmentView;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) TextCheckCell(org.telegram.ui.Cells.TextCheckCell) SpannableStringBuilder(android.text.SpannableStringBuilder) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) Menu(android.view.Menu) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) ActionBar(org.telegram.ui.ActionBar.ActionBar) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) NumberPicker(org.telegram.ui.Components.NumberPicker) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) MenuItem(android.view.MenuItem) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) ActionMode(android.view.ActionMode) FrameLayout(android.widget.FrameLayout)

Example 4 with TextCheckCell

use of org.telegram.ui.Cells.TextCheckCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class VoIPHelper method showCallDebugSettings.

public static void showCallDebugSettings(final Context context) {
    final SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    LinearLayout ll = new LinearLayout(context);
    ll.setOrientation(LinearLayout.VERTICAL);
    TextView warning = new TextView(context);
    warning.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    warning.setText("Please only change these settings if you know exactly what they do.");
    warning.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    ll.addView(warning, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 16, 8, 16, 8));
    final TextCheckCell tcpCell = new TextCheckCell(context);
    tcpCell.setTextAndCheck("Force TCP", preferences.getBoolean("dbg_force_tcp_in_calls", false), false);
    tcpCell.setOnClickListener(v -> {
        boolean force = preferences.getBoolean("dbg_force_tcp_in_calls", false);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putBoolean("dbg_force_tcp_in_calls", !force);
        editor.commit();
        tcpCell.setChecked(!force);
    });
    ll.addView(tcpCell);
    if (BuildVars.DEBUG_VERSION && BuildVars.LOGS_ENABLED) {
        final TextCheckCell dumpCell = new TextCheckCell(context);
        dumpCell.setTextAndCheck("Dump detailed stats", preferences.getBoolean("dbg_dump_call_stats", false), false);
        dumpCell.setOnClickListener(v -> {
            boolean force = preferences.getBoolean("dbg_dump_call_stats", false);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putBoolean("dbg_dump_call_stats", !force);
            editor.commit();
            dumpCell.setChecked(!force);
        });
        ll.addView(dumpCell);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        final TextCheckCell connectionServiceCell = new TextCheckCell(context);
        connectionServiceCell.setTextAndCheck("Enable ConnectionService", preferences.getBoolean("dbg_force_connection_service", false), false);
        connectionServiceCell.setOnClickListener(v -> {
            boolean force = preferences.getBoolean("dbg_force_connection_service", false);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putBoolean("dbg_force_connection_service", !force);
            editor.commit();
            connectionServiceCell.setChecked(!force);
        });
        ll.addView(connectionServiceCell);
    }
    new AlertDialog.Builder(context).setTitle(LocaleController.getString("DebugMenuCallSettings", R.string.DebugMenuCallSettings)).setView(ll).show();
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) SharedPreferences(android.content.SharedPreferences) TextCheckCell(org.telegram.ui.Cells.TextCheckCell) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 5 with TextCheckCell

use of org.telegram.ui.Cells.TextCheckCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class DataSettingsActivity method createView.

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setTitle(LocaleController.getString("DataSettings", R.string.DataSettings));
    if (AndroidUtilities.isTablet()) {
        actionBar.setOccupyStatusBar(false);
    }
    actionBar.setAllowOverlayTitle(true);
    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(layoutManager = 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 == mobileRow || position == roamingRow || position == wifiRow) {
            if (LocaleController.isRTL && x <= AndroidUtilities.dp(76) || !LocaleController.isRTL && x >= view.getMeasuredWidth() - AndroidUtilities.dp(76)) {
                boolean wasEnabled = listAdapter.isRowEnabled(resetDownloadRow);
                NotificationsCheckCell cell = (NotificationsCheckCell) view;
                boolean checked = cell.isChecked();
                DownloadController.Preset preset;
                DownloadController.Preset defaultPreset;
                String key;
                String key2;
                int num;
                if (position == mobileRow) {
                    preset = DownloadController.getInstance(currentAccount).mobilePreset;
                    defaultPreset = DownloadController.getInstance(currentAccount).mediumPreset;
                    key = "mobilePreset";
                    key2 = "currentMobilePreset";
                    num = 0;
                } else if (position == wifiRow) {
                    preset = DownloadController.getInstance(currentAccount).wifiPreset;
                    defaultPreset = DownloadController.getInstance(currentAccount).highPreset;
                    key = "wifiPreset";
                    key2 = "currentWifiPreset";
                    num = 1;
                } else {
                    preset = DownloadController.getInstance(currentAccount).roamingPreset;
                    defaultPreset = DownloadController.getInstance(currentAccount).lowPreset;
                    key = "roamingPreset";
                    key2 = "currentRoamingPreset";
                    num = 2;
                }
                if (!checked && preset.enabled) {
                    preset.set(defaultPreset);
                } else {
                    preset.enabled = !preset.enabled;
                }
                SharedPreferences.Editor editor = MessagesController.getMainSettings(currentAccount).edit();
                editor.putString(key, preset.toString());
                editor.putInt(key2, 3);
                editor.commit();
                cell.setChecked(!checked);
                RecyclerView.ViewHolder holder = listView.findContainingViewHolder(view);
                if (holder != null) {
                    listAdapter.onBindViewHolder(holder, position);
                }
                DownloadController.getInstance(currentAccount).checkAutodownloadSettings();
                DownloadController.getInstance(currentAccount).savePresetToServer(num);
                if (wasEnabled != listAdapter.isRowEnabled(resetDownloadRow)) {
                    listAdapter.notifyItemChanged(resetDownloadRow);
                }
            } else {
                int type;
                if (position == mobileRow) {
                    type = 0;
                } else if (position == wifiRow) {
                    type = 1;
                } else {
                    type = 2;
                }
                presentFragment(new DataAutoDownloadActivity(type));
            }
        } else if (position == resetDownloadRow) {
            if (getParentActivity() == null || !view.isEnabled()) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("ResetAutomaticMediaDownloadAlertTitle", R.string.ResetAutomaticMediaDownloadAlertTitle));
            builder.setMessage(LocaleController.getString("ResetAutomaticMediaDownloadAlert", R.string.ResetAutomaticMediaDownloadAlert));
            builder.setPositiveButton(LocaleController.getString("Reset", R.string.Reset), (dialogInterface, i) -> {
                DownloadController.Preset preset;
                DownloadController.Preset defaultPreset;
                String key;
                SharedPreferences.Editor editor = MessagesController.getMainSettings(currentAccount).edit();
                for (int a = 0; a < 3; a++) {
                    if (a == 0) {
                        preset = DownloadController.getInstance(currentAccount).mobilePreset;
                        defaultPreset = DownloadController.getInstance(currentAccount).mediumPreset;
                        key = "mobilePreset";
                    } else if (a == 1) {
                        preset = DownloadController.getInstance(currentAccount).wifiPreset;
                        defaultPreset = DownloadController.getInstance(currentAccount).highPreset;
                        key = "wifiPreset";
                    } else {
                        preset = DownloadController.getInstance(currentAccount).roamingPreset;
                        defaultPreset = DownloadController.getInstance(currentAccount).lowPreset;
                        key = "roamingPreset";
                    }
                    preset.set(defaultPreset);
                    preset.enabled = defaultPreset.isEnabled();
                    editor.putInt("currentMobilePreset", DownloadController.getInstance(currentAccount).currentMobilePreset = 3);
                    editor.putInt("currentWifiPreset", DownloadController.getInstance(currentAccount).currentWifiPreset = 3);
                    editor.putInt("currentRoamingPreset", DownloadController.getInstance(currentAccount).currentRoamingPreset = 3);
                    editor.putString(key, preset.toString());
                }
                editor.commit();
                DownloadController.getInstance(currentAccount).checkAutodownloadSettings();
                for (int a = 0; a < 3; a++) {
                    DownloadController.getInstance(currentAccount).savePresetToServer(a);
                }
                listAdapter.notifyItemRangeChanged(mobileRow, 4);
            });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            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 == storageUsageRow) {
            presentFragment(new CacheControlActivity());
        } else if (position == useLessDataForCallsRow) {
            final SharedPreferences preferences = MessagesController.getGlobalMainSettings();
            int selected = 0;
            switch(preferences.getInt("VoipDataSaving", VoIPHelper.getDataSavingDefault())) {
                case Instance.DATA_SAVING_NEVER:
                    selected = 0;
                    break;
                case Instance.DATA_SAVING_ROAMING:
                    selected = 1;
                    break;
                case Instance.DATA_SAVING_MOBILE:
                    selected = 2;
                    break;
                case Instance.DATA_SAVING_ALWAYS:
                    selected = 3;
                    break;
            }
            Dialog dlg = AlertsCreator.createSingleChoiceDialog(getParentActivity(), new String[] { LocaleController.getString("UseLessDataNever", R.string.UseLessDataNever), LocaleController.getString("UseLessDataOnRoaming", R.string.UseLessDataOnRoaming), LocaleController.getString("UseLessDataOnMobile", R.string.UseLessDataOnMobile), LocaleController.getString("UseLessDataAlways", R.string.UseLessDataAlways) }, LocaleController.getString("VoipUseLessData", R.string.VoipUseLessData), selected, (dialog, which) -> {
                int val = -1;
                switch(which) {
                    case 0:
                        val = Instance.DATA_SAVING_NEVER;
                        break;
                    case 1:
                        val = Instance.DATA_SAVING_ROAMING;
                        break;
                    case 2:
                        val = Instance.DATA_SAVING_MOBILE;
                        break;
                    case 3:
                        val = Instance.DATA_SAVING_ALWAYS;
                        break;
                }
                if (val != -1) {
                    preferences.edit().putInt("VoipDataSaving", val).commit();
                }
                if (listAdapter != null) {
                    listAdapter.notifyItemChanged(position);
                }
            });
            setVisibleDialog(dlg);
            dlg.show();
        } else if (position == dataUsageRow) {
            presentFragment(new DataUsageActivity());
        } else if (position == storageNumRow) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("StoragePath", R.string.StoragePath));
            final LinearLayout linearLayout = new LinearLayout(getParentActivity());
            linearLayout.setOrientation(LinearLayout.VERTICAL);
            builder.setView(linearLayout);
            String dir = storageDirs.get(0).getAbsolutePath();
            if (!TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
                for (int a = 0, N = storageDirs.size(); a < N; a++) {
                    String path = storageDirs.get(a).getAbsolutePath();
                    if (path.startsWith(SharedConfig.storageCacheDir)) {
                        dir = path;
                        break;
                    }
                }
            }
            for (int a = 0, N = storageDirs.size(); a < N; a++) {
                String storageDir = storageDirs.get(a).getAbsolutePath();
                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(storageDir, storageDir.startsWith(dir));
                linearLayout.addView(cell);
                cell.setOnClickListener(v -> {
                    SharedConfig.storageCacheDir = storageDir;
                    SharedConfig.saveConfig();
                    ImageLoader.getInstance().checkMediaPaths();
                    builder.getDismissRunnable().run();
                    listAdapter.notifyItemChanged(storageNumRow);
                });
            }
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
        } else if (position == proxyRow) {
            presentFragment(new ProxyListActivity());
        } else if (position == enableStreamRow) {
            SharedConfig.toggleStreamMedia();
            TextCheckCell textCheckCell = (TextCheckCell) view;
            textCheckCell.setChecked(SharedConfig.streamMedia);
        } else if (position == enableAllStreamRow) {
            SharedConfig.toggleStreamAllVideo();
            TextCheckCell textCheckCell = (TextCheckCell) view;
            textCheckCell.setChecked(SharedConfig.streamAllVideo);
        } else if (position == enableMkvRow) {
            SharedConfig.toggleStreamMkv();
            TextCheckCell textCheckCell = (TextCheckCell) view;
            textCheckCell.setChecked(SharedConfig.streamMkv);
        } else if (position == enableCacheStreamRow) {
            SharedConfig.toggleSaveStreamMedia();
            TextCheckCell textCheckCell = (TextCheckCell) view;
            textCheckCell.setChecked(SharedConfig.saveStreamMedia);
        } else if (position == quickRepliesRow) {
            presentFragment(new QuickRepliesSettingsActivity());
        } else if (position == autoplayGifsRow) {
            SharedConfig.toggleAutoplayGifs();
            if (view instanceof TextCheckCell) {
                ((TextCheckCell) view).setChecked(SharedConfig.autoplayGifs);
            }
        } else if (position == autoplayVideoRow) {
            SharedConfig.toggleAutoplayVideo();
            if (view instanceof TextCheckCell) {
                ((TextCheckCell) view).setChecked(SharedConfig.autoplayVideo);
            }
        } else if (position == clearDraftsRow) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("AreYouSureClearDraftsTitle", R.string.AreYouSureClearDraftsTitle));
            builder.setMessage(LocaleController.getString("AreYouSureClearDrafts", R.string.AreYouSureClearDrafts));
            builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
                TLRPC.TL_messages_clearAllDrafts req = new TLRPC.TL_messages_clearAllDrafts();
                getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> getMediaDataController().clearAllDrafts(true)));
            });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            AlertDialog alertDialog = builder.create();
            showDialog(alertDialog);
            TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
            if (button != null) {
                button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
            }
        }
    });
    return fragmentView;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Context(android.content.Context) LinearLayout(android.widget.LinearLayout) Theme(org.telegram.ui.ActionBar.Theme) FrameLayout(android.widget.FrameLayout) AndroidUtilities(org.telegram.messenger.AndroidUtilities) Dialog(android.app.Dialog) LocaleController(org.telegram.messenger.LocaleController) HeaderCell(org.telegram.ui.Cells.HeaderCell) AlertsCreator(org.telegram.ui.Components.AlertsCreator) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) ArrayList(java.util.ArrayList) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) TLRPC(org.telegram.tgnet.TLRPC) ActionBar(org.telegram.ui.ActionBar.ActionBar) NotificationsCheckCell(org.telegram.ui.Cells.NotificationsCheckCell) View(android.view.View) SharedConfig(org.telegram.messenger.SharedConfig) BuildVars(org.telegram.messenger.BuildVars) RecyclerView(androidx.recyclerview.widget.RecyclerView) Build(android.os.Build) DownloadController(org.telegram.messenger.DownloadController) DialogInterface(android.content.DialogInterface) ImageLoader(org.telegram.messenger.ImageLoader) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) R(org.telegram.messenger.R) TextUtils(android.text.TextUtils) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) LayoutHelper(org.telegram.ui.Components.LayoutHelper) Instance(org.telegram.messenger.voip.Instance) ViewGroup(android.view.ViewGroup) File(java.io.File) MessagesController(org.telegram.messenger.MessagesController) Gravity(android.view.Gravity) TextView(android.widget.TextView) SharedPreferences(android.content.SharedPreferences) RadioColorCell(org.telegram.ui.Cells.RadioColorCell) TextCheckCell(org.telegram.ui.Cells.TextCheckCell) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) VoIPHelper(org.telegram.ui.Components.voip.VoIPHelper) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextCheckCell(org.telegram.ui.Cells.TextCheckCell) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TLRPC(org.telegram.tgnet.TLRPC) Dialog(android.app.Dialog) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) TextView(android.widget.TextView) ActionBar(org.telegram.ui.ActionBar.ActionBar) SharedPreferences(android.content.SharedPreferences) NotificationsCheckCell(org.telegram.ui.Cells.NotificationsCheckCell) FrameLayout(android.widget.FrameLayout) DownloadController(org.telegram.messenger.DownloadController) RecyclerView(androidx.recyclerview.widget.RecyclerView) RadioColorCell(org.telegram.ui.Cells.RadioColorCell) LinearLayout(android.widget.LinearLayout)

Aggregations

TextCheckCell (org.telegram.ui.Cells.TextCheckCell)18 View (android.view.View)15 ActionBar (org.telegram.ui.ActionBar.ActionBar)15 TextView (android.widget.TextView)13 HeaderCell (org.telegram.ui.Cells.HeaderCell)13 RecyclerListView (org.telegram.ui.Components.RecyclerListView)13 FrameLayout (android.widget.FrameLayout)12 RecyclerView (androidx.recyclerview.widget.RecyclerView)12 ArrayList (java.util.ArrayList)12 AlertDialog (org.telegram.ui.ActionBar.AlertDialog)12 TextInfoPrivacyCell (org.telegram.ui.Cells.TextInfoPrivacyCell)12 TextSettingsCell (org.telegram.ui.Cells.TextSettingsCell)12 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)11 TLRPC (org.telegram.tgnet.TLRPC)11 Context (android.content.Context)10 ViewGroup (android.view.ViewGroup)10 AndroidUtilities (org.telegram.messenger.AndroidUtilities)10 LocaleController (org.telegram.messenger.LocaleController)10 R (org.telegram.messenger.R)10 BaseFragment (org.telegram.ui.ActionBar.BaseFragment)10