mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 05:35:39 +03:00
commit
8062340f63
4 changed files with 57 additions and 42 deletions
|
@ -118,11 +118,11 @@ android {
|
|||
javaMaxHeapSize "4g"
|
||||
}
|
||||
|
||||
compileSdkVersion 28
|
||||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
targetSdkVersion 29
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
|
|
@ -1 +1 @@
|
|||
407
|
||||
409
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 59 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 73 warnings</span>
|
||||
|
|
|
@ -37,7 +37,9 @@ import com.owncloud.android.utils.ThemeUtils;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -51,11 +53,11 @@ public final class MediaProvider {
|
|||
private static final Uri IMAGES_MEDIA_URI = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
private static final String[] FILE_PROJECTION = new String[]{MediaStore.MediaColumns.DATA};
|
||||
private static final String IMAGES_FILE_SELECTION = MediaStore.Images.Media.BUCKET_ID + "=";
|
||||
private static final String[] IMAGES_FOLDER_PROJECTION = {"Distinct " + MediaStore.Images.Media.BUCKET_ID,
|
||||
private static final String[] IMAGES_FOLDER_PROJECTION = {MediaStore.Images.Media.BUCKET_ID,
|
||||
MediaStore.Images.Media.BUCKET_DISPLAY_NAME};
|
||||
private static final String IMAGES_FOLDER_SORT_ORDER = MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " ASC";
|
||||
|
||||
private static final String[] VIDEOS_FOLDER_PROJECTION = {"Distinct " + MediaStore.Video.Media.BUCKET_ID,
|
||||
private static final String[] VIDEOS_FOLDER_PROJECTION = {MediaStore.Video.Media.BUCKET_ID,
|
||||
MediaStore.Video.Media.BUCKET_DISPLAY_NAME};
|
||||
|
||||
private MediaProvider() {
|
||||
|
@ -86,26 +88,33 @@ public final class MediaProvider {
|
|||
String dataPath = MainApp.getStoragePath() + File.separator + MainApp.getDataFolder();
|
||||
|
||||
if (cursorFolders != null) {
|
||||
String folderName;
|
||||
String fileSortOrder = MediaStore.Images.Media.DATE_TAKEN + " DESC LIMIT " + itemLimit;
|
||||
Cursor cursorImages;
|
||||
|
||||
while (cursorFolders.moveToNext()) {
|
||||
String folderId = cursorFolders.getString(cursorFolders.getColumnIndex(MediaStore.Images.Media
|
||||
.BUCKET_ID));
|
||||
Map<String, String> uniqueFolders = new HashMap<>();
|
||||
|
||||
// since sdk 29 we have to manually distinct on bucket id
|
||||
while (cursorFolders.moveToNext()) {
|
||||
uniqueFolders.put(cursorFolders.getString(
|
||||
cursorFolders.getColumnIndex(MediaStore.Images.Media.BUCKET_ID)),
|
||||
cursorFolders.getString(
|
||||
cursorFolders.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME))
|
||||
);
|
||||
}
|
||||
cursorFolders.close();
|
||||
|
||||
for (Map.Entry<String, String> folder : uniqueFolders.entrySet()) {
|
||||
MediaFolder mediaFolder = new MediaFolder();
|
||||
folderName = cursorFolders.getString(cursorFolders.getColumnIndex(
|
||||
MediaStore.Images.Media.BUCKET_DISPLAY_NAME));
|
||||
|
||||
mediaFolder.type = MediaFolderType.IMAGE;
|
||||
mediaFolder.folderName = folderName;
|
||||
mediaFolder.folderName = folder.getValue();
|
||||
mediaFolder.filePaths = new ArrayList<>();
|
||||
|
||||
// query images
|
||||
cursorImages = contentResolver.query(
|
||||
IMAGES_MEDIA_URI,
|
||||
FILE_PROJECTION,
|
||||
IMAGES_FILE_SELECTION + folderId,
|
||||
IMAGES_FILE_SELECTION + folder.getKey(),
|
||||
null,
|
||||
fileSortOrder
|
||||
);
|
||||
|
@ -133,7 +142,7 @@ public final class MediaProvider {
|
|||
Cursor count = contentResolver.query(
|
||||
IMAGES_MEDIA_URI,
|
||||
FILE_PROJECTION,
|
||||
IMAGES_FILE_SELECTION + folderId,
|
||||
IMAGES_FILE_SELECTION + folder.getKey(),
|
||||
null,
|
||||
null);
|
||||
|
||||
|
@ -146,7 +155,6 @@ public final class MediaProvider {
|
|||
}
|
||||
}
|
||||
}
|
||||
cursorFolders.close();
|
||||
}
|
||||
|
||||
return mediaFolders;
|
||||
|
@ -203,22 +211,29 @@ public final class MediaProvider {
|
|||
String fileSortOrder = MediaStore.Video.Media.DATE_TAKEN + " DESC LIMIT " + itemLimit;
|
||||
Cursor cursorVideos;
|
||||
|
||||
while (cursorFolders.moveToNext()) {
|
||||
String folderId = cursorFolders.getString(cursorFolders.getColumnIndex(MediaStore.Video.Media
|
||||
.BUCKET_ID));
|
||||
Map<String, String> uniqueFolders = new HashMap<>();
|
||||
|
||||
// since sdk 29 we have to manually distinct on bucket id
|
||||
while (cursorFolders.moveToNext()) {
|
||||
uniqueFolders.put(cursorFolders.getString(
|
||||
cursorFolders.getColumnIndex(MediaStore.Video.Media.BUCKET_ID)),
|
||||
cursorFolders.getString(
|
||||
cursorFolders.getColumnIndex(MediaStore.Video.Media.BUCKET_DISPLAY_NAME))
|
||||
);
|
||||
}
|
||||
cursorFolders.close();
|
||||
|
||||
for (Map.Entry<String, String> folder : uniqueFolders.entrySet()) {
|
||||
MediaFolder mediaFolder = new MediaFolder();
|
||||
folderName = cursorFolders.getString(cursorFolders.getColumnIndex(
|
||||
MediaStore.Video.Media.BUCKET_DISPLAY_NAME));
|
||||
mediaFolder.type = MediaFolderType.VIDEO;
|
||||
mediaFolder.folderName = folderName;
|
||||
mediaFolder.folderName = folder.getValue();
|
||||
mediaFolder.filePaths = new ArrayList<>();
|
||||
|
||||
// query videos
|
||||
cursorVideos = contentResolver.query(
|
||||
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
FILE_PROJECTION,
|
||||
MediaStore.Video.Media.BUCKET_ID + "=" + folderId,
|
||||
MediaStore.Video.Media.BUCKET_ID + "=" + folder.getKey(),
|
||||
null,
|
||||
fileSortOrder);
|
||||
Log.d(TAG, "Reading videos for " + mediaFolder.folderName);
|
||||
|
@ -243,7 +258,7 @@ public final class MediaProvider {
|
|||
Cursor count = contentResolver.query(
|
||||
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
FILE_PROJECTION,
|
||||
MediaStore.Video.Media.BUCKET_ID + "=" + folderId,
|
||||
MediaStore.Video.Media.BUCKET_ID + "=" + folder.getKey(),
|
||||
null,
|
||||
null);
|
||||
|
||||
|
|
Loading…
Reference in a new issue