org.telegram.messenger.UserConfig Java Examples

The following examples show how to use org.telegram.messenger.UserConfig. 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: DrawerUserCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (UserConfig.getActivatedAccountsCount() <= 1 || !NotificationsController.getInstance(accountNumber).showBadgeNumber) {
        return;
    }
    int counter = NotificationsController.getInstance(accountNumber).getTotalUnreadCount();
    if (counter <= 0) {
        return;
    }

    String text = String.format("%d", counter);
    int countTop = AndroidUtilities.dp(12.5f);
    int textWidth = (int) Math.ceil(Theme.dialogs_countTextPaint.measureText(text));
    int countWidth = Math.max(AndroidUtilities.dp(10), textWidth);
    int countLeft = getMeasuredWidth() - countWidth - AndroidUtilities.dp(25);

    int x = countLeft - AndroidUtilities.dp(5.5f);
    rect.set(x, countTop, x + countWidth + AndroidUtilities.dp(14), countTop + AndroidUtilities.dp(23));
    canvas.drawRoundRect(rect, 11.5f * AndroidUtilities.density, 11.5f * AndroidUtilities.density, Theme.dialogs_countPaint);

    canvas.drawText(text, rect.left + (rect.width() - textWidth) / 2, countTop + AndroidUtilities.dp(16), Theme.dialogs_countTextPaint);
}
 
Example #2
Source File: ContactsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
private void askForPermissons(boolean alert) {
    Activity activity = getParentActivity();
    if (activity == null || !UserConfig.getInstance(currentAccount).syncContacts || activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
        return;
    }
    if (alert && askAboutContacts) {
        AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, new MessagesStorage.IntCallback() {
            @Override
            public void run(int param) {
                askAboutContacts = param != 0;
                MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).commit();
                askForPermissons(false);
            }
        });
        showDialog(builder.create());
        return;
    }
    ArrayList<String> permissons = new ArrayList<>();
    permissons.add(Manifest.permission.READ_CONTACTS);
    permissons.add(Manifest.permission.WRITE_CONTACTS);
    permissons.add(Manifest.permission.GET_ACCOUNTS);
    String[] items = permissons.toArray(new String[permissons.size()]);
    activity.requestPermissions(items, 1);
}
 
Example #3
Source File: MentionsAdapter.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo)
{
    currentAccount = UserConfig.selectedAccount;
    info = chatInfo;
    if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null)
    {
        TLRPC.Chat chat = parentFragment.getCurrentChat();
        if (chat != null)
        {
            inlineMediaEnabled = ChatObject.canSendStickers(chat);
            if (inlineMediaEnabled)
            {
                searchResultUsernames = null;
                notifyDataSetChanged();
                delegate.needChangePanelVisibility(false);
                processFoundUser(foundContextBot);
            }
        }
    }
    if (lastText != null)
    {
        searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
    }
}
 
Example #4
Source File: VoIPHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private static void doInitiateCall(TLRPC.User user, Activity activity) {
	if (activity == null || user==null) {
		return;
	}
	if(System.currentTimeMillis()-lastCallTime<2000)
		return;
	lastCallTime=System.currentTimeMillis();
	Intent intent = new Intent(activity, VoIPService.class);
	intent.putExtra("user_id", user.id);
	intent.putExtra("is_outgoing", true);
	intent.putExtra("start_incall_activity", true);
	intent.putExtra("account", UserConfig.selectedAccount);
	try {
		activity.startService(intent);
	} catch (Throwable e) {
		FileLog.e(e);
	}
}
 
Example #5
Source File: PaymentFormActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public PaymentFormActivity(TLRPC.TL_payments_paymentForm form, MessageObject message) {
    int step;
    if (form.invoice.shipping_address_requested || form.invoice.email_requested || form.invoice.name_requested || form.invoice.phone_requested) {
        step = 0;
    } else if (form.saved_credentials != null) {
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            if (UserConfig.getInstance(currentAccount).tmpPassword.valid_until < ConnectionsManager.getInstance(currentAccount).getCurrentTime() + 60) {
                UserConfig.getInstance(currentAccount).tmpPassword = null;
                UserConfig.getInstance(currentAccount).saveConfig(false);
            }
        }
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            step = 4;
        } else {
            step = 3;
        }
    } else {
        step = 2;
    }
    init(form, message, step, null, null, null, null, null, false, null);
}
 
