Skip to content

Commit

Permalink
release 1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBoy722 committed Jul 6, 2020
1 parent 1bc7d04 commit bfb4be1
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,4 @@ private void updateProgressCallbackTask() {
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void setUpFolderSelector(){

final ArrayList<pictureFolderContent> pictureFolders = new ArrayList<>();
pictureFolders.add(new pictureFolderContent("all","*All*"));
pictureFolders.addAll(MediaFacer.withPictureContex(this).getPictureFolders());
pictureFolders.addAll(MediaFacer.withPictureContex(this).getAbsolutePictureFolders());

final ArrayList<String> folders = new ArrayList<>();
for(int i = 0;i < pictureFolders.size();i++){
Expand All @@ -126,9 +126,10 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
Toast.makeText(pictureActivity.this,String.valueOf(allPhotos.size()),Toast.LENGTH_LONG).show();
setUpAndDisplayPictures();
}else {
allPhotos = MediaFacer
allPhotos = pictureFolders.get(position).getPhotos();
/* allPhotos = MediaFacer
.withPictureContex(pictureActivity.this)
.getAllPictureContentByBucket_id(pictureFolders.get(position).getBucket_id());
.getAllPictureContentByBucket_id(pictureFolders.get(position).getBucket_id());*/
Toast.makeText(pictureActivity.this,String.valueOf(allPhotos.size()),Toast.LENGTH_LONG).show();
setUpAndDisplayPictures();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void setupFolderSelector(){

final ArrayList<videoFolderContent> videoFolders = new ArrayList<>();
videoFolders.add(new videoFolderContent("all","*All*"));
videoFolders.addAll(MediaFacer.withVideoContex(this).getVideoFolders(VideoGet.externalContentUri));
videoFolders.addAll(MediaFacer.withVideoContex(this).getAbsoluteVideoFolders(VideoGet.externalContentUri));

final ArrayList<String> folders = new ArrayList<>();
for(int i = 0;i < videoFolders.size();i++){
Expand All @@ -81,9 +81,10 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
Toast.makeText(videoActivity.this,String.valueOf(allVideos.size()),Toast.LENGTH_LONG).show();
setuUpAndDisplayVideos();
}else {
allVideos = MediaFacer
allVideos = videoFolders.get(position).getVideoFiles();
/* allVideos = MediaFacer
.withVideoContex(videoActivity.this)
.getAllVideoContentByBucket_id(videoFolders.get(position).getBucket_id());
.getAllVideoContentByBucket_id(videoFolders.get(position).getBucket_id());*/
Toast.makeText(videoActivity.this,String.valueOf(allVideos.size()),Toast.LENGTH_LONG).show();
setuUpAndDisplayVideos();
}
Expand Down Expand Up @@ -117,7 +118,6 @@ public void onVideoItemLongClicked(int position) {

}


private void playVideo(int position){

videoPlayerFragment playerFragment = new videoPlayerFragment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.io.File;
import java.util.ArrayList;


public class AudioGet {

private static AudioGet audioGet;
Expand Down
120 changes: 109 additions & 11 deletions mediafacer/src/main/java/com/CodeBoy/MediaFacer/PictureGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ static PictureGet getInstance(Context contx){
/**Returns an ArrayList of {@link pictureContent} */
public ArrayList<pictureContent> getAllPictureContents(Uri contentLocation){
ArrayList<pictureContent> images = new ArrayList<>();
String[] projection = { MediaStore.Images.Media.DATA ,MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.SIZE, MediaStore.Images.Media.DATE_ADDED,MediaStore.Images.Media._ID,
String[] projection = {
MediaStore.Images.Media.DATA,
MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.SIZE,
MediaStore.Images.Media.DATE_ADDED,
MediaStore.Images.Media._ID,
MediaStore.Images.Media.DATE_MODIFIED};
cursor = pictureContex.getContentResolver().query( contentLocation, projection, null, null,
"LOWER ("+MediaStore.Images.Media.DATE_TAKEN+") DESC");

try {
cursor.moveToFirst();
do{
Expand All @@ -66,6 +69,13 @@ public ArrayList<pictureContent> getAllPictureContents(Uri contentLocation){
pictureContent.setDate_added(0000);
}

try{
pictureContent.setDate_taken(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_TAKEN)));
}catch (Exception ex){
ex.printStackTrace();
pictureContent.setDate_taken(0000);
}

try{
pictureContent.setDate_modified(cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_MODIFIED)));
}catch (Exception ex){
Expand All @@ -83,6 +93,7 @@ public ArrayList<pictureContent> getAllPictureContents(Uri contentLocation){
}

/**Returns an ArrayList of {@link pictureFolderContent} */

public ArrayList<pictureFolderContent> getPictureFolders(){
ArrayList<pictureFolderContent> picFolders = new ArrayList<>();
ArrayList<Integer> picPaths = new ArrayList<>();
Expand All @@ -97,13 +108,10 @@ public ArrayList<pictureFolderContent> getPictureFolders(){
cursor.moveToFirst();
do{
pictureFolderContent photoFolder = new pictureFolderContent();
String name = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DISPLAY_NAME));
String folder = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.BUCKET_DISPLAY_NAME));
String datapath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA));

//if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
int bucket_id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.BUCKET_ID));
//}else {}

String folderpaths = datapath.substring(0, datapath.lastIndexOf(folder+"/"));
folderpaths = folderpaths+folder+"/";
Expand Down Expand Up @@ -159,24 +167,114 @@ public ArrayList<pictureContent> getAllPictureContentByBucket_id(int bucket_id){
pictureContent.setDate_added(0000);
}

try{
pictureContent.setDate_taken(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_TAKEN)));
}catch (Exception ex){
ex.printStackTrace();
pictureContent.setDate_taken(0000);
}

try{
pictureContent.setDate_modified(cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_MODIFIED)));
}catch (Exception ex){
ex.printStackTrace();
pictureContent.setDate_added(0000);
}

