Search in sources :

Example 6 with Album

use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.

the class SingleMediaActivity method loadUri.

private void loadUri(Uri uri) {
    album = new Album(uri.toString(), uri.getPath());
    album.settings = AlbumSettings.getDefaults();
    try {
        InputStream inputStream = getContentResolver().openInputStream(uri);
        if (inputStream != null)
            inputStream.close();
    } catch (Exception ex) {
        boolean showEasterEgg = Prefs.showEasterEgg();
        ((TextView) findViewById(R.id.nothing_to_show_text_emoji_easter_egg)).setText(R.string.error_occured_open_media);
        findViewById(R.id.nothing_to_show_placeholder).setVisibility(!showEasterEgg ? View.VISIBLE : View.GONE);
        findViewById(R.id.ll_emoji_easter_egg).setVisibility(showEasterEgg ? View.VISIBLE : View.GONE);
    }
    media = new ArrayList<>(Collections.singletonList(new Media(uri)));
    position = 0;
    customUri = true;
}
Also used : InputStream(java.io.InputStream) Media(org.horaapps.leafpic.data.Media) Album(org.horaapps.leafpic.data.Album) DeleteException(org.horaapps.leafpic.util.file.DeleteException)

Example 7 with Album

use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.

the class SelectAlbumBottomSheet method toggleExplorerMode.

private void toggleExplorerMode(boolean enabled) {
    folders = new ArrayList<File>();
    setExploreMode(enabled);
    if (enabled) {
        displayContentFolder(Environment.getExternalStorageDirectory());
        imgExploreMode.setIcon(theme.getIcon(CommunityMaterial.Icon.cmd_folder));
        exploreModePanel.setVisibility(View.VISIBLE);
    } else {
        currentFolderPath.setText(R.string.local_folder);
        for (Album album : ((MyApplication) getActivity().getApplicationContext()).getAlbums().dispAlbums) {
            folders.add(new File(album.getPath()));
        }
        imgExploreMode.setIcon(theme.getIcon(CommunityMaterial.Icon.cmd_compass_outline));
        exploreModePanel.setVisibility(View.GONE);
    }
    adapter.notifyDataSetChanged();
}
Also used : Album(org.horaapps.leafpic.data.Album) File(java.io.File)

Example 8 with Album

use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.

the class MediaStoreProvider method getHiddenAlbums.

private static ArrayList<Album> getHiddenAlbums(Context context) {
    ArrayList<Album> list = new ArrayList<Album>();
    String[] projection = new String[] { MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.PARENT };
    String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "=" + MediaStore.Files.FileColumns.MEDIA_TYPE_NONE + " and " + MediaStore.Files.FileColumns.DATA + " LIKE '%.nomedia'";
    Cursor cur = context.getContentResolver().query(MediaStore.Files.getContentUri("external"), projection, selection, null, null);
    if (cur != null && cur.moveToFirst()) {
        do {
            File folder = new File(cur.getString(0)).getParentFile();
            File[] files = folder.listFiles(new ImageFileFilter(true));
            if (files != null && files.length > 0) {
                Album album = new Album(context, folder.getAbsolutePath(), -1, folder.getName(), files.length);
                // TODO: 21/08/16 sort and find?
                long lastMod = Long.MIN_VALUE;
                File f = null;
                for (File file : files) {
                    if (file.lastModified() > lastMod) {
                        f = file;
                        lastMod = file.lastModified();
                    }
                }
                if (f != null && !isExcluded(f.getPath())) {
                    album.addMedia(new Media(f.getPath(), f.lastModified()));
                    list.add(album);
                }
            }
        } while (cur.moveToNext());
        cur.close();
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) Media(org.horaapps.leafpic.data.Media) Album(org.horaapps.leafpic.data.Album) Cursor(android.database.Cursor) File(java.io.File) ImageFileFilter(org.horaapps.leafpic.data.base.ImageFileFilter)

Example 9 with Album

use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.

the class AlbumsFragment method onPrepareOptionsMenu.

@Override
public void onPrepareOptionsMenu(Menu menu) {
    boolean editMode = editMode();
    boolean oneSelected = getSelectedCount() == 1;
    menu.setGroupVisible(R.id.general_album_items, !editMode);
    menu.setGroupVisible(R.id.edit_mode_items, editMode);
    menu.setGroupVisible(R.id.one_selected_items, oneSelected);
    menu.findItem(R.id.select_all).setTitle(getSelectedCount() == getCount() ? R.string.clear_selected : R.string.select_all);
    if (editMode) {
        menu.findItem(R.id.hide).setTitle(hidden ? R.string.unhide : R.string.hide);
    } else {
        menu.findItem(R.id.ascending_sort_order).setChecked(sortingOrder() == SortingOrder.ASCENDING);
        switch(sortingMode()) {
            case NAME:
                menu.findItem(R.id.name_sort_mode).setChecked(true);
                break;
            case SIZE:
                menu.findItem(R.id.size_sort_mode).setChecked(true);
                break;
            case DATE:
            default:
                menu.findItem(R.id.date_taken_sort_mode).setChecked(true);
                break;
            case NUMERIC:
                menu.findItem(R.id.numeric_sort_mode).setChecked(true);
                break;
        }
    }
    if (oneSelected) {
        Album selectedAlbum = adapter.getFirstSelectedAlbum();
        menu.findItem(R.id.pin_album).setTitle(selectedAlbum.isPinned() ? getString(R.string.un_pin) : getString(R.string.pin));
        menu.findItem(R.id.clear_album_cover).setVisible(selectedAlbum.hasCover());
    }
    super.onPrepareOptionsMenu(menu);
}
Also used : Album(org.horaapps.leafpic.data.Album)

Example 10 with Album

use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.

the class AlbumsAdapter method removeSelectedAlbums.

public void removeSelectedAlbums() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
        albums.removeIf(Album::isSelected);
    else {
        Iterator<Album> iter = albums.iterator();
        while (iter.hasNext()) {
            Album album = iter.next();
            if (album.isSelected())
                iter.remove();
        }
    }
    selectedCount = 0;
    notifyDataSetChanged();
}
Also used : Album(org.horaapps.leafpic.data.Album)

Aggregations

Album (org.horaapps.leafpic.data.Album)11 Media (org.horaapps.leafpic.data.Media)7 File (java.io.File)5 ArrayList (java.util.ArrayList)3 Cursor (android.database.Cursor)2 AlertDialog (android.support.v7.app.AlertDialog)2 View (android.view.View)2 TextView (android.widget.TextView)2 BindView (butterknife.BindView)2 InputStream (java.io.InputStream)2 SortingOrder (org.horaapps.leafpic.data.sort.SortingOrder)2 Security (org.horaapps.leafpic.util.Security)2 DeleteException (org.horaapps.leafpic.util.file.DeleteException)2 ArgbEvaluator (android.animation.ArgbEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 ActivityInfo (android.content.pm.ActivityInfo)1 Configuration (android.content.res.Configuration)1