Search in sources :

Example 1 with SecureDocument

use of org.telegram.messenger.SecureDocument in project Telegram-FOSS by Telegram-FOSS-Team.

the class PassportActivity method addDocumentViewInternal.

private void addDocumentViewInternal(TLRPC.TL_secureFile f, int uploadingType) {
    SecureDocumentKey secureDocumentKey = getSecureDocumentKey(f.secret, f.file_hash);
    SecureDocument secureDocument = new SecureDocument(secureDocumentKey, f, null, null, null);
    addDocumentView(secureDocument, uploadingType);
}
Also used : SecureDocumentKey(org.telegram.messenger.SecureDocumentKey) SecureDocument(org.telegram.messenger.SecureDocument)

Example 2 with SecureDocument

use of org.telegram.messenger.SecureDocument in project Telegram-FOSS by Telegram-FOSS-Team.

the class PassportActivity method checkFieldsForError.

private boolean checkFieldsForError() {
    if (currentDocumentsType != null) {
        if (errorsValues.containsKey("error_all") || errorsValues.containsKey("error_document_all")) {
            onFieldError(topErrorCell);
            return true;
        }
        if (uploadDocumentCell != null) {
            if (documents.isEmpty()) {
                onFieldError(uploadDocumentCell);
                return true;
            } else {
                for (int a = 0, size = documents.size(); a < size; a++) {
                    SecureDocument document = documents.get(a);
                    String key = "files" + getDocumentHash(document);
                    if (key != null && errorsValues.containsKey(key)) {
                        onFieldError(documentsCells.get(document));
                        return true;
                    }
                }
            }
        }
        if (errorsValues.containsKey("files_all") || errorsValues.containsKey("translation_all")) {
            onFieldError(bottomCell);
            return true;
        }
        if (uploadFrontCell != null) {
            if (frontDocument == null) {
                onFieldError(uploadFrontCell);
                return true;
            } else {
                String key = "front" + getDocumentHash(frontDocument);
                if (errorsValues.containsKey(key)) {
                    onFieldError(documentsCells.get(frontDocument));
                    return true;
                }
            }
        }
        if (currentDocumentsType.type instanceof TLRPC.TL_secureValueTypeIdentityCard || currentDocumentsType.type instanceof TLRPC.TL_secureValueTypeDriverLicense) {
            if (uploadReverseCell != null) {
                if (reverseDocument == null) {
                    onFieldError(uploadReverseCell);
                    return true;
                } else {
                    String key = "reverse" + getDocumentHash(reverseDocument);
                    if (errorsValues.containsKey(key)) {
                        onFieldError(documentsCells.get(reverseDocument));
                        return true;
                    }
                }
            }
        }
        if (uploadSelfieCell != null && currentBotId != 0) {
            if (selfieDocument == null) {
                onFieldError(uploadSelfieCell);
                return true;
            } else {
                String key = "selfie" + getDocumentHash(selfieDocument);
                if (errorsValues.containsKey(key)) {
                    onFieldError(documentsCells.get(selfieDocument));
                    return true;
                }
            }
        }
        if (uploadTranslationCell != null && currentBotId != 0) {
            if (translationDocuments.isEmpty()) {
                onFieldError(uploadTranslationCell);
                return true;
            } else {
                for (int a = 0, size = translationDocuments.size(); a < size; a++) {
                    SecureDocument document = translationDocuments.get(a);
                    String key = "translation" + getDocumentHash(document);
                    if (errorsValues.containsKey(key)) {
                        onFieldError(documentsCells.get(document));
                        return true;
                    }
                }
            }
        }
    }
    for (int i = 0; i < 2; i++) {
        EditTextBoldCursor[] fields;
        if (i == 0) {
            fields = inputFields;
        } else {
            fields = nativeInfoCell != null && nativeInfoCell.getVisibility() == View.VISIBLE ? inputExtraFields : null;
        }
        if (fields == null) {
            continue;
        }
        for (int a = 0; a < fields.length; a++) {
            boolean error = false;
            if (fields[a].hasErrorText()) {
                error = true;
            }
            if (!errorsValues.isEmpty()) {
                String key;
                if (currentType.type instanceof TLRPC.TL_secureValueTypePersonalDetails) {
                    if (i == 0) {
                        switch(a) {
                            case FIELD_NAME:
                                key = "first_name";
                                break;
                            case FIELD_MIDNAME:
                                key = "middle_name";
                                break;
                            case FIELD_SURNAME:
                                key = "last_name";
                                break;
                            case FIELD_BIRTHDAY:
                                key = "birth_date";
                                break;
                            case FIELD_GENDER:
                                key = "gender";
                                break;
                            case FIELD_CITIZENSHIP:
                                key = "country_code";
                                break;
                            case FIELD_RESIDENCE:
                                key = "residence_country_code";
                                break;
                            case FIELD_CARDNUMBER:
                                key = "document_no";
                                break;
                            case FIELD_EXPIRE:
                                key = "expiry_date";
                                break;
                            default:
                                key = null;
                                break;
                        }
                    } else {
                        switch(a) {
                            case FIELD_NATIVE_NAME:
                                key = "first_name_native";
                                break;
                            case FIELD_NATIVE_MIDNAME:
                                key = "middle_name_native";
                                break;
                            case FIELD_NATIVE_SURNAME:
                                key = "last_name_native";
                                break;
                            default:
                                key = null;
                                break;
                        }
                    }
                } else if (currentType.type instanceof TLRPC.TL_secureValueTypeAddress) {
                    switch(a) {
                        case FIELD_STREET1:
                            key = "street_line1";
                            break;
                        case FIELD_STREET2:
                            key = "street_line2";
                            break;
                        case FIELD_CITY:
                            key = "city";
                            break;
                        case FIELD_STATE:
                            key = "state";
                            break;
                        case FIELD_COUNTRY:
                            key = "country_code";
                            break;
                        case FIELD_POSTCODE:
                            key = "post_code";
                            break;
                        default:
                            key = null;
                            break;
                    }
                } else {
                    key = null;
                }
                if (key != null) {
                    String value = errorsValues.get(key);
                    if (!TextUtils.isEmpty(value)) {
                        if (value.equals(fields[a].getText().toString())) {
                            error = true;
                        }
                    }
                }
            }
            if (documentOnly) {
                if (currentDocumentsType != null && a < FIELD_CARDNUMBER) {
                    continue;
                }
            }
            if (!error) {
                int len = fields[a].length();
                boolean allowZeroLength = false;
                if (currentActivityType == TYPE_IDENTITY) {
                    if (a == FIELD_EXPIRE) {
                        continue;
                    } else if (i == 0 && (a == FIELD_NAME || a == FIELD_SURNAME || a == FIELD_MIDNAME) || i == 1 && (a == FIELD_NATIVE_NAME || a == FIELD_NATIVE_MIDNAME || a == FIELD_NATIVE_SURNAME)) {
                        if (len > 255) {
                            error = true;
                        }
                        if (i == 0 && a == FIELD_MIDNAME || i == 1 && a == FIELD_NATIVE_MIDNAME) {
                            allowZeroLength = true;
                        }
                    } else if (a == FIELD_CARDNUMBER) {
                        if (len > 24) {
                            error = true;
                        }
                    }
                } else if (currentActivityType == TYPE_ADDRESS) {
                    if (a == FIELD_STREET2) {
                        continue;
                    } else if (a == FIELD_CITY) {
                        if (len < 2) {
                            error = true;
                        }
                    } else if (a == FIELD_STATE) {
                        if ("US".equals(currentCitizeship)) {
                            if (len < 2) {
                                error = true;
                            }
                        } else {
                            continue;
                        }
                    } else if (a == FIELD_POSTCODE) {
                        if (len < 2 || len > 10) {
                            error = true;
                        }
                    }
                }
                if (!error && !allowZeroLength && len == 0) {
                    error = true;
                }
            }
            if (error) {
                onFieldError(fields[a]);
                return true;
            }
        }
    }
    return false;
}
Also used : EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) TLRPC(org.telegram.tgnet.TLRPC) SecureDocument(org.telegram.messenger.SecureDocument)

