Java Code Examples for org.telegram.messenger.UserConfig#MAX_ACCOUNT_COUNT
The following examples show how to use
org.telegram.messenger.UserConfig#MAX_ACCOUNT_COUNT .
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: PopupNotificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
protected void onFinish() { if (finished) { return; } finished = true; if (isReply) { popupMessages.clear(); } for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.appDidLogout); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.updateInterfaces); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingProgressDidChanged); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidReset); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.contactsDidLoaded); } NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.pushMessagesUpdated); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoaded); if (chatActivityEnterView != null) { chatActivityEnterView.onDestroy(); } if (wakeLock.isHeld()) { wakeLock.release(); } }
Example 2
Source File: FragmentContextView.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); topPadding = 0; if (isLocation) { NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.liveLocationsChanged); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.liveLocationsCacheChanged); } else { for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidReset); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingPlayStateChanged); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidStart); } NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.messagePlayingSpeedChanged); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didStartedCall); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didEndCall); } }
Example 3
Source File: FragmentContextView.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); topPadding = 0; if (isLocation) { NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.liveLocationsChanged); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.liveLocationsCacheChanged); } else { for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidReset); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingPlayStateChanged); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidStarted); } NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didStartedCall); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didEndedCall); } }
Example 4
Source File: LogoutActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public boolean onFragmentCreate() { super.onFragmentCreate(); rowCount = 0; alternativeHeaderRow = rowCount++; if (UserConfig.getActivatedAccountsCount() < UserConfig.MAX_ACCOUNT_COUNT) { addAccountRow = rowCount++; } else { addAccountRow = -1; } if (SharedConfig.passcodeHash.length() <= 0) { passcodeRow = rowCount++; } else { passcodeRow = -1; } cacheRow = rowCount++; phoneRow = rowCount++; supportRow = rowCount++; alternativeSectionRow = rowCount++; logoutRow = rowCount++; logoutSectionRow = rowCount++; return true; }
Example 5
Source File: LogoutActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public boolean onFragmentCreate() { super.onFragmentCreate(); rowCount = 0; alternativeHeaderRow = rowCount++; if (UserConfig.getActivatedAccountsCount() < UserConfig.MAX_ACCOUNT_COUNT) { addAccountRow = rowCount++; } else { addAccountRow = -1; } if (SharedConfig.passcodeHash.length() <= 0) { passcodeRow = rowCount++; } else { passcodeRow = -1; } cacheRow = rowCount++; phoneRow = rowCount++; supportRow = rowCount++; alternativeSectionRow = rowCount++; logoutRow = rowCount++; logoutSectionRow = rowCount++; return true; }
Example 6
Source File: ThemesHorizontalListCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.fileDidLoad); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.fileDidFailToLoad); } }
Example 7
Source File: ConnectionsManager.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public static void setLangCode(String langCode) { langCode = langCode.replace('_', '-').toLowerCase(); for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { native_setLangCode(a, langCode); } }
Example 8
Source File: DrawerLayoutAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public int getItemViewType(int i) { if (i == 0) { return 0; } else if (i == 1) { return 1; } i -= 2; if (accountsShown) { if (i < accountNumbers.size()) { return 4; } else { if (accountNumbers.size() < UserConfig.MAX_ACCOUNT_COUNT) { if (i == accountNumbers.size()){ return 5; } else if (i == accountNumbers.size() + 1) { return 2; } } else { if (i == accountNumbers.size()) { return 2; } } } i -= getAccountRowsCount(); } if (items.get(i) == null) { return 2; } return 3; }
Example 9
Source File: PopupNotificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void handleIntent(Intent intent) { isReply = intent != null && intent.getBooleanExtra("force", false); popupMessages.clear(); if (isReply) { int account = intent != null ? intent.getIntExtra("currentAccount", UserConfig.selectedAccount) : UserConfig.selectedAccount; popupMessages.addAll(NotificationsController.getInstance(account).popupReplyMessages); } else { for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { if (UserConfig.getInstance(a).isClientActivated()) { popupMessages.addAll(NotificationsController.getInstance(a).popupMessages); } } } KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); if (km.inKeyguardRestrictedInputMode() || !ApplicationLoader.isScreenOn) { getWindow().addFlags( WindowManager.LayoutParams.FLAG_DIM_BEHIND | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { getWindow().addFlags( WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } if (currentMessageObject == null) { currentMessageNum = 0; } getNewMessage(); }
Example 10
Source File: DrawerLayoutAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private int getAccountRowsCount() { int count = accountNumbers.size() + 1; if (accountNumbers.size() < UserConfig.MAX_ACCOUNT_COUNT) { count++; } return count; }
Example 11
Source File: DrawerLayoutAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public int getAccountRowsCount() { int count = accountNumbers.size() + 1; if (accountNumbers.size() < UserConfig.MAX_ACCOUNT_COUNT) count++; return count; }
Example 12
Source File: ConnectionsManager.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public static void setLangCode(String langCode) { langCode = langCode.replace('_', '-').toLowerCase(); for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { native_setLangCode(a, langCode); } }
Example 13
Source File: SharingLocationsAlert.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private LocationController.SharingLocationInfo getLocation(int position) { for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { ArrayList<LocationController.SharingLocationInfo> infos = LocationController.getInstance(a).sharingLocationsUI; if (position >= infos.size()) { position -= infos.size(); } else { return infos.get(position); } } return null; }
Example 14
Source File: FragmentContextView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); if (isLocation) { NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.liveLocationsChanged); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.liveLocationsCacheChanged); if (additionalContextView != null) { additionalContextView.checkVisibility(); } checkLiveLocation(true); } else { for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.messagePlayingDidReset); NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.messagePlayingPlayStateChanged); NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.messagePlayingDidStarted); } NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didStartedCall); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didEndedCall); if (additionalContextView != null) { additionalContextView.checkVisibility(); } if (VoIPService.getSharedInstance() != null && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING) { checkCall(true); } else { checkPlayer(true); updatePlaybackButton(); } } }
Example 15
Source File: ConnectionsManager.java From Telegram with GNU General Public License v2.0 | 5 votes |
public static void setRegId(String regId, String status) { String pushString = regId; if (TextUtils.isEmpty(pushString) && !TextUtils.isEmpty(status)) { pushString = status; } for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { native_setRegId(a, pushString); } }
Example 16
Source File: AlertsCreator.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static AlertDialog createAccountSelectDialog(Activity parentActivity, final AccountSelectDelegate delegate) { if (UserConfig.getActivatedAccountsCount() < 2) { return null; } AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); final Runnable dismissRunnable = builder.getDismissRunnable(); final AlertDialog[] alertDialog = new AlertDialog[1]; final LinearLayout linearLayout = new LinearLayout(parentActivity); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { TLRPC.User u = UserConfig.getInstance(a).getCurrentUser(); if (u != null) { AccountSelectCell cell = new AccountSelectCell(parentActivity); cell.setAccount(a, false); cell.setPadding(AndroidUtilities.dp(14), 0, AndroidUtilities.dp(14), 0); cell.setBackgroundDrawable(Theme.getSelectorDrawable(false)); linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50)); cell.setOnClickListener(v -> { if (alertDialog[0] != null) { alertDialog[0].setOnDismissListener(null); } dismissRunnable.run(); AccountSelectCell cell1 = (AccountSelectCell) v; delegate.didSelectAccount(cell1.getAccountNumber()); }); } } builder.setTitle(LocaleController.getString("SelectAccount", R.string.SelectAccount)); builder.setView(linearLayout); builder.setPositiveButton(LocaleController.getString("Cancel", R.string.Cancel), null); return alertDialog[0] = builder.create(); }
Example 17
Source File: PopupNotificationActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void handleIntent(Intent intent) { isReply = intent != null && intent.getBooleanExtra("force", false); popupMessages.clear(); if (isReply) { int account = intent != null ? intent.getIntExtra("currentAccount", UserConfig.selectedAccount) : UserConfig.selectedAccount; popupMessages.addAll(NotificationsController.getInstance(account).popupReplyMessages); } else { for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { if (UserConfig.getInstance(a).isClientActivated()) { popupMessages.addAll(NotificationsController.getInstance(a).popupMessages); } } } KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); if (km.inKeyguardRestrictedInputMode() || !ApplicationLoader.isScreenOn) { getWindow().addFlags( WindowManager.LayoutParams.FLAG_DIM_BEHIND | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { getWindow().addFlags( WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } if (currentMessageObject == null) { currentMessageNum = 0; } getNewMessage(); }
Example 18
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static AlertDialog createAccountSelectDialog(Activity parentActivity, final AccountSelectDelegate delegate) { if (UserConfig.getActivatedAccountsCount() < 2) { return null; } AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); final Runnable dismissRunnable = builder.getDismissRunnable(); final AlertDialog[] alertDialog = new AlertDialog[1]; final LinearLayout linearLayout = new LinearLayout(parentActivity); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { TLRPC.User u = UserConfig.getInstance(a).getCurrentUser(); if (u != null) { AccountSelectCell cell = new AccountSelectCell(parentActivity); cell.setAccount(a, false); cell.setPadding(AndroidUtilities.dp(14), 0, AndroidUtilities.dp(14), 0); cell.setBackgroundDrawable(Theme.getSelectorDrawable(false)); linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); cell.setOnClickListener(v -> { if (alertDialog[0] != null) { alertDialog[0].setOnDismissListener(null); } dismissRunnable.run(); AccountSelectCell cell1 = (AccountSelectCell) v; delegate.didSelectAccount(cell1.getAccountNumber()); }); } } builder.setTitle(LocaleController.getString("SelectAccount", R.string.SelectAccount)); builder.setView(linearLayout); builder.setPositiveButton(LocaleController.getString("Cancel", R.string.Cancel), null); return alertDialog[0] = builder.create(); }
Example 19
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 20
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)); }