images.add(pictureContent);
}while(cursor.moveToNext());
cursor.close();
// ArrayList<pictureContent> reSelection = new ArrayList<>();
// for(int i = images.size()-1;i > -1;i--){
// reSelection.add(images.get(i));
// }
// images = reSelection;
} catch (Exception e) {
e.printStackTrace();
}
return images;
}

public ArrayList<pictureFolderContent> getAbsolutePictureFolders(){
ArrayList<pictureFolderContent> absolutePictureFolders = new ArrayList<>();
ArrayList<Integer> picturePaths = new ArrayList<>();
@SuppressLint("InlinedApi") String[] projection = {
MediaStore.Images.ImageColumns.DATA,
MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
MediaStore.Images.Media.BUCKET_ID,
MediaStore.Images.Media.SIZE,
MediaStore.Images.Media.DATE_ADDED,
MediaStore.Images.Media._ID,
MediaStore.Images.Media.DATE_TAKEN,
MediaStore.Images.Media.DATE_MODIFIED};
cursor = pictureContex.getContentResolver().query( externalContentUri, projection, null, null,
"LOWER ("+MediaStore.Images.Media.DATE_TAKEN+") DESC");
try{
cursor.moveToFirst();
do{

pictureFolderContent photoFolder = new pictureFolderContent();
pictureContent pictureContent = new pictureContent();

pictureContent.setPicturName(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DISPLAY_NAME)));

pictureContent.setPicturePath(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)));

pictureContent.setPictureSize(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.SIZE)));

int id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID));
pictureContent.setPictureId(id);

Uri contentUri = Uri.withAppendedPath(externalContentUri, String.valueOf(id));
pictureContent.setAssertFileStringUri(contentUri.toString());

try{
pictureContent.setDate_added(cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_ADDED)));
}catch (Exception ex){
ex.printStackTrace();
pictureContent.setDate_added(0000);
}

try{
pictureContent.setDate_taken(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_TAKEN)));
}catch (Exception ex){
ex.printStackTrace();
pictureContent.setDate_taken(0000);
}

try{
pictureContent.setDate_modified(cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_MODIFIED)));
}catch (Exception ex){
ex.printStackTrace();
pictureContent.setDate_added(0000);
}

String folder = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.BUCKET_DISPLAY_NAME));
String datapath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA));

int bucket_id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.BUCKET_ID));

String folderpaths = datapath.substring(0, datapath.lastIndexOf(folder+"/"));
folderpaths = folderpaths+folder+"/";
if (!picturePaths.contains(bucket_id)) {
picturePaths.add(bucket_id);

photoFolder.setBucket_id(bucket_id);
photoFolder.setFolderPath(folderpaths);
photoFolder.setFolderName(folder);
photoFolder.getPhotos().add(pictureContent);
absolutePictureFolders.add(photoFolder);
}else {
for (int i = 0; i < absolutePictureFolders.size();i++){
if(absolutePictureFolders.get(i).getBucket_id() == bucket_id){
absolutePictureFolders.get(i).getPhotos().add(pictureContent);
}
}
}
}while (cursor.moveToNext());
}catch (Exception e){
e.printStackTrace();
}