Example #6
Source File: SettingsActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.updateInterfaces) {
        int mask = (Integer) args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            updateUserData();
        }
    } else if (id == NotificationCenter.userInfoDidLoad) {
        Integer uid = (Integer) args[0];
        if (uid == UserConfig.getInstance(currentAccount).getClientUserId() && listAdapter != null) {
            userInfo = (TLRPC.UserFull) args[1];
            if (!TextUtils.equals(userInfo.about, currentBio)) {
                listAdapter.notifyItemChanged(bioRow);
            }
        }
    } else if (id == NotificationCenter.emojiDidLoad) {
        if (listView != null) {
            listView.invalidateViews();
        }
    }
}
 
Example #7
Source File: SettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
    if (fileLocation == null) {
        return null;
    }
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    if (user != null && user.photo != null && user.photo.photo_big != null) {
        TLRPC.FileLocation photoBig = user.photo.photo_big;
        if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
            int coords[] = new int[2];
            avatarImage.getLocationInWindow(coords);
            PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
            object.viewX = coords[0];
            object.viewY = coords[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight);
            object.parentView = avatarImage;
            object.imageReceiver = avatarImage.getImageReceiver();
            object.dialogId = UserConfig.getInstance(currentAccount).getClientUserId();
            object.thumb = object.imageReceiver.getBitmapSafe();
            object.size = -1;
            object.radius = avatarImage.getImageReceiver().getRoundRadius();
            object.scale = avatarImage.getScaleX();
            return object;
        }
    }
    return null;
}
 
Example #8
Source File: SettingsActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    super.onFragmentCreate();

    hasOwnBackground = true;
    imageUpdater = new ImageUpdater();
    imageUpdater.parentFragment = this;
    imageUpdater.delegate = this;
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.updateInterfaces);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.userInfoDidLoad);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);

    updateRows();

    getMediaDataController().checkFeaturedStickers();
    getMessagesController().loadSuggestedFilters();
    userInfo = getMessagesController().getUserFull(UserConfig.getInstance(currentAccount).getClientUserId());
    getMessagesController().loadUserInfo(UserConfig.getInstance(currentAccount).getCurrentUser(), true, classGuid);

    return true;
}
 
Example #9
Source File: ContactsAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setSortType(int value) {
    sortType = value;
    if (sortType == 2) {
        if (onlineContacts == null) {
            onlineContacts = new ArrayList<>(ContactsController.getInstance(currentAccount).contacts);
            int selfId = UserConfig.getInstance(currentAccount).clientUserId;
            for (int a = 0, N = onlineContacts.size(); a < N; a++) {
                if (onlineContacts.get(a).user_id == selfId) {
                    onlineContacts.remove(a);
                    break;
                }
            }
        }
        sortOnlineContacts();
    } else {
        notifyDataSetChanged();
    }
}
 
Example #10
Source File: LogoutActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@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 #11
Source File: PrivacySettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void loadPasswordSettings() {
    if (UserConfig.getInstance(currentAccount).hasSecureData) {
        return;
    }
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
        if (response != null) {
            TLRPC.TL_account_password password = (TLRPC.TL_account_password) response;
            if (password.has_secure_values) {
                AndroidUtilities.runOnUIThread(() -> {
                    UserConfig.getInstance(currentAccount).hasSecureData = true;
                    UserConfig.getInstance(currentAccount).saveConfig(false);
                    updateRows();
                });
            }
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example #12
Source File: ChatAvatarContainer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void updateOnlineCount() {
    if (parentFragment == null) {
        return;
    }
    onlineCount = 0;
    TLRPC.ChatFull info = parentFragment.getCurrentChatInfo();
    if (info == null) {
        return;
    }
    int currentTime = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
    if (info instanceof TLRPC.TL_chatFull || info instanceof TLRPC.TL_channelFull && info.participants_count <= 200 && info.participants != null) {
        for (int a = 0; a < info.participants.participants.size(); a++) {
            TLRPC.ChatParticipant participant = info.participants.participants.get(a);
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(participant.user_id);
            if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.getInstance(currentAccount).getClientUserId()) && user.status.expires > 10000) {
                onlineCount++;
            }
        }
    }
}
 
Example #13
Source File: VoIPHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private static void doInitiateCall(TLRPC.User user, Activity activity) {
	if (activity == null || user == null) {
		return;
	}
	if (System.currentTimeMillis() - lastCallTime < 2000)
		return;
	lastCallTime = System.currentTimeMillis();
	Intent intent = new Intent(activity, VoIPService.class);
	intent.putExtra("user_id", user.id);
	intent.putExtra("is_outgoing", true);
	intent.putExtra("start_incall_activity", true);
	intent.putExtra("account", UserConfig.selectedAccount);
	try {
		activity.startService(intent);
	} catch (Throwable e) {
		FileLog.e(e);
	}
}
 
