use of org.telegram.ui.Cells.TextSettingsCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class ThemeSetUrlActivity method createView.
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
if (creatingNewTheme) {
actionBar.setTitle(LocaleController.getString("NewThemeTitle", R.string.NewThemeTitle));
} else {
actionBar.setTitle(LocaleController.getString("EditThemeTitle", R.string.EditThemeTitle));
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == done_button) {
saveTheme();
}
}
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItem(done_button, LocaleController.getString("Done", R.string.Done).toUpperCase());
fragmentView = new LinearLayout(context);
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
LinearLayout linearLayout = (LinearLayout) fragmentView;
linearLayout.setOrientation(LinearLayout.VERTICAL);
fragmentView.setOnTouchListener((v, event) -> true);
linearLayoutTypeContainer = new LinearLayout(context);
linearLayoutTypeContainer.setOrientation(LinearLayout.VERTICAL);
linearLayoutTypeContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout.addView(linearLayoutTypeContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
headerCell = new HeaderCell(context, 23);
headerCell.setText(LocaleController.getString("Info", R.string.Info));
linearLayoutTypeContainer.addView(headerCell);
nameField = new EditTextBoldCursor(context);
nameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
nameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
nameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
nameField.setMaxLines(1);
nameField.setLines(1);
nameField.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
nameField.setBackgroundDrawable(null);
nameField.setPadding(0, 0, 0, 0);
nameField.setSingleLine(true);
InputFilter[] inputFilters = new InputFilter[1];
inputFilters[0] = new InputFilter.LengthFilter(128);
nameField.setFilters(inputFilters);
nameField.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
nameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
nameField.setHint(LocaleController.getString("ThemeNamePlaceholder", R.string.ThemeNamePlaceholder));
nameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
nameField.setCursorSize(AndroidUtilities.dp(20));
nameField.setCursorWidth(1.5f);
linearLayoutTypeContainer.addView(nameField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50, 23, 0, 23, 0));
nameField.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_DONE) {
AndroidUtilities.hideKeyboard(nameField);
return true;
}
return false;
});
divider = new View(context) {
@Override
protected void onDraw(Canvas canvas) {
canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
}
};
linearLayoutTypeContainer.addView(divider, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
LinearLayout linkContainer = new LinearLayout(context);
linkContainer.setOrientation(LinearLayout.HORIZONTAL);
linearLayoutTypeContainer.addView(linkContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50, 23, 0, 23, 0));
editText = new EditTextBoldCursor(context);
editText.setText(getMessagesController().linkPrefix + "/addtheme/");
editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
editText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
editText.setMaxLines(1);
editText.setLines(1);
editText.setEnabled(false);
editText.setBackgroundDrawable(null);
editText.setPadding(0, 0, 0, 0);
editText.setSingleLine(true);
editText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
linkContainer.addView(editText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 50));
linkField = new EditTextBoldCursor(context);
linkField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
linkField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
linkField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
linkField.setMaxLines(1);
linkField.setLines(1);
linkField.setBackgroundDrawable(null);
linkField.setPadding(0, 0, 0, 0);
linkField.setSingleLine(true);
linkField.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
linkField.setImeOptions(EditorInfo.IME_ACTION_DONE);
linkField.setHint(LocaleController.getString("SetUrlPlaceholder", R.string.SetUrlPlaceholder));
linkField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
linkField.setCursorSize(AndroidUtilities.dp(20));
linkField.setCursorWidth(1.5f);
linkContainer.addView(linkField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50));
linkField.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
doneButton.performClick();
return true;
}
return false;
});
linkField.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
if (ignoreCheck) {
return;
}
checkUrl(linkField.getText().toString(), false);
}
@Override
public void afterTextChanged(Editable editable) {
if (creatingNewTheme) {
return;
}
if (linkField.length() > 0) {
String url = "https://" + getMessagesController().linkPrefix + "/addtheme/" + linkField.getText();
String text = LocaleController.formatString("ThemeHelpLink", R.string.ThemeHelpLink, url);
int index = text.indexOf(url);
SpannableStringBuilder textSpan = new SpannableStringBuilder(text);
if (index >= 0) {
textSpan.setSpan(new LinkSpan(url), index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
helpInfoCell.setText(TextUtils.concat(infoText, "\n\n", textSpan));
} else {
helpInfoCell.setText(infoText);
}
}
});
if (creatingNewTheme) {
linkField.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
helpInfoCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("ThemeCreateHelp2", R.string.ThemeCreateHelp2)));
} else {
helpInfoCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("ThemeCreateHelp", R.string.ThemeCreateHelp)));
}
});
}
checkInfoCell = new TextInfoPrivacyCell(context);
checkInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
checkInfoCell.setVisibility(View.GONE);
checkInfoCell.setBottomPadding(0);
linearLayout.addView(checkInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
helpInfoCell = new TextInfoPrivacyCell(context);
helpInfoCell.getTextView().setMovementMethod(new LinkMovementMethodMy());
helpInfoCell.getTextView().setHighlightColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkSelection));
if (creatingNewTheme) {
helpInfoCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("ThemeCreateHelp", R.string.ThemeCreateHelp)));
} else {
helpInfoCell.setText(infoText = AndroidUtilities.replaceTags(LocaleController.getString("ThemeSetUrlHelp", R.string.ThemeSetUrlHelp)));
}
linearLayout.addView(helpInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
if (creatingNewTheme) {
helpInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
messagesCell = new ThemePreviewMessagesCell(context, parentLayout, 1);
linearLayout.addView(messagesCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
createCell = new TextSettingsCell(context);
createCell.setBackgroundDrawable(Theme.getSelectorDrawable(true));
createCell.setText(LocaleController.getString("UseDifferentTheme", R.string.UseDifferentTheme), false);
linearLayout.addView(createCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
createCell.setOnClickListener(v -> {
if (getParentActivity() == null) {
return;
}
BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity(), false);
builder.setApplyBottomPadding(false);
LinearLayout container = new LinearLayout(context);
container.setOrientation(LinearLayout.VERTICAL);
TextView titleView = new TextView(context);
titleView.setText(LocaleController.getString("ChooseTheme", R.string.ChooseTheme));
titleView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
titleView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
container.addView(titleView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 22, 12, 22, 4));
titleView.setOnTouchListener((v2, event) -> true);
builder.setCustomView(container);
ArrayList<Theme.ThemeInfo> themes = new ArrayList<>();
for (int a = 0, N = Theme.themes.size(); a < N; a++) {
Theme.ThemeInfo themeInfo = Theme.themes.get(a);
if (themeInfo.info != null && themeInfo.info.document == null) {
continue;
}
themes.add(themeInfo);
}
ThemesHorizontalListCell cell = new ThemesHorizontalListCell(context, ThemeActivity.THEME_TYPE_OTHER, themes, new ArrayList<>()) {
@Override
protected void updateRows() {
builder.getDismissRunnable().run();
}
};
container.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 148, 0, 7, 0, 1));
cell.scrollToCurrentTheme(fragmentView.getMeasuredWidth(), false);
showDialog(builder.create());
});
createInfoCell = new TextInfoPrivacyCell(context);
createInfoCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("UseDifferentThemeInfo", R.string.UseDifferentThemeInfo)));
createInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
linearLayout.addView(createInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
} else {
helpInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
}
if (info != null) {
ignoreCheck = true;
nameField.setText(info.title);
nameField.setSelection(nameField.length());
linkField.setText(info.slug);
linkField.setSelection(linkField.length());
ignoreCheck = false;
}
return fragmentView;
}
use of org.telegram.ui.Cells.TextSettingsCell 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();
}
}
use of org.telegram.ui.Cells.TextSettingsCell 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;
}
use of org.telegram.ui.Cells.TextSettingsCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class PassportActivity method createEmailInterface.
private void createEmailInterface(Context context) {
actionBar.setTitle(LocaleController.getString("PassportEmail", R.string.PassportEmail));
if (!TextUtils.isEmpty(currentEmail)) {
TextSettingsCell settingsCell1 = new TextSettingsCell(context);
settingsCell1.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
settingsCell1.setBackgroundDrawable(Theme.getSelectorDrawable(true));
settingsCell1.setText(LocaleController.formatString("PassportPhoneUseSame", R.string.PassportPhoneUseSame, currentEmail), false);
linearLayout2.addView(settingsCell1, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
settingsCell1.setOnClickListener(v -> {
useCurrentValue = true;
doneItem.callOnClick();
useCurrentValue = false;
});
bottomCell = new TextInfoPrivacyCell(context);
bottomCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
bottomCell.setText(LocaleController.getString("PassportPhoneUseSameEmailInfo", R.string.PassportPhoneUseSameEmailInfo));
linearLayout2.addView(bottomCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
inputFields = new EditTextBoldCursor[1];
for (int a = 0; a < 1; a++) {
ViewGroup container = new FrameLayout(context);
linearLayout2.addView(container, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50));
container.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
inputFields[a] = new EditTextBoldCursor(context);
inputFields[a].setTag(a);
inputFields[a].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
inputFields[a].setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
inputFields[a].setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
inputFields[a].setBackgroundDrawable(null);
inputFields[a].setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
inputFields[a].setCursorSize(AndroidUtilities.dp(20));
inputFields[a].setCursorWidth(1.5f);
inputFields[a].setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
inputFields[a].setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
inputFields[a].setHint(LocaleController.getString("PaymentShippingEmailPlaceholder", R.string.PaymentShippingEmailPlaceholder));
if (currentTypeValue != null && currentTypeValue.plain_data instanceof TLRPC.TL_securePlainEmail) {
TLRPC.TL_securePlainEmail securePlainEmail = (TLRPC.TL_securePlainEmail) currentTypeValue.plain_data;
if (!TextUtils.isEmpty(securePlainEmail.email)) {
inputFields[a].setText(securePlainEmail.email);
}
}
inputFields[a].setSelection(inputFields[a].length());
inputFields[a].setPadding(0, 0, 0, AndroidUtilities.dp(6));
inputFields[a].setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
container.addView(inputFields[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 21, 12, 21, 6));
inputFields[a].setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_DONE || i == EditorInfo.IME_ACTION_NEXT) {
doneItem.callOnClick();
return true;
}
return false;
});
}
bottomCell = new TextInfoPrivacyCell(context);
bottomCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
bottomCell.setText(LocaleController.getString("PassportEmailUploadInfo", R.string.PassportEmailUploadInfo));
linearLayout2.addView(bottomCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
use of org.telegram.ui.Cells.TextSettingsCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class PassportActivity method createManageInterface.
private void createManageInterface(Context context) {
FrameLayout frameLayout = (FrameLayout) fragmentView;
actionBar.setTitle(LocaleController.getString("TelegramPassport", R.string.TelegramPassport));
actionBar.createMenu().addItem(info_item, R.drawable.profile_info);
headerCell = new HeaderCell(context);
headerCell.setText(LocaleController.getString("PassportProvidedInformation", R.string.PassportProvidedInformation));
headerCell.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout2.addView(headerCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
sectionCell = new ShadowSectionCell(context);
sectionCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
linearLayout2.addView(sectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
addDocumentCell = new TextSettingsCell(context);
addDocumentCell.setBackgroundDrawable(Theme.getSelectorDrawable(true));
addDocumentCell.setText(LocaleController.getString("PassportNoDocumentsAdd", R.string.PassportNoDocumentsAdd), true);
linearLayout2.addView(addDocumentCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
addDocumentCell.setOnClickListener(v -> openAddDocumentAlert());
deletePassportCell = new TextSettingsCell(context);
deletePassportCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText3));
deletePassportCell.setBackgroundDrawable(Theme.getSelectorDrawable(true));
deletePassportCell.setText(LocaleController.getString("TelegramPassportDelete", R.string.TelegramPassportDelete), false);
linearLayout2.addView(deletePassportCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
deletePassportCell.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("TelegramPassportDeleteTitle", R.string.TelegramPassportDeleteTitle));
builder.setMessage(LocaleController.getString("TelegramPassportDeleteAlert", R.string.TelegramPassportDeleteAlert));
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialog, which) -> {
TLRPC.TL_account_deleteSecureValue req = new TLRPC.TL_account_deleteSecureValue();
for (int a = 0; a < currentForm.values.size(); a++) {
req.types.add(currentForm.values.get(a).type);
}
needShowProgress();
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
for (int a = 0; a < linearLayout2.getChildCount(); a++) {
View child = linearLayout2.getChildAt(a);
if (child instanceof TextDetailSecureCell) {
linearLayout2.removeView(child);
a--;
}
}
needHideProgress();
typesViews.clear();
typesValues.clear();
currentForm.values.clear();
updateManageVisibility();
}));
});
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));
}
});
addDocumentSectionCell = new ShadowSectionCell(context);
addDocumentSectionCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
linearLayout2.addView(addDocumentSectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
emptyLayout = new LinearLayout(context);
emptyLayout.setOrientation(LinearLayout.VERTICAL);
emptyLayout.setGravity(Gravity.CENTER);
emptyLayout.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
if (AndroidUtilities.isTablet()) {
linearLayout2.addView(emptyLayout, new LinearLayout.LayoutParams(LayoutHelper.MATCH_PARENT, AndroidUtilities.dp(528) - ActionBar.getCurrentActionBarHeight()));
} else {
linearLayout2.addView(emptyLayout, new LinearLayout.LayoutParams(LayoutHelper.MATCH_PARENT, AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight()));
}
emptyImageView = new ImageView(context);
emptyImageView.setImageResource(R.drawable.no_passport);
emptyImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_sessions_devicesImage), PorterDuff.Mode.MULTIPLY));
emptyLayout.addView(emptyImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
emptyTextView1 = new TextView(context);
emptyTextView1.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
emptyTextView1.setGravity(Gravity.CENTER);
emptyTextView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
emptyTextView1.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
emptyTextView1.setText(LocaleController.getString("PassportNoDocuments", R.string.PassportNoDocuments));
emptyLayout.addView(emptyTextView1, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 16, 0, 0));
emptyTextView2 = new TextView(context);
emptyTextView2.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
emptyTextView2.setGravity(Gravity.CENTER);
emptyTextView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
emptyTextView2.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0);
emptyTextView2.setText(LocaleController.getString("PassportNoDocumentsInfo", R.string.PassportNoDocumentsInfo));
emptyLayout.addView(emptyTextView2, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 14, 0, 0));
emptyTextView3 = new TextView(context);
emptyTextView3.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
emptyTextView3.setGravity(Gravity.CENTER);
emptyTextView3.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
emptyTextView3.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
emptyTextView3.setGravity(Gravity.CENTER);
emptyTextView3.setText(LocaleController.getString("PassportNoDocumentsAdd", R.string.PassportNoDocumentsAdd).toUpperCase());
emptyLayout.addView(emptyTextView3, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 30, Gravity.CENTER, 0, 16, 0, 0));
emptyTextView3.setOnClickListener(v -> openAddDocumentAlert());
for (int a = 0, size = currentForm.values.size(); a < size; a++) {
TLRPC.TL_secureValue value = currentForm.values.get(a);
TLRPC.TL_secureRequiredType requiredType;
ArrayList<TLRPC.TL_secureRequiredType> documentTypes;
boolean documentOnly;
if (isPersonalDocument(value.type)) {
documentTypes = new ArrayList<>();
requiredType = new TLRPC.TL_secureRequiredType();
requiredType.type = value.type;
requiredType.selfie_required = true;
requiredType.translation_required = true;
documentTypes.add(requiredType);
requiredType = new TLRPC.TL_secureRequiredType();
requiredType.type = new TLRPC.TL_secureValueTypePersonalDetails();
documentOnly = true;
} else if (isAddressDocument(value.type)) {
documentTypes = new ArrayList<>();
requiredType = new TLRPC.TL_secureRequiredType();
requiredType.type = value.type;
requiredType.translation_required = true;
documentTypes.add(requiredType);
requiredType = new TLRPC.TL_secureRequiredType();
requiredType.type = new TLRPC.TL_secureValueTypeAddress();
documentOnly = true;
} else {
requiredType = new TLRPC.TL_secureRequiredType();
requiredType.type = value.type;
documentTypes = null;
documentOnly = false;
}
addField(context, requiredType, documentTypes, documentOnly, a == size - 1);
}
updateManageVisibility();
}
Aggregations