diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index fb7f4a8..ac216bc 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml
new file mode 100644
index 0000000..2aa056d
--- /dev/null
+++ b/.idea/google-java-format.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 05305de..57c5c3d 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -7,7 +7,7 @@
-
+
-
diff --git a/.idea/misc.xml b/.idea/misc.xml
index a509e45..ecc6173 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,12 +4,17 @@
-
+
diff --git a/SmartFileBrowser/build.gradle b/SmartFileBrowser/build.gradle
index ffb05ff..feffe2f 100644
--- a/SmartFileBrowser/build.gradle
+++ b/SmartFileBrowser/build.gradle
@@ -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"
@@ -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
@@ -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{
diff --git a/SmartFileBrowser/src/main/AndroidManifest.xml b/SmartFileBrowser/src/main/AndroidManifest.xml
index 28ee965..889aba3 100644
--- a/SmartFileBrowser/src/main/AndroidManifest.xml
+++ b/SmartFileBrowser/src/main/AndroidManifest.xml
@@ -1,7 +1,6 @@
+ xmlns:tools="http://schemas.android.com/tools">
names, Map 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) {
@@ -314,11 +315,8 @@ public void onChanged(List 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);
@@ -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());
diff --git a/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/acitivties/VideoViewActivity.java b/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/acitivties/VideoViewActivity.java
index adc58d8..4a25116 100644
--- a/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/acitivties/VideoViewActivity.java
+++ b/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/acitivties/VideoViewActivity.java
@@ -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;
@@ -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);
+ }
}
diff --git a/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/customClasses/SmartFileBrowser.java b/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/customClasses/SmartFilePicker.java
similarity index 80%
rename from SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/customClasses/SmartFileBrowser.java
rename to SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/customClasses/SmartFilePicker.java
index 9508d92..e8a7dc2 100644
--- a/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/customClasses/SmartFileBrowser.java
+++ b/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/customClasses/SmartFilePicker.java
@@ -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 sOnGalleryModelClickListener;
+public class SmartFilePicker {
public static class IntentBuilder{
private SFBFileFilter mFileFilter;
private boolean showVideosInGallery=true;
@@ -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 onGalleryModelClickListener){
- sOnGalleryModelClickListener=onGalleryModelClickListener;
- return this;
- }
+
public Intent build(Context context){
Intent filePickerIntent=new Intent(context, FileBrowserMainActivity.class);
filePickerIntent.putExtra("mShowVideosInGallery",showVideosInGallery);
@@ -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;
}
diff --git a/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/viewModel/Repository.java b/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/viewModel/Repository.java
index ce14464..9a0bd1d 100644
--- a/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/viewModel/Repository.java
+++ b/SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/viewModel/Repository.java
@@ -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 galleryModelList=new ArrayList<>();
if (addCameraItem){
GalleryModel cameraModel=new GalleryModel();
@@ -120,13 +118,16 @@ public LiveData> getAlbums(){
/*get newest item to set its path for allMedia item*/
List temp=new ArrayList<>(imageModelSet);
temp.addAll(videoModelSet);
- AlbumModel newest= Collections.max(temp, new Comparator() {
- @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() {
+ @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 albumModelSet=new HashSet<>(temp);
List albumModelList=new ArrayList<>(albumModelSet);
albumModelList.add(0,allMedia);
diff --git a/build.gradle b/build.gradle
index 0f01fbd..b871658 100644
--- a/build.gradle
+++ b/build.gradle
@@ -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
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 45357c7..f84c82e 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -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