diff --git a/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/DisplayOneActivity.java b/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/DisplayOneActivity.java index 158f6521..08f147d2 100644 --- a/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/DisplayOneActivity.java +++ b/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/DisplayOneActivity.java @@ -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); diff --git a/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/DisplayTwoActivity.java b/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/DisplayTwoActivity.java index beaa4c2d..7b0c6d25 100644 --- a/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/DisplayTwoActivity.java +++ b/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/DisplayTwoActivity.java @@ -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). @@ -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. @@ -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. */ @@ -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); } @@ -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(); @@ -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(); diff --git a/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/OrganizeNewPhotosActivity.java b/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/OrganizeNewPhotosActivity.java index 4196d69e..c8405735 100644 --- a/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/OrganizeNewPhotosActivity.java +++ b/Augendiagnose/src/de/eisfeldj/augendiagnose/activities/OrganizeNewPhotosActivity.java @@ -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); } /** diff --git a/Augendiagnose/src/de/eisfeldj/augendiagnose/components/ListPicturesForNameArrayAdapter.java b/Augendiagnose/src/de/eisfeldj/augendiagnose/components/ListPicturesForNameArrayAdapter.java index 2c4b7237..6b23f000 100644 --- a/Augendiagnose/src/de/eisfeldj/augendiagnose/components/ListPicturesForNameArrayAdapter.java +++ b/Augendiagnose/src/de/eisfeldj/augendiagnose/components/ListPicturesForNameArrayAdapter.java @@ -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); } }); diff --git a/Augendiagnose/src/de/eisfeldj/augendiagnose/fragments/DisplayImageFragment.java b/Augendiagnose/src/de/eisfeldj/augendiagnose/fragments/DisplayImageFragment.java index ee90e5a2..53ea258b 100644 --- a/Augendiagnose/src/de/eisfeldj/augendiagnose/fragments/DisplayImageFragment.java +++ b/Augendiagnose/src/de/eisfeldj/augendiagnose/fragments/DisplayImageFragment.java @@ -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; /** @@ -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. @@ -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. */ @@ -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); } @@ -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); } /* @@ -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; diff --git a/Augendiagnose/src/de/eisfeldj/augendiagnose/util/EyePhoto.java b/Augendiagnose/src/de/eisfeldj/augendiagnose/util/EyePhoto.java index ebfd5a4a..8bdd02dd 100644 --- a/Augendiagnose/src/de/eisfeldj/augendiagnose/util/EyePhoto.java +++ b/Augendiagnose/src/de/eisfeldj/augendiagnose/util/EyePhoto.java @@ -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; } diff --git a/Augendiagnose/src/de/eisfeldj/augendiagnose/util/ImageSelectionAndDisplayHandler.java b/Augendiagnose/src/de/eisfeldj/augendiagnose/util/ImageSelectionAndDisplayHandler.java index 6b1b5fdb..dcaaed9f 100644 --- a/Augendiagnose/src/de/eisfeldj/augendiagnose/util/ImageSelectionAndDisplayHandler.java +++ b/Augendiagnose/src/de/eisfeldj/augendiagnose/util/ImageSelectionAndDisplayHandler.java @@ -118,7 +118,7 @@ else if (isSelectedView(view)) { } else { DisplayTwoActivity.startActivity(activity, getSelectedImage().getAbsolutePath(), view.getEyePhoto() - .getAbsolutePath()); + .getAbsolutePath(), false); cleanSelectedViews(); } } @@ -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(); }