Java Code Examples for org.telegram.messenger.MediaController#allMediaAlbumEntry()

The following examples show how to use org.telegram.messenger.MediaController#allMediaAlbumEntry() . 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: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private MediaController.PhotoEntry getPhotoEntryAtPosition(int position) {
    if (position < 0) {
        return null;
    }
    int cameraCount = cameraPhotos.size();
    if (position < cameraCount) {
        return (MediaController.PhotoEntry) cameraPhotos.get(position);
    }
    position -= cameraCount;
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (position < albumEntry.photos.size()) {
        return albumEntry.photos.get(position);
    }
    return null;
}
 
Example 2
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void init() {
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry != null) {
        for (int a = 0; a < Math.min(100, albumEntry.photos.size()); a++) {
            MediaController.PhotoEntry photoEntry = albumEntry.photos.get(a);
            photoEntry.reset();
        }
    }
    if (currentHintAnimation != null) {
        currentHintAnimation.cancel();
        currentHintAnimation = null;
    }
    hintTextView.setAlpha(0.0f);
    hintTextView.setVisibility(View.INVISIBLE);
    attachPhotoLayoutManager.scrollToPositionWithOffset(0, 1000000);
    cameraPhotoLayoutManager.scrollToPositionWithOffset(0, 1000000);
    clearSelectedPhotos();
    layoutManager.scrollToPositionWithOffset(0, 1000000);
    updatePhotosButton();
}
 
Example 3
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void onRevealAnimationEnd(boolean open) {
    NotificationCenter.getInstance(currentAccount).setAnimationInProgress(false);
    revealAnimationInProgress = false;
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (open && Build.VERSION.SDK_INT <= 19 && albumEntry == null) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
    if (open) {
        checkCamera(true);
        showHint();
    }
}
 
Example 4
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int getItemCount() {
    int count = 0;
    if (needCamera && deviceHasGoodCamera) {
        count++;
    }
    count += cameraPhotos.size();
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry != null) {
        count += albumEntry.photos.size();
    }
    return count;
}
 
Example 5
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private MediaController.PhotoEntry getPhotoEntryAtPosition(int position) {
    if (position < 0) {
        return null;
    }
    int cameraCount = cameraPhotos.size();
    if (position < cameraCount) {
        return (MediaController.PhotoEntry) cameraPhotos.get(position);
    }
    position -= cameraCount;
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (position < albumEntry.photos.size()) {
        return albumEntry.photos.get(position);
    }
    return null;
}
 
Example 6
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void init() {
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry != null) {
        for (int a = 0; a < Math.min(100, albumEntry.photos.size()); a++) {
            MediaController.PhotoEntry photoEntry = albumEntry.photos.get(a);
            photoEntry.reset();
        }
    }
    if (currentHintAnimation != null) {
        currentHintAnimation.cancel();
        currentHintAnimation = null;
    }
    hintTextView.setAlpha(0.0f);
    hintTextView.setVisibility(View.INVISIBLE);
    attachPhotoLayoutManager.scrollToPositionWithOffset(0, 1000000);
    cameraPhotoLayoutManager.scrollToPositionWithOffset(0, 1000000);
    clearSelectedPhotos();
    layoutManager.scrollToPositionWithOffset(0, 1000000);
    updatePhotosButton();
}
 
Example 7
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void onRevealAnimationEnd(boolean open) {
    NotificationCenter.getInstance(currentAccount).setAnimationInProgress(false);
    revealAnimationInProgress = false;
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (open && Build.VERSION.SDK_INT <= 19 && albumEntry == null) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
    if (open) {
        checkCamera(true);
        showHint();
    }
}
 
Example 8
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int getItemCount() {
    int count = 0;
    if (needCamera && deviceHasGoodCamera) {
        count++;
    }
    count += cameraPhotos.size();
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry != null) {
        count += albumEntry.photos.size();
    }
    return count;
}
 
Example 9
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void loadGalleryPhotos() {
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry == null && Build.VERSION.SDK_INT >= 21) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
}
 
Example 10
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void loadGalleryPhotos() {
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry == null && Build.VERSION.SDK_INT >= 21) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
}
 
Example 11
Source File: ChatAttachAlert.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onOpenAnimationEnd() {
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (Build.VERSION.SDK_INT <= 19 && albumEntry == null) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
    currentAttachLayout.onOpenAnimationEnd();
    AndroidUtilities.makeAccessibilityAnnouncement(LocaleController.getString("AccDescrAttachButton", R.string.AccDescrAttachButton));
}
 
Example 12
Source File: ChatAttachAlertPhotoLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void loadGalleryPhotos() {
    MediaController.AlbumEntry albumEntry;
    if (parentAlert.baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry == null && Build.VERSION.SDK_INT >= 21) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
}
 
Example 13
Source File: ChatAttachAlert.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onOpenAnimationEnd() {
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (Build.VERSION.SDK_INT <= 19 && albumEntry == null) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
    currentAttachLayout.onOpenAnimationEnd();
    AndroidUtilities.makeAccessibilityAnnouncement(LocaleController.getString("AccDescrAttachButton", R.string.AccDescrAttachButton));
}
 
