use of org.telegram.ui.ActionBar.ActionBarMenu in project Telegram-FOSS by Telegram-FOSS-Team.
the class MessageStatisticActivity method updateMenu.
private void updateMenu() {
if (chat != null && chat.can_view_stats) {
ActionBarMenu menu = actionBar.createMenu();
menu.clearItems();
ActionBarMenuItem headerItem = menu.addItem(0, R.drawable.ic_ab_other);
headerItem.addSubItem(1, R.drawable.msg_stats, LocaleController.getString("ViewChannelStats", R.string.ViewChannelStats));
}
}
use of org.telegram.ui.ActionBar.ActionBarMenu in project Telegram-FOSS by Telegram-FOSS-Team.
the class NotificationsCustomSettingsActivity method createView.
@Override
public View createView(Context context) {
searching = false;
searchWas = false;
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
if (currentType == -1) {
actionBar.setTitle(LocaleController.getString("NotificationsExceptions", R.string.NotificationsExceptions));
} else {
actionBar.setTitle(LocaleController.getString("Notifications", R.string.Notifications));
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
if (exceptions != null && !exceptions.isEmpty()) {
ActionBarMenu menu = actionBar.createMenu();
ActionBarMenuItem searchItem = menu.addItem(search_button, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
@Override
public void onSearchExpand() {
searching = true;
emptyView.setShowAtCenter(true);
}
@Override
public void onSearchCollapse() {
searchAdapter.searchDialogs(null);
searching = false;
searchWas = false;
emptyView.setText(LocaleController.getString("NoExceptions", R.string.NoExceptions));
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
listView.setFastScrollVisible(true);
listView.setVerticalScrollBarEnabled(false);
emptyView.setShowAtCenter(false);
}
@Override
public void onTextChanged(EditText editText) {
if (searchAdapter == null) {
return;
}
String text = editText.getText().toString();
if (text.length() != 0) {
searchWas = true;
if (listView != null) {
emptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
emptyView.showProgress();
listView.setAdapter(searchAdapter);
searchAdapter.notifyDataSetChanged();
listView.setFastScrollVisible(false);
listView.setVerticalScrollBarEnabled(true);
}
}
searchAdapter.searchDialogs(text);
}
});
searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
}
searchAdapter = new SearchAdapter(context);
fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
emptyView = new EmptyTextProgressView(context);
emptyView.setTextSize(18);
emptyView.setText(LocaleController.getString("NoExceptions", R.string.NoExceptions));
emptyView.showTextView();
frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView = new RecyclerListView(context);
listView.setEmptyView(emptyView);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, 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 (listView.getAdapter() == searchAdapter || position >= exceptionsStartRow && position < exceptionsEndRow) {
ArrayList<NotificationsSettingsActivity.NotificationException> arrayList;
NotificationsSettingsActivity.NotificationException exception;
boolean newException;
if (listView.getAdapter() == searchAdapter) {
Object object = searchAdapter.getObject(position);
if (object instanceof NotificationsSettingsActivity.NotificationException) {
arrayList = searchAdapter.searchResult;
exception = (NotificationsSettingsActivity.NotificationException) object;
newException = false;
} else {
long did;
if (object instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) object;
did = user.id;
} else {
TLRPC.Chat chat = (TLRPC.Chat) object;
did = -chat.id;
}
if (exceptionsDict.containsKey(did)) {
exception = exceptionsDict.get(did);
newException = false;
} else {
newException = true;
exception = new NotificationsSettingsActivity.NotificationException();
exception.did = did;
if (object instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) object;
exception.did = user.id;
} else {
TLRPC.Chat chat = (TLRPC.Chat) object;
exception.did = -chat.id;
}
}
arrayList = exceptions;
}
} else {
arrayList = exceptions;
int index = position - exceptionsStartRow;
if (index < 0 || index >= arrayList.size()) {
return;
}
exception = arrayList.get(index);
newException = false;
}
if (exception == null) {
return;
}
AlertsCreator.showCustomNotificationsDialog(NotificationsCustomSettingsActivity.this, exception.did, -1, null, currentAccount, null, param -> {
if (param == 0) {
if (newException) {
return;
}
if (arrayList != exceptions) {
int idx = exceptions.indexOf(exception);
if (idx >= 0) {
exceptions.remove(idx);
exceptionsDict.remove(exception.did);
}
}
arrayList.remove(exception);
if (arrayList == exceptions) {
if (exceptionsAddRow != -1 && arrayList.isEmpty()) {
listView.getAdapter().notifyItemChanged(exceptionsAddRow);
listView.getAdapter().notifyItemRemoved(deleteAllRow);
listView.getAdapter().notifyItemRemoved(deleteAllSectionRow);
}
listView.getAdapter().notifyItemRemoved(position);
updateRows(false);
checkRowsEnabled();
} else {
updateRows(true);
searchAdapter.notifyDataSetChanged();
}
actionBar.closeSearchField();
} else {
SharedPreferences preferences = getNotificationsSettings();
exception.hasCustom = preferences.getBoolean("custom_" + exception.did, false);
exception.notify = preferences.getInt("notify2_" + exception.did, 0);
if (exception.notify != 0) {
int time = preferences.getInt("notifyuntil_" + exception.did, -1);
if (time != -1) {
exception.muteUntil = time;
}
}
if (newException) {
exceptions.add(exception);
exceptionsDict.put(exception.did, exception);
updateRows(true);
} else {
listView.getAdapter().notifyItemChanged(position);
}
actionBar.closeSearchField();
}
});
return;
}
if (position == exceptionsAddRow) {
Bundle args = new Bundle();
args.putBoolean("onlySelect", true);
args.putBoolean("checkCanWrite", false);
if (currentType == NotificationsController.TYPE_GROUP) {
args.putInt("dialogsType", 6);
} else if (currentType == NotificationsController.TYPE_CHANNEL) {
args.putInt("dialogsType", 5);
} else {
args.putInt("dialogsType", 4);
}
DialogsActivity activity = new DialogsActivity(args);
activity.setDelegate((fragment, dids, message, param) -> {
Bundle args2 = new Bundle();
args2.putLong("dialog_id", dids.get(0));
args2.putBoolean("exception", true);
ProfileNotificationsActivity profileNotificationsActivity = new ProfileNotificationsActivity(args2);
profileNotificationsActivity.setDelegate(exception -> {
exceptions.add(0, exception);
updateRows(true);
});
presentFragment(profileNotificationsActivity, true);
});
presentFragment(activity);
} else if (position == deleteAllRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("NotificationsDeleteAllExceptionTitle", R.string.NotificationsDeleteAllExceptionTitle));
builder.setMessage(LocaleController.getString("NotificationsDeleteAllExceptionAlert", R.string.NotificationsDeleteAllExceptionAlert));
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
SharedPreferences preferences = getNotificationsSettings();
SharedPreferences.Editor editor = preferences.edit();
for (int a = 0, N = exceptions.size(); a < N; a++) {
NotificationsSettingsActivity.NotificationException exception = exceptions.get(a);
editor.remove("notify2_" + exception.did).remove("custom_" + exception.did);
getMessagesStorage().setDialogFlags(exception.did, 0);
TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(exception.did);
if (dialog != null) {
dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
}
}
editor.commit();
for (int a = 0, N = exceptions.size(); a < N; a++) {
NotificationsSettingsActivity.NotificationException exception = exceptions.get(a);
getNotificationsController().updateServerNotificationsSettings(exception.did, false);
}
exceptions.clear();
exceptionsDict.clear();
updateRows(true);
getNotificationCenter().postNotificationName(NotificationCenter.notificationsSettingsUpdated);
});
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 == alertRow) {
enabled = getNotificationsController().isGlobalNotificationsEnabled(currentType);
NotificationsCheckCell checkCell = (NotificationsCheckCell) view;
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(position);
if (!enabled) {
getNotificationsController().setGlobalNotificationsEnabled(currentType, 0);
checkCell.setChecked(true);
if (holder != null) {
adapter.onBindViewHolder(holder, position);
}
checkRowsEnabled();
} else {
AlertsCreator.showCustomNotificationsDialog(NotificationsCustomSettingsActivity.this, 0, currentType, exceptions, currentAccount, param -> {
int offUntil;
SharedPreferences preferences = getNotificationsSettings();
if (currentType == NotificationsController.TYPE_PRIVATE) {
offUntil = preferences.getInt("EnableAll2", 0);
} else if (currentType == NotificationsController.TYPE_GROUP) {
offUntil = preferences.getInt("EnableGroup2", 0);
} else {
offUntil = preferences.getInt("EnableChannel2", 0);
}
int currentTime = getConnectionsManager().getCurrentTime();
int iconType;
if (offUntil < currentTime) {
iconType = 0;
} else if (offUntil - 60 * 60 * 24 * 365 >= currentTime) {
iconType = 0;
} else {
iconType = 2;
}
checkCell.setChecked(getNotificationsController().isGlobalNotificationsEnabled(currentType), iconType);
if (holder != null) {
adapter.onBindViewHolder(holder, position);
}
checkRowsEnabled();
});
}
} else if (position == previewRow) {
if (!view.isEnabled()) {
return;
}
SharedPreferences preferences = getNotificationsSettings();
SharedPreferences.Editor editor = preferences.edit();
if (currentType == NotificationsController.TYPE_PRIVATE) {
enabled = preferences.getBoolean("EnablePreviewAll", true);
editor.putBoolean("EnablePreviewAll", !enabled);
} else if (currentType == NotificationsController.TYPE_GROUP) {
enabled = preferences.getBoolean("EnablePreviewGroup", true);
editor.putBoolean("EnablePreviewGroup", !enabled);
} else {
enabled = preferences.getBoolean("EnablePreviewChannel", true);
editor.putBoolean("EnablePreviewChannel", !enabled);
}
editor.commit();
getNotificationsController().updateServerNotificationsSettings(currentType);
} else if (position == messageSoundRow) {
if (!view.isEnabled()) {
return;
}
try {
SharedPreferences preferences = getNotificationsSettings();
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
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_NOTIFICATION));
Uri currentSound = null;
String defaultPath = null;
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
if (defaultUri != null) {
defaultPath = defaultUri.getPath();
}
String path;
if (currentType == NotificationsController.TYPE_PRIVATE) {
path = preferences.getString("GlobalSoundPath", defaultPath);
} else if (currentType == NotificationsController.TYPE_GROUP) {
path = preferences.getString("GroupSoundPath", defaultPath);
} else {
path = preferences.getString("ChannelSoundPath", 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 == messageLedRow) {
if (!view.isEnabled()) {
return;
}
showDialog(AlertsCreator.createColorSelectDialog(getParentActivity(), 0, currentType, () -> {
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(position);
if (holder != null) {
adapter.onBindViewHolder(holder, position);
}
}));
} else if (position == messagePopupNotificationRow) {
if (!view.isEnabled()) {
return;
}
showDialog(AlertsCreator.createPopupSelectDialog(getParentActivity(), currentType, () -> {
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(position);
if (holder != null) {
adapter.onBindViewHolder(holder, position);
}
}));
} else if (position == messageVibrateRow) {
if (!view.isEnabled()) {
return;
}
String key;
if (currentType == NotificationsController.TYPE_PRIVATE) {
key = "vibrate_messages";
} else if (currentType == NotificationsController.TYPE_GROUP) {
key = "vibrate_group";
} else {
key = "vibrate_channel";
}
showDialog(AlertsCreator.createVibrationSelectDialog(getParentActivity(), 0, key, () -> {
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(position);
if (holder != null) {
adapter.onBindViewHolder(holder, position);
}
}));
} else if (position == messagePriorityRow) {
if (!view.isEnabled()) {
return;
}
showDialog(AlertsCreator.createPrioritySelectDialog(getParentActivity(), 0, currentType, () -> {
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(position);
if (holder != null) {
adapter.onBindViewHolder(holder, position);
}
}));
}
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(!enabled);
}
});
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
}
});
return fragmentView;
}
use of org.telegram.ui.ActionBar.ActionBarMenu in project Telegram-FOSS by Telegram-FOSS-Team.
the class LoginActivity method createView.
@Override
public View createView(Context context) {
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == done_button) {
onDoneButtonPressed();
} else if (id == -1) {
if (onBackPressed()) {
finishFragment();
}
}
}
});
currentDoneType = DONE_TYPE_FLOATING;
doneButtonVisible[DONE_TYPE_FLOATING] = true;
doneButtonVisible[DONE_TYPE_ACTION] = false;
ActionBarMenu menu = actionBar.createMenu();
actionBar.setAllowOverlayTitle(true);
doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
doneProgressView = new ContextProgressView(context, 1);
doneProgressView.setAlpha(0.0f);
doneProgressView.setScaleX(0.1f);
doneProgressView.setScaleY(0.1f);
doneProgressView.setVisibility(View.INVISIBLE);
doneItem.setAlpha(0.0f);
doneItem.setScaleX(0.1f);
doneItem.setScaleY(0.1f);
doneItem.addView(doneProgressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
doneItem.setContentDescription(LocaleController.getString("Done", R.string.Done));
doneItem.setVisibility(doneButtonVisible[DONE_TYPE_ACTION] ? View.VISIBLE : View.GONE);
FrameLayout container = new FrameLayout(context) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
MarginLayoutParams marginLayoutParams = (MarginLayoutParams) floatingButtonContainer.getLayoutParams();
if (Bulletin.getVisibleBulletin() != null && Bulletin.getVisibleBulletin().isShowing()) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
marginLayoutParams.bottomMargin = AndroidUtilities.dp(14) + Bulletin.getVisibleBulletin().getLayout().getMeasuredHeight() - AndroidUtilities.dp(10);
} else {
marginLayoutParams.bottomMargin = AndroidUtilities.dp(14);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
};
fragmentView = container;
ScrollView scrollView = new ScrollView(context) {
@Override
public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
if (currentViewNum == 1 || currentViewNum == 2 || currentViewNum == 4) {
rectangle.bottom += AndroidUtilities.dp(40);
}
return super.requestChildRectangleOnScreen(child, rectangle, immediate);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
scrollHeight = MeasureSpec.getSize(heightMeasureSpec) - AndroidUtilities.dp(30);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
};
scrollView.setFillViewport(true);
container.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
FrameLayout frameLayout = new FrameLayout(context);
scrollView.addView(frameLayout, LayoutHelper.createScroll(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT));
views[0] = new PhoneView(context);
views[1] = new LoginActivitySmsView(context, 1);
views[2] = new LoginActivitySmsView(context, 2);
views[3] = new LoginActivitySmsView(context, 3);
views[4] = new LoginActivitySmsView(context, 4);
views[5] = new LoginActivityRegisterView(context);
views[6] = new LoginActivityPasswordView(context);
views[7] = new LoginActivityRecoverView(context);
views[8] = new LoginActivityResetWaitView(context);
views[9] = new LoginActivityNewPasswordView(context, 0);
views[10] = new LoginActivityNewPasswordView(context, 1);
views[11] = new LoginActivitySmsView(context, 11);
for (int a = 0; a < views.length; a++) {
views[a].setVisibility(a == 0 ? View.VISIBLE : View.GONE);
frameLayout.addView(views[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, AndroidUtilities.isTablet() ? 26 : 18, 30, AndroidUtilities.isTablet() ? 26 : 18, 0));
}
Bundle savedInstanceState = loadCurrentState();
if (savedInstanceState != null) {
currentViewNum = savedInstanceState.getInt("currentViewNum", 0);
syncContacts = savedInstanceState.getInt("syncContacts", 1) == 1;
if (currentViewNum >= 1 && currentViewNum <= 4) {
int time = savedInstanceState.getInt("open");
if (time != 0 && Math.abs(System.currentTimeMillis() / 1000 - time) >= 24 * 60 * 60) {
currentViewNum = 0;
savedInstanceState = null;
clearCurrentState();
}
} else if (currentViewNum == 6) {
LoginActivityPasswordView view = (LoginActivityPasswordView) views[6];
if (view.currentPassword == null) {
currentViewNum = 0;
savedInstanceState = null;
clearCurrentState();
}
} else if (currentViewNum == 7) {
LoginActivityRecoverView view = (LoginActivityRecoverView) views[7];
if (view.passwordString == null) {
currentViewNum = 0;
savedInstanceState = null;
clearCurrentState();
}
}
}
floatingButtonContainer = new FrameLayout(context);
floatingButtonContainer.setVisibility(doneButtonVisible[DONE_TYPE_FLOATING] ? View.VISIBLE : View.GONE);
Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground));
if (Build.VERSION.SDK_INT < 21) {
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
drawable = combinedDrawable;
}
floatingButtonContainer.setBackgroundDrawable(drawable);
if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator();
animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(floatingButtonIcon, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
animator.addState(new int[] {}, ObjectAnimator.ofFloat(floatingButtonIcon, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
floatingButtonContainer.setStateListAnimator(animator);
floatingButtonContainer.setOutlineProvider(new ViewOutlineProvider() {
@SuppressLint("NewApi")
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
}
});
}
VerticalPositionAutoAnimator.attach(floatingButtonContainer);
container.addView(floatingButtonContainer, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 14, 14));
floatingButtonContainer.setOnClickListener(view -> onDoneButtonPressed());
floatingButtonIcon = new ImageView(context);
floatingButtonIcon.setScaleType(ImageView.ScaleType.CENTER);
floatingButtonIcon.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
floatingButtonIcon.setImageResource(R.drawable.actionbtn_next);
floatingButtonContainer.setContentDescription(LocaleController.getString("Done", R.string.Done));
floatingButtonContainer.addView(floatingButtonIcon, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60));
floatingProgressView = new RadialProgressView(context);
floatingProgressView.setSize(AndroidUtilities.dp(22));
floatingProgressView.setProgressColor(Theme.getColor(Theme.key_chats_actionIcon));
floatingProgressView.setAlpha(0.0f);
floatingProgressView.setScaleX(0.1f);
floatingProgressView.setScaleY(0.1f);
floatingProgressView.setVisibility(View.INVISIBLE);
floatingButtonContainer.addView(floatingProgressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
if (savedInstanceState != null) {
restoringState = true;
}
for (int a = 0; a < views.length; a++) {
if (savedInstanceState != null) {
if (a >= 1 && a <= 4) {
if (a == currentViewNum) {
views[a].restoreStateParams(savedInstanceState);
}
} else {
views[a].restoreStateParams(savedInstanceState);
}
}
if (currentViewNum == a) {
actionBar.setBackButtonImage(views[a].needBackButton() || newAccount ? R.drawable.ic_ab_back : 0);
views[a].setVisibility(View.VISIBLE);
views[a].onShow();
currentDoneType = DONE_TYPE_FLOATING;
if (a == 1 || a == 2 || a == 3 || a == 4 || a == 8) {
showDoneButton(false, false);
} else {
showDoneButton(true, false);
}
if (a == 1 || a == 2 || a == 3 || a == 4) {
currentDoneType = DONE_TYPE_ACTION;
}
} else {
views[a].setVisibility(View.GONE);
}
}
restoringState = false;
actionBar.setTitle(views[currentViewNum].getHeaderName());
return fragmentView;
}
use of org.telegram.ui.ActionBar.ActionBarMenu in project Telegram-FOSS by Telegram-FOSS-Team.
the class MemberRequestsActivity method createView.
@Override
public View createView(Context context) {
actionBar.setAllowOverlayTitle(true);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setTitle(delegate.isChannel ? LocaleController.getString("SubscribeRequests", R.string.SubscribeRequests) : LocaleController.getString("MemberRequests", R.string.MemberRequests));
ActionBarMenu menu = actionBar.createMenu();
ActionBarMenuItem searchItem = menu.addItem(searchMenuItem, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
@Override
public void onSearchExpand() {
super.onSearchExpand();
delegate.setSearchExpanded(true);
}
@Override
public void onSearchCollapse() {
super.onSearchCollapse();
delegate.setSearchExpanded(false);
delegate.setQuery(null);
}
@Override
public void onTextChanged(EditText editText) {
super.onTextChanged(editText);
delegate.setQuery(editText.getText().toString());
}
});
searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
searchItem.setVisibility(View.GONE);
FrameLayout rootLayout = delegate.getRootLayout();
delegate.loadMembers();
return fragmentView = rootLayout;
}
use of org.telegram.ui.ActionBar.ActionBarMenu in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChangePhoneActivity method createView.
@Override
public View createView(Context context) {
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == done_button) {
views[currentViewNum].onNextPressed(null);
} else if (id == -1) {
finishFragment();
}
}
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done));
ScrollView scrollView = new ScrollView(context) {
@Override
public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
if (currentViewNum == 1 || currentViewNum == 2 || currentViewNum == 4) {
rectangle.bottom += AndroidUtilities.dp(40);
}
return super.requestChildRectangleOnScreen(child, rectangle, immediate);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
scrollHeight = MeasureSpec.getSize(heightMeasureSpec) - AndroidUtilities.dp(30);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
};
scrollView.setFillViewport(true);
fragmentView = scrollView;
FrameLayout frameLayout = new FrameLayout(context);
scrollView.addView(frameLayout, LayoutHelper.createScroll(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT));
views[0] = new PhoneView(context);
views[1] = new LoginActivitySmsView(context, 1);
views[2] = new LoginActivitySmsView(context, 2);
views[3] = new LoginActivitySmsView(context, 3);
views[4] = new LoginActivitySmsView(context, 4);
for (int a = 0; a < views.length; a++) {
views[a].setVisibility(a == 0 ? View.VISIBLE : View.GONE);
frameLayout.addView(views[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, a == 0 ? LayoutHelper.WRAP_CONTENT : LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, AndroidUtilities.isTablet() ? 26 : 18, 30, AndroidUtilities.isTablet() ? 26 : 18, 0));
}
actionBar.setTitle(views[0].getHeaderName());
return fragmentView;
}
Aggregations