Skip to content

Commit ed97757

Browse files
Merge pull request #13 from smartdevelopers-ir/changes_for_android_11
2023/05/29
2 parents 18bcd45 + f6da3ed commit ed97757

File tree

12 files changed

+56
-57
lines changed

12 files changed

+56
-57
lines changed

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/google-java-format.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SmartFileBrowser/build.gradle

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ plugins {
55
}
66

77
android {
8-
compileSdkVersion 32
9-
buildToolsVersion '31.0.0'
8+
compileSdkVersion 33
109

1110
defaultConfig {
1211
minSdkVersion 19
13-
targetSdkVersion 32
14-
versionCode 1
15-
versionName "1.0"
12+
targetSdkVersion 33
1613

1714
vectorDrawables.useSupportLibrary=true
1815
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -29,9 +26,10 @@ android {
2926
sourceCompatibility JavaVersion.VERSION_1_8
3027
targetCompatibility JavaVersion.VERSION_1_8
3128
}
29+
namespace 'ir.smartdevelopers.smartfilebrowser'
3230
}
3331
group = 'ir.smartdevelopers'
34-
version = '1.5.0'
32+
version = '1.5.1'
3533
task sourcesJar(type: Jar) {
3634
archiveClassifier.set("sources")
3735
from android.sourceSets.main.java.srcDirs
@@ -42,21 +40,15 @@ task javadocJar2(type: Jar) {
4240
}
4341
dependencies {
4442

45-
implementation 'androidx.appcompat:appcompat:1.5.1'
46-
implementation 'com.google.android.material:material:1.6.1'
43+
implementation 'androidx.appcompat:appcompat:1.6.1'
44+
implementation 'com.google.android.material:material:1.9.0'
4745
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
4846
implementation 'com.github.bumptech.glide:glide:4.12.0'
4947

5048
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
5149
implementation 'com.github.aurelhubert:ahbottomnavigation:v2.3.4'
52-
def lifecycle_version = "2.5.1"
53-
// ViewModel
54-
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
55-
// LiveData
56-
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
5750

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

6153
}
6254
afterEvaluate{

SmartFileBrowser/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="ir.smartdevelopers.smartfilebrowser">
3+
xmlns:tools="http://schemas.android.com/tools">
54

65
<uses-feature
76
android:name="android.hardware.camera.any"

SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/acitivties/FileBrowserMainActivity.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import androidx.lifecycle.LiveData;
1515
import androidx.lifecycle.Observer;
1616
import androidx.lifecycle.ViewModelProvider;
17+
import androidx.lifecycle.ViewModelStoreOwner;
1718
import androidx.recyclerview.widget.DiffUtil;
1819
import androidx.recyclerview.widget.GridLayoutManager;
1920
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -247,10 +248,10 @@ public void onMapSharedElements(List<String> names, Map<String, View> sharedElem
247248
super.onCreate(savedInstanceState);
248249
setContentView(R.layout.activity_file_browser_main);
249250
mSelectionFileViewModel = new ViewModelProvider(this).get(SelectionFileViewModel.class);
250-
mGalleryViewModel = new ViewModelProvider(this, new ViewModelProvider.AndroidViewModelFactory(getApplication()))
251+
mGalleryViewModel = new ViewModelProvider( this, (ViewModelProvider.Factory) new ViewModelProvider.AndroidViewModelFactory(getApplication()))
251252
.get(GalleryViewModel.class);
252253
mFilesViewModel = new ViewModelProvider(this,
253-
new ViewModelProvider.AndroidViewModelFactory(getApplication()))
254+
(ViewModelProvider.Factory) new ViewModelProvider.AndroidViewModelFactory(getApplication()))
254255
.get(FilesViewModel.class);
255256
mResultListener = ResultListener.getInstance();
256257
if (savedInstanceState == null) {
@@ -314,11 +315,8 @@ public void onChanged(List<FileBrowserModel> fileBrowserModels) {
314315
mGalleryAdapter.setOnItemLongClickListener(mOnGalleryItemLongClickListener);
315316
mGalleryAdapter.setOnZoomOutClickListener(mOnZoomOutClickListener);
316317
mGalleryAdapter.setOnItemChooseListener(mOnItemChooseListener);
317-
int imageHeight = (getResources().getDisplayMetrics().widthPixels / spanCount) - (gapSpace * 2);
318318
mGalleryRecyclerView.setItemViewCacheSize(20);
319319
mGalleryRecyclerView.setHasFixedSize(true);
320-
// mGalleryLayoutManager.setItemPrefetchEnabled(true);
321-
// mGalleryLayoutManager.setInitialPrefetchItemCount(15);
322320
mGalleryRecyclerView.setLayoutManager(mGalleryLayoutManager);
323321
mGalleryRecyclerView.addItemDecoration(new GalleyItemDecoration(spanCount, gapSpace, true));
324322
mGalleryRecyclerView.setAdapter(mGalleryAdapter);
@@ -682,6 +680,7 @@ private void initViews(Bundle savedInstanceState) {
682680
mBottomNavigationView.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW);
683681

684682
int[] res = {android.R.attr.actionBarSize};
683+
@SuppressLint("ResourceType")
685684
TypedArray typedArray = obtainStyledAttributes(res);
686685
mActionBarSize = typedArray.getDimensionPixelSize(0, 56) +
687686
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics());

SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/acitivties/VideoViewActivity.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import android.widget.VideoView;
4040
import com.google.android.material.slider.LabelFormatter;
4141
import com.google.android.material.slider.Slider;
42+
43+
import java.io.IOException;
4244
import java.util.Locale;
4345
import ir.smartdevelopers.smartfilebrowser.R;
4446
import ir.smartdevelopers.smartfilebrowser.customClasses.MyVideoView;
@@ -233,7 +235,11 @@ private void loadVideoThumbnail() {
233235

234236
setTime(0,txtCurrentTime);
235237
ActivityCompat.startPostponedEnterTransition(VideoViewActivity.this);
236-
retriever.release();
238+
try {
239+
retriever.release();
240+
} catch (IOException e) {
241+
Log.e(getPackageName(),e.getMessage(),e);
242+
}
237243
}
238244

239245

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,18 @@
22

33
import android.content.Context;
44
import android.content.Intent;
5-
import android.graphics.drawable.StateListDrawable;
65
import android.net.Uri;
76
import android.os.Bundle;
87
import android.os.Parcelable;
98

109
import androidx.annotation.Nullable;
11-
import androidx.core.content.FileProvider;
1210

1311
import java.io.File;
14-
import java.util.Collections;
15-
import java.util.List;
1612

1713
import ir.smartdevelopers.smartfilebrowser.acitivties.FileBrowserMainActivity;
1814
import ir.smartdevelopers.smartfilebrowser.models.GalleryModel;
1915

20-
public class SmartFileBrowser {
21-
public static OnItemClickListener<GalleryModel> sOnGalleryModelClickListener;
16+
public class SmartFilePicker {
2217
public static class IntentBuilder{
2318
private SFBFileFilter mFileFilter;
2419
private boolean showVideosInGallery=true;
@@ -37,44 +32,41 @@ public IntentBuilder setShowVideosInGallery(boolean showVideosInGallery) {
3732
return this;
3833
}
3934

40-
public IntentBuilder setShowCamera(boolean showCamera) {
35+
public IntentBuilder showCamera(boolean showCamera) {
4136
this.showCamera = showCamera;
4237
return this;
4338
}
4439

45-
public IntentBuilder setCanSelectMultipleInGallery(boolean canSelectMultipleInGallery) {
40+
public IntentBuilder canSelectMultipleInGallery(boolean canSelectMultipleInGallery) {
4641
this.canSelectMultipleInGallery = canSelectMultipleInGallery;
4742
return this;
4843
}
4944

50-
public IntentBuilder setCanSelectMultipleInFiles(boolean canSelectMultipleInFiles) {
45+
public IntentBuilder canSelectMultipleInFiles(boolean canSelectMultipleInFiles) {
5146
this.canSelectMultipleInFiles = canSelectMultipleInFiles;
5247
return this;
5348
}
5449

55-
public IntentBuilder setShowPDFTab(boolean showPDFTab) {
50+
public IntentBuilder showPDFTab(boolean showPDFTab) {
5651
this.showPDFTab = showPDFTab;
5752
return this;
5853
}
5954

60-
public IntentBuilder setShowFilesTab(boolean showFilesTab) {
55+
public IntentBuilder showFilesTab(boolean showFilesTab) {
6156
this.showFilesTab = showFilesTab;
6257
return this;
6358
}
6459

65-
public IntentBuilder setShowAudioTab(boolean showAudioTab) {
60+
public IntentBuilder showAudioTab(boolean showAudioTab) {
6661
this.showAudioTab = showAudioTab;
6762
return this;
6863
}
6964

70-
public IntentBuilder setShowGalleryTab(boolean showGalleryTab) {
65+
public IntentBuilder showGalleryTab(boolean showGalleryTab) {
7166
this.showGalleryTab = showGalleryTab;
7267
return this;
7368
}
74-
public IntentBuilder setOnGalleryItemClickListener(OnItemClickListener<GalleryModel> onGalleryModelClickListener){
75-
sOnGalleryModelClickListener=onGalleryModelClickListener;
76-
return this;
77-
}
69+
7870
public Intent build(Context context){
7971
Intent filePickerIntent=new Intent(context, FileBrowserMainActivity.class);
8072
filePickerIntent.putExtra("mShowVideosInGallery",showVideosInGallery);
@@ -96,7 +88,7 @@ public IntentBuilder setFileFilter(SFBFileFilter fileFilter) {
9688
return this;
9789
}
9890

99-
public IntentBuilder setShowPickFromSystemGalleyMenu(boolean showPickFromSystemGalleyMenu) {
91+
public IntentBuilder showPickFromSystemGalleyMenu(boolean showPickFromSystemGalleyMenu) {
10092
this.showPickFromSystemGalleyMenu = showPickFromSystemGalleyMenu;
10193
return this;
10294
}

SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/viewModel/Repository.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ public Repository(Application application) {
5252
}
5353

5454
public void getGalleryMediaList(String selection, String[] selectionArgs, boolean addCameraItem, boolean showVideosInGallery){
55-
// if (galleryList==null){
56-
// galleryList=new MutableLiveData<>();
57-
// }
55+
5856
List<GalleryModel> galleryModelList=new ArrayList<>();
5957
if (addCameraItem){
6058
GalleryModel cameraModel=new GalleryModel();
@@ -120,13 +118,16 @@ public LiveData<List<AlbumModel>> getAlbums(){
120118
/*get newest item to set its path for allMedia item*/
121119
List<AlbumModel> temp=new ArrayList<>(imageModelSet);
122120
temp.addAll(videoModelSet);
123-
AlbumModel newest= Collections.max(temp, new Comparator<AlbumModel>() {
124-
@Override
125-
public int compare(AlbumModel o1, AlbumModel o2) {
126-
return Long.compare(o1.getTimeTaken(),o2.getTimeTaken());
127-
}
128-
});
129-
AlbumModel allMedia=new AlbumModel(-1,wContext.get().getString(R.string.sfb_all_media),newest.getImagePath(),0);
121+
AlbumModel newest= null;
122+
if (temp.size() > 0){
123+
newest = Collections.max(temp, new Comparator<AlbumModel>() {
124+
@Override
125+
public int compare(AlbumModel o1, AlbumModel o2) {
126+
return Long.compare(o1.getTimeTaken(),o2.getTimeTaken());
127+
}
128+
});
129+
}
130+
AlbumModel allMedia=new AlbumModel(-1,wContext.get().getString(R.string.sfb_all_media),newest != null ? newest.getImagePath() : "",0);
130131
Set<AlbumModel> albumModelSet=new HashSet<>(temp);
131132
List<AlbumModel> albumModelList=new ArrayList<>(albumModelSet);
132133
albumModelList.add(0,allMedia);

0 commit comments

Comments
 (0)