Skip to content

Commit b0eaa52

Browse files
Merge pull request #18 from smartdevelopers-ir/v2.0.6
V2.0.6
2 parents 6fde638 + afb98dd commit b0eaa52

30 files changed

+385
-777
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This is Telegram like File Picker for android .
2121

2222
``` gradel
2323
dependencies {
24-
implementation 'com.github.smartdevelopers-ir:SmartFilePicker:2.0.3'
24+
implementation 'com.github.smartdevelopers-ir:SmartFilePicker:2.0.5'
2525
}
2626
```
2727

SmartFileBrowser/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ android {
3434
}
3535
}
3636
group = 'ir.smartdevelopers'
37-
version = '2.0.3'
37+
version = '2.0.5'
3838

3939
dependencies {
4040

SmartFileBrowser/src/main/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@
2727
<activity
2828
android:name=".acitivties.VideoViewActivity"
2929
android:exported="false"
30-
android:theme="@style/sfb_EditorTheme"
30+
android:theme="@style/sfb_AppTheme.sfb_EditorTheme"
3131
android:screenOrientation="locked"
3232
/>
3333
<activity
3434
android:name=".acitivties.PhotoEditorActivity"
3535
android:exported="false"
36-
android:theme="@style/sfb_EditorTheme"
36+
android:theme="@style/sfb_AppTheme.sfb_EditorTheme"
3737
android:screenOrientation="locked"
3838
/>
3939
<activity
4040
android:name=".acitivties.FileBrowserMainActivity"
4141
android:configChanges="keyboard|orientation"
4242
android:launchMode="singleInstance"
43-
android:theme="@style/sfb_MainAppTheme.sfb_AppTheme" /> <!-- <activity -->
43+
android:theme="@style/sfb_AppTheme" /> <!-- <activity -->
4444
<!-- android:name="iamutkarshtiwari.github.io.ananas.editimage.EditImageActivity" -->
4545
<!-- android:exported="true" -->
4646
<!-- android:label="@string/sfb_image_editor_label" -->

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

Lines changed: 110 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
11
package ir.smartdevelopers.smartfilebrowser.acitivties;
22

3-
import androidx.activity.OnBackPressedCallback;
4-
import androidx.annotation.NonNull;
5-
import androidx.annotation.Nullable;
6-
import androidx.appcompat.app.AppCompatActivity;
7-
import androidx.appcompat.widget.AppCompatTextView;
8-
import androidx.constraintlayout.widget.Group;
9-
import androidx.core.app.ActivityCompat;
10-
import androidx.core.app.ActivityOptionsCompat;
11-
import androidx.core.app.SharedElementCallback;
12-
import androidx.core.content.ContextCompat;
13-
import androidx.core.content.FileProvider;
14-
import androidx.core.graphics.Insets;
15-
import androidx.core.graphics.drawable.DrawableKt;
16-
import androidx.core.view.ViewCompat;
17-
import androidx.core.view.WindowCompat;
18-
import androidx.core.view.WindowInsetsCompat;
19-
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
20-
import androidx.lifecycle.LiveData;
21-
import androidx.lifecycle.Observer;
22-
import androidx.lifecycle.ViewModelProvider;
23-
import androidx.recyclerview.widget.LinearLayoutManager;
24-
import androidx.recyclerview.widget.RecyclerView;
25-
263
import android.Manifest;
274
import android.animation.Animator;
285
import android.animation.AnimatorListenerAdapter;
@@ -39,6 +16,7 @@
3916
import android.graphics.Color;
4017
import android.graphics.Rect;
4118
import android.graphics.drawable.ColorDrawable;
19+
import android.graphics.drawable.Drawable;
4220
import android.net.Uri;
4321
import android.os.Build;
4422
import android.os.Bundle;
@@ -67,10 +45,33 @@
6745
import android.widget.TextView;
6846
import android.widget.Toast;
6947

48+
import androidx.activity.OnBackPressedCallback;
49+
import androidx.annotation.NonNull;
50+
import androidx.annotation.Nullable;
51+
import androidx.appcompat.app.AppCompatActivity;
52+
import androidx.appcompat.content.res.AppCompatResources;
53+
import androidx.appcompat.widget.AppCompatTextView;
54+
import androidx.constraintlayout.widget.Group;
55+
import androidx.core.app.ActivityCompat;
56+
import androidx.core.app.ActivityOptionsCompat;
57+
import androidx.core.app.SharedElementCallback;
58+
import androidx.core.content.ContextCompat;
59+
import androidx.core.content.FileProvider;
60+
import androidx.core.graphics.Insets;
61+
import androidx.core.graphics.drawable.DrawableKt;
62+
import androidx.core.view.ViewCompat;
63+
import androidx.core.view.WindowCompat;
64+
import androidx.core.view.WindowInsetsCompat;
65+
import androidx.exifinterface.media.ExifInterface;
66+
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
67+
import androidx.lifecycle.LiveData;
68+
import androidx.lifecycle.Observer;
69+
import androidx.lifecycle.ViewModelProvider;
70+
import androidx.recyclerview.widget.LinearLayoutManager;
71+
import androidx.recyclerview.widget.RecyclerView;
7072

7173
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
7274
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
73-
7475
import com.google.android.material.appbar.AppBarLayout;
7576
import com.google.android.material.bottomsheet.BottomSheetBehavior;
7677

@@ -87,23 +88,23 @@
8788
import ir.smartdevelopers.smartfilebrowser.adapters.AlbumAdapter;
8889
import ir.smartdevelopers.smartfilebrowser.adapters.FileBrowserAdapter;
8990
import ir.smartdevelopers.smartfilebrowser.adapters.GalleryAdapter;
91+
import ir.smartdevelopers.smartfilebrowser.customClasses.FileUtil;
9092
import ir.smartdevelopers.smartfilebrowser.customClasses.GalleryLayoutManager;
9193
import ir.smartdevelopers.smartfilebrowser.customClasses.GalleyItemDecoration;
9294
import ir.smartdevelopers.smartfilebrowser.customClasses.MyBehavior;
93-
import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemLongClickListener;
94-
import ir.smartdevelopers.smartfilebrowser.customClasses.OnSearchListener;
95-
import ir.smartdevelopers.smartfilebrowser.customClasses.ResultListener;
96-
import ir.smartdevelopers.smartfilebrowser.customClasses.Utils;
97-
import ir.smartdevelopers.smartfilebrowser.models.FileModel;
98-
import ir.smartdevelopers.smartfilebrowser.customClasses.FileUtil;
9995
import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemChooseListener;
10096
import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemClickListener;
97+
import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemLongClickListener;
10198
import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemSelectListener;
99+
import ir.smartdevelopers.smartfilebrowser.customClasses.OnSearchListener;
100+
import ir.smartdevelopers.smartfilebrowser.customClasses.ResultListener;
102101
import ir.smartdevelopers.smartfilebrowser.customClasses.RoundLinearLayout;
103102
import ir.smartdevelopers.smartfilebrowser.customClasses.SFBFileFilter;
104103
import ir.smartdevelopers.smartfilebrowser.customClasses.SearchView;
104+
import ir.smartdevelopers.smartfilebrowser.customClasses.Utils;
105105
import ir.smartdevelopers.smartfilebrowser.models.AlbumModel;
106106
import ir.smartdevelopers.smartfilebrowser.models.FileBrowserModel;
107+
import ir.smartdevelopers.smartfilebrowser.models.FileModel;
107108
import ir.smartdevelopers.smartfilebrowser.models.GalleryModel;
108109
import ir.smartdevelopers.smartfilebrowser.viewModel.FilesViewModel;
109110
import ir.smartdevelopers.smartfilebrowser.viewModel.GalleryViewModel;
@@ -244,8 +245,9 @@ public boolean accept(File pathname) {
244245

245246
@Override
246247
protected void onCreate(Bundle savedInstanceState) {
247-
setTheme(R.style.sfb_MainAppTheme_sfb_AppTheme);
248+
setTheme(R.style.sfb_AppTheme);
248249
Window window = getWindow();
250+
// window.setSharedElementsUseOverlay(false);
249251
WindowCompat.enableEdgeToEdge(window);
250252
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
251253
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
@@ -732,11 +734,11 @@ public void onItemClicked(GalleryModel model, View view, int position) {
732734
}
733735
};
734736
}
735-
736737
private void openVideoActivity(GalleryModel model, View view, int position) {
737738
Uri uri = FileProvider.getUriForFile(this, getPackageName() + ".sfb_provider", model.getCurrentFile());
738739
Intent videoActivityIntent = new Intent(this, VideoViewActivity.class);
739740
videoActivityIntent.setData(uri);
741+
740742
Bundle options = null;
741743
if (view != null) {
742744
String sharedName = ViewCompat.getTransitionName(view);
@@ -746,7 +748,8 @@ private void openVideoActivity(GalleryModel model, View view, int position) {
746748
options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, view, sharedName).toBundle();
747749
videoActivityIntent.putExtra(VideoViewActivity.KEY_TRANSITION_NAME, sharedName);
748750
}
749-
ActivityCompat.startActivity(this, videoActivityIntent, options);
751+
ActivityCompat.startActivityForResult(this,videoActivityIntent,696987, options);
752+
// ContextCompat.startActivity(this,videoActivityIntent, options);
750753
}
751754

752755
private void openImageEditor(GalleryModel model, View view, int position) {
@@ -758,11 +761,13 @@ private void openImageEditor(GalleryModel model, View view, int position) {
758761
Intent editorIntent = new Intent(this, PhotoEditorActivity.class);
759762
editorIntent.setData(uri);
760763
if (view instanceof ImageView){
761-
Rect rect = Utils.calculateBitmapBound(getResources(),model);
762-
Bitmap preview = DrawableKt.toBitmap(((ImageView) view).getDrawable(),rect.width(),rect.height(), Bitmap.Config.ARGB_8888);
763-
764-
PhotoEditorActivity.Preview = preview;
764+
Drawable d = ((ImageView) view).getDrawable();
765+
if (d != null){
766+
Rect rect = Utils.calculateBitmapBound(getResources(),model);
767+
PhotoEditorActivity.Preview = DrawableKt.toBitmap(d,rect.width(),rect.height(), Bitmap.Config.ARGB_8888);
768+
}
765769
}
770+
766771
editorIntent.putExtra(PhotoEditorActivity.KEY_SAVE_PATH, mEditedImagePath);
767772
Bundle options = null;
768773
if (view != null) {
@@ -804,25 +809,39 @@ private void setFileBrowserEnabled(boolean enabled) {
804809
mFileBrowserEnabled = enabled;
805810
}
806811

807-
812+
private AHBottomNavigationItem createNavItem(int colorAttr, int titleRes, int iconRes){
813+
TypedValue value = new TypedValue();
814+
getTheme().resolveAttribute(colorAttr,value,true);
815+
return new AHBottomNavigationItem(
816+
getString(titleRes),
817+
AppCompatResources.getDrawable(this,iconRes),
818+
value.data);
819+
}
808820
private void initViews(Bundle savedInstanceState) {
809821

822+
int[] attrs={R.attr.SFBColorGallery,R.attr.SFBColorPDF,R.attr.SFBColorAudio,R.attr.SFBColorFile};
823+
810824
if (mShowGalleryTab) {
811-
AHBottomNavigationItem gallery = new AHBottomNavigationItem(R.string.sfb_gallery, R.drawable.sfb_ic_gallery, R.color.sfb_color_gallery);
812-
mBottomNavigationView.addItem(gallery);
825+
mBottomNavigationView.addItem(createNavItem(attrs[0],R.string.sfb_gallery,R.drawable.sfb_ic_gallery));
813826
}
814827
if (mShowPDFTab) {
815-
AHBottomNavigationItem pdf = new AHBottomNavigationItem(R.string.sfb_PDF, R.drawable.sfb_ic_pdf, R.color.sfb_color_pdf);
816-
mBottomNavigationView.addItem(pdf);
828+
mBottomNavigationView.addItem(createNavItem(attrs[1],R.string.sfb_PDF, R.drawable.sfb_ic_pdf));
817829
}
818830
if (mShowAudioTab) {
819-
AHBottomNavigationItem audio = new AHBottomNavigationItem(R.string.sfb_audio, R.drawable.sfb_ic_square_audio, R.color.sfb_color_audio);
820-
mBottomNavigationView.addItem(audio);
831+
mBottomNavigationView.addItem(createNavItem(attrs[2],R.string.sfb_audio, R.drawable.sfb_ic_square_audio));
821832
}
822833
if (mShowFilesTab) {
823-
AHBottomNavigationItem files = new AHBottomNavigationItem(R.string.sfb_file, R.drawable.sfb_ic_file, R.color.sfb_color_file);
824-
mBottomNavigationView.addItem(files);
825-
}
834+
mBottomNavigationView.addItem(createNavItem(attrs[3],R.string.sfb_file, R.drawable.sfb_ic_file));
835+
}
836+
TypedValue value = new TypedValue();
837+
getTheme().resolveAttribute(R.attr.SFBBottomNavActiveColor,value,true);
838+
int colorActive = value.data;
839+
getTheme().resolveAttribute(R.attr.SFBBottomNavInactiveColor,value,true);
840+
int colorInactive = value.data;
841+
mBottomNavigationView.setColoredModeColors(colorActive,colorInactive);
842+
getTheme().resolveAttribute(R.attr.SFBBottomNavColorDisabled,value,true);
843+
int colorDisabled = value.data;
844+
mBottomNavigationView.setItemDisableColor(colorDisabled);
826845
mBottomNavigationView.setOnTabSelectedListener(mOnMenuItemSelectionListener);
827846
mBottomNavigationView.setColored(true);
828847
mBottomNavigationView.setUseElevation(true);
@@ -1213,7 +1232,7 @@ public void onChanged(List<AlbumModel> albumModels) {
12131232
mAlbumListIsShowing = true;
12141233
int duration = animate ? 100 : 0;
12151234
FrameLayout albumPlaceHolderRoot = findViewById(R.id.fileBrowser_activity_main_albumPlaceHolderRoot);
1216-
1235+
albumPlaceHolderRoot.setAlpha(0);
12171236
mAlbumPlaceHolder.post(() -> {
12181237
AppCompatTextView spnSelectAlbum = findViewById(R.id.fileBrowser_activity_main_spnSelectAlbum);
12191238
int[] location = new int[2];
@@ -1223,6 +1242,18 @@ public void onChanged(List<AlbumModel> albumModels) {
12231242
mAlbumPlaceHolder.setX(x);
12241243
mAlbumPlaceHolder.setY(y);
12251244
mAlbumPlaceHolder.animate().setDuration(duration).scaleY(1).scaleX(1).alpha(1)
1245+
.setUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
1246+
@Override
1247+
public void onAnimationUpdate(@NonNull ValueAnimator animation) {
1248+
float alpha = 0;
1249+
if (mAlbumListIsShowing){
1250+
alpha = animation.getAnimatedFraction();
1251+
}else{
1252+
alpha = 1 - animation.getAnimatedFraction();
1253+
}
1254+
albumPlaceHolderRoot.setAlpha(alpha);
1255+
}
1256+
})
12261257
.withStartAction(() -> {
12271258
mAlbumPlaceHolder.setAlpha(0);
12281259
mAlbumPlaceHolder.setScaleY(0);
@@ -1237,6 +1268,9 @@ public void onChanged(List<AlbumModel> albumModels) {
12371268
@SuppressLint("ClickableViewAccessibility")
12381269
@Override
12391270
public boolean onTouch(View v, MotionEvent event) {
1271+
if (!mAlbumListIsShowing){
1272+
return false;
1273+
}
12401274
hideAlbumList(true);
12411275
return true;
12421276
}
@@ -1879,15 +1913,43 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
18791913
if (requestCode == REQ_CODE_TACK_PICTURE) {
18801914
if (resultCode == Activity.RESULT_OK) {
18811915
File takenPic = new File(tackingPictureFilePath);
1916+
18821917
if (takenPic.isFile()) {
1918+
int width = 0;
1919+
int height = 0;
1920+
int orientation = 0;
1921+
18831922
FileUtil.scanMediaFile(this, takenPic);
1923+
try {
1924+
ExifInterface exifInterface = new ExifInterface(takenPic);
1925+
width = exifInterface.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0);
1926+
height = exifInterface.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0);
1927+
int orint = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0);
1928+
switch (orint) {
1929+
case ExifInterface.ORIENTATION_ROTATE_90:
1930+
orientation = 90;
1931+
break;
1932+
case ExifInterface.ORIENTATION_ROTATE_180:
1933+
orientation = 180;
1934+
break;
1935+
case ExifInterface.ORIENTATION_ROTATE_270:
1936+
orientation = 270;
1937+
break;
1938+
}
1939+
} catch (Exception ignore) {
1940+
1941+
}
1942+
18841943
GalleryModel newPicModel = new GalleryModel();
18851944
newPicModel.setType(FileUtil.TYPE_IMAGE);
18861945
newPicModel.setSelected(true);
18871946
newPicModel.setName(takenPic.getName());
18881947
newPicModel.setPath(takenPic.getPath());
18891948
newPicModel.setUri(FileProvider.getUriForFile(getApplicationContext(),
18901949
getPackageName() + ".sfb_provider", takenPic));
1950+
newPicModel.setWidth(width);
1951+
newPicModel.setHeight(height);
1952+
newPicModel.setOrientation(orientation);
18911953
mGalleryAdapter.addNewPic(newPicModel);
18921954

18931955
}

0 commit comments

Comments
 (0)