Example 3 with SecureDocument

use of org.telegram.messenger.SecureDocument in project Telegram-FOSS by Telegram-FOSS-Team.

the class PhotoViewer method checkProgress.

private void checkProgress(int a, boolean scroll, boolean animated) {
    int index = currentIndex;
    if (a == 1) {
        index += 1;
    } else if (a == 2) {
        index -= 1;
    }
    if (currentFileNames[a] != null) {
        File f1 = null;
        File f2 = null;
        boolean isVideo = false;
        boolean canStream = false;
        boolean canAutoPlay = false;
        MessageObject messageObject = null;
        if (currentMessageObject != null) {
            if (index < 0 || index >= imagesArr.size()) {
                photoProgressViews[a].setBackgroundState(PROGRESS_NONE, animated, true);
                return;
            }
            messageObject = imagesArr.get(index);
            canAutoPlay = shouldMessageObjectAutoPlayed(messageObject);
            if (sharedMediaType == MediaDataController.MEDIA_FILE && !messageObject.canPreviewDocument()) {
                photoProgressViews[a].setBackgroundState(PROGRESS_NONE, animated, true);
                return;
            }
            if (!TextUtils.isEmpty(messageObject.messageOwner.attachPath)) {
                f1 = new File(messageObject.messageOwner.attachPath);
            }
            if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageObject.messageOwner.media.webpage != null && messageObject.messageOwner.media.webpage.document == null) {
                TLObject fileLocation = getFileLocation(index, null);
                f2 = FileLoader.getPathToAttach(fileLocation, true);
            } else {
                f2 = FileLoader.getPathToMessage(messageObject.messageOwner);
            }
            if (messageObject.isVideo()) {
                canStream = SharedConfig.streamMedia && messageObject.canStreamVideo() && !DialogObject.isEncryptedDialog(messageObject.getDialogId());
                isVideo = true;
            }
        } else if (currentBotInlineResult != null) {
            if (index < 0 || index >= imagesArrLocals.size()) {
                photoProgressViews[a].setBackgroundState(PROGRESS_NONE, animated, true);
                return;
            }
            TLRPC.BotInlineResult botInlineResult = (TLRPC.BotInlineResult) imagesArrLocals.get(index);
            if (botInlineResult.type.equals("video") || MessageObject.isVideoDocument(botInlineResult.document)) {
                if (botInlineResult.document != null) {
                    f1 = FileLoader.getPathToAttach(botInlineResult.document);
                } else if (botInlineResult.content instanceof TLRPC.TL_webDocument) {
                    f1 = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.MD5(botInlineResult.content.url) + "." + ImageLoader.getHttpUrlExtension(botInlineResult.content.url, "mp4"));
                }
                isVideo = true;
            } else if (botInlineResult.document != null) {
                f1 = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_DOCUMENT), currentFileNames[a]);
            } else if (botInlineResult.photo != null) {
                f1 = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_IMAGE), currentFileNames[a]);
            }
            f2 = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), currentFileNames[a]);
        } else if (currentFileLocation != null) {
            if (index < 0 || index >= imagesArrLocationsVideo.size()) {
                photoProgressViews[a].setBackgroundState(PROGRESS_NONE, animated, true);
                return;
            }
            ImageLocation location = imagesArrLocationsVideo.get(index);
            f1 = FileLoader.getPathToAttach(location.location, getFileLocationExt(location), avatarsDialogId != 0 || isEvent);
        } else if (currentSecureDocument != null) {
            if (index < 0 || index >= secureDocuments.size()) {
                photoProgressViews[a].setBackgroundState(PROGRESS_NONE, animated, true);
                return;
            }
            SecureDocument location = secureDocuments.get(index);
            f1 = FileLoader.getPathToAttach(location, true);
        } else if (currentPathObject != null) {
            f1 = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_DOCUMENT), currentFileNames[a]);
            f2 = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), currentFileNames[a]);
        } else if (pageBlocksAdapter != null) {
            f1 = pageBlocksAdapter.getFile(index);
            isVideo = pageBlocksAdapter.isVideo(index);
            canAutoPlay = shouldIndexAutoPlayed(index);
        }
        File f1Final = f1;
        File f2Final = f2;
        MessageObject messageObjectFinal = messageObject;
        boolean canStreamFinal = canStream;
        boolean canAutoPlayFinal = !(a == 0 && dontAutoPlay) && canAutoPlay;
        boolean isVideoFinal = isVideo;
        Utilities.globalQueue.postRunnable(() -> {
            boolean exists = false;
            if (f1Final != null) {
                exists = f1Final.exists();
            }
            if (!exists && f2Final != null) {
                exists = f2Final.exists();
            }
            if (!exists && a != 0 && messageObjectFinal != null && canStreamFinal) {
                if (DownloadController.getInstance(currentAccount).canDownloadMedia(messageObjectFinal.messageOwner) != 0) {
                    if ((parentChatActivity == null || parentChatActivity.getCurrentEncryptedChat() == null) && !messageObjectFinal.shouldEncryptPhotoOrVideo()) {
                        final TLRPC.Document document = messageObjectFinal.getDocument();
                        if (document != null) {
                            FileLoader.getInstance(currentAccount).loadFile(document, messageObjectFinal, 0, 10);
                        }
                    }
                }
            }
            boolean existsFinal = exists;
            AndroidUtilities.runOnUIThread(() -> {
                if (shownControlsByEnd && !actionBarWasShownBeforeByEnd && isPlaying) {
                    photoProgressViews[a].setBackgroundState(PROGRESS_PLAY, false, false);
                    return;
                }
                if ((f1Final != null || f2Final != null) && (existsFinal || canStreamFinal)) {
                    if (a != 0 || !isPlaying) {
                        if (isVideoFinal && (!canAutoPlayFinal || a == 0 && playerWasPlaying)) {
                            photoProgressViews[a].setBackgroundState(PROGRESS_PLAY, animated, true);
                        } else {
                            photoProgressViews[a].setBackgroundState(PROGRESS_NONE, animated, true);
                        }
                    }
                    if (a == 0) {
                        if (!existsFinal) {
                            if (!FileLoader.getInstance(currentAccount).isLoadingFile(currentFileNames[a])) {
                                menuItem.hideSubItem(gallery_menu_cancel_loading);
                            } else {
                                menuItem.showSubItem(gallery_menu_cancel_loading);
                            }
                        } else {
                            menuItem.hideSubItem(gallery_menu_cancel_loading);
                        }
                    }
                } else {
                    if (isVideoFinal) {
                        if (!FileLoader.getInstance(currentAccount).isLoadingFile(currentFileNames[a])) {
                            photoProgressViews[a].setBackgroundState(PROGRESS_LOAD, false, true);
                        } else {
                            photoProgressViews[a].setBackgroundState(PROGRESS_CANCEL, false, true);
                        }
                    } else {
                        photoProgressViews[a].setBackgroundState(PROGRESS_EMPTY, animated, true);
                    }
                    Float progress = ImageLoader.getInstance().getFileProgress(currentFileNames[a]);
                    if (progress == null) {
                        progress = 0.0f;
                    }
                    photoProgressViews[a].setProgress(progress, false);
                }
                if (a == 0) {
                    canZoom = !isEmbedVideo && (!imagesArrLocals.isEmpty() || (currentFileNames[0] != null && photoProgressViews[0].backgroundState != 0));
                }
            });
        });
    } else {
        boolean isLocalVideo = false;
        if (!imagesArrLocals.isEmpty() && index >= 0 && index < imagesArrLocals.size()) {
            Object object = imagesArrLocals.get(index);
            if (object instanceof MediaController.PhotoEntry) {
                MediaController.PhotoEntry photoEntry = ((MediaController.PhotoEntry) object);
                isLocalVideo = photoEntry.isVideo;
            }
        }
        if (isLocalVideo) {
            photoProgressViews[a].setBackgroundState(PROGRESS_PLAY, animated, true);
        } else {
            photoProgressViews[a].setBackgroundState(PROGRESS_NONE, animated, true);
        }
    }
}
Also used : MediaController(org.telegram.messenger.MediaController) Paint(android.graphics.Paint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint) TLRPC(org.telegram.tgnet.TLRPC) ImageLocation(org.telegram.messenger.ImageLocation) SecureDocument(org.telegram.messenger.SecureDocument) TLObject(org.telegram.tgnet.TLObject) UserObject(org.telegram.messenger.UserObject) TLObject(org.telegram.tgnet.TLObject) MessageObject(org.telegram.messenger.MessageObject) DialogObject(org.telegram.messenger.DialogObject) ChatObject(org.telegram.messenger.ChatObject) WebFile(org.telegram.messenger.WebFile) File(java.io.File) MessageObject(org.telegram.messenger.MessageObject)

