Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/google-java-format.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 6 additions & 14 deletions SmartFileBrowser/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ plugins {
}

android {
compileSdkVersion 32
buildToolsVersion '31.0.0'
compileSdkVersion 33

defaultConfig {
minSdkVersion 19
targetSdkVersion 32
versionCode 1
versionName "1.0"
targetSdkVersion 33

vectorDrawables.useSupportLibrary=true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -29,9 +26,10 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'ir.smartdevelopers.smartfilebrowser'
}
group = 'ir.smartdevelopers'
version = '1.5.0'
version = '1.5.1'
task sourcesJar(type: Jar) {
archiveClassifier.set("sources")
from android.sourceSets.main.java.srcDirs
Expand All @@ -42,21 +40,15 @@ task javadocJar2(type: Jar) {
}
dependencies {

implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.github.bumptech.glide:glide:4.12.0'

annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.aurelhubert:ahbottomnavigation:v2.3.4'
def lifecycle_version = "2.5.1"
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"

implementation 'com.github.smartdevelopers-ir:PhotoEditor:1.1.3'
// implementation 'ir.smartdevelopers:photo-editor:1.1.0'

}
afterEvaluate{
Expand Down
3 changes: 1 addition & 2 deletions SmartFileBrowser/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="ir.smartdevelopers.smartfilebrowser">
xmlns:tools="http://schemas.android.com/tools">

<uses-feature
android:name="android.hardware.camera.any"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStoreOwner;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
Expand Down Expand Up @@ -247,10 +248,10 @@ public void onMapSharedElements(List<String> names, Map<String, View> sharedElem
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_file_browser_main);
mSelectionFileViewModel = new ViewModelProvider(this).get(SelectionFileViewModel.class);
mGalleryViewModel = new ViewModelProvider(this, new ViewModelProvider.AndroidViewModelFactory(getApplication()))
mGalleryViewModel = new ViewModelProvider( this, (ViewModelProvider.Factory) new ViewModelProvider.AndroidViewModelFactory(getApplication()))
.get(GalleryViewModel.class);
mFilesViewModel = new ViewModelProvider(this,
new ViewModelProvider.AndroidViewModelFactory(getApplication()))
(ViewModelProvider.Factory) new ViewModelProvider.AndroidViewModelFactory(getApplication()))
.get(FilesViewModel.class);
mResultListener = ResultListener.getInstance();
if (savedInstanceState == null) {
Expand Down Expand Up @@ -314,11 +315,8 @@ public void onChanged(List<FileBrowserModel> fileBrowserModels) {
mGalleryAdapter.setOnItemLongClickListener(mOnGalleryItemLongClickListener);
mGalleryAdapter.setOnZoomOutClickListener(mOnZoomOutClickListener);
mGalleryAdapter.setOnItemChooseListener(mOnItemChooseListener);
int imageHeight = (getResources().getDisplayMetrics().widthPixels / spanCount) - (gapSpace * 2);
mGalleryRecyclerView.setItemViewCacheSize(20);
mGalleryRecyclerView.setHasFixedSize(true);
// mGalleryLayoutManager.setItemPrefetchEnabled(true);
// mGalleryLayoutManager.setInitialPrefetchItemCount(15);
mGalleryRecyclerView.setLayoutManager(mGalleryLayoutManager);
mGalleryRecyclerView.addItemDecoration(new GalleyItemDecoration(spanCount, gapSpace, true));
mGalleryRecyclerView.setAdapter(mGalleryAdapter);
Expand Down Expand Up @@ -682,6 +680,7 @@ private void initViews(Bundle savedInstanceState) {
mBottomNavigationView.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW);

int[] res = {android.R.attr.actionBarSize};
@SuppressLint("ResourceType")
TypedArray typedArray = obtainStyledAttributes(res);
mActionBarSize = typedArray.getDimensionPixelSize(0, 56) +
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import android.widget.VideoView;
import com.google.android.material.slider.LabelFormatter;
import com.google.android.material.slider.Slider;

import java.io.IOException;
import java.util.Locale;
import ir.smartdevelopers.smartfilebrowser.R;
import ir.smartdevelopers.smartfilebrowser.customClasses.MyVideoView;
Expand Down Expand Up @@ -233,7 +235,11 @@ private void loadVideoThumbnail() {

setTime(0,txtCurrentTime);
ActivityCompat.startPostponedEnterTransition(VideoViewActivity.this);
retriever.release();
try {
retriever.release();
} catch (IOException e) {
Log.e(getPackageName(),e.getMessage(),e);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,18 @@

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.StateListDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;

import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;

import java.io.File;
import java.util.Collections;
import java.util.List;

import ir.smartdevelopers.smartfilebrowser.acitivties.FileBrowserMainActivity;
import ir.smartdevelopers.smartfilebrowser.models.GalleryModel;

public class SmartFileBrowser {
public static OnItemClickListener<GalleryModel> sOnGalleryModelClickListener;
public class SmartFilePicker {
public static class IntentBuilder{
private SFBFileFilter mFileFilter;
private boolean showVideosInGallery=true;
Expand All @@ -37,44 +32,41 @@ public IntentBuilder setShowVideosInGallery(boolean showVideosInGallery) {
return this;
}

public IntentBuilder setShowCamera(boolean showCamera) {
public IntentBuilder showCamera(boolean showCamera) {
this.showCamera = showCamera;
return this;
}

public IntentBuilder setCanSelectMultipleInGallery(boolean canSelectMultipleInGallery) {
public IntentBuilder canSelectMultipleInGallery(boolean canSelectMultipleInGallery) {
this.canSelectMultipleInGallery = canSelectMultipleInGallery;
return this;
}

public IntentBuilder setCanSelectMultipleInFiles(boolean canSelectMultipleInFiles) {
public IntentBuilder canSelectMultipleInFiles(boolean canSelectMultipleInFiles) {
this.canSelectMultipleInFiles = canSelectMultipleInFiles;
return this;
}

public IntentBuilder setShowPDFTab(boolean showPDFTab) {
public IntentBuilder showPDFTab(boolean showPDFTab) {
this.showPDFTab = showPDFTab;
return this;
}

public IntentBuilder setShowFilesTab(boolean showFilesTab) {
public IntentBuilder showFilesTab(boolean showFilesTab) {
this.showFilesTab = showFilesTab;
return this;
}

public IntentBuilder setShowAudioTab(boolean showAudioTab) {
public IntentBuilder showAudioTab(boolean showAudioTab) {
this.showAudioTab = showAudioTab;
return this;
}

public IntentBuilder setShowGalleryTab(boolean showGalleryTab) {
public IntentBuilder showGalleryTab(boolean showGalleryTab) {
this.showGalleryTab = showGalleryTab;
return this;
}
public IntentBuilder setOnGalleryItemClickListener(OnItemClickListener<GalleryModel> onGalleryModelClickListener){
sOnGalleryModelClickListener=onGalleryModelClickListener;
return this;
}

public Intent build(Context context){
Intent filePickerIntent=new Intent(context, FileBrowserMainActivity.class);
filePickerIntent.putExtra("mShowVideosInGallery",showVideosInGallery);
Expand All @@ -96,7 +88,7 @@ public IntentBuilder setFileFilter(SFBFileFilter fileFilter) {
return this;
}

public IntentBuilder setShowPickFromSystemGalleyMenu(boolean showPickFromSystemGalleyMenu) {
public IntentBuilder showPickFromSystemGalleyMenu(boolean showPickFromSystemGalleyMenu) {
this.showPickFromSystemGalleyMenu = showPickFromSystemGalleyMenu;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public Repository(Application application) {
}

public void getGalleryMediaList(String selection, String[] selectionArgs, boolean addCameraItem, boolean showVideosInGallery){
// if (galleryList==null){
// galleryList=new MutableLiveData<>();
// }

List<GalleryModel> galleryModelList=new ArrayList<>();
if (addCameraItem){
GalleryModel cameraModel=new GalleryModel();
Expand Down Expand Up @@ -120,13 +118,16 @@ public LiveData<List<AlbumModel>> getAlbums(){
/*get newest item to set its path for allMedia item*/
List<AlbumModel> temp=new ArrayList<>(imageModelSet);
temp.addAll(videoModelSet);
AlbumModel newest= Collections.max(temp, new Comparator<AlbumModel>() {
@Override
public int compare(AlbumModel o1, AlbumModel o2) {
return Long.compare(o1.getTimeTaken(),o2.getTimeTaken());
}
});
AlbumModel allMedia=new AlbumModel(-1,wContext.get().getString(R.string.sfb_all_media),newest.getImagePath(),0);
AlbumModel newest= null;
if (temp.size() > 0){
newest = Collections.max(temp, new Comparator<AlbumModel>() {
@Override
public int compare(AlbumModel o1, AlbumModel o2) {
return Long.compare(o1.getTimeTaken(),o2.getTimeTaken());
}
});
}
AlbumModel allMedia=new AlbumModel(-1,wContext.get().getString(R.string.sfb_all_media),newest != null ? newest.getImagePath() : "",0);
Set<AlbumModel> albumModelSet=new HashSet<>(temp);
List<AlbumModel> albumModelList=new ArrayList<>(albumModelSet);
albumModelList.add(0,allMedia);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath 'com.android.tools.build:gradle:7.4.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip