use of org.telegram.ui.Cells.RadioColorCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class AlertsCreator method createPopupSelectDialog.
public static Dialog createPopupSelectDialog(Activity parentActivity, final int globalType, final Runnable onSelect) {
SharedPreferences preferences = MessagesController.getNotificationsSettings(UserConfig.selectedAccount);
final int[] selected = new int[1];
if (globalType == NotificationsController.TYPE_PRIVATE) {
selected[0] = preferences.getInt("popupAll", 0);
} else if (globalType == NotificationsController.TYPE_GROUP) {
selected[0] = preferences.getInt("popupGroup", 0);
} else {
selected[0] = preferences.getInt("popupChannel", 0);
}
String[] descriptions = new String[] { LocaleController.getString("NoPopup", R.string.NoPopup), LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn), LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff), LocaleController.getString("AlwaysShowPopup", R.string.AlwaysShowPopup) };
final LinearLayout linearLayout = new LinearLayout(parentActivity);
linearLayout.setOrientation(LinearLayout.VERTICAL);
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
for (int a = 0; a < descriptions.length; a++) {
RadioColorCell cell = new RadioColorCell(parentActivity);
cell.setTag(a);
cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
cell.setTextAndValue(descriptions[a], selected[0] == a);
linearLayout.addView(cell);
cell.setOnClickListener(v -> {
selected[0] = (Integer) v.getTag();
final SharedPreferences preferences1 = MessagesController.getNotificationsSettings(UserConfig.selectedAccount);
SharedPreferences.Editor editor = preferences1.edit();
if (globalType == NotificationsController.TYPE_PRIVATE) {
editor.putInt("popupAll", selected[0]);
} else if (globalType == NotificationsController.TYPE_GROUP) {
editor.putInt("popupGroup", selected[0]);
} else {
editor.putInt("popupChannel", selected[0]);
}
editor.commit();
builder.getDismissRunnable().run();
if (onSelect != null) {
onSelect.run();
}
});
}
builder.setTitle(LocaleController.getString("PopupNotification", R.string.PopupNotification));
builder.setView(linearLayout);
builder.setPositiveButton(LocaleController.getString("Cancel", R.string.Cancel), null);
return builder.create();
}
use of org.telegram.ui.Cells.RadioColorCell 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;
}
use of org.telegram.ui.Cells.RadioColorCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class StickersActivity method createView.
@Override
public View createView(Context context) {
actionBar.setBackButtonDrawable(new BackDrawable(false));
actionBar.setAllowOverlayTitle(true);
if (currentType == MediaDataController.TYPE_IMAGE) {
actionBar.setTitle(LocaleController.getString("StickersName", R.string.StickersName));
} else {
actionBar.setTitle(LocaleController.getString("Masks", R.string.Masks));
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
if (onBackPressed()) {
finishFragment();
}
} else if (id == MENU_ARCHIVE || id == MENU_DELETE || id == MENU_SHARE) {
if (!needReorder) {
if (activeReorderingRequests == 0) {
listAdapter.processSelectionMenu(id);
}
} else {
sendReorder();
}
}
}
});
final ActionBarMenu actionMode = actionBar.createActionMode();
selectedCountTextView = new NumberTextView(actionMode.getContext());
selectedCountTextView.setTextSize(18);
selectedCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
selectedCountTextView.setTextColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon));
actionMode.addView(selectedCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 72, 0, 0, 0));
selectedCountTextView.setOnTouchListener((v, event) -> true);
shareMenuItem = actionMode.addItemWithWidth(MENU_SHARE, R.drawable.msg_share, AndroidUtilities.dp(54));
archiveMenuItem = actionMode.addItemWithWidth(MENU_ARCHIVE, R.drawable.msg_archive, AndroidUtilities.dp(54));
deleteMenuItem = actionMode.addItemWithWidth(MENU_DELETE, R.drawable.msg_delete, AndroidUtilities.dp(54));
listAdapter = new ListAdapter(context, MediaDataController.getInstance(currentAccount).getStickerSets(currentType));
fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
listView = new RecyclerListView(context);
listView.setFocusable(true);
listView.setTag(7);
layoutManager = new LinearLayoutManager(context) {
@Override
public boolean supportsPredictiveItemAnimations() {
return false;
}
@Override
protected void calculateExtraLayoutSpace(@NonNull RecyclerView.State state, @NonNull int[] extraLayoutSpace) {
extraLayoutSpace[1] = listView.getHeight();
}
};
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
listView.setLayoutManager(layoutManager);
itemTouchHelper = new ItemTouchHelper(new TouchHelperCallback());
itemTouchHelper.attachToRecyclerView(listView);
itemAnimator = (DefaultItemAnimator) listView.getItemAnimator();
itemAnimator.setSupportsChangeAnimations(false);
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView.setAdapter(listAdapter);
listView.setOnItemClickListener((view, position) -> {
if (position >= stickersStartRow && position < stickersEndRow && getParentActivity() != null) {
if (!listAdapter.hasSelected()) {
final TLRPC.TL_messages_stickerSet stickerSet = listAdapter.stickerSets.get(position - stickersStartRow);
ArrayList<TLRPC.Document> stickers = stickerSet.documents;
if (stickers == null || stickers.isEmpty()) {
return;
}
showDialog(new StickersAlert(getParentActivity(), StickersActivity.this, null, stickerSet, null));
} else {
listAdapter.toggleSelected(position);
}
} else if (position == featuredRow) {
final TrendingStickersLayout.Delegate trendingDelegate = new TrendingStickersLayout.Delegate() {
@Override
public void onStickerSetAdd(TLRPC.StickerSetCovered stickerSet, boolean primary) {
MediaDataController.getInstance(currentAccount).toggleStickerSet(getParentActivity(), stickerSet, 2, StickersActivity.this, false, false);
}
@Override
public void onStickerSetRemove(TLRPC.StickerSetCovered stickerSet) {
MediaDataController.getInstance(currentAccount).toggleStickerSet(getParentActivity(), stickerSet, 0, StickersActivity.this, false, false);
}
};
trendingStickersAlert = new TrendingStickersAlert(context, this, new TrendingStickersLayout(context, trendingDelegate), null);
trendingStickersAlert.show();
} else if (position == archivedRow) {
presentFragment(new ArchivedStickersActivity(currentType));
} else if (position == masksRow) {
presentFragment(new StickersActivity(MediaDataController.TYPE_MASK));
} else if (position == suggestRow) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("SuggestStickers", R.string.SuggestStickers));
String[] items = new String[] { LocaleController.getString("SuggestStickersAll", R.string.SuggestStickersAll), LocaleController.getString("SuggestStickersInstalled", R.string.SuggestStickersInstalled), LocaleController.getString("SuggestStickersNone", R.string.SuggestStickersNone) };
final LinearLayout linearLayout = new LinearLayout(getParentActivity());
linearLayout.setOrientation(LinearLayout.VERTICAL);
builder.setView(linearLayout);
for (int a = 0; a < items.length; a++) {
RadioColorCell cell = new RadioColorCell(getParentActivity());
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(items[a], SharedConfig.suggestStickers == a);
linearLayout.addView(cell);
cell.setOnClickListener(v -> {
Integer which = (Integer) v.getTag();
SharedConfig.setSuggestStickers(which);
listAdapter.notifyItemChanged(suggestRow);
builder.getDismissRunnable().run();
});
}
showDialog(builder.create());
} else if (position == loopRow) {
SharedConfig.toggleLoopStickers();
listAdapter.notifyItemChanged(loopRow, ListAdapter.UPDATE_LOOP_STICKERS);
}
});
listView.setOnItemLongClickListener((view, position) -> {
if (!listAdapter.hasSelected() && position >= stickersStartRow && position < stickersEndRow) {
listAdapter.toggleSelected(position);
return true;
} else {
return false;
}
});
return fragmentView;
}
use of org.telegram.ui.Cells.RadioColorCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class SessionsActivity method createView.
@Override
public View createView(Context context) {
globalFlickerLoadingView = new FlickerLoadingView(context);
globalFlickerLoadingView.setIsSingleCell(true);
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
if (currentType == 0) {
actionBar.setTitle(LocaleController.getString("Devices", R.string.Devices));
} else {
actionBar.setTitle(LocaleController.getString("WebSessionsTitle", R.string.WebSessionsTitle));
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
listAdapter = new ListAdapter(context);
fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
emptyLayout = new LinearLayout(context);
emptyLayout.setOrientation(LinearLayout.VERTICAL);
emptyLayout.setGravity(Gravity.CENTER);
emptyLayout.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
emptyLayout.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight()));
imageView = new ImageView(context);
if (currentType == 0) {
imageView.setImageResource(R.drawable.devices);
} else {
imageView.setImageResource(R.drawable.no_apps);
}
imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_sessions_devicesImage), PorterDuff.Mode.MULTIPLY));
emptyLayout.addView(imageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
textView1 = new TextView(context);
textView1.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
textView1.setGravity(Gravity.CENTER);
textView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
textView1.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
if (currentType == 0) {
textView1.setText(LocaleController.getString("NoOtherSessions", R.string.NoOtherSessions));
} else {
textView1.setText(LocaleController.getString("NoOtherWebSessions", R.string.NoOtherWebSessions));
}
emptyLayout.addView(textView1, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 16, 0, 0));
textView2 = new TextView(context);
textView2.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
textView2.setGravity(Gravity.CENTER);
textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
textView2.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0);
if (currentType == 0) {
textView2.setText(LocaleController.getString("NoOtherSessionsInfo", R.string.NoOtherSessionsInfo));
} else {
textView2.setText(LocaleController.getString("NoOtherWebSessionsInfo", R.string.NoOtherWebSessionsInfo));
}
emptyLayout.addView(textView2, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 14, 0, 0));
emptyView = new EmptyTextProgressView(context);
emptyView.showProgress();
frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER));
listView = new RecyclerListView(context);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
listView.setVerticalScrollBarEnabled(false);
listView.setEmptyView(emptyView);
listView.setAnimateEmptyView(true, 0);
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView.setAdapter(listAdapter);
listView.setOnItemClickListener((view, position) -> {
if (position == ttlRow) {
if (getParentActivity() == null) {
return;
}
int selected;
if (ttlDays <= 7) {
selected = 0;
} else if (ttlDays <= 93) {
selected = 1;
} else if (ttlDays <= 183) {
selected = 2;
} else {
selected = 3;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("SessionsSelfDestruct", R.string.SessionsSelfDestruct));
String[] items = new String[] { LocaleController.formatPluralString("Weeks", 1), LocaleController.formatPluralString("Months", 3), LocaleController.formatPluralString("Months", 6), LocaleController.formatPluralString("Years", 1) };
final LinearLayout linearLayout = new LinearLayout(getParentActivity());
linearLayout.setOrientation(LinearLayout.VERTICAL);
builder.setView(linearLayout);
for (int a = 0; a < items.length; a++) {
RadioColorCell cell = new RadioColorCell(getParentActivity());
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(items[a], selected == a);
linearLayout.addView(cell);
cell.setOnClickListener(v -> {
builder.getDismissRunnable().run();
Integer which = (Integer) v.getTag();
int value = 0;
if (which == 0) {
value = 7;
} else if (which == 1) {
value = 90;
} else if (which == 2) {
value = 183;
} else if (which == 3) {
value = 365;
}
final TLRPC.TL_account_setAuthorizationTTL req = new TLRPC.TL_account_setAuthorizationTTL();
req.authorization_ttl_days = value;
ttlDays = value;
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
getConnectionsManager().sendRequest(req, (response, error) -> {
});
});
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
} else if (position == terminateAllSessionsRow) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
String buttonText;
if (currentType == 0) {
builder.setMessage(LocaleController.getString("AreYouSureSessions", R.string.AreYouSureSessions));
builder.setTitle(LocaleController.getString("AreYouSureSessionsTitle", R.string.AreYouSureSessionsTitle));
buttonText = LocaleController.getString("Terminate", R.string.Terminate);
} else {
builder.setMessage(LocaleController.getString("AreYouSureWebSessions", R.string.AreYouSureWebSessions));
builder.setTitle(LocaleController.getString("TerminateWebSessionsTitle", R.string.TerminateWebSessionsTitle));
buttonText = LocaleController.getString("Disconnect", R.string.Disconnect);
}
builder.setPositiveButton(buttonText, (dialogInterface, i) -> {
if (currentType == 0) {
TLRPC.TL_auth_resetAuthorizations req = new TLRPC.TL_auth_resetAuthorizations();
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
AndroidUtilities.runOnUIThread(() -> {
if (getParentActivity() == null) {
return;
}
if (error == null && response instanceof TLRPC.TL_boolTrue) {
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), Toast.LENGTH_SHORT);
toast.show();
finishFragment();
}
});
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
UserConfig userConfig = UserConfig.getInstance(a);
if (!userConfig.isClientActivated()) {
continue;
}
userConfig.registeredForPush = false;
userConfig.saveConfig(false);
MessagesController.getInstance(a).registerForPush(SharedConfig.pushString);
ConnectionsManager.getInstance(a).setUserId(userConfig.getClientUserId());
}
});
} else {
TLRPC.TL_account_resetWebAuthorizations req = new TLRPC.TL_account_resetWebAuthorizations();
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (getParentActivity() == null) {
return;
}
if (error == null && response instanceof TLRPC.TL_boolTrue) {
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("TerminateAllWebSessions", R.string.TerminateAllWebSessions), Toast.LENGTH_SHORT);
toast.show();
} else {
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("UnknownError", R.string.UnknownError), Toast.LENGTH_SHORT);
toast.show();
}
finishFragment();
}));
}
});
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 >= otherSessionsStartRow && position < otherSessionsEndRow || position >= passwordSessionsStartRow && position < passwordSessionsEndRow || position == currentSessionRow) {
if (getParentActivity() == null) {
return;
}
if (currentType == 0) {
final TLRPC.TL_authorization authorization;
boolean isCurrentSession = false;
if (position == currentSessionRow) {
authorization = currentSession;
isCurrentSession = true;
} else if (position >= otherSessionsStartRow && position < otherSessionsEndRow) {
authorization = (TLRPC.TL_authorization) sessions.get(position - otherSessionsStartRow);
} else {
authorization = (TLRPC.TL_authorization) passwordSessions.get(position - passwordSessionsStartRow);
}
showSessionBottomSheet(authorization, isCurrentSession);
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
final boolean[] param = new boolean[1];
String buttonText;
if (currentType == 0) {
builder.setMessage(LocaleController.getString("TerminateSessionText", R.string.TerminateSessionText));
builder.setTitle(LocaleController.getString("AreYouSureSessionTitle", R.string.AreYouSureSessionTitle));
buttonText = LocaleController.getString("Terminate", R.string.Terminate);
} else {
final TLRPC.TL_webAuthorization authorization = (TLRPC.TL_webAuthorization) sessions.get(position - otherSessionsStartRow);
builder.setMessage(LocaleController.formatString("TerminateWebSessionText", R.string.TerminateWebSessionText, authorization.domain));
builder.setTitle(LocaleController.getString("TerminateWebSessionTitle", R.string.TerminateWebSessionTitle));
buttonText = LocaleController.getString("Disconnect", R.string.Disconnect);
FrameLayout frameLayout1 = new FrameLayout(getParentActivity());
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(authorization.bot_id);
String name;
if (user != null) {
name = UserObject.getFirstName(user);
} else {
name = "";
}
CheckBoxCell cell = new CheckBoxCell(getParentActivity(), 1);
cell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
cell.setText(LocaleController.formatString("TerminateWebSessionStop", R.string.TerminateWebSessionStop, name), "", false, false);
cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
frameLayout1.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 0));
cell.setOnClickListener(v -> {
if (!v.isEnabled()) {
return;
}
CheckBoxCell cell1 = (CheckBoxCell) v;
param[0] = !param[0];
cell1.setChecked(param[0], true);
});
builder.setCustomViewOffset(16);
builder.setView(frameLayout1);
}
builder.setPositiveButton(buttonText, (dialogInterface, option) -> {
if (getParentActivity() == null) {
return;
}
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.setCanCacnel(false);
progressDialog.show();
if (currentType == 0) {
final TLRPC.TL_authorization authorization;
if (position >= otherSessionsStartRow && position < otherSessionsEndRow) {
authorization = (TLRPC.TL_authorization) sessions.get(position - otherSessionsStartRow);
} else {
authorization = (TLRPC.TL_authorization) passwordSessions.get(position - passwordSessionsStartRow);
}
TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization();
req.hash = authorization.hash;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
if (error == null) {
sessions.remove(authorization);
passwordSessions.remove(authorization);
updateRows();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
}));
} else {
final TLRPC.TL_webAuthorization authorization = (TLRPC.TL_webAuthorization) sessions.get(position - otherSessionsStartRow);
TLRPC.TL_account_resetWebAuthorization req = new TLRPC.TL_account_resetWebAuthorization();
req.hash = authorization.hash;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
if (error == null) {
sessions.remove(authorization);
updateRows();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
}));
if (param[0]) {
MessagesController.getInstance(currentAccount).blockPeer(authorization.bot_id);
}
}
});
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));
}
}
});
if (currentType == 0) {
undoView = new UndoView(context) {
@Override
public void hide(boolean apply, int animated) {
if (!apply) {
TLRPC.TL_authorization authorization = (TLRPC.TL_authorization) getCurrentInfoObject();
TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization();
req.hash = authorization.hash;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (error == null) {
sessions.remove(authorization);
passwordSessions.remove(authorization);
updateRows();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
loadSessions(true);
}
}));
}
super.hide(apply, animated);
}
};
frameLayout.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
}
itemsEnterAnimator = new RecyclerItemsEnterAnimator(listView, true) {
@Override
public View getProgressView() {
View progressView = null;
for (int i = 0; i < listView.getChildCount(); i++) {
View child = listView.getChildAt(i);
if (listView.getChildAdapterPosition(child) >= 0 && child instanceof SessionCell && ((SessionCell) child).isStub()) {
progressView = child;
}
}
return progressView;
}
};
itemsEnterAnimator.animateAlphaProgressView = false;
updateRows();
return fragmentView;
}
use of org.telegram.ui.Cells.RadioColorCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class PrivacySettingsActivity method createView.
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("PrivacySettings", R.string.PrivacySettings));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
listAdapter = new ListAdapter(context);
fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
listView = new RecyclerListView(context);
listView.setLayoutManager(layoutManager = 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);
listView.setOnItemClickListener((view, position) -> {
if (!view.isEnabled()) {
return;
}
if (position == blockedRow) {
presentFragment(new PrivacyUsersActivity());
} else if (position == sessionsRow) {
presentFragment(new SessionsActivity(0));
} else if (position == webSessionsRow) {
presentFragment(new SessionsActivity(1));
} else if (position == deleteAccountRow) {
if (getParentActivity() == null) {
return;
}
int ttl = getContactsController().getDeleteAccountTTL();
int selected;
if (ttl <= 31) {
selected = 0;
} else if (ttl <= 93) {
selected = 1;
} else if (ttl <= 182) {
selected = 2;
} else {
selected = 3;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("DeleteAccountTitle", R.string.DeleteAccountTitle));
String[] items = new String[] { LocaleController.formatPluralString("Months", 1), LocaleController.formatPluralString("Months", 3), LocaleController.formatPluralString("Months", 6), LocaleController.formatPluralString("Years", 1) };
final LinearLayout linearLayout = new LinearLayout(getParentActivity());
linearLayout.setOrientation(LinearLayout.VERTICAL);
builder.setView(linearLayout);
for (int a = 0; a < items.length; a++) {
RadioColorCell cell = new RadioColorCell(getParentActivity());
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(items[a], selected == a);
linearLayout.addView(cell);
cell.setOnClickListener(v -> {
builder.getDismissRunnable().run();
Integer which = (Integer) v.getTag();
int value = 0;
if (which == 0) {
value = 30;
} else if (which == 1) {
value = 90;
} else if (which == 2) {
value = 182;
} else if (which == 3) {
value = 365;
}
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.setCanCacnel(false);
progressDialog.show();
final TLRPC.TL_account_setAccountTTL req = new TLRPC.TL_account_setAccountTTL();
req.ttl = new TLRPC.TL_accountDaysTTL();
req.ttl.days = value;
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
if (response instanceof TLRPC.TL_boolTrue) {
getContactsController().setDeleteAccountTTL(req.ttl.days);
listAdapter.notifyDataSetChanged();
}
}));
});
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
} else if (position == lastSeenRow) {
presentFragment(new PrivacyControlActivity(ContactsController.PRIVACY_RULES_TYPE_LASTSEEN));
} else if (position == phoneNumberRow) {
presentFragment(new PrivacyControlActivity(ContactsController.PRIVACY_RULES_TYPE_PHONE));
} else if (position == groupsRow) {
presentFragment(new PrivacyControlActivity(ContactsController.PRIVACY_RULES_TYPE_INVITE));
} else if (position == callsRow) {
presentFragment(new PrivacyControlActivity(ContactsController.PRIVACY_RULES_TYPE_CALLS));
} else if (position == profilePhotoRow) {
presentFragment(new PrivacyControlActivity(ContactsController.PRIVACY_RULES_TYPE_PHOTO));
} else if (position == forwardsRow) {
presentFragment(new PrivacyControlActivity(ContactsController.PRIVACY_RULES_TYPE_FORWARDS));
} else if (position == passwordRow) {
if (currentPassword == null) {
return;
}
if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) {
AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
}
if (currentPassword.has_password) {
TwoStepVerificationActivity fragment = new TwoStepVerificationActivity();
fragment.setPassword(currentPassword);
presentFragment(fragment);
} else {
int type;
if (TextUtils.isEmpty(currentPassword.email_unconfirmed_pattern)) {
type = TwoStepVerificationSetupActivity.TYPE_INTRO;
} else {
type = TwoStepVerificationSetupActivity.TYPE_EMAIL_CONFIRM;
}
presentFragment(new TwoStepVerificationSetupActivity(type, currentPassword));
}
} else if (position == passcodeRow) {
if (SharedConfig.passcodeHash.length() > 0) {
presentFragment(new PasscodeActivity(2));
} else {
presentFragment(new PasscodeActivity(0));
}
} else if (position == secretWebpageRow) {
if (getMessagesController().secretWebpagePreview == 1) {
getMessagesController().secretWebpagePreview = 0;
} else {
getMessagesController().secretWebpagePreview = 1;
}
MessagesController.getGlobalMainSettings().edit().putInt("secretWebpage2", getMessagesController().secretWebpagePreview).commit();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(getMessagesController().secretWebpagePreview == 1);
}
} else if (position == contactsDeleteRow) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("SyncContactsDeleteTitle", R.string.SyncContactsDeleteTitle));
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("SyncContactsDeleteText", R.string.SyncContactsDeleteText)));
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
AlertDialog.Builder builder12 = new AlertDialog.Builder(getParentActivity(), 3, null);
progressDialog = builder12.show();
progressDialog.setCanCacnel(false);
if (currentSync != newSync) {
currentSync = getUserConfig().syncContacts = newSync;
getUserConfig().saveConfig(false);
}
getContactsController().deleteAllContacts(() -> progressDialog.dismiss());
});
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 == contactsSuggestRow) {
final TextCheckCell cell = (TextCheckCell) view;
if (newSuggest) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("SuggestContactsTitle", R.string.SuggestContactsTitle));
builder.setMessage(LocaleController.getString("SuggestContactsAlert", R.string.SuggestContactsAlert));
builder.setPositiveButton(LocaleController.getString("MuteDisable", R.string.MuteDisable), (dialogInterface, i) -> {
TLRPC.TL_payments_clearSavedInfo req = new TLRPC.TL_payments_clearSavedInfo();
req.credentials = clear[1];
req.info = clear[0];
getUserConfig().tmpPassword = null;
getUserConfig().saveConfig(false);
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
newSuggest = !newSuggest;
cell.setChecked(newSuggest);
}));
});
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 {
cell.setChecked(newSuggest = true);
}
} else if (position == newChatsRow) {
final TextCheckCell cell = (TextCheckCell) view;
archiveChats = !archiveChats;
cell.setChecked(archiveChats);
} else if (position == contactsSyncRow) {
newSync = !newSync;
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(newSync);
}
} else if (position == secretMapRow) {
AlertsCreator.showSecretLocationAlert(getParentActivity(), currentAccount, () -> listAdapter.notifyDataSetChanged(), false, null);
} else if (position == paymentsClearRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("PrivacyPaymentsClearAlertTitle", R.string.PrivacyPaymentsClearAlertTitle));
builder.setMessage(LocaleController.getString("PrivacyPaymentsClearAlertText", R.string.PrivacyPaymentsClearAlertText));
LinearLayout linearLayout = new LinearLayout(getParentActivity());
linearLayout.setOrientation(LinearLayout.VERTICAL);
builder.setView(linearLayout);
for (int a = 0; a < 2; a++) {
String name;
if (a == 0) {
name = LocaleController.getString("PrivacyClearShipping", R.string.PrivacyClearShipping);
} else {
name = LocaleController.getString("PrivacyClearPayment", R.string.PrivacyClearPayment);
}
clear[a] = true;
CheckBoxCell checkBoxCell = new CheckBoxCell(getParentActivity(), 1, 21, null);
checkBoxCell.setTag(a);
checkBoxCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
checkBoxCell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
linearLayout.addView(checkBoxCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50));
checkBoxCell.setText(name, null, true, false);
checkBoxCell.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
checkBoxCell.setOnClickListener(v -> {
CheckBoxCell cell = (CheckBoxCell) v;
int num = (Integer) cell.getTag();
clear[num] = !clear[num];
cell.setChecked(clear[num], true);
});
}
builder.setPositiveButton(LocaleController.getString("ClearButton", R.string.ClearButton), (dialogInterface, i) -> {
try {
if (visibleDialog != null) {
visibleDialog.dismiss();
}
} catch (Exception e) {
FileLog.e(e);
}
AlertDialog.Builder builder1 = new AlertDialog.Builder(getParentActivity());
builder1.setTitle(LocaleController.getString("PrivacyPaymentsClearAlertTitle", R.string.PrivacyPaymentsClearAlertTitle));
builder1.setMessage(LocaleController.getString("PrivacyPaymentsClearAlert", R.string.PrivacyPaymentsClearAlert));
builder1.setPositiveButton(LocaleController.getString("ClearButton", R.string.ClearButton), (dialogInterface2, i2) -> {
TLRPC.TL_payments_clearSavedInfo req = new TLRPC.TL_payments_clearSavedInfo();
req.credentials = clear[1];
req.info = clear[0];
getUserConfig().tmpPassword = null;
getUserConfig().saveConfig(false);
getConnectionsManager().sendRequest(req, (response, error) -> {
});
String text;
if (clear[0] && clear[1]) {
text = LocaleController.getString("PrivacyPaymentsPaymentShippingCleared", R.string.PrivacyPaymentsPaymentShippingCleared);
} else if (clear[0]) {
text = LocaleController.getString("PrivacyPaymentsShippingInfoCleared", R.string.PrivacyPaymentsShippingInfoCleared);
} else if (clear[1]) {
text = LocaleController.getString("PrivacyPaymentsPaymentInfoCleared", R.string.PrivacyPaymentsPaymentInfoCleared);
} else {
return;
}
BulletinFactory.of(PrivacySettingsActivity.this).createSimpleBulletin(R.raw.chats_infotip, text).show();
});
builder1.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder1.create());
AlertDialog alertDialog = builder1.create();
showDialog(alertDialog);
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
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 == passportRow) {
presentFragment(new PassportActivity(PassportActivity.TYPE_PASSWORD, 0, "", "", null, null, null, null, null));
}
});
return fragmentView;
}
Aggregations