Example 4 with SecureDocument

use of org.telegram.messenger.SecureDocument in project Telegram-FOSS by Telegram-FOSS-Team.

the class PhotoViewer method setIndexToImage.

private void setIndexToImage(ImageReceiver imageReceiver, int index) {
    imageReceiver.setOrientation(0, false);
    if (!secureDocuments.isEmpty()) {
        if (index >= 0 && index < secureDocuments.size()) {
            Object object = secureDocuments.get(index);
            int size = (int) (AndroidUtilities.getPhotoSize() / AndroidUtilities.density);
            ImageReceiver.BitmapHolder placeHolder = null;
            if (currentThumb != null && imageReceiver == centerImage) {
                placeHolder = currentThumb;
            }
            if (placeHolder == null) {
                placeHolder = placeProvider.getThumbForPhoto(null, null, index);
            }
            SecureDocument document = secureDocuments.get(index);
            int imageSize = document.secureFile.size;
            imageReceiver.setImage(ImageLocation.getForSecureDocument(document), "d", null, null, placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, imageSize, null, null, 0);
        }
    } else if (!imagesArrLocals.isEmpty()) {
        if (index >= 0 && index < imagesArrLocals.size()) {
            Object object = imagesArrLocals.get(index);
            int size = (int) (AndroidUtilities.getPhotoSize() / AndroidUtilities.density);
            ImageReceiver.BitmapHolder placeHolder = null;
            if (currentThumb != null && imageReceiver == centerImage) {
                placeHolder = currentThumb;
            }
            if (placeHolder == null) {
                placeHolder = placeProvider.getThumbForPhoto(null, null, index);
            }
            String path = null;
            TLRPC.Document document = null;
            WebFile webDocument = null;
            ImageLocation videoThumb = null;
            TLRPC.PhotoSize photo = null;
            TLObject photoObject = null;
            int imageSize = 0;
            String filter = null;
            boolean isVideo = false;
            int cacheType = 0;
            if (object instanceof MediaController.PhotoEntry) {
                MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) object;
                isVideo = photoEntry.isVideo;
                if (photoEntry.isVideo) {
                    if (photoEntry.thumbPath != null) {
                        if (fromCamera) {
                            Bitmap b = BitmapFactory.decodeFile(photoEntry.thumbPath);
                            if (b != null) {
                                placeHolder = new ImageReceiver.BitmapHolder(b);
                                photoEntry.thumbPath = null;
                            }
                        } else {
                            path = photoEntry.thumbPath;
                        }
                    } else {
                        path = "vthumb://" + photoEntry.imageId + ":" + photoEntry.path;
                    }
                } else {
                    if (photoEntry.filterPath != null) {
                        path = photoEntry.filterPath;
                    } else {
                        imageReceiver.setOrientation(photoEntry.orientation, false);
                        path = photoEntry.path;
                    }
                    filter = String.format(Locale.US, "%d_%d", size, size);
                }
            } else if (object instanceof TLRPC.BotInlineResult) {
                cacheType = 1;
                TLRPC.BotInlineResult botInlineResult = ((TLRPC.BotInlineResult) object);
                if (botInlineResult.type.equals("video") || MessageObject.isVideoDocument(botInlineResult.document)) {
                    if (botInlineResult.document != null) {
                        photo = FileLoader.getClosestPhotoSizeWithSize(botInlineResult.document.thumbs, 90);
                        photoObject = botInlineResult.document;
                    } else if (botInlineResult.thumb instanceof TLRPC.TL_webDocument) {
                        webDocument = WebFile.createWithWebDocument(botInlineResult.thumb);
                    }
                } else if (botInlineResult.type.equals("gif") && botInlineResult.document != null) {
                    document = botInlineResult.document;
                    imageSize = botInlineResult.document.size;
                    TLRPC.VideoSize videoSize = MessageObject.getDocumentVideoThumb(botInlineResult.document);
                    if (videoSize != null) {
                        videoThumb = ImageLocation.getForDocument(videoSize, document);
                    }
                    filter = "d";
                } else if (botInlineResult.photo != null) {
                    TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(botInlineResult.photo.sizes, AndroidUtilities.getPhotoSize());
                    photo = sizeFull;
                    photoObject = botInlineResult.photo;
                    imageSize = sizeFull.size;
                    filter = String.format(Locale.US, "%d_%d", size, size);
                } else if (botInlineResult.content instanceof TLRPC.TL_webDocument) {
                    if (botInlineResult.type.equals("gif")) {
                        filter = "d";
                        if (botInlineResult.thumb instanceof TLRPC.TL_webDocument && "video/mp4".equals(botInlineResult.thumb.mime_type)) {
                            videoThumb = ImageLocation.getForWebFile(WebFile.createWithWebDocument(botInlineResult.thumb));
                        }
                    } else {
                        filter = String.format(Locale.US, "%d_%d", size, size);
                    }
                    webDocument = WebFile.createWithWebDocument(botInlineResult.content);
                }
            } else if (object instanceof MediaController.SearchImage) {
                cacheType = 1;
                MediaController.SearchImage photoEntry = (MediaController.SearchImage) object;
                if (photoEntry.photoSize != null) {
                    photo = photoEntry.photoSize;
                    photoObject = photoEntry.photo;
                    imageSize = photoEntry.photoSize.size;
                } else if (photoEntry.filterPath != null) {
                    path = photoEntry.filterPath;
                } else if (photoEntry.document != null) {
                    document = photoEntry.document;
                    imageSize = photoEntry.document.size;
                } else {
                    path = photoEntry.imageUrl;
                    imageSize = photoEntry.size;
                }
                filter = "d";
            }
            if (document != null) {
                TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90);
                if (videoThumb != null) {
                    imageReceiver.setImage(ImageLocation.getForDocument(document), "d", videoThumb, null, placeHolder == null ? ImageLocation.getForDocument(thumb, document) : null, String.format(Locale.US, "%d_%d", size, size), placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, imageSize, null, object, cacheType);
                } else {
                    imageReceiver.setImage(ImageLocation.getForDocument(document), "d", placeHolder == null ? ImageLocation.getForDocument(thumb, document) : null, String.format(Locale.US, "%d_%d", size, size), placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, imageSize, null, object, cacheType);
                }
            } else if (photo != null) {
                imageReceiver.setImage(ImageLocation.getForObject(photo, photoObject), filter, placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, imageSize, null, object, cacheType);
            } else if (webDocument != null) {
                if (videoThumb != null) {
                    imageReceiver.setImage(ImageLocation.getForWebFile(webDocument), filter, videoThumb, null, (Drawable) null, object, cacheType);
                } else {
                    imageReceiver.setImage(ImageLocation.getForWebFile(webDocument), filter, placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : (isVideo && parentActivity != null ? parentActivity.getResources().getDrawable(R.drawable.nophotos) : null), null, object, cacheType);
                }
            } else {
                imageReceiver.setImage(path, filter, placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : (isVideo && parentActivity != null ? parentActivity.getResources().getDrawable(R.drawable.nophotos) : null), null, imageSize);
            }
        } else {
            imageReceiver.setImageBitmap((Bitmap) null);
        }
    } else if (pageBlocksAdapter != null) {
        int[] size = new int[1];
        TLObject media = pageBlocksAdapter.getMedia(index);
        TLRPC.PhotoSize fileLocation = pageBlocksAdapter.getFileLocation(media, size);
        if (fileLocation != null) {
            if (media instanceof TLRPC.Photo) {
                TLRPC.Photo photo = (TLRPC.Photo) media;
                ImageReceiver.BitmapHolder placeHolder = null;
                if (currentThumb != null && imageReceiver == centerImage) {
                    placeHolder = currentThumb;
                }
                if (size[0] == 0) {
                    size[0] = -1;
                }
                TLRPC.PhotoSize thumbLocation = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 80);
                imageReceiver.setImage(ImageLocation.getForPhoto(fileLocation, photo), null, ImageLocation.getForPhoto(thumbLocation, photo), "b", placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, size[0], null, pageBlocksAdapter.getParentObject(), 1);
            } else if (pageBlocksAdapter.isVideo(index)) {
                if (!(fileLocation.location instanceof TLRPC.TL_fileLocationUnavailable)) {
                    ImageReceiver.BitmapHolder placeHolder = null;
                    if (currentThumb != null && imageReceiver == centerImage) {
                        placeHolder = currentThumb;
                    }
                    imageReceiver.setImage(null, null, placeHolder == null ? ImageLocation.getForDocument(fileLocation, (TLRPC.Document) media) : null, "b", placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, 0, null, pageBlocksAdapter.getParentObject(), 1);
                } else {
                    imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
                }
            } else if (currentAnimation != null) {
                imageReceiver.setImageBitmap(currentAnimation);
                currentAnimation.addSecondParentView(containerView);
            }
        } else {
            if (size[0] == 0) {
                imageReceiver.setImageBitmap((Bitmap) null);
            } else {
                imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
            }
        }
    } else {
        MessageObject messageObject;
        if (!imagesArr.isEmpty() && index >= 0 && index < imagesArr.size()) {
            messageObject = imagesArr.get(index);
            imageReceiver.setShouldGenerateQualityThumb(true);
        } else {
            messageObject = null;
        }
        if (messageObject != null) {
            String restrictionReason = MessagesController.getRestrictionReason(messageObject.messageOwner.restriction_reason);
            if (!TextUtils.isEmpty(restrictionReason)) {
                imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
                return;
            } else if (messageObject.isVideo()) {
                if (messageObject.photoThumbs != null && !messageObject.photoThumbs.isEmpty()) {
                    ImageReceiver.BitmapHolder placeHolder = null;
                    if (currentThumb != null && imageReceiver == centerImage) {
                        placeHolder = currentThumb;
                    }
                    TLRPC.PhotoSize thumbLocation = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 320);
                    imageReceiver.setNeedsQualityThumb(thumbLocation.w < 100 && thumbLocation.h < 100);
                    imageReceiver.setImage(null, null, placeHolder == null ? ImageLocation.getForObject(thumbLocation, messageObject.photoThumbsObject) : null, "b", placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, 0, null, messageObject, 1);
                    if (currentThumb != null) {
                        imageReceiver.setOrientation(currentThumb.orientation, false);
                    }
                } else {
                    imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
                }
                return;
            } else if (currentAnimation != null) {
                currentAnimation.addSecondParentView(containerView);
                imageReceiver.setImageBitmap(currentAnimation);
                return;
            } else if (sharedMediaType == MediaDataController.MEDIA_FILE) {
                if (messageObject.canPreviewDocument()) {
                    TLRPC.Document document = messageObject.getDocument();
                    imageReceiver.setNeedsQualityThumb(true);
                    ImageReceiver.BitmapHolder placeHolder = null;
                    if (currentThumb != null && imageReceiver == centerImage) {
                        placeHolder = currentThumb;
                    }
                    TLRPC.PhotoSize thumbLocation = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 100);
                    int size = (int) (2048 / AndroidUtilities.density);
                    imageReceiver.setImage(ImageLocation.getForDocument(document), String.format(Locale.US, "%d_%d", size, size), placeHolder == null ? ImageLocation.getForDocument(thumbLocation, document) : null, "b", placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, document.size, null, messageObject, 0);
                } else {
                    OtherDocumentPlaceholderDrawable drawable = new OtherDocumentPlaceholderDrawable(parentActivity, containerView, messageObject);
                    imageReceiver.setImageBitmap(drawable);
                }
                return;
            }
        }
        int[] size = new int[1];
        ImageLocation imageLocation = getImageLocation(index, size);
        TLObject fileLocation = getFileLocation(index, size);
        imageReceiver.setNeedsQualityThumb(true);
        if (imageLocation != null) {
            ImageReceiver.BitmapHolder placeHolder = null;
            if (currentThumb != null && imageReceiver == centerImage) {
                placeHolder = currentThumb;
            }
            if (size[0] == 0) {
                size[0] = -1;
            }
            TLRPC.PhotoSize thumbLocation;
            TLObject photoObject;
            if (messageObject != null) {
                thumbLocation = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 100);
                photoObject = messageObject.photoThumbsObject;
            } else {
                thumbLocation = null;
                photoObject = null;
            }
            if (thumbLocation != null && thumbLocation == fileLocation) {
                thumbLocation = null;
            }
            boolean cacheOnly = messageObject != null && messageObject.isWebpage() || avatarsDialogId != 0 || isEvent;
            Object parentObject;
            ImageLocation videoThumb = null;
            if (messageObject != null) {
                parentObject = messageObject;
                if (sharedMediaType == MediaDataController.MEDIA_GIF) {
                    TLRPC.Document document = messageObject.getDocument();
                    TLRPC.VideoSize videoSize = MessageObject.getDocumentVideoThumb(document);
                    if (videoSize != null) {
                        videoThumb = ImageLocation.getForDocument(videoSize, document);
                    }
                }
            } else if (avatarsDialogId != 0) {
                if (avatarsDialogId > 0) {
                    parentObject = MessagesController.getInstance(currentAccount).getUser(avatarsDialogId);
                } else {
                    parentObject = MessagesController.getInstance(currentAccount).getChat(-avatarsDialogId);
                }
            } else {
                parentObject = null;
            }
            if (videoThumb != null) {
                imageReceiver.setImage(imageLocation, null, videoThumb, null, placeHolder == null ? ImageLocation.getForObject(thumbLocation, photoObject) : null, "b", placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, size[0], null, parentObject, cacheOnly ? 1 : 0);
            } else {
                String filter;
                if (avatarsDialogId != 0) {
                    filter = imageLocation.imageType == FileLoader.IMAGE_TYPE_ANIMATION ? ImageLoader.AUTOPLAY_FILTER : null;
                } else {
                    filter = null;
                }
                imageReceiver.setImage(imageLocation, filter, placeHolder == null ? ImageLocation.getForObject(thumbLocation, photoObject) : null, "b", placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, size[0], null, parentObject, cacheOnly ? 1 : 0);
            }
        } else {
            if (size[0] == 0) {
                imageReceiver.setImageBitmap((Bitmap) null);
            } else {
                imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
            }
        }
    }
}
Also used : MediaController(org.telegram.messenger.MediaController) SizeNotifierFrameLayoutPhoto(org.telegram.ui.Components.SizeNotifierFrameLayoutPhoto) SpannableString(android.text.SpannableString) SecureDocument(org.telegram.messenger.SecureDocument) WebFile(org.telegram.messenger.WebFile) ImageLocation(org.telegram.messenger.ImageLocation) TLRPC(org.telegram.tgnet.TLRPC) ImageReceiver(org.telegram.messenger.ImageReceiver) Bitmap(android.graphics.Bitmap) OtherDocumentPlaceholderDrawable(org.telegram.ui.Components.OtherDocumentPlaceholderDrawable) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) VideoForwardDrawable(org.telegram.ui.Components.VideoForwardDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) OtherDocumentPlaceholderDrawable(org.telegram.ui.Components.OtherDocumentPlaceholderDrawable) PlayPauseDrawable(org.telegram.ui.Components.PlayPauseDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Paint(android.graphics.Paint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint) SecureDocument(org.telegram.messenger.SecureDocument) TLObject(org.telegram.tgnet.TLObject) UserObject(org.telegram.messenger.UserObject) TLObject(org.telegram.tgnet.TLObject) MessageObject(org.telegram.messenger.MessageObject) DialogObject(org.telegram.messenger.DialogObject) ChatObject(org.telegram.messenger.ChatObject) MessageObject(org.telegram.messenger.MessageObject)

Example 5 with SecureDocument

use of org.telegram.messenger.SecureDocument in project Telegram-FOSS by Telegram-FOSS-Team.

the class PassportActivity method openTypeActivity.

private void openTypeActivity(TLRPC.TL_secureRequiredType requiredType, TLRPC.TL_secureRequiredType documentRequiredType, ArrayList<TLRPC.TL_secureRequiredType> availableDocumentTypes, boolean documentOnly) {
    int activityType = -1;
    final int availableDocumentTypesCount = availableDocumentTypes != null ? availableDocumentTypes.size() : 0;
    TLRPC.SecureValueType type = requiredType.type;
    TLRPC.SecureValueType documentType = documentRequiredType != null ? documentRequiredType.type : null;
    if (type instanceof TLRPC.TL_secureValueTypePersonalDetails) {
        activityType = TYPE_IDENTITY;
    } else if (type instanceof TLRPC.TL_secureValueTypeAddress) {
        activityType = TYPE_ADDRESS;
    } else if (type instanceof TLRPC.TL_secureValueTypePhone) {
        activityType = TYPE_PHONE;
    } else if (type instanceof TLRPC.TL_secureValueTypeEmail) {
        activityType = TYPE_EMAIL;
    }
    if (activityType != -1) {
        HashMap<String, String> errors = !documentOnly ? errorsMap.get(getNameForType(type)) : null;
        HashMap<String, String> documentsErrors = errorsMap.get(getNameForType(documentType));
        TLRPC.TL_secureValue value = getValueByType(requiredType, false);
        TLRPC.TL_secureValue documentsValue = getValueByType(documentRequiredType, false);
        final PassportActivity activity = new PassportActivity(activityType, currentForm, currentPassword, requiredType, value, documentRequiredType, documentsValue, typesValues.get(requiredType), documentRequiredType != null ? typesValues.get(documentRequiredType) : null);
        activity.delegate = new PassportActivityDelegate() {

            private TLRPC.InputSecureFile getInputSecureFile(SecureDocument document) {
                if (document.inputFile != null) {
                    TLRPC.TL_inputSecureFileUploaded inputSecureFileUploaded = new TLRPC.TL_inputSecureFileUploaded();
                    inputSecureFileUploaded.id = document.inputFile.id;
                    inputSecureFileUploaded.parts = document.inputFile.parts;
                    inputSecureFileUploaded.md5_checksum = document.inputFile.md5_checksum;
                    inputSecureFileUploaded.file_hash = document.fileHash;
                    inputSecureFileUploaded.secret = document.fileSecret;
                    return inputSecureFileUploaded;
                } else {
                    TLRPC.TL_inputSecureFile inputSecureFile = new TLRPC.TL_inputSecureFile();
                    inputSecureFile.id = document.secureFile.id;
                    inputSecureFile.access_hash = document.secureFile.access_hash;
                    return inputSecureFile;
                }
            }

            private void renameFile(SecureDocument oldDocument, TLRPC.TL_secureFile newSecureFile) {
                File oldFile = FileLoader.getPathToAttach(oldDocument);
                String oldKey = oldDocument.secureFile.dc_id + "_" + oldDocument.secureFile.id;
                File newFile = FileLoader.getPathToAttach(newSecureFile);
                String newKey = newSecureFile.dc_id + "_" + newSecureFile.id;
                oldFile.renameTo(newFile);
                ImageLoader.getInstance().replaceImageInCache(oldKey, newKey, null, false);
            }

            @Override
            public void saveValue(final TLRPC.TL_secureRequiredType requiredType, final String text, final String json, final TLRPC.TL_secureRequiredType documentRequiredType, final String documentsJson, final ArrayList<SecureDocument> documents, final SecureDocument selfie, final ArrayList<SecureDocument> translationDocuments, final SecureDocument front, final SecureDocument reverse, final Runnable finishRunnable, final ErrorRunnable errorRunnable) {
                TLRPC.TL_inputSecureValue inputSecureValue = null;
                if (!TextUtils.isEmpty(json)) {
                    inputSecureValue = new TLRPC.TL_inputSecureValue();
                    inputSecureValue.type = requiredType.type;
                    inputSecureValue.flags |= 1;
                    EncryptionResult result = encryptData(AndroidUtilities.getStringBytes(json));
                    inputSecureValue.data = new TLRPC.TL_secureData();
                    inputSecureValue.data.data = result.encryptedData;
                    inputSecureValue.data.data_hash = result.fileHash;
                    inputSecureValue.data.secret = result.fileSecret;
                } else if (!TextUtils.isEmpty(text)) {
                    TLRPC.SecurePlainData plainData;
                    if (type instanceof TLRPC.TL_secureValueTypeEmail) {
                        TLRPC.TL_securePlainEmail securePlainEmail = new TLRPC.TL_securePlainEmail();
                        securePlainEmail.email = text;
                        plainData = securePlainEmail;
                    } else if (type instanceof TLRPC.TL_secureValueTypePhone) {
                        TLRPC.TL_securePlainPhone securePlainPhone = new TLRPC.TL_securePlainPhone();
                        securePlainPhone.phone = text;
                        plainData = securePlainPhone;
                    } else {
                        return;
                    }
                    inputSecureValue = new TLRPC.TL_inputSecureValue();
                    inputSecureValue.type = requiredType.type;
                    inputSecureValue.flags |= 32;
                    inputSecureValue.plain_data = plainData;
                }
                if (!documentOnly && inputSecureValue == null) {
                    if (errorRunnable != null) {
                        errorRunnable.onError(null, null);
                    }
                    return;
                }
                TLRPC.TL_inputSecureValue fileInputSecureValue;
                if (documentRequiredType != null) {
                    fileInputSecureValue = new TLRPC.TL_inputSecureValue();
                    fileInputSecureValue.type = documentRequiredType.type;
                    if (!TextUtils.isEmpty(documentsJson)) {
                        fileInputSecureValue.flags |= 1;
                        EncryptionResult result = encryptData(AndroidUtilities.getStringBytes(documentsJson));
                        fileInputSecureValue.data = new TLRPC.TL_secureData();
                        fileInputSecureValue.data.data = result.encryptedData;
                        fileInputSecureValue.data.data_hash = result.fileHash;
                        fileInputSecureValue.data.secret = result.fileSecret;
                    }
                    if (front != null) {
                        fileInputSecureValue.front_side = getInputSecureFile(front);
                        fileInputSecureValue.flags |= 2;
                    }
                    if (reverse != null) {
                        fileInputSecureValue.reverse_side = getInputSecureFile(reverse);
                        fileInputSecureValue.flags |= 4;
                    }
                    if (selfie != null) {
                        fileInputSecureValue.selfie = getInputSecureFile(selfie);
                        fileInputSecureValue.flags |= 8;
                    }
                    if (translationDocuments != null && !translationDocuments.isEmpty()) {
                        fileInputSecureValue.flags |= 64;
                        for (int a = 0, size = translationDocuments.size(); a < size; a++) {
                            fileInputSecureValue.translation.add(getInputSecureFile(translationDocuments.get(a)));
                        }
                    }
                    if (documents != null && !documents.isEmpty()) {
                        fileInputSecureValue.flags |= 16;
                        for (int a = 0, size = documents.size(); a < size; a++) {
                            fileInputSecureValue.files.add(getInputSecureFile(documents.get(a)));
                        }
                    }
                    if (documentOnly) {
                        inputSecureValue = fileInputSecureValue;
                        fileInputSecureValue = null;
                    }
                } else {
                    fileInputSecureValue = null;
                }
                final PassportActivityDelegate currentDelegate = this;
                final TLRPC.TL_inputSecureValue finalFileInputSecureValue = fileInputSecureValue;
                final TLRPC.TL_account_saveSecureValue req = new TLRPC.TL_account_saveSecureValue();
                req.value = inputSecureValue;
                req.secure_secret_id = secureSecretId;
                ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {

                    private void onResult(final TLRPC.TL_error error, final TLRPC.TL_secureValue newValue, final TLRPC.TL_secureValue newPendingValue) {
                        AndroidUtilities.runOnUIThread(() -> {
                            if (error != null) {
                                if (errorRunnable != null) {
                                    errorRunnable.onError(error.text, text);
                                }
                                AlertsCreator.processError(currentAccount, error, PassportActivity.this, req, text);
                            } else {
                                if (documentOnly) {
                                    if (documentRequiredType != null) {
                                        removeValue(documentRequiredType);
                                    } else {
                                        removeValue(requiredType);
                                    }
                                } else {
                                    removeValue(requiredType);
                                    removeValue(documentRequiredType);
                                }
                                if (newValue != null) {
                                    currentForm.values.add(newValue);
                                }
                                if (newPendingValue != null) {
                                    currentForm.values.add(newPendingValue);
                                }
                                if (documents != null && !documents.isEmpty()) {
                                    for (int a = 0, size = documents.size(); a < size; a++) {
                                        SecureDocument document = documents.get(a);
                                        if (document.inputFile != null) {
                                            for (int b = 0, size2 = newValue.files.size(); b < size2; b++) {
                                                TLRPC.SecureFile file = newValue.files.get(b);
                                                if (file instanceof TLRPC.TL_secureFile) {
                                                    TLRPC.TL_secureFile secureFile = (TLRPC.TL_secureFile) file;
                                                    if (Utilities.arraysEquals(document.fileSecret, 0, secureFile.secret, 0)) {
                                                        renameFile(document, secureFile);
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (selfie != null && selfie.inputFile != null && newValue.selfie instanceof TLRPC.TL_secureFile) {
                                    TLRPC.TL_secureFile secureFile = (TLRPC.TL_secureFile) newValue.selfie;
                                    if (Utilities.arraysEquals(selfie.fileSecret, 0, secureFile.secret, 0)) {
                                        renameFile(selfie, secureFile);
                                    }
                                }
                                if (front != null && front.inputFile != null && newValue.front_side instanceof TLRPC.TL_secureFile) {
                                    TLRPC.TL_secureFile secureFile = (TLRPC.TL_secureFile) newValue.front_side;
                                    if (Utilities.arraysEquals(front.fileSecret, 0, secureFile.secret, 0)) {
                                        renameFile(front, secureFile);
                                    }
                                }
                                if (reverse != null && reverse.inputFile != null && newValue.reverse_side instanceof TLRPC.TL_secureFile) {
                                    TLRPC.TL_secureFile secureFile = (TLRPC.TL_secureFile) newValue.reverse_side;
                                    if (Utilities.arraysEquals(reverse.fileSecret, 0, secureFile.secret, 0)) {
                                        renameFile(reverse, secureFile);
                                    }
                                }
                                if (translationDocuments != null && !translationDocuments.isEmpty()) {
                                    for (int a = 0, size = translationDocuments.size(); a < size; a++) {
                                        SecureDocument document = translationDocuments.get(a);
                                        if (document.inputFile != null) {
                                            for (int b = 0, size2 = newValue.translation.size(); b < size2; b++) {
                                                TLRPC.SecureFile file = newValue.translation.get(b);
                                                if (file instanceof TLRPC.TL_secureFile) {
                                                    TLRPC.TL_secureFile secureFile = (TLRPC.TL_secureFile) file;
                                                    if (Utilities.arraysEquals(document.fileSecret, 0, secureFile.secret, 0)) {
                                                        renameFile(document, secureFile);
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                setTypeValue(requiredType, text, json, documentRequiredType, documentsJson, documentOnly, availableDocumentTypesCount);
                                if (finishRunnable != null) {
                                    finishRunnable.run();
                                }
                            }
                        });
                    }

                    @Override
                    public void run(final TLObject response, final TLRPC.TL_error error) {
                        if (error != null) {
                            if (error.text.equals("EMAIL_VERIFICATION_NEEDED")) {
                                TLRPC.TL_account_sendVerifyEmailCode req = new TLRPC.TL_account_sendVerifyEmailCode();
                                req.email = text;
                                ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response1, error1) -> AndroidUtilities.runOnUIThread(() -> {
                                    if (response1 != null) {
                                        TLRPC.TL_account_sentEmailCode res = (TLRPC.TL_account_sentEmailCode) response1;
                                        HashMap<String, String> values = new HashMap<>();
                                        values.put("email", text);
                                        values.put("pattern", res.email_pattern);
                                        PassportActivity activity1 = new PassportActivity(TYPE_EMAIL_VERIFICATION, currentForm, currentPassword, requiredType, null, null, null, values, null);
                                        activity1.currentAccount = currentAccount;
                                        activity1.emailCodeLength = res.length;
                                        activity1.saltedPassword = saltedPassword;
                                        activity1.secureSecret = secureSecret;
                                        activity1.delegate = currentDelegate;
                                        presentFragment(activity1, true);
                                    } else {
                                        showAlertWithText(LocaleController.getString("PassportEmail", R.string.PassportEmail), error1.text);
                                        if (errorRunnable != null) {
                                            errorRunnable.onError(error1.text, text);
                                        }
                                    }
                                }));
                                return;
                            } else if (error.text.equals("PHONE_VERIFICATION_NEEDED")) {
                                AndroidUtilities.runOnUIThread(() -> errorRunnable.onError(error.text, text));
                                return;
                            }
                        }
                        if (error == null && finalFileInputSecureValue != null) {
                            final TLRPC.TL_secureValue pendingValue = (TLRPC.TL_secureValue) response;
                            final TLRPC.TL_account_saveSecureValue req = new TLRPC.TL_account_saveSecureValue();
                            req.value = finalFileInputSecureValue;
                            req.secure_secret_id = secureSecretId;
                            ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response12, error12) -> onResult(error12, (TLRPC.TL_secureValue) response12, pendingValue));
                        } else {
                            onResult(error, (TLRPC.TL_secureValue) response, null);
                        }
                    }
                });
            }

            @Override
            public SecureDocument saveFile(TLRPC.TL_secureFile secureFile) {
                String path = FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE) + "/" + secureFile.dc_id + "_" + secureFile.id + ".jpg";
                EncryptionResult result = createSecureDocument(path);
                return new SecureDocument(result.secureDocumentKey, secureFile, path, result.fileHash, result.fileSecret);
            }

            @Override
            public void deleteValue(TLRPC.TL_secureRequiredType requiredType, TLRPC.TL_secureRequiredType documentRequiredType, ArrayList<TLRPC.TL_secureRequiredType> documentRequiredTypes, boolean deleteType, Runnable finishRunnable, ErrorRunnable errorRunnable) {
                deleteValueInternal(requiredType, documentRequiredType, documentRequiredTypes, deleteType, finishRunnable, errorRunnable, documentOnly);
            }
        };
        activity.currentAccount = currentAccount;
        activity.saltedPassword = saltedPassword;
        activity.secureSecret = secureSecret;
        activity.currentBotId = currentBotId;
        activity.fieldsErrors = errors;
        activity.documentOnly = documentOnly;
        activity.documentsErrors = documentsErrors;
        activity.availableDocumentTypes = availableDocumentTypes;
        if (activityType == TYPE_EMAIL) {
            activity.currentEmail = currentEmail;
        }
        presentFragment(activity);
    }
}
Also used : HashMap(java.util.HashMap) TLRPC(org.telegram.tgnet.TLRPC) RequestDelegate(org.telegram.tgnet.RequestDelegate) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) SecureDocument(org.telegram.messenger.SecureDocument) TLObject(org.telegram.tgnet.TLObject)

Aggregations

SecureDocument (org.telegram.messenger.SecureDocument)9 TLRPC (org.telegram.tgnet.TLRPC)7 SuppressLint (android.annotation.SuppressLint)6 Paint (android.graphics.Paint)6 TextPaint (android.text.TextPaint)6 TLObject (org.telegram.tgnet.TLObject)3 Bitmap (android.graphics.Bitmap)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ChatObject (org.telegram.messenger.ChatObject)2 DialogObject (org.telegram.messenger.DialogObject)2 ImageLocation (org.telegram.messenger.ImageLocation)2 MediaController (org.telegram.messenger.MediaController)2 MessageObject (org.telegram.messenger.MessageObject)2 UserObject (org.telegram.messenger.UserObject)2 WebFile (org.telegram.messenger.WebFile)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1