|
1 | 1 | package ir.smartdevelopers.smartfilebrowser.acitivties; |
2 | 2 |
|
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.content.res.AppCompatResources; |
8 | | -import androidx.appcompat.widget.AppCompatTextView; |
9 | | -import androidx.constraintlayout.widget.Group; |
10 | | -import androidx.core.app.ActivityCompat; |
11 | | -import androidx.core.app.ActivityOptionsCompat; |
12 | | -import androidx.core.app.SharedElementCallback; |
13 | | -import androidx.core.content.ContextCompat; |
14 | | -import androidx.core.content.FileProvider; |
15 | | -import androidx.core.graphics.Insets; |
16 | | -import androidx.core.graphics.drawable.DrawableKt; |
17 | | -import androidx.core.view.ViewCompat; |
18 | | -import androidx.core.view.WindowCompat; |
19 | | -import androidx.core.view.WindowInsetsCompat; |
20 | | -import androidx.interpolator.view.animation.FastOutSlowInInterpolator; |
21 | | -import androidx.lifecycle.LiveData; |
22 | | -import androidx.lifecycle.Observer; |
23 | | -import androidx.lifecycle.ViewModelProvider; |
24 | | -import androidx.recyclerview.widget.LinearLayoutManager; |
25 | | -import androidx.recyclerview.widget.RecyclerView; |
26 | | - |
27 | 3 | import android.Manifest; |
28 | 4 | import android.animation.Animator; |
29 | 5 | import android.animation.AnimatorListenerAdapter; |
|
69 | 45 | import android.widget.TextView; |
70 | 46 | import android.widget.Toast; |
71 | 47 |
|
| 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; |
72 | 72 |
|
73 | 73 | import com.aurelhubert.ahbottomnavigation.AHBottomNavigation; |
74 | 74 | import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem; |
75 | | - |
76 | 75 | import com.google.android.material.appbar.AppBarLayout; |
77 | 76 | import com.google.android.material.bottomsheet.BottomSheetBehavior; |
78 | 77 |
|
|
89 | 88 | import ir.smartdevelopers.smartfilebrowser.adapters.AlbumAdapter; |
90 | 89 | import ir.smartdevelopers.smartfilebrowser.adapters.FileBrowserAdapter; |
91 | 90 | import ir.smartdevelopers.smartfilebrowser.adapters.GalleryAdapter; |
| 91 | +import ir.smartdevelopers.smartfilebrowser.customClasses.FileUtil; |
92 | 92 | import ir.smartdevelopers.smartfilebrowser.customClasses.GalleryLayoutManager; |
93 | 93 | import ir.smartdevelopers.smartfilebrowser.customClasses.GalleyItemDecoration; |
94 | 94 | import ir.smartdevelopers.smartfilebrowser.customClasses.MyBehavior; |
95 | | -import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemLongClickListener; |
96 | | -import ir.smartdevelopers.smartfilebrowser.customClasses.OnSearchListener; |
97 | | -import ir.smartdevelopers.smartfilebrowser.customClasses.ResultListener; |
98 | | -import ir.smartdevelopers.smartfilebrowser.customClasses.Utils; |
99 | | -import ir.smartdevelopers.smartfilebrowser.models.FileModel; |
100 | | -import ir.smartdevelopers.smartfilebrowser.customClasses.FileUtil; |
101 | 95 | import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemChooseListener; |
102 | 96 | import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemClickListener; |
| 97 | +import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemLongClickListener; |
103 | 98 | import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemSelectListener; |
| 99 | +import ir.smartdevelopers.smartfilebrowser.customClasses.OnSearchListener; |
| 100 | +import ir.smartdevelopers.smartfilebrowser.customClasses.ResultListener; |
104 | 101 | import ir.smartdevelopers.smartfilebrowser.customClasses.RoundLinearLayout; |
105 | 102 | import ir.smartdevelopers.smartfilebrowser.customClasses.SFBFileFilter; |
106 | 103 | import ir.smartdevelopers.smartfilebrowser.customClasses.SearchView; |
| 104 | +import ir.smartdevelopers.smartfilebrowser.customClasses.Utils; |
107 | 105 | import ir.smartdevelopers.smartfilebrowser.models.AlbumModel; |
108 | 106 | import ir.smartdevelopers.smartfilebrowser.models.FileBrowserModel; |
| 107 | +import ir.smartdevelopers.smartfilebrowser.models.FileModel; |
109 | 108 | import ir.smartdevelopers.smartfilebrowser.models.GalleryModel; |
110 | 109 | import ir.smartdevelopers.smartfilebrowser.viewModel.FilesViewModel; |
111 | 110 | import ir.smartdevelopers.smartfilebrowser.viewModel.GalleryViewModel; |
@@ -1914,15 +1913,43 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten |
1914 | 1913 | if (requestCode == REQ_CODE_TACK_PICTURE) { |
1915 | 1914 | if (resultCode == Activity.RESULT_OK) { |
1916 | 1915 | File takenPic = new File(tackingPictureFilePath); |
| 1916 | + |
1917 | 1917 | if (takenPic.isFile()) { |
| 1918 | + int width = 0; |
| 1919 | + int height = 0; |
| 1920 | + int orientation = 0; |
| 1921 | + |
1918 | 1922 | 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 | + |
1919 | 1943 | GalleryModel newPicModel = new GalleryModel(); |
1920 | 1944 | newPicModel.setType(FileUtil.TYPE_IMAGE); |
1921 | 1945 | newPicModel.setSelected(true); |
1922 | 1946 | newPicModel.setName(takenPic.getName()); |
1923 | 1947 | newPicModel.setPath(takenPic.getPath()); |
1924 | 1948 | newPicModel.setUri(FileProvider.getUriForFile(getApplicationContext(), |
1925 | 1949 | getPackageName() + ".sfb_provider", takenPic)); |
| 1950 | + newPicModel.setWidth(width); |
| 1951 | + newPicModel.setHeight(height); |
| 1952 | + newPicModel.setOrientation(orientation); |
1926 | 1953 | mGalleryAdapter.addNewPic(newPicModel); |
1927 | 1954 |
|
1928 | 1955 | } |
|
0 commit comments