Skip to content

Commit eb6b687

Browse files
committed
2021/11/15
added new image editor
1 parent 60218e4 commit eb6b687

File tree

4 files changed

+61
-13
lines changed

4 files changed

+61
-13
lines changed

SmartFileBrowser/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ task javadocJar2(type: Jar) {
4242
}
4343
dependencies {
4444

45-
implementation 'androidx.appcompat:appcompat:1.3.1'
45+
implementation 'androidx.appcompat:appcompat:1.4.0'
4646
implementation 'com.google.android.material:material:1.4.0'
47-
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
47+
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
4848
implementation 'com.github.bumptech.glide:glide:4.12.0'
4949
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
5050
// implementation 'it.sephiroth.android.library.bottomnavigation:bottom-navigation:3.0.0'
@@ -57,7 +57,7 @@ dependencies {
5757
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
5858
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
5959
implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version"
60-
implementation 'com.github.smartdevelopers-ir:PhotoEditor:1.1.0'
60+
implementation 'com.github.smartdevelopers-ir:PhotoEditor:1.1.1'
6161
// implementation 'ir.smartdevelopers:photo-editor:1.1.0'
6262
}
6363
afterEvaluate{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void onMapSharedElements(List<String> names, Map<String, View> sharedElem
194194
for (View view:sharedElements.values()){
195195
if (view instanceof ImageView){
196196
if (mResultListener.getSavedBitmap()!=null){
197-
((ImageView) view).setImageBitmap(mResultListener.getSavedBitmap());
197+
((ImageView) view).setImageBitmap(mResultListener.getSavedBitmap().copy(Bitmap.Config.ARGB_8888,true));
198198
mResultListener.setSavedBitmap(null);
199199
}
200200
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@
4343

4444
public class PhotoEditorActivity extends AppCompatActivity {
4545

46-
public static final String KEY_PHOTO_URI = "photo_uri";
4746
public static final String KEY_TRANSITION_NAME = "transition_name";
4847
public static final String KEY_SAVE_PATH = "save_path";
49-
public static final String KEY_IS_EDITED = "is_edited";
50-
public static final String KEY_THUMBNAIL = "thumbnail";
48+
5149

5250
private PhotoEditorFragment mPhotoEditorFragment;
5351
private ImageButton btnDone;

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

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
import android.content.ContentResolver;
66
import android.content.Context;
77
import android.database.Cursor;
8+
import android.net.Uri;
9+
import android.os.Build;
10+
import android.os.Bundle;
811
import android.provider.MediaStore;
912
import android.text.TextUtils;
1013

14+
import androidx.annotation.Nullable;
15+
import androidx.core.content.ContentResolverCompat;
1116
import androidx.lifecycle.LiveData;
1217
import androidx.lifecycle.MutableLiveData;
1318

@@ -31,9 +36,9 @@
3136
import ir.smartdevelopers.smartfilebrowser.models.GalleryModel;
3237

3338
public class Repository {
34-
private ExecutorService mExecutorService;
35-
private ContentResolver mContentResolver;
36-
private WeakReference<Context> wContext;
39+
private final ExecutorService mExecutorService;
40+
private final ContentResolver mContentResolver;
41+
private final WeakReference<Context> wContext;
3742
private MutableLiveData<List<GalleryModel>> galleryList;
3843
public Repository(Application application) {
3944
mExecutorService= Executors.newCachedThreadPool();
@@ -165,7 +170,7 @@ private List<GalleryModel> getGalleryModel(Cursor cursor,String[] projection){
165170

166171
/**
167172
* @param modelType is one of {@link FileBrowserModel} model types
168-
* @param filesLiveData */
173+
**/
169174
public void getFirstBrowserPageList(String selection,String[] selectionArgs, int modelType,
170175
FileFilter fileFilter,
171176
MutableLiveData<List<FileBrowserModel>> filesLiveData){
@@ -184,8 +189,27 @@ public void getFirstBrowserPageList(String selection,String[] selectionArgs, int
184189
MediaStore.Files.FileColumns.DATA,
185190
MediaStore.Files.FileColumns.MIME_TYPE};
186191

187-
Cursor cursor=mContentResolver.query(MediaStore.Files.getContentUri("external"),projection, finalSelection,
188-
selectionArgs, MediaStore.MediaColumns.DATE_ADDED+" DESC LIMIT 30");
192+
193+
Cursor cursor=getCursor(MediaStore.Files.getContentUri("external"),
194+
projection,finalSelection,selectionArgs,
195+
MediaStore.MediaColumns.DATE_ADDED+" DESC" ,30);
196+
// if (Build.VERSION.SDK_INT>=26){
197+
// Bundle args=new Bundle();
198+
//// args.putInt(ContentResolver.QUERY_ARG_LIMIT,30);
199+
//// args.putInt(ContentResolver.QUERY_ARG_SORT_DIRECTION,ContentResolver.QUERY_SORT_DIRECTION_DESCENDING);
200+
//// args.putString(ContentResolver.QUERY_ARG_SORT_COLUMNS,MediaStore.MediaColumns.DATE_ADDED);
201+
//// args.putString(ContentResolver.Que,MediaStore.MediaColumns.DATE_ADDED);
202+
// args.putString(ContentResolver.QUERY_ARG_SQL_SELECTION,finalSelection);
203+
// args.putStringArray(ContentResolver.QUERY_ARG_SQL_SELECTION_ARGS,selectionArgs);
204+
// cursor=mContentResolver.query(MediaStore.Files.getContentUri("external"),
205+
// projection,args,null);
206+
// }else {
207+
// cursor =mContentResolver.query(MediaStore.Files.getContentUri("external"),
208+
// projection, finalSelection,
209+
// selectionArgs,
210+
// MediaStore.MediaColumns.DATE_ADDED+" DESC LIMIT 30");
211+
// }
212+
189213
int idIndex=cursor.getColumnIndex(projection[0]);
190214
int pathIndex=cursor.getColumnIndex(projection[1]);
191215
// int dateIndex=cursor.getColumnIndex(projection[2]);
@@ -221,4 +245,30 @@ public void getFirstBrowserPageList(String selection,String[] selectionArgs, int
221245

222246

223247
}
248+
249+
private Cursor getCursor(Uri uri,String[] projection,String selection,
250+
String[] selectionArgs,String sortOrder,@Nullable Integer limit){
251+
Cursor cursor;
252+
if (Build.VERSION.SDK_INT>=26){
253+
Bundle args=new Bundle();
254+
args.putString(ContentResolver.QUERY_ARG_SQL_SELECTION,selection);
255+
args.putStringArray(ContentResolver.QUERY_ARG_SQL_SELECTION_ARGS,selectionArgs);
256+
args.putString(ContentResolver.QUERY_ARG_SQL_SORT_ORDER,sortOrder);
257+
if (limit !=null){
258+
args.putInt(ContentResolver.QUERY_ARG_LIMIT,limit);
259+
}
260+
cursor=mContentResolver.query(uri,
261+
projection,args,null);
262+
}else {
263+
String sOrder=sortOrder;
264+
if (limit != null) {
265+
sOrder=sortOrder+" LIMIT "+limit;
266+
}
267+
cursor =mContentResolver.query(uri,
268+
projection, selection,
269+
selectionArgs,
270+
sOrder);
271+
}
272+
return cursor;
273+
}
224274
}

0 commit comments

Comments
 (0)