Java Code Examples for org.telegram.ui.ActionBar.Theme#getEventType()
The following examples show how to use
org.telegram.ui.ActionBar.Theme#getEventType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DrawerLayoutAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void resetItems() { accountNumbers.clear(); for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { if (UserConfig.getInstance(a).isClientActivated()) { accountNumbers.add(a); } } Collections.sort(accountNumbers, (o1, o2) -> { long l1 = UserConfig.getInstance(o1).loginTime; long l2 = UserConfig.getInstance(o2).loginTime; if (l1 > l2) { return 1; } else if (l1 < l2) { return -1; } return 0; }); items.clear(); if (!UserConfig.getInstance(UserConfig.selectedAccount).isClientActivated()) { return; } int eventType = Theme.getEventType(); int newGroupIcon; int newSecretIcon; int newChannelIcon; int contactsIcon; int callsIcon; int savedIcon; int settingsIcon; int inviteIcon; int helpIcon; if (eventType == 0) { newGroupIcon = R.drawable.menu_groups_ny; newSecretIcon = R.drawable.menu_secret_ny; newChannelIcon = R.drawable.menu_channel_ny; contactsIcon = R.drawable.menu_contacts_ny; callsIcon = R.drawable.menu_calls_ny; savedIcon = R.drawable.menu_bookmarks_ny; settingsIcon = R.drawable.menu_settings_ny; inviteIcon = R.drawable.menu_invite_ny; helpIcon = R.drawable.menu_help_ny; } else if (eventType == 1) { newGroupIcon = R.drawable.menu_groups_14; newSecretIcon = R.drawable.menu_secret_14; newChannelIcon = R.drawable.menu_broadcast_14; contactsIcon = R.drawable.menu_contacts_14; callsIcon = R.drawable.menu_calls_14; savedIcon = R.drawable.menu_bookmarks_14; settingsIcon = R.drawable.menu_settings_14; inviteIcon = R.drawable.menu_secret_ny; helpIcon = R.drawable.menu_help; } else { newGroupIcon = R.drawable.menu_groups; newSecretIcon = R.drawable.menu_secret; newChannelIcon = R.drawable.menu_broadcast; contactsIcon = R.drawable.menu_contacts; callsIcon = R.drawable.menu_calls; savedIcon = R.drawable.menu_saved; settingsIcon = R.drawable.menu_settings; inviteIcon = R.drawable.menu_invite; helpIcon = R.drawable.menu_help; } items.add(new Item(2, LocaleController.getString("NewGroup", R.string.NewGroup), newGroupIcon)); items.add(new Item(3, LocaleController.getString("NewSecretChat", R.string.NewSecretChat), newSecretIcon)); items.add(new Item(4, LocaleController.getString("NewChannel", R.string.NewChannel), newChannelIcon)); items.add(new Item(6, LocaleController.getString("Contacts", R.string.Contacts), contactsIcon)); items.add(new Item(10, LocaleController.getString("Calls", R.string.Calls), callsIcon)); items.add(new Item(11, LocaleController.getString("SavedMessages", R.string.SavedMessages), savedIcon)); items.add(new Item(8, LocaleController.getString("Settings", R.string.Settings), settingsIcon)); items.add(null); // divider items.add(new Item(7, LocaleController.getString("InviteFriends", R.string.InviteFriends), inviteIcon)); items.add(new Item(9, LocaleController.getString("TelegramFAQ", R.string.TelegramFAQ), helpIcon)); }
Example 2
Source File: DrawerProfileCell.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public DrawerProfileCell(Context context) { super(context); shadowView = new ImageView(context); shadowView.setVisibility(INVISIBLE); shadowView.setScaleType(ImageView.ScaleType.FIT_XY); shadowView.setImageResource(R.drawable.bottom_shadow); addView(shadowView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 70, Gravity.LEFT | Gravity.BOTTOM)); avatarImageView = new BackupImageView(context); avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32)); addView(avatarImageView, LayoutHelper.createFrame(64, 64, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 0, 67)); nameTextView = new TextView(context); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); nameTextView.setLines(1); nameTextView.setMaxLines(1); nameTextView.setSingleLine(true); nameTextView.setGravity(Gravity.LEFT); nameTextView.setEllipsize(TextUtils.TruncateAt.END); addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 76, 28)); phoneTextView = new TextView(context); phoneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); phoneTextView.setLines(1); phoneTextView.setMaxLines(1); phoneTextView.setSingleLine(true); phoneTextView.setGravity(Gravity.LEFT); addView(phoneTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 76, 9)); arrowView = new ImageView(context); arrowView.setScaleType(ImageView.ScaleType.CENTER); arrowView.setImageResource(R.drawable.menu_expand); addView(arrowView, LayoutHelper.createFrame(59, 59, Gravity.RIGHT | Gravity.BOTTOM)); setArrowState(false); darkThemeView = new ImageView(context); darkThemeView.setScaleType(ImageView.ScaleType.CENTER); darkThemeView.setImageResource(R.drawable.menu_night); darkThemeView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_menuName), PorterDuff.Mode.MULTIPLY)); if (Build.VERSION.SDK_INT >= 21) { darkThemeView.setBackgroundDrawable(Theme.createSelectorDrawable(darkThemeBackgroundColor = Theme.getColor(Theme.key_listSelector), 1, AndroidUtilities.dp(17))); Theme.setRippleDrawableForceSoftware((RippleDrawable) darkThemeView.getBackground()); } darkThemeView.setOnClickListener(v -> { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", Activity.MODE_PRIVATE); String dayThemeName = preferences.getString("lastDayTheme", "Blue"); if (Theme.getTheme(dayThemeName) == null) { dayThemeName = "Blue"; } String nightThemeName = preferences.getString("lastDarkTheme", "Dark Blue"); if (Theme.getTheme(nightThemeName) == null) { nightThemeName = "Dark Blue"; } Theme.ThemeInfo themeInfo = Theme.getActiveTheme(); if (dayThemeName.equals(nightThemeName)) { if (themeInfo.isDark()) { dayThemeName = "Blue"; } else { nightThemeName = "Dark Blue"; } } if (dayThemeName.equals(themeInfo.getKey())) { themeInfo = Theme.getTheme(nightThemeName); } else { themeInfo = Theme.getTheme(dayThemeName); } if (Theme.selectedAutoNightType != Theme.AUTO_NIGHT_TYPE_NONE) { Toast.makeText(getContext(), LocaleController.getString("AutoNightModeOff", R.string.AutoNightModeOff), Toast.LENGTH_SHORT).show(); Theme.selectedAutoNightType = Theme.AUTO_NIGHT_TYPE_NONE; Theme.saveAutoNightThemeConfig(); Theme.cancelAutoNightThemeCallbacks(); } int[] pos = new int[2]; darkThemeView.getLocationInWindow(pos); pos[0] += darkThemeView.getMeasuredWidth() / 2; pos[1] += darkThemeView.getMeasuredHeight() / 2; NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, themeInfo, false, pos, -1); }); addView(darkThemeView, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 90)); if (Theme.getEventType() == 0) { snowflakesEffect = new SnowflakesEffect(); snowflakesEffect.setColorKey(Theme.key_chats_menuName); } }
Example 3
Source File: DrawerLayoutAdapter.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void resetItems() { accountNumbers.clear(); for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { if (UserConfig.getInstance(a).isClientActivated()) { accountNumbers.add(a); } } Collections.sort(accountNumbers, (o1, o2) -> { long l1 = UserConfig.getInstance(o1).loginTime; long l2 = UserConfig.getInstance(o2).loginTime; if (l1 > l2) { return 1; } else if (l1 < l2) { return -1; } return 0; }); items.clear(); if (!UserConfig.getInstance(UserConfig.selectedAccount).isClientActivated()) { return; } int eventType = Theme.getEventType(); int newGroupIcon; int newSecretIcon; int newChannelIcon; int contactsIcon; int callsIcon; int savedIcon; int settingsIcon; int inviteIcon; int helpIcon; if (eventType == 0) { newGroupIcon = R.drawable.menu_groups_ny; newSecretIcon = R.drawable.menu_secret_ny; newChannelIcon = R.drawable.menu_channel_ny; contactsIcon = R.drawable.menu_contacts_ny; callsIcon = R.drawable.menu_calls_ny; savedIcon = R.drawable.menu_bookmarks_ny; settingsIcon = R.drawable.menu_settings_ny; inviteIcon = R.drawable.menu_invite_ny; helpIcon = R.drawable.menu_help_ny; } else if (eventType == 1) { newGroupIcon = R.drawable.menu_groups_14; newSecretIcon = R.drawable.menu_secret_14; newChannelIcon = R.drawable.menu_broadcast_14; contactsIcon = R.drawable.menu_contacts_14; callsIcon = R.drawable.menu_calls_14; savedIcon = R.drawable.menu_bookmarks_14; settingsIcon = R.drawable.menu_settings_14; inviteIcon = R.drawable.menu_secret_ny; helpIcon = R.drawable.menu_help; } else { newGroupIcon = R.drawable.menu_groups; newSecretIcon = R.drawable.menu_secret; newChannelIcon = R.drawable.menu_broadcast; contactsIcon = R.drawable.menu_contacts; callsIcon = R.drawable.menu_calls; savedIcon = R.drawable.menu_saved; settingsIcon = R.drawable.menu_settings; inviteIcon = R.drawable.menu_invite; helpIcon = R.drawable.menu_help; } items.add(new Item(2, LocaleController.getString("NewGroup", R.string.NewGroup), newGroupIcon)); items.add(new Item(3, LocaleController.getString("NewSecretChat", R.string.NewSecretChat), newSecretIcon)); items.add(new Item(4, LocaleController.getString("NewChannel", R.string.NewChannel), newChannelIcon)); items.add(new Item(6, LocaleController.getString("Contacts", R.string.Contacts), contactsIcon)); items.add(new Item(10, LocaleController.getString("Calls", R.string.Calls), callsIcon)); items.add(new Item(11, LocaleController.getString("SavedMessages", R.string.SavedMessages), savedIcon)); items.add(new Item(8, LocaleController.getString("Settings", R.string.Settings), settingsIcon)); items.add(null); // divider items.add(new Item(7, LocaleController.getString("InviteFriends", R.string.InviteFriends), inviteIcon)); items.add(new Item(9, LocaleController.getString("TelegramFAQ", R.string.TelegramFAQ), helpIcon)); }
Example 4
Source File: DrawerProfileCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public DrawerProfileCell(Context context) { super(context); shadowView = new ImageView(context); shadowView.setVisibility(INVISIBLE); shadowView.setScaleType(ImageView.ScaleType.FIT_XY); shadowView.setImageResource(R.drawable.bottom_shadow); addView(shadowView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 70, Gravity.LEFT | Gravity.BOTTOM)); avatarImageView = new BackupImageView(context); avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32)); addView(avatarImageView, LayoutHelper.createFrame(64, 64, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 0, 67)); nameTextView = new TextView(context); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); nameTextView.setLines(1); nameTextView.setMaxLines(1); nameTextView.setSingleLine(true); nameTextView.setGravity(Gravity.LEFT); nameTextView.setEllipsize(TextUtils.TruncateAt.END); addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 76, 28)); phoneTextView = new TextView(context); phoneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); phoneTextView.setLines(1); phoneTextView.setMaxLines(1); phoneTextView.setSingleLine(true); phoneTextView.setGravity(Gravity.LEFT); addView(phoneTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 76, 9)); arrowView = new ImageView(context); arrowView.setScaleType(ImageView.ScaleType.CENTER); arrowView.setImageResource(R.drawable.menu_expand); addView(arrowView, LayoutHelper.createFrame(59, 59, Gravity.RIGHT | Gravity.BOTTOM)); setArrowState(false); darkThemeView = new ImageView(context); darkThemeView.setScaleType(ImageView.ScaleType.CENTER); darkThemeView.setImageResource(R.drawable.menu_night); darkThemeView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_menuName), PorterDuff.Mode.MULTIPLY)); if (Build.VERSION.SDK_INT >= 21) { darkThemeView.setBackgroundDrawable(Theme.createSelectorDrawable(darkThemeBackgroundColor = Theme.getColor(Theme.key_listSelector), 1, AndroidUtilities.dp(17))); Theme.setRippleDrawableForceSoftware((RippleDrawable) darkThemeView.getBackground()); } darkThemeView.setOnClickListener(v -> { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", Activity.MODE_PRIVATE); String dayThemeName = preferences.getString("lastDayTheme", "Blue"); if (Theme.getTheme(dayThemeName) == null) { dayThemeName = "Blue"; } String nightThemeName = preferences.getString("lastDarkTheme", "Dark Blue"); if (Theme.getTheme(nightThemeName) == null) { nightThemeName = "Dark Blue"; } Theme.ThemeInfo themeInfo = Theme.getActiveTheme(); if (dayThemeName.equals(nightThemeName)) { if (themeInfo.isDark()) { dayThemeName = "Blue"; } else { nightThemeName = "Dark Blue"; } } if (dayThemeName.equals(themeInfo.getKey())) { themeInfo = Theme.getTheme(nightThemeName); } else { themeInfo = Theme.getTheme(dayThemeName); } if (Theme.selectedAutoNightType != Theme.AUTO_NIGHT_TYPE_NONE) { Toast.makeText(getContext(), LocaleController.getString("AutoNightModeOff", R.string.AutoNightModeOff), Toast.LENGTH_SHORT).show(); Theme.selectedAutoNightType = Theme.AUTO_NIGHT_TYPE_NONE; Theme.saveAutoNightThemeConfig(); Theme.cancelAutoNightThemeCallbacks(); } int[] pos = new int[2]; darkThemeView.getLocationInWindow(pos); pos[0] += darkThemeView.getMeasuredWidth() / 2; pos[1] += darkThemeView.getMeasuredHeight() / 2; NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, themeInfo, false, pos, -1); }); addView(darkThemeView, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 90)); if (Theme.getEventType() == 0) { snowflakesEffect = new SnowflakesEffect(); snowflakesEffect.setColorKey(Theme.key_chats_menuName); } }