Example #14
Source File: PhotoViewerCaptionEnterView.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setFieldText(CharSequence text) {
    if (messageEditText == null) {
        return;
    }
    messageEditText.setText(text);
    messageEditText.setSelection(messageEditText.getText().length());
    if (delegate != null) {
        delegate.onTextChanged(messageEditText.getText());
    }
    int old = captionMaxLength;
    captionMaxLength = MessagesController.getInstance(UserConfig.selectedAccount).maxCaptionLength;
    if (old != captionMaxLength) {
        InputFilter[] inputFilters = new InputFilter[1];
        inputFilters[0] = new InputFilter.LengthFilter(captionMaxLength);
        messageEditText.setFilters(inputFilters);
    }
}
 
Example #15
Source File: ChatAvatarContainer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void updateOnlineCount() {
    if (parentFragment == null) {
        return;
    }
    onlineCount = 0;
    TLRPC.ChatFull info = parentFragment.getCurrentChatInfo();
    if (info == null) {
        return;
    }
    int currentTime = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
    if (info instanceof TLRPC.TL_chatFull || info instanceof TLRPC.TL_channelFull && info.participants_count <= 200 && info.participants != null) {
        for (int a = 0; a < info.participants.participants.size(); a++) {
            TLRPC.ChatParticipant participant = info.participants.participants.get(a);
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(participant.user_id);
            if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.getInstance(currentAccount).getClientUserId()) && user.status.expires > 10000) {
                onlineCount++;
            }
        }
    }
}
 
Example #16
Source File: SettingsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index, boolean needPreview) {
    if (fileLocation == null) {
        return null;
    }
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    if (user != null && user.photo != null && user.photo.photo_big != null) {
        TLRPC.FileLocation photoBig = user.photo.photo_big;
        if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
            int[] coords = new int[2];
            avatarImage.getLocationInWindow(coords);
            PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
            object.viewX = coords[0];
            object.viewY = coords[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight);
            object.parentView = avatarImage;
            object.imageReceiver = avatarImage.getImageReceiver();
            object.dialogId = UserConfig.getInstance(currentAccount).getClientUserId();
            object.thumb = object.imageReceiver.getBitmapSafe();
            object.size = -1;
            object.radius = avatarImage.getImageReceiver().getRoundRadius();
            object.scale = avatarContainer.getScaleX();
            return object;
        }
    }
    return null;
}
 
Example #17
Source File: MentionsAdapter.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo)
{
    currentAccount = UserConfig.selectedAccount;
    info = chatInfo;
    if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null)
    {
        TLRPC.Chat chat = parentFragment.getCurrentChat();
        if (chat != null)
        {
            inlineMediaEnabled = ChatObject.canSendStickers(chat);
            if (inlineMediaEnabled)
            {
                searchResultUsernames = null;
                notifyDataSetChanged();
                delegate.needChangePanelVisibility(false);
                processFoundUser(foundContextBot);
            }
        }
    }
    if (lastText != null)
    {
        searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
    }
}
 
Example #18
Source File: SettingsActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateUserData() {
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    if (user == null) {
        return;
    }
    TLRPC.FileLocation photoBig = null;
    if (user.photo != null) {
        photoBig = user.photo.photo_big;
    }
    avatarDrawable = new AvatarDrawable(user, true);

    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    if (avatarImage != null) {
        avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);

        nameTextView.setText(UserObject.getUserName(user));
        onlineTextView.setText(LocaleController.getString("Online", R.string.Online));

        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);
    }
}
 
Example #19
Source File: ConnectionsManager.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onPostExecute(final NativeByteBuffer result)
{
    Utilities.stageQueue.postRunnable(() ->
    {
        if (result != null)
        {
            native_applyDnsConfig(currentAccount, result.address,
                    UserConfig.getInstance(currentAccount).getClientPhone());
        }
        else
        {
            if (BuildVars.LOGS_ENABLED)
                FileLog.d("failed to get azure result");
        }
        currentTask = null;
    });
}
 
Example #20
Source File: VoIPHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public static void showRateAlert(Context context, TLRPC.TL_messageActionPhoneCall call) {
	SharedPreferences prefs = MessagesController.getNotificationsSettings(UserConfig.selectedAccount); // always called from chat UI
	Set<String> hashes = prefs.getStringSet("calls_access_hashes", (Set<String>) Collections.EMPTY_SET);
	for (String hash : hashes) {
		String[] d = hash.split(" ");
		if (d.length < 2)
			continue;
		if (d[0].equals(call.call_id + "")) {
			try {
				long accessHash = Long.parseLong(d[1]);
				showRateAlert(context, null, call.call_id, accessHash, UserConfig.selectedAccount, true);
			} catch (Exception ignore) {
			}
			return;
		}
	}
}
 
