Skip to content

Commit

Permalink
Enabled overlay in preview while organizing
Browse files Browse the repository at this point in the history
  • Loading branch information
jeisfeld committed Jun 20, 2015
1 parent 7447029 commit fb402fe
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected final void onCreate(final Bundle savedInstanceState) {
if (fragmentImage == null) {
fragmentImage = new DisplayImageFragment();
if (type == TYPE_FILENAME) {
fragmentImage.setParameters(file, 1);
fragmentImage.setParameters(file, 1, null);
}
else {
fragmentImage.setParameters(fileResource, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import de.eisfeldj.augendiagnose.fragments.EditCommentFragment;
import de.eisfeldj.augendiagnose.util.AutoKeyboardLayoutUtility;
import de.eisfeldj.augendiagnose.util.DialogUtil;
import de.eisfeldj.augendiagnose.util.EyePhoto.RightLeft;

/**
* Activity to display two pictures on full screen (screen split in two halves).
Expand All @@ -23,6 +24,10 @@ public class DisplayTwoActivity extends DisplayImageActivity {
* The resource key for the second file to be displayed.
*/
private static final String STRING_EXTRA_FILE2 = "de.eisfeldj.augendiagnose.FILE2";
/**
* The resource key for the flag indicating if images should be pre-configured as right/left.
*/
private static final String BOOLEAN_EXTRA_PRESETRIGHTLEFT = "de.eisfeldj.augendiagnose.PRESETRIGHTLEFT";

/**
* The fragment tag for the first image fragment.
Expand All @@ -33,6 +38,11 @@ public class DisplayTwoActivity extends DisplayImageActivity {
*/
private static final String FRAGMENT_IMAGE2_TAG = "FRAGMENT_IMAGE2_TAG";

/**
* Flag indicating if the images are flagged right/left independent of the metadata.
*/
private boolean presetRightLeft;

/**
* The views displaying the files.
*/
Expand All @@ -58,11 +68,15 @@ public class DisplayTwoActivity extends DisplayImageActivity {
* The filename of the first picture.
* @param filename2
* The filename of the second picture.
* @param presetRightLeft
* Flag indicating if the images are flagged right/left independent of the metadata.
*/
public static void startActivity(final Context context, final String filename1, final String filename2) {
public static void startActivity(final Context context, final String filename1, final String filename2,
final boolean presetRightLeft) {
Intent intent = new Intent(context, DisplayTwoActivity.class);
intent.putExtra(STRING_EXTRA_FILE1, filename1);
intent.putExtra(STRING_EXTRA_FILE2, filename2);
intent.putExtra(BOOLEAN_EXTRA_PRESETRIGHTLEFT, presetRightLeft);
context.startActivity(intent);
}

Expand All @@ -75,13 +89,14 @@ public final void onCreate(final Bundle savedInstanceState) {

String file1 = getIntent().getStringExtra(STRING_EXTRA_FILE1);
String file2 = getIntent().getStringExtra(STRING_EXTRA_FILE2);
presetRightLeft = getIntent().getBooleanExtra(BOOLEAN_EXTRA_PRESETRIGHTLEFT, false);

setContentView(R.layout.activity_display_two);

fragmentImage1 = (DisplayImageFragment) getFragmentManager().findFragmentByTag(FRAGMENT_IMAGE1_TAG);
if (fragmentImage1 == null) {
fragmentImage1 = createFragment();
fragmentImage1.setParameters(file1, 1);
fragmentImage1.setParameters(file1, 1, presetRightLeft ? RightLeft.RIGHT : null);

getFragmentManager().beginTransaction().add(R.id.fragment_image1, fragmentImage1, FRAGMENT_IMAGE1_TAG)
.commit();
Expand All @@ -90,7 +105,7 @@ public final void onCreate(final Bundle savedInstanceState) {
fragmentImage2 = (DisplayImageFragment) getFragmentManager().findFragmentByTag(FRAGMENT_IMAGE2_TAG);
if (fragmentImage2 == null) {
fragmentImage2 = createFragment();
fragmentImage2.setParameters(file2, 2);
fragmentImage2.setParameters(file2, 2, presetRightLeft ? RightLeft.LEFT : null);

getFragmentManager().beginTransaction().add(R.id.fragment_image2, fragmentImage2, FRAGMENT_IMAGE2_TAG)
.commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public final void setDate(final int yearSelected, final int monthOfYear, final i
* The view triggering the onClick action.
*/
public final void displayNewImages(final View view) {
DisplayTwoActivity.startActivity(this, photoRight.getAbsolutePath(), photoLeft.getAbsolutePath());
DisplayTwoActivity.startActivity(this, photoRight.getAbsolutePath(), photoLeft.getAbsolutePath(), true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ public final View getView(final int position, final View convertView, final View
@Override
public void onClick(final View v) {
ImageSelectionAndDisplayHandler.getInstance().cleanSelectedViews();
DisplayTwoActivity.startActivity(ListPicturesForNameArrayAdapter.this.activity, eyePhotoPairs[position]
.getRightEye().getAbsolutePath(), eyePhotoPairs[position].getLeftEye().getAbsolutePath());
DisplayTwoActivity
.startActivity(ListPicturesForNameArrayAdapter.this.activity, eyePhotoPairs[position]
.getRightEye().getAbsolutePath(), eyePhotoPairs[position].getLeftEye()
.getAbsolutePath(), true);

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import de.eisfeldj.augendiagnose.components.colorpicker.ColorPickerDialog;
import de.eisfeldj.augendiagnose.components.colorpicker.ColorPickerSwatch.OnColorSelectedListener;
import de.eisfeldj.augendiagnose.util.DialogUtil;
import de.eisfeldj.augendiagnose.util.EyePhoto.RightLeft;
import de.eisfeldj.augendiagnose.util.PreferenceUtil;

/**
Expand Down Expand Up @@ -60,6 +61,10 @@ public class DisplayImageFragment extends Fragment implements GuiElementUpdater,
* The resource kay for the image index (in case of multiple images).
*/
protected static final String STRING_IMAGEINDEX = "de.eisfeldj.augendiagnose.IMAGEINDEX";
/**
* The resource kay for the rightleft information (if not contained in the image).
*/
protected static final String STRING_RIGHTLEFT = "de.eisfeldj.augendiagnose.RIGHTLEFT";

/**
* Type value set if the fragment shows an image by filename.
Expand Down Expand Up @@ -90,6 +95,11 @@ public class DisplayImageFragment extends Fragment implements GuiElementUpdater,
*/
private int imageIndex;

/**
* Information if right or left image.
*/
private RightLeft rightLeft;

/**
* Flag indicating if overlays are allowed.
*/
Expand Down Expand Up @@ -190,13 +200,19 @@ protected final void setLandscape(final boolean newIsLandscape) {
* the file path.
* @param initialImageIndex
* The index of the view (required if there are multiple such fragments)
* @param initialRightLeft
* Information if it is the right or left eye (if not in image metadata)
* @return
*/
public final void setParameters(final String initialFile, final int initialImageIndex) {
public final void setParameters(final String initialFile, final int initialImageIndex,
final RightLeft initialRightLeft) {
Bundle args = new Bundle();
args.putString(STRING_FILE, initialFile);
args.putInt(STRING_TYPE, TYPE_FILENAME);
args.putInt(STRING_IMAGEINDEX, initialImageIndex);
if (initialRightLeft != null) {
args.putSerializable(STRING_RIGHTLEFT, initialRightLeft);
}

setArguments(args);
}
Expand Down Expand Up @@ -229,6 +245,7 @@ public final void onCreate(final Bundle savedInstanceState) {
file = getArguments().getString(STRING_FILE);
fileResource = getArguments().getInt(STRING_FILERESOURCE, -1);
imageIndex = getArguments().getInt(STRING_IMAGEINDEX, 0);
rightLeft = (RightLeft) getArguments().getSerializable(STRING_RIGHTLEFT);
}

/*
Expand Down Expand Up @@ -618,6 +635,10 @@ public final void initializeImages() {
imageView.setImage(file, getActivity(), imageIndex);
}

if (imageView.getEyePhoto().getRightLeft() == null && rightLeft != null) {
imageView.getEyePhoto().setRightLeft(rightLeft);
}

if (!imageView.canHandleOverlays()) {
getView().findViewById(R.id.buttonOverlayLayout).setVisibility(View.GONE);
allowOverlays = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public final RightLeft getRightLeft() {
return rightLeft;
}

private void setRightLeft(final RightLeft rightLeft) {
public final void setRightLeft(final RightLeft rightLeft) {
this.rightLeft = rightLeft;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ else if (isSelectedView(view)) {
}
else {
DisplayTwoActivity.startActivity(activity, getSelectedImage().getAbsolutePath(), view.getEyePhoto()
.getAbsolutePath());
.getAbsolutePath(), false);
cleanSelectedViews();
}
}
Expand Down Expand Up @@ -151,7 +151,7 @@ public void prepareViewForSecondSelection(final EyeImageView view) {
public void onClick(final View v) {
DisplayTwoActivity
.startActivity(activity, getSelectedImage().getAbsolutePath(), view.getEyePhoto()
.getAbsolutePath());
.getAbsolutePath(), false);
cleanSelectedViews();
secondActivity.finish();
}
Expand Down

0 comments on commit fb402fe

Please sign in to comment.