Java Code Examples for org.telegram.tgnet.TLRPC#TL_chatPhoto

The following examples show how to use org.telegram.tgnet.TLRPC#TL_chatPhoto . 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: ChatEditActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private boolean checkDiscard() {
    String about = info != null && info.about != null ? info.about : "";
    if (info != null && ChatObject.isChannel(currentChat) && info.hidden_prehistory != historyHidden ||
            imageUpdater.uploadingImage != null ||
            nameTextView != null && !currentChat.title.equals(nameTextView.getText().toString()) ||
            descriptionTextView != null && !about.equals(descriptionTextView.getText().toString()) ||
            signMessages != currentChat.signatures ||
            uploadedAvatar != null || avatar == null && currentChat.photo instanceof TLRPC.TL_chatPhoto) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("UserRestrictionsApplyChanges", R.string.UserRestrictionsApplyChanges));
        if (isChannel) {
            builder.setMessage(LocaleController.getString("ChannelSettingsChangedAlert", R.string.ChannelSettingsChangedAlert));
        } else {
            builder.setMessage(LocaleController.getString("GroupSettingsChangedAlert", R.string.GroupSettingsChangedAlert));
        }
        builder.setPositiveButton(LocaleController.getString("ApplyTheme", R.string.ApplyTheme), (dialogInterface, i) -> processDone());
        builder.setNegativeButton(LocaleController.getString("PassportDiscard", R.string.PassportDiscard), (dialog, which) -> finishFragment());
        showDialog(builder.create());
        return false;
    }
    return true;
}
 
Example 2
Source File: ChatEditActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private boolean checkDiscard() {
    String about = info != null && info.about != null ? info.about : "";
    if (info != null && ChatObject.isChannel(currentChat) && info.hidden_prehistory != historyHidden ||
            imageUpdater.uploadingImage != null ||
            nameTextView != null && !currentChat.title.equals(nameTextView.getText().toString()) ||
            descriptionTextView != null && !about.equals(descriptionTextView.getText().toString()) ||
            signMessages != currentChat.signatures ||
            uploadedAvatar != null || avatar == null && currentChat.photo instanceof TLRPC.TL_chatPhoto) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("UserRestrictionsApplyChanges", R.string.UserRestrictionsApplyChanges));
        if (isChannel) {
            builder.setMessage(LocaleController.getString("ChannelSettingsChangedAlert", R.string.ChannelSettingsChangedAlert));
        } else {
            builder.setMessage(LocaleController.getString("GroupSettingsChangedAlert", R.string.GroupSettingsChangedAlert));
        }
        builder.setPositiveButton(LocaleController.getString("ApplyTheme", R.string.ApplyTheme), (dialogInterface, i) -> processDone());
        builder.setNegativeButton(LocaleController.getString("PassportDiscard", R.string.PassportDiscard), (dialog, which) -> finishFragment());
        showDialog(builder.create());
        return false;
    }
    return true;
}
 
Example 3
Source File: ChatEditActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void processDone() {
    if (donePressed || nameTextView == null) {
        return;
    }
    if (nameTextView.length() == 0) {
        Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
        if (v != null) {
            v.vibrate(200);
        }
        AndroidUtilities.shakeView(nameTextView, 2, 0);
        return;
    }
    donePressed = true;
    if (!ChatObject.isChannel(currentChat) && !historyHidden) {
        MessagesController.getInstance(currentAccount).convertToMegaGroup(getParentActivity(), chatId, this, param -> {
            if (param == 0) {
                donePressed = false;
                return;
            }
            chatId = param;
            currentChat = MessagesController.getInstance(currentAccount).getChat(param);
            donePressed = false;
            if (info != null) {
                info.hidden_prehistory = true;
            }
            processDone();
        });
        return;
    }

    if (info != null) {
        if (ChatObject.isChannel(currentChat) && info.hidden_prehistory != historyHidden) {
            info.hidden_prehistory = historyHidden;
            MessagesController.getInstance(currentAccount).toogleChannelInvitesHistory(chatId, historyHidden);
        }
    }

    if (imageUpdater.uploadingImage != null) {
        createAfterUpload = true;
        progressDialog = new AlertDialog(getParentActivity(), 3);
        progressDialog.setOnCancelListener(dialog -> {
            createAfterUpload = false;
            progressDialog = null;
            donePressed = false;
        });
        progressDialog.show();
        return;
    }

    if (!currentChat.title.equals(nameTextView.getText().toString())) {
        MessagesController.getInstance(currentAccount).changeChatTitle(chatId, nameTextView.getText().toString());
    }
    String about = info != null && info.about != null ? info.about : "";
    if (descriptionTextView != null && !about.equals(descriptionTextView.getText().toString())) {
        MessagesController.getInstance(currentAccount).updateChatAbout(chatId, descriptionTextView.getText().toString(), info);
    }
    if (signMessages != currentChat.signatures) {
        currentChat.signatures = true;
        MessagesController.getInstance(currentAccount).toogleChannelSignatures(chatId, signMessages);
    }
    if (uploadedAvatar != null) {
        MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, uploadedAvatar, avatar, avatarBig);
    } else if (avatar == null && currentChat.photo instanceof TLRPC.TL_chatPhoto) {
        MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, null, null, null);
    }
    finishFragment();
}
 
Example 4
Source File: ChatEditActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void processDone() {
    if (donePressed || nameTextView == null) {
        return;
    }
    if (nameTextView.length() == 0) {
        Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
        if (v != null) {
            v.vibrate(200);
        }
        AndroidUtilities.shakeView(nameTextView, 2, 0);
        return;
    }
    donePressed = true;
    if (!ChatObject.isChannel(currentChat) && !historyHidden) {
        MessagesController.getInstance(currentAccount).convertToMegaGroup(getParentActivity(), chatId, this, param -> {
            if (param == 0) {
                donePressed = false;
                return;
            }
            chatId = param;
            currentChat = MessagesController.getInstance(currentAccount).getChat(param);
            donePressed = false;
            if (info != null) {
                info.hidden_prehistory = true;
            }
            processDone();
        });
        return;
    }

    if (info != null) {
        if (ChatObject.isChannel(currentChat) && info.hidden_prehistory != historyHidden) {
            info.hidden_prehistory = historyHidden;
            MessagesController.getInstance(currentAccount).toogleChannelInvitesHistory(chatId, historyHidden);
        }
    }

    if (imageUpdater.uploadingImage != null) {
        createAfterUpload = true;
        progressDialog = new AlertDialog(getParentActivity(), 3);
        progressDialog.setOnCancelListener(dialog -> {
            createAfterUpload = false;
            progressDialog = null;
            donePressed = false;
        });
        progressDialog.show();
        return;
    }

    if (!currentChat.title.equals(nameTextView.getText().toString())) {
        MessagesController.getInstance(currentAccount).changeChatTitle(chatId, nameTextView.getText().toString());
    }
    String about = info != null && info.about != null ? info.about : "";
    if (descriptionTextView != null && !about.equals(descriptionTextView.getText().toString())) {
        MessagesController.getInstance(currentAccount).updateChatAbout(chatId, descriptionTextView.getText().toString(), info);
    }
    if (signMessages != currentChat.signatures) {
        currentChat.signatures = true;
        MessagesController.getInstance(currentAccount).toogleChannelSignatures(chatId, signMessages);
    }
    if (uploadedAvatar != null) {
        MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, uploadedAvatar, avatar, avatarBig);
    } else if (avatar == null && currentChat.photo instanceof TLRPC.TL_chatPhoto) {
        MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, null, null, null);
    }
    finishFragment();
}