Skip to content

Commit

Permalink
#180: Allow show image from Uri that cannot be translated to file (i.…
Browse files Browse the repository at this point in the history
…e. WhatsApp photo)
  • Loading branch information
k3b committed Aug 19, 2020
1 parent 57ea45c commit ffb8009
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ private void defineMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_image_detail_locked, menu);
LockScreen.removeDangerousCommandsFromMenu(menu);

} else if (null == getCurrentIFile()) {
} else if (mAdapter != null && mAdapter.isInSingleImageMode()) {
getMenuInflater().inflate(R.menu.menu_image_detail_non_file, menu);
} else {
getMenuInflater().inflate(R.menu.menu_image_detail, menu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,12 @@ public void setIconResourceName(String name) {
mImageButtonController.setContext(name);
}

public boolean isInSingleImageMode() {
return false;
}

private class ImageButtonControllerImpl {
private MenuItem mMenuItem = null ;
private MenuItem mMenuItem = null;
private View.OnClickListener mClickListener;
private final View.OnLongClickListener mLongClickListener;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Cursor swapCursor(Cursor newCursor) {

@Override
public int getCount() {
if (imageUri != null) return 1;
if (isInSingleImageMode()) return 1;
if (mArrayImpl != null) {
return mArrayImpl.getCount();
}
Expand All @@ -86,17 +86,22 @@ public IFile getFullFilePath(int position) {
}

private IFile getLocalFullFilePath(int position) {
if (imageUri != null) return null;
if (isInSingleImageMode()) return null;
if (mArrayImpl != null) return mArrayImpl.getFullFilePathfromArray(position);
return null;
}

public boolean isInSingleImageMode() {
if (imageUri != null) return true;
return super.isInSingleImageMode();
}

/**
* translates offset in adapter to id of image
*/
@Override
public long getImageId(int position) {
if (imageUri != null) return -1;
if (isInSingleImageMode()) return -1;
if (mArrayImpl != null) return mArrayImpl.getImageId(position);
return super.getImageId(position);
}
Expand All @@ -108,7 +113,7 @@ public long getImageId(int position) {
public Uri getImageUri(int position) {
Uri uri = super.getImageUri(position);

if ((uri == null) && (this.imageUri != null)) {
if ((uri == null) && (isInSingleImageMode())) {
uri = this.imageUri;
}

Expand All @@ -117,7 +122,7 @@ public Uri getImageUri(int position) {

@Override
public Date getDatePhotoTaken(int position) {
if (imageUri != null) return null;
if (isInSingleImageMode()) return null;
if (mArrayImpl != null) return null;
return super.getDatePhotoTaken(position);
}
Expand All @@ -130,7 +135,7 @@ public View instantiateItem(ViewGroup container, int position) {
return createViewWithContent(position, container, file, null, "instantiateItemFromArray(#", 32767);
}

if (this.imageUri != null) {
if (isInSingleImageMode()) {
// special case where uri exists and cannot be translated to file uri.
return createViewWithContent(position, container, null, this.imageUri, "instantiateItemFromArray(" + imageUri, 32767);
}
Expand Down

0 comments on commit ffb8009

Please sign in to comment.