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;
}
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);
}
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());
}
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);
}
});
}
}
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;
}
}
Aggregations