return absolutePictureFolders;
}

}
88 changes: 85 additions & 3 deletions mediafacer/src/main/java/com/CodeBoy/MediaFacer/VideoGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public ArrayList<videoContent> getAllVideoContent(Uri contentLocation) {
videoContent.setDate_added(0000);
}

try{
videoContent.setDate_taken(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATE_TAKEN)));
}catch (Exception ex){
ex.printStackTrace();
videoContent.setDate_added(0000);
}

try{
videoContent.setDate_modified(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATE_MODIFIED)));
}catch (Exception ex){
Expand Down Expand Up @@ -107,13 +114,10 @@ public ArrayList<videoFolderContent> getVideoFolders(Uri contentLocation){
cursor.moveToFirst();
do{
videoFolderContent videoFolder = new videoFolderContent();
String name = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME));
String folder = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.BUCKET_DISPLAY_NAME));
String datapath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));

//if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
int bucket_id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.BUCKET_ID));
//}else {}

String folderpaths = datapath.substring(0, datapath.lastIndexOf(folder+"/"));
folderpaths = folderpaths+folder+"/";
Expand Down Expand Up @@ -180,6 +184,14 @@ public ArrayList<videoContent> getAllVideoContentByBucket_id(int bucket_id){
videoContent.setDate_added(0000);
}

try{
videoContent.setDate_taken(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATE_TAKEN)));
}catch (Exception ex){
ex.printStackTrace();
videoContent.setDate_added(0000);
}


try{
videoContent.setDate_modified(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATE_MODIFIED)));
}catch (Exception ex){
Expand Down Expand Up @@ -207,15 +219,85 @@ public ArrayList<videoFolderContent> getAbsoluteVideoFolders(Uri contentLocation
MediaStore.Video.Media.BUCKET_ID,
MediaStore.Video.Media.SIZE,
MediaStore.Video.Media._ID,
MediaStore.Video.Media.DURATION,
MediaStore.Video.Media.DATE_ADDED,
MediaStore.Video.Media.DATE_MODIFIED,
MediaStore.Video.Media.DATE_TAKEN,
MediaStore.Video.Media.ALBUM,
MediaStore.Video.Media.ARTIST};
cursor = videoContex.getContentResolver().query(contentLocation, projection, null, null, "LOWER ("+MediaStore.Video.Media.DATE_TAKEN+") DESC");//DESC
try{
cursor.moveToFirst();
do{
videoFolderContent videoFolder = new videoFolderContent();
videoContent videoContent = new videoContent();

videoContent.setVideoName(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME)));

videoContent.setPath(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)));

videoContent.setVideoDuration(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION)));

videoContent.setVideoSize(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE)));

int id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Video.Media._ID));
videoContent.setVideoId(id);

Uri contentUri = Uri.withAppendedPath(contentLocation, String.valueOf(id));
videoContent.setAssetFileStringUri(contentUri.toString());

videoContent.setAlbum(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.ALBUM)));

videoContent.setArtist(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST)));

try{
videoContent.setDate_added(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATE_ADDED)));
}catch (Exception ex){
ex.printStackTrace();
videoContent.setDate_added(0000);
}

try{
videoContent.setDate_taken(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATE_TAKEN)));
}catch (Exception ex){
ex.printStackTrace();
videoContent.setDate_added(0000);
}

try{
videoContent.setDate_modified(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATE_MODIFIED)));
}catch (Exception ex){
ex.printStackTrace();
videoContent.setDate_added(0000);
}

String folder = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.BUCKET_DISPLAY_NAME));
String datapath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));

int bucket_id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.BUCKET_ID));

String folderpaths = datapath.substring(0, datapath.lastIndexOf(folder+"/"));
folderpaths = folderpaths+folder+"/";

if (!videoPaths.contains(bucket_id)) {
videoPaths.add(bucket_id);
videoFolder.setBucket_id(bucket_id);
videoFolder.setFolderPath(folderpaths);
videoFolder.setFolderName(folder);
videoFolder.getVideoFiles().add(videoContent);
allVideoFolders.add(videoFolder);
}else{
for(int i = 0; i < allVideoFolders.size();i++){
if(allVideoFolders.get(i).getBucket_id() == bucket_id){
allVideoFolders.get(i).getVideoFiles().add(videoContent);
}
}
}
}while (cursor.moveToNext());
cursor.close();
}catch (Exception e){
e.printStackTrace();
}
return allVideoFolders;
}

Expand Down

0 comments on commit bfb4be1

Please sign in to comment.