Example 14
Source File: ChatAttachAlertPhotoLayout.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void loadGalleryPhotos() {
    MediaController.AlbumEntry albumEntry;
    if (parentAlert.baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry == null && Build.VERSION.SDK_INT >= 21) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
}
 
Example 15
Source File: ChatAttachAlertPhotoLayout.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
void onInit(boolean hasMedia) {
    mediaEnabled = hasMedia;
    if (cameraView != null) {
        cameraView.setAlpha(mediaEnabled ? 1.0f : 0.2f);
        cameraView.setEnabled(mediaEnabled);
    }
    if (cameraIcon != null) {
        cameraIcon.setAlpha(mediaEnabled ? 1.0f : 0.2f);
        cameraIcon.setEnabled(mediaEnabled);
    }
    if (parentAlert.baseFragment instanceof ChatActivity) {
        TLRPC.Chat chat = ((ChatActivity) parentAlert.baseFragment).getCurrentChat();
        galleryAlbumEntry = MediaController.allMediaAlbumEntry;
        if (mediaEnabled) {
            progressView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
        } else {
            if (ChatObject.isActionBannedByDefault(chat, ChatObject.ACTION_SEND_MEDIA)) {
                progressView.setText(LocaleController.getString("GlobalAttachMediaRestricted", R.string.GlobalAttachMediaRestricted));
            } else if (AndroidUtilities.isBannedForever(chat.banned_rights)) {
                progressView.setText(LocaleController.formatString("AttachMediaRestrictedForever", R.string.AttachMediaRestrictedForever));
            } else {
                progressView.setText(LocaleController.formatString("AttachMediaRestricted", R.string.AttachMediaRestricted, LocaleController.formatDateForBan(chat.banned_rights.until_date)));
            }
        }
    } else {
        galleryAlbumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (Build.VERSION.SDK_INT >= 23) {
        noGalleryPermissions = parentAlert.baseFragment.getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED;
    }
    if (galleryAlbumEntry != null) {
        for (int a = 0; a < Math.min(100, galleryAlbumEntry.photos.size()); a++) {
            MediaController.PhotoEntry photoEntry = galleryAlbumEntry.photos.get(a);
            photoEntry.reset();
        }
    }
    clearSelectedPhotos();
    updatePhotosCounter(false);
    cameraPhotoLayoutManager.scrollToPositionWithOffset(0, 1000000);
    layoutManager.scrollToPositionWithOffset(0, 1000000);

    dropDown.setText(LocaleController.getString("ChatGallery", R.string.ChatGallery));

    selectedAlbumEntry = galleryAlbumEntry;
    if (selectedAlbumEntry != null) {
        loading = false;
        if (progressView != null) {
            progressView.showTextView();
        }
    }
    updateAlbumsDropDown();
}
 
Example 16
Source File: ChatAttachAlertPhotoLayout.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
void onInit(boolean hasMedia) {
    mediaEnabled = hasMedia;
    if (cameraView != null) {
        cameraView.setAlpha(mediaEnabled ? 1.0f : 0.2f);
        cameraView.setEnabled(mediaEnabled);
    }
    if (cameraIcon != null) {
        cameraIcon.setAlpha(mediaEnabled ? 1.0f : 0.2f);
        cameraIcon.setEnabled(mediaEnabled);
    }
    if (parentAlert.baseFragment instanceof ChatActivity) {
        TLRPC.Chat chat = ((ChatActivity) parentAlert.baseFragment).getCurrentChat();
        galleryAlbumEntry = MediaController.allMediaAlbumEntry;
        if (mediaEnabled) {
            progressView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
        } else {
            if (ChatObject.isActionBannedByDefault(chat, ChatObject.ACTION_SEND_MEDIA)) {
                progressView.setText(LocaleController.getString("GlobalAttachMediaRestricted", R.string.GlobalAttachMediaRestricted));
            } else if (AndroidUtilities.isBannedForever(chat.banned_rights)) {
                progressView.setText(LocaleController.formatString("AttachMediaRestrictedForever", R.string.AttachMediaRestrictedForever));
            } else {
                progressView.setText(LocaleController.formatString("AttachMediaRestricted", R.string.AttachMediaRestricted, LocaleController.formatDateForBan(chat.banned_rights.until_date)));
            }
        }
    } else {
        galleryAlbumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (Build.VERSION.SDK_INT >= 23) {
        noGalleryPermissions = parentAlert.baseFragment.getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED;
    }
    if (galleryAlbumEntry != null) {
        for (int a = 0; a < Math.min(100, galleryAlbumEntry.photos.size()); a++) {
            MediaController.PhotoEntry photoEntry = galleryAlbumEntry.photos.get(a);
            photoEntry.reset();
        }
    }
    clearSelectedPhotos();
    updatePhotosCounter(false);
    cameraPhotoLayoutManager.scrollToPositionWithOffset(0, 1000000);
    layoutManager.scrollToPositionWithOffset(0, 1000000);

    dropDown.setText(LocaleController.getString("ChatGallery", R.string.ChatGallery));

    selectedAlbumEntry = galleryAlbumEntry;
    if (selectedAlbumEntry != null) {
        loading = false;
        if (progressView != null) {
            progressView.showTextView();
        }
    }
    updateAlbumsDropDown();
}