do not display videos if the app is used as an image chooser
This commit is contained in:
parent
b36e85844d
commit
99a2ea6829
3 changed files with 16 additions and 5 deletions
|
@ -3,5 +3,5 @@ package com.simplemobiletools.gallery;
|
|||
public class Constants {
|
||||
public static final String DIRECTORY = "directory";
|
||||
public static final String MEDIUM = "medium";
|
||||
public static final String PICK_INTENT = "is_pick_intent";
|
||||
public static final String PICK_IMAGE_INTENT = "is_image_pick_intent";
|
||||
}
|
||||
|
|
|
@ -55,12 +55,14 @@ public class MainActivity extends AppCompatActivity
|
|||
private List<String> toBeDeleted;
|
||||
private ActionMode actionMode;
|
||||
private Parcelable state;
|
||||
private boolean isImagePickIntent;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
ButterKnife.bind(this);
|
||||
isImagePickIntent = isImagePickIntent(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,6 +139,9 @@ public class MainActivity extends AppCompatActivity
|
|||
for (int i = 0; i < 2; i++) {
|
||||
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
if (i == 1) {
|
||||
if (isImagePickIntent)
|
||||
continue;
|
||||
|
||||
uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
final String[] columns = {MediaStore.Images.Media.DATA};
|
||||
|
@ -319,8 +324,9 @@ public class MainActivity extends AppCompatActivity
|
|||
});
|
||||
}
|
||||
|
||||
private boolean isPickIntent(Intent intent) {
|
||||
return intent != null && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_PICK);
|
||||
private boolean isImagePickIntent(Intent intent) {
|
||||
return intent != null && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_PICK) &&
|
||||
intent.getData().equals(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -338,7 +344,7 @@ public class MainActivity extends AppCompatActivity
|
|||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final Intent intent = new Intent(this, MediaActivity.class);
|
||||
intent.putExtra(Constants.DIRECTORY, dirs.get(position).getPath());
|
||||
intent.putExtra(Constants.PICK_INTENT, isPickIntent(getIntent()));
|
||||
intent.putExtra(Constants.PICK_IMAGE_INTENT, isImagePickIntent);
|
||||
startActivityForResult(intent, PICK_IMAGE);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,12 +47,14 @@ public class MediaActivity extends AppCompatActivity
|
|||
private boolean isSnackbarShown;
|
||||
private List<String> toBeDeleted;
|
||||
private Parcelable state;
|
||||
private boolean isImagePickIntent;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_media);
|
||||
ButterKnife.bind(this);
|
||||
isImagePickIntent = getIntent().getBooleanExtra(Constants.PICK_IMAGE_INTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,6 +112,9 @@ public class MediaActivity extends AppCompatActivity
|
|||
for (int i = 0; i < 2; i++) {
|
||||
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
if (i == 1) {
|
||||
if (isImagePickIntent)
|
||||
continue;
|
||||
|
||||
uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
final String where = MediaStore.Images.Media.DATA + " like ? ";
|
||||
|
@ -234,7 +239,7 @@ public class MediaActivity extends AppCompatActivity
|
|||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (getIntent().getBooleanExtra(Constants.PICK_INTENT, false)) {
|
||||
if (isImagePickIntent) {
|
||||
final Intent result = new Intent();
|
||||
result.setData(Uri.parse(media.get(position).getPath()));
|
||||
setResult(RESULT_OK, result);
|
||||
|
|
Loading…
Reference in a new issue