Search in sources :

Example 6 with Settings

use of us.koller.cameraroll.data.Settings in project Camera-Roll-Android-App by kollerlukas.

the class FileOperation method getTreeUri.

public Uri getTreeUri(Intent workIntent, String path) {
    Log.d("FileOperation", "getTreeUri");
    Uri treeUri;
    String treeUriExtra = workIntent.getStringExtra(FileOperation.REMOVABLE_STORAGE_TREE_URI);
    if (treeUriExtra != null) {
        treeUri = Uri.parse(treeUriExtra);
    } else {
        Settings s = Settings.getInstance(getApplicationContext());
        treeUri = s.getRemovableStorageTreeUri();
    }
    if (path != null) {
        // check if path is child of the treeUri
        DocumentFile file = StorageUtil.parseDocumentFile(getApplicationContext(), treeUri, new File(path));
        if (file != null) {
            return treeUri;
        } else {
            requestPermissionForRemovableStorageBroadcast(workIntent);
        }
    } else {
        return treeUri;
    }
    return null;
}
Also used : DocumentFile(android.support.v4.provider.DocumentFile) Uri(android.net.Uri) File(java.io.File) DocumentFile(android.support.v4.provider.DocumentFile) Settings(us.koller.cameraroll.data.Settings)

Example 7 with Settings

use of us.koller.cameraroll.data.Settings in project Camera-Roll-Android-App by kollerlukas.

the class FileHolder method setSelected.

public void setSelected(boolean selected) {
    Context context = itemView.getContext();
    Settings s = Settings.getInstance(itemView.getContext());
    Theme theme = s.getThemeInstance(context);
    int color = selected ? theme.getAccentColor(context) : ContextCompat.getColor(context, android.R.color.transparent);
    itemView.setBackgroundColor(color);
    TextView textView = itemView.findViewById(R.id.text);
    textView.setTextColor(selected ? theme.getAccentTextColor(context) : theme.getTextColorPrimary(context));
    ImageView folderIndicator = itemView.findViewById(R.id.folder_indicator);
    folderIndicator.setColorFilter(selected ? theme.getAccentTextColor(context) : theme.getTextColorSecondary(context), PorterDuff.Mode.SRC_IN);
}
Also used : Context(android.content.Context) Theme(us.koller.cameraroll.themes.Theme) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Settings(us.koller.cameraroll.data.Settings)

Example 8 with Settings

use of us.koller.cameraroll.data.Settings in project Camera-Roll-Android-App by kollerlukas.

the class VirtualAlbum method create.

public void create(Context context, ArrayList<Album> albums) {
    getAlbumItems().clear();
    for (int i = 0; i < albums.size(); i++) {
        Album album = albums.get(i);
        if (contains(album.getPath())) {
            getAlbumItems().addAll(album.getAlbumItems());
        }
    }
    Settings s = Settings.getInstance(context);
    int sortBy = s.sortAlbumBy();
    SortUtil.sort(getAlbumItems(), sortBy);
    pinned = Provider.isAlbumPinned(getPath(), Provider.getPinnedPaths());
}
Also used : SuppressLint(android.annotation.SuppressLint) Settings(us.koller.cameraroll.data.Settings)

Example 9 with Settings

use of us.koller.cameraroll.data.Settings in project Camera-Roll-Android-App by kollerlukas.

the class BaseActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    // registering RemovableStorage...Receiver here so only the visible activity receives the broadcast
    removableStoragePermissionRequestBroadcastReceiver = getRemovableStoragePermissionRequestBroadcastReceiver();
    if (removableStoragePermissionRequestBroadcastReceiver != null) {
        IntentFilter filter = new IntentFilter();
        filter.addAction(FileOperation.NEED_REMOVABLE_STORAGE_PERMISSION);
        broadcastReceivers.add(removableStoragePermissionRequestBroadcastReceiver);
        LocalBroadcastManager.getInstance(this).registerReceiver(removableStoragePermissionRequestBroadcastReceiver, filter);
    }
    if (MediaProvider.dataChanged) {
        MediaProvider.dataChanged = false;
        Settings s = Settings.getInstance(this);
        boolean hiddenFolders = s.getHiddenFolders();
        MediaProvider provider = new MediaProvider(this);
        provider.loadAlbums(this, hiddenFolders, new MediaProvider.OnMediaLoadedCallback() {

            @Override
            public void onMediaLoaded(ArrayList<Album> albums) {
                LocalBroadcastManager manager = LocalBroadcastManager.getInstance(BaseActivity.this);
                manager.sendBroadcast(new Intent().setAction(DATA_CHANGED));
            }

            @Override
            public void timeout() {
            }

            @Override
            public void needPermission() {
                MediaProvider.checkPermission(BaseActivity.this);
            }
        });
    }
}
Also used : IntentFilter(android.content.IntentFilter) MediaProvider(us.koller.cameraroll.data.provider.MediaProvider) Album(us.koller.cameraroll.data.models.Album) Intent(android.content.Intent) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) Settings(us.koller.cameraroll.data.Settings)

Example 10 with Settings

use of us.koller.cameraroll.data.Settings in project Camera-Roll-Android-App by kollerlukas.

the class SortUtil method sortAlbums.

public static void sortAlbums(Activity context, ArrayList<Album> albums) {
    Settings settings = Settings.getInstance(context);
    int sortAlbumBy = settings.sortAlbumBy();
    for (int i = 0; i < albums.size(); i++) {
        sort(albums.get(i).getAlbumItems(), sortAlbumBy);
    }
    int sortAlbumsBy = settings.sortAlbumsBy();
    switch(sortAlbumsBy) {
        case BY_NAME:
        case BY_DATE:
            sort(albums, sortAlbumsBy);
            return;
        case BY_SIZE:
            // Sorting
            Collections.sort(albums, new Comparator<Album>() {

                @Override
                public int compare(Album a1, Album a2) {
                    if (a1 != null && a2 != null) {
                        if (a1.pinned() ^ a2.pinned()) {
                            return a2.pinned() ? 1 : -1;
                        }
                        Integer a1_size = a1.getAlbumItems().size();
                        Integer a2_size = a2.getAlbumItems().size();
                        return a2_size.compareTo(a1_size);
                    }
                    return 0;
                }
            });
            break;
        default:
            break;
    }
}
Also used : Album(us.koller.cameraroll.data.models.Album) Settings(us.koller.cameraroll.data.Settings)

Aggregations

Settings (us.koller.cameraroll.data.Settings)10 Album (us.koller.cameraroll.data.models.Album)4 VirtualAlbum (us.koller.cameraroll.data.models.VirtualAlbum)2 Theme (us.koller.cameraroll.themes.Theme)2 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Drawable (android.graphics.drawable.Drawable)1 Uri (android.net.Uri)1 RequiresApi (android.support.annotation.RequiresApi)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 LocalBroadcastManager (android.support.v4.content.LocalBroadcastManager)1 DocumentFile (android.support.v4.provider.DocumentFile)1 ActionBar (android.support.v7.app.ActionBar)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1