Example #21
Source File: DrawerLayoutAdapter.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getItemViewType(int i)
{
    if (i == 0)
        return 0;

    else if (i == 1)
        return 1;

    i -= 2;

    if (accountsShowed)
    {
        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 (i == 3)
        return 2;

    return 3;
}
 
Example #22
Source File: InviteContactsActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.contactsImported);
    fetchContacts();
    if (!UserConfig.getInstance(currentAccount).contactsReimported) {
        ContactsController.getInstance(currentAccount).forceImportContacts();
        UserConfig.getInstance(currentAccount).contactsReimported = true;
        UserConfig.getInstance(currentAccount).saveConfig(false);
    }
    return super.onFragmentCreate();
}
 
Example #23
Source File: SettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onFragmentDestroy() {
    super.onFragmentDestroy();
    if (avatarImage != null) {
        avatarImage.setImageDrawable(null);
    }
    MessagesController.getInstance(currentAccount).cancelLoadFullUser(UserConfig.getInstance(currentAccount).getClientUserId());
    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.updateInterfaces);
    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.featuredStickersDidLoaded);
    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.userInfoDidLoaded);
    NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
    imageUpdater.clear();
}
 
Example #24
Source File: ThemesHorizontalListCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
        NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.fileDidLoad);
        NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.fileDidFailToLoad);
    }
}
 
Example #25
Source File: LocationActivityAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setLiveLocations(ArrayList<LocationActivity.LiveLocation> liveLocations) {
    currentLiveLocations = new ArrayList<>(liveLocations);
    int uid = UserConfig.getInstance(currentAccount).getClientUserId();
    for (int a = 0; a < currentLiveLocations.size(); a++) {
        if (currentLiveLocations.get(a).id == uid) {
            currentLiveLocations.remove(a);
            break;
        }
    }
    notifyDataSetChanged();
}
 
Example #26
Source File: ChatActionCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setMessageObject(MessageObject messageObject) {
    if (currentMessageObject == messageObject && (hasReplyMessage || messageObject.replyMessageObject == null)) {
        return;
    }
    currentMessageObject = messageObject;
    hasReplyMessage = messageObject.replyMessageObject != null;
    previousWidth = 0;
    if (currentMessageObject.type == 11) {
        int id = 0;
        if (messageObject.messageOwner.to_id != null) {
            if (messageObject.messageOwner.to_id.chat_id != 0) {
                id = messageObject.messageOwner.to_id.chat_id;
            } else if (messageObject.messageOwner.to_id.channel_id != 0) {
                id = messageObject.messageOwner.to_id.channel_id;
            } else {
                id = messageObject.messageOwner.to_id.user_id;
                if (id == UserConfig.getInstance(currentAccount).getClientUserId()) {
                    id = messageObject.messageOwner.from_id;
                }
            }
        }
        avatarDrawable.setInfo(id, null, null);
        if (currentMessageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
            imageReceiver.setImage(null, null, avatarDrawable, null, currentMessageObject, 0);
        } else {
            TLRPC.PhotoSize photo = FileLoader.getClosestPhotoSizeWithSize(currentMessageObject.photoThumbs, AndroidUtilities.dp(64));
            if (photo != null) {
                imageReceiver.setImage(ImageLocation.getForObject(photo, currentMessageObject.photoThumbsObject), "50_50", avatarDrawable, null, currentMessageObject, 0);
            } else {
                imageReceiver.setImageBitmap(avatarDrawable);
            }
        }
        imageReceiver.setVisible(!PhotoViewer.isShowingImage(currentMessageObject), false);
    } else {
        imageReceiver.setImageBitmap((Bitmap) null);
    }
    requestLayout();
}
 
Example #27
Source File: ConnectionsManager.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public boolean isPushConnectionEnabled() {
    SharedPreferences preferences = MessagesController.getGlobalNotificationsSettings();
    if (preferences.contains("pushConnection")) {
        return preferences.getBoolean("pushConnection", true);
    } else {
        return MessagesController.getMainSettings(UserConfig.selectedAccount).getBoolean("backgroundConnection", false);
    }
}
 
Example #28
Source File: TestActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onFragmentDestroy() {
    super.onFragmentDestroy();
    if (encryptedString != null) {
        SharedPreferences preferences = MessagesController.getMainSettings(UserConfig.selectedAccount);
        preferences.edit().remove("test_enc").commit();
    }
}
 
Example #29
Source File: AlertsCreator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
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 #30
Source File: ConnectionsManager.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static void onLogout(final int currentAccount)
{
    AndroidUtilities.runOnUIThread(() ->
    {
        if (UserConfig.getInstance(currentAccount).getClientUserId() != 0)
        {
            UserConfig.getInstance(currentAccount).clearConfig();
            MessagesController.getInstance(currentAccount).performLogout(0);
        }
    });
}