diff --git a/app/src/main/java/net/sourceforge/opencamera/ui/DrawPreview.java b/app/src/main/java/net/sourceforge/opencamera/ui/DrawPreview.java index 41df473781080b5eaa3a3f1e9604c0cc5c0f4c51..0150f16f0bd68f2ec792bf325f28fe38cdffbea9 100644 --- a/app/src/main/java/net/sourceforge/opencamera/ui/DrawPreview.java +++ b/app/src/main/java/net/sourceforge/opencamera/ui/DrawPreview.java @@ -2074,73 +2074,6 @@ public class DrawPreview { } } - { - /*int focus_seekbars_margin_left_dp = 85; - if( want_histogram ) - focus_seekbars_margin_left_dp += DrawPreview.histogram_height_dp;*/ - // 135 needed to make room for on-screen info lines in DrawPreview.onDrawInfoLines(), including the histogram - // but we also need to take the top_icon_shift into account, for widescreen aspect ratios and "icons along top" UI placement - int focus_seekbars_margin_left_dp = 135; - int new_focus_seekbars_margin_left = (int) (focus_seekbars_margin_left_dp * scale + 0.5f); // convert dps to pixels - if( top_icon_shift > 0 ) { - //noinspection SuspiciousNameCombination - new_focus_seekbars_margin_left += top_icon_shift; - } - - if( focus_seekbars_margin_left == -1 || new_focus_seekbars_margin_left != focus_seekbars_margin_left ) { - // we check whether focus_seekbars_margin_left has changed, in case there is a performance cost for setting layoutparams - this.focus_seekbars_margin_left = new_focus_seekbars_margin_left; - if( MyDebug.LOG ) - Log.d(TAG, "set focus_seekbars_margin_left to " + focus_seekbars_margin_left); - - // "left" and "right" here are written assuming we're in landscape system orientation - - View view = main_activity.findViewById(R.id.focus_seekbar); - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)view.getLayoutParams(); - preview.getView().getLocationOnScreen(gui_location); - int preview_left = gui_location[system_orientation_portrait ? 1 : 0]; - if( system_orientation == MainActivity.SystemOrientation.REVERSE_LANDSCAPE ) - preview_left += preview.getView().getWidth(); // actually want preview-right for reverse landscape - - view.getLocationOnScreen(gui_location); - int seekbar_right = gui_location[system_orientation_portrait ? 1 : 0]; - if( system_orientation == MainActivity.SystemOrientation.LANDSCAPE || system_orientation == MainActivity.SystemOrientation.PORTRAIT ) { - // n.b., we read view.getWidth() even if system_orientation is portrait, because the seekbar is rotated in portrait orientation - seekbar_right += view.getWidth(); - } - else { - // and for reversed landscape, the seekbar is rotated 180 degrees, and getLocationOnScreen() returns the location after the rotation - seekbar_right -= view.getWidth(); - } - - int min_seekbar_width = (int) (150 * scale + 0.5f); // convert dps to pixels - int new_seekbar_width; - if( system_orientation == MainActivity.SystemOrientation.LANDSCAPE || system_orientation == MainActivity.SystemOrientation.PORTRAIT ) { - new_seekbar_width = seekbar_right - (preview_left+focus_seekbars_margin_left); - } - else { - // reversed landscape - new_seekbar_width = preview_left - focus_seekbars_margin_left - seekbar_right; - } - new_seekbar_width = Math.max(new_seekbar_width, min_seekbar_width); - /*if( MyDebug.LOG ) { - Log.d(TAG, "preview_left: " + preview_left); - Log.d(TAG, "seekbar_right: " + seekbar_right); - Log.d(TAG, "new_seekbar_width: " + new_seekbar_width); - }*/ - layoutParams.width = new_seekbar_width; - view.setLayoutParams(layoutParams); - - view = main_activity.findViewById(R.id.focus_bracketing_target_seekbar); - layoutParams = (RelativeLayout.LayoutParams)view.getLayoutParams(); - layoutParams.width = new_seekbar_width; - view.setLayoutParams(layoutParams); - - // need to update due to changing width of focus seekbars - main_activity.getMainUI().setFocusSeekbarsRotation(); - } - } - int battery_x = top_x; int battery_y = top_y + (int) (5 * scale + 0.5f); int battery_width = (int) (5 * scale + 0.5f); // convert dps to pixels diff --git a/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java b/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java index bbe2fa97d6c619bf5d797a517cb53009026db2e0..136d0f7381ebd57938c8e6d9e46cb131e2c4d935 100644 --- a/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java +++ b/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java @@ -31,7 +31,10 @@ import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.SeekBar; +import androidx.annotation.IdRes; +import androidx.annotation.NonNull; import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.constraintlayout.widget.ConstraintSet; import net.sourceforge.opencamera.MainActivity; import net.sourceforge.opencamera.MyApplicationInterface; @@ -528,11 +531,7 @@ public class MainUI { } } - view = main_activity.findViewById(R.id.top_bg); - layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams(); - layoutParams.width = button_size; - view.setLayoutParams(layoutParams); - top_icon = view; + top_icon = setUpTopBarHolderUI(system_orientation_portrait, system_orientation_reversed_landscape, button_size); } } else { // need to reset size/margins to their default @@ -555,13 +554,10 @@ public class MainUI { // end icon panel - int rightSideMargin = (int) ScaleUtils.convertDpToPx(main_activity, 23.0f); - rightSideMargin += navigation_gap; + int navigationBarSideMargin = (int) ScaleUtils.convertDpToPx(main_activity, 23.0f); + navigationBarSideMargin += navigation_gap; - view = main_activity.findViewById(R.id.bottom_buttons_holder); - int bottomBarLeftPadding = (int) ScaleUtils.convertDpToPx(main_activity, 23.0f); - int bottomBarTopBottomPadding = (int) ScaleUtils.convertDpToPx(main_activity, 20.0f); - view.setPadding(bottomBarLeftPadding, bottomBarTopBottomPadding, rightSideMargin, bottomBarTopBottomPadding); + setUpBottomBarHolderUI(system_orientation_portrait, system_orientation_reversed_landscape, navigationBarSideMargin); view = main_activity.findViewById(R.id.take_photo); setViewRotation(view, ui_rotation); @@ -569,8 +565,7 @@ public class MainUI { view = main_activity.findViewById(R.id.switch_camera); setViewRotation(view, ui_rotation); - view = main_activity.findViewById(R.id.switch_multi_camera); - setViewRotation(view, ui_rotation); + setupMultiCameraUI(ui_rotation, system_orientation_portrait, system_orientation_reversed_landscape); view = main_activity.findViewById(R.id.pause_video); setViewRotation(view, ui_rotation); @@ -587,40 +582,12 @@ public class MainUI { view = main_activity.findViewById(R.id.take_photo_when_video_recording); setViewRotation(view, ui_rotation); - view = main_activity.findViewById(R.id.zoom); - setViewRotation(view, ui_rotation); - - view = main_activity.findViewById(R.id.zoom_seekbar); - LinearLayout.LayoutParams linearLayoutParams = (LinearLayout.LayoutParams) view.getLayoutParams(); - int zoomSeekBarMarginRight = (rightSideMargin + 140); - linearLayoutParams.setMargins(0, 0, zoomSeekBarMarginRight, 0); - view.setLayoutParams(linearLayoutParams); - - view = main_activity.findViewById(R.id.focus_seekbar); - layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams(); - layoutParams.addRule(align_left, R.id.preview); - layoutParams.addRule(align_right, 0); - // layoutParams.addRule(left_of, R.id.zoom_seekbar); - layoutParams.addRule(right_of, 0); - layoutParams.addRule(above, 0); - layoutParams.addRule(below, 0); - layoutParams.addRule(align_parent_top, 0); - layoutParams.addRule(align_parent_bottom, RelativeLayout.TRUE); - layoutParams.addRule(align_parent_left, 0); - layoutParams.addRule(align_parent_right, 0); - view.setLayoutParams(layoutParams); + setUpZoomControlUI(ui_rotation, system_orientation_portrait, system_orientation_reversed_landscape); - view = main_activity.findViewById(R.id.focus_bracketing_target_seekbar); - layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams(); - layoutParams.addRule(align_left, R.id.preview); - layoutParams.addRule(align_right, 0); - //layoutParams.addRule(left_of, R.id.zoom_seekbar); - layoutParams.addRule(right_of, 0); - layoutParams.addRule(above, R.id.focus_seekbar); - layoutParams.addRule(below, 0); - view.setLayoutParams(layoutParams); + view = main_activity.findViewById(R.id.zoom_seekbar_holder); + setViewRotation(view, ui_rotation); - setFocusSeekbarsRotation(); + setupFocusSeekBarUI(ui_rotation, system_orientation_portrait, system_orientation_reversed_landscape); } if (!popup_container_only) { @@ -816,6 +783,298 @@ public class MainUI { } } + private void setupMultiCameraUI(int ui_rotation, boolean orientationPortrait, boolean orientationReverseLandscape) { + View multiCamera = main_activity.findViewById(R.id.switch_multi_camera); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(multiCamera.getLayoutParams().width, multiCamera.getLayoutParams().height); + + int size21dp = (int) ScaleUtils.convertDpToPx(main_activity, 21.0f); + int size20dp = (int) ScaleUtils.convertDpToPx(main_activity, 20.0f); + + if (orientationPortrait) { + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_END, RelativeLayout.TRUE); + layoutParams.addRule(RelativeLayout.ABOVE, R.id.bottom_buttons_holder); + layoutParams.setMargins(0, 0, size21dp, size20dp); + } else if (orientationReverseLandscape) { + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + layoutParams.addRule(RelativeLayout.END_OF, R.id.bottom_buttons_holder); + layoutParams.setMargins(size20dp, 0, 0, size21dp); + } else { + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + layoutParams.addRule(RelativeLayout.START_OF, R.id.bottom_buttons_holder); + layoutParams.setMargins(0, size21dp, size20dp, 0); + } + + multiCamera.setLayoutParams(layoutParams); + setViewRotation(multiCamera, ui_rotation); + } + + private void setupFocusSeekBarUI(int rotation, boolean orientationPortrait, boolean orientationReverseLandscape) { + View focusSeekBarHolder = main_activity.findViewById(R.id.focus_seekbar_holder); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + + if (orientationPortrait) { + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START, RelativeLayout.TRUE); + layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + } else if (orientationReverseLandscape) { + layoutParams.addRule(RelativeLayout.END_OF, R.id.bottom_buttons_holder); + layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + } else { + layoutParams.addRule(RelativeLayout.START_OF, R.id.bottom_buttons_holder); + layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + } + + focusSeekBarHolder.setLayoutParams(layoutParams); + setViewRotation(focusSeekBarHolder, rotation + 90); + } + + private void setUpZoomControlUI(int rotation, boolean orientationPortrait, boolean orientationReverseLandscape) { + int margin = (int) ScaleUtils.convertDpToPx(main_activity, 60.0f); + + View zoom = main_activity.findViewById(R.id.zoom); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(zoom.getLayoutParams().width, zoom.getLayoutParams().height); + + if (orientationPortrait) { + layoutParams.addRule(RelativeLayout.BELOW, R.id.top_bg); + layoutParams.setMargins(0, margin, 0, 0); + layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + } else if (orientationReverseLandscape) { + layoutParams.addRule(RelativeLayout.START_OF, R.id.top_bg); + layoutParams.setMargins(0, 0, margin, 0); + layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + } else { + layoutParams.addRule(RelativeLayout.END_OF, R.id.top_bg); + layoutParams.setMargins(margin, 0, 0, 0); + layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + } + + zoom.setLayoutParams(layoutParams); + setViewRotation(zoom, rotation); + } + + private View setUpTopBarHolderUI(boolean orientationPortrait, boolean orientationReverseLandscape, int topButtonSize) { + int width = orientationPortrait ? ViewGroup.LayoutParams.MATCH_PARENT : topButtonSize; + int height = orientationPortrait ? topButtonSize : ViewGroup.LayoutParams.MATCH_PARENT; + int topBarAlignment = orientationPortrait ? RelativeLayout.ALIGN_PARENT_TOP : (orientationReverseLandscape ? RelativeLayout.ALIGN_PARENT_END : RelativeLayout.ALIGN_PARENT_START); + + View topBar = main_activity.findViewById(R.id.top_bg); + RelativeLayout.LayoutParams topBarLayoutParams = new RelativeLayout.LayoutParams(width, height); + topBarLayoutParams.addRule(topBarAlignment, RelativeLayout.TRUE); + topBar.setLayoutParams(topBarLayoutParams); + return topBar; + } + + private void setUpBottomBarHolderUI(boolean orientationPortrait, boolean orientationReverseLandscape, int navigationBarSideMargin) { + ConstraintLayout bottomBar = main_activity.findViewById(R.id.bottom_buttons_holder); + // set up layoutParam + int bottomBarWidth = orientationPortrait ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT; + int bottomBarHeight = orientationPortrait ? ViewGroup.LayoutParams.WRAP_CONTENT : ViewGroup.LayoutParams.MATCH_PARENT; + int bottomBarAlignment = orientationPortrait ? RelativeLayout.ALIGN_PARENT_BOTTOM : (orientationReverseLandscape ? RelativeLayout.ALIGN_PARENT_START : RelativeLayout.ALIGN_PARENT_END); + RelativeLayout.LayoutParams bottomBarLayoutParams = new RelativeLayout.LayoutParams(bottomBarWidth, bottomBarHeight); + bottomBarLayoutParams.addRule(bottomBarAlignment, RelativeLayout.TRUE); + bottomBar.setLayoutParams(bottomBarLayoutParams); + + // set up padding + int size20dp = (int) ScaleUtils.convertDpToPx(main_activity, 20.0f); + int size23dp = (int) ScaleUtils.convertDpToPx(main_activity, 23.0f); + + int bottomBarLeftPadding = orientationPortrait ? size20dp : (orientationReverseLandscape ? navigationBarSideMargin : size23dp); + int bottomBarRightPadding = orientationPortrait ? size20dp : (orientationReverseLandscape ? size23dp : navigationBarSideMargin); + int bottomBarTopPadding = orientationPortrait ? size23dp : size20dp; + int bottomBarBottomPadding = orientationPortrait ? navigationBarSideMargin : size20dp; + bottomBar.setPadding(bottomBarLeftPadding, bottomBarTopPadding, bottomBarRightPadding, bottomBarBottomPadding); + + setUpBottomItemsUI(bottomBar, orientationPortrait, orientationReverseLandscape); + } + + private void setUpBottomItemsUI(ConstraintLayout bottomHolder, boolean orientationPortrait, boolean orientationReverseLandscape) { + ConstraintSet constraintSet = new ConstraintSet(); + constraintSet.clone(bottomHolder); + + clearAllDynamicBottomBarItemConstraint(constraintSet); + + if (orientationPortrait) { + connectPortraitConstraintForBottomItems(constraintSet); + } else if (orientationReverseLandscape) { + connectReverseLandscapeConstraintForBottomItems(constraintSet); + } else { + connectLandscapeConstraintForBottomItems(constraintSet); + } + + constraintSet.applyTo(bottomHolder); + } + + private void clearAllDynamicBottomBarItemConstraint(@NonNull ConstraintSet constraintSet) { + clearAllConstraint(constraintSet, R.id.place_holder_view); + clearAllConstraint(constraintSet, R.id.gallery); + clearAllConstraint(constraintSet, R.id.switch_camera); + clearAllConstraint(constraintSet, R.id.pause_video); + clearAllConstraint(constraintSet, R.id.switch_video); + clearAllConstraint(constraintSet, R.id.take_photo_when_video_recording); + clearAllConstraint(constraintSet, R.id.cancel_panorama); + clearAllConstraint(constraintSet, R.id.finish_panorama); + } + + private void clearAllConstraint(@NonNull ConstraintSet constraintSet, @IdRes int id) { + constraintSet.clear(id, ConstraintSet.TOP); + constraintSet.clear(id, ConstraintSet.BOTTOM); + constraintSet.clear(id, ConstraintSet.START); + constraintSet.clear(id, ConstraintSet.END); + } + + private void connectConstraintParentTopBottom(@NonNull ConstraintSet constraintSet, @IdRes int id) { + constraintSet.connect(id, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP); + constraintSet.connect(id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM); + } + + private void connectConstraintParentStartEnd(@NonNull ConstraintSet constraintSet, @IdRes int id) { + constraintSet.connect(id, ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START); + constraintSet.connect(id, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END); + } + + private void connectPortraitConstraintForBottomItems(@NonNull ConstraintSet constraintSet) { + int id; + + //placeHolderView + id = R.id.place_holder_view; + connectConstraintParentTopBottom(constraintSet, id); + constraintSet.connect(id, ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START); + + //gallery + id = R.id.gallery; + connectConstraintParentTopBottom(constraintSet, id); + constraintSet.connect(id, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END); + + //switchCamera + id = R.id.switch_camera; + connectConstraintParentTopBottom(constraintSet, id); + constraintSet.connect(id, ConstraintSet.END, R.id.gallery, ConstraintSet.START); + constraintSet.connect(id, ConstraintSet.START, R.id.take_photo, ConstraintSet.END); + + //pauseVideo + id = R.id.pause_video; + connectConstraintParentTopBottom(constraintSet, id); + constraintSet.connect(id, ConstraintSet.END, R.id.gallery, ConstraintSet.START); + constraintSet.connect(id, ConstraintSet.START, R.id.take_photo, ConstraintSet.END); + + //switchVideo + id = R.id.switch_video; + connectConstraintParentTopBottom(constraintSet, id); + constraintSet.connect(id, ConstraintSet.END, R.id.take_photo, ConstraintSet.START); + constraintSet.connect(id, ConstraintSet.START, R.id.place_holder_view, ConstraintSet.END); + + //takePhotoOnVideo + id = R.id.take_photo_when_video_recording; + connectConstraintParentTopBottom(constraintSet, id); + constraintSet.connect(id, ConstraintSet.END, R.id.take_photo, ConstraintSet.START); + constraintSet.connect(id, ConstraintSet.START, R.id.place_holder_view, ConstraintSet.END); + + //cancelPanorama + id = R.id.cancel_panorama; + connectConstraintParentTopBottom(constraintSet, id); + constraintSet.connect(id, ConstraintSet.START, R.id.place_holder_center_view, ConstraintSet.END); + + //finishPanorama + id = R.id.finish_panorama; + connectConstraintParentTopBottom(constraintSet, id); + constraintSet.connect(id, ConstraintSet.END, R.id.place_holder_center_view, ConstraintSet.START); + } + + private void connectReverseLandscapeConstraintForBottomItems(@NonNull ConstraintSet constraintSet) { + int id; + + //placeHolderView + id = R.id.place_holder_view; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP); + + //gallery + id = R.id.gallery; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM); + + //switchCamera + id = R.id.switch_camera; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.BOTTOM, R.id.gallery, ConstraintSet.TOP); + constraintSet.connect(id, ConstraintSet.TOP, R.id.take_photo, ConstraintSet.BOTTOM); + + //pauseVideo + id = R.id.pause_video; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.BOTTOM, R.id.gallery, ConstraintSet.TOP); + constraintSet.connect(id, ConstraintSet.TOP, R.id.take_photo, ConstraintSet.BOTTOM); + + //switchVideo + id = R.id.switch_video; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.BOTTOM, R.id.take_photo, ConstraintSet.TOP); + constraintSet.connect(id, ConstraintSet.TOP, R.id.place_holder_view, ConstraintSet.BOTTOM); + + //takePhotoOnVideo + id = R.id.take_photo_when_video_recording; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.BOTTOM, R.id.take_photo, ConstraintSet.TOP); + constraintSet.connect(id, ConstraintSet.TOP, R.id.place_holder_view, ConstraintSet.BOTTOM); + + //cancelPanorama + id = R.id.cancel_panorama; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.TOP, R.id.place_holder_center_view, ConstraintSet.BOTTOM); + + //finishPanorama + id = R.id.finish_panorama; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.BOTTOM, R.id.place_holder_center_view, ConstraintSet.TOP); + } + + private void connectLandscapeConstraintForBottomItems(@NonNull ConstraintSet constraintSet) { + int id; + + //placeHolderView + id = R.id.place_holder_view; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM); + + //gallery + id = R.id.gallery; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP); + + //switchCamera + id = R.id.switch_camera; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.TOP, R.id.gallery, ConstraintSet.BOTTOM); + constraintSet.connect(id, ConstraintSet.BOTTOM, R.id.take_photo, ConstraintSet.TOP); + + //pauseVideo + id = R.id.pause_video; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.TOP, R.id.gallery, ConstraintSet.BOTTOM); + constraintSet.connect(id, ConstraintSet.BOTTOM, R.id.take_photo, ConstraintSet.TOP); + + //switchVideo + id = R.id.switch_video; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.TOP, R.id.take_photo, ConstraintSet.BOTTOM); + constraintSet.connect(id, ConstraintSet.BOTTOM, R.id.place_holder_view, ConstraintSet.TOP); + + //takePhotoOnVideo + id = R.id.take_photo_when_video_recording; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.TOP, R.id.take_photo, ConstraintSet.BOTTOM); + constraintSet.connect(id, ConstraintSet.BOTTOM, R.id.place_holder_view, ConstraintSet.TOP); + + //cancelPanorama + id = R.id.cancel_panorama; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.BOTTOM, R.id.place_holder_center_view, ConstraintSet.TOP); + + //finishPanorama + id = R.id.finish_panorama; + connectConstraintParentStartEnd(constraintSet, id); + constraintSet.connect(id, ConstraintSet.TOP, R.id.place_holder_center_view, ConstraintSet.BOTTOM); + } + /** Wrapper for layoutParams.setMargins, but where the margins are supplied for landscape orientation, * and if in portrait these are automatically rotated. */ diff --git a/app/src/main/java/net/sourceforge/opencamera/ui/PopupView.java b/app/src/main/java/net/sourceforge/opencamera/ui/PopupView.java index 8100aa0f0f2eba41ea0e4673cf6b5c6c56dc6f17..d5c92b5f1d95032306f064c67be64b4ce6ae9400 100644 --- a/app/src/main/java/net/sourceforge/opencamera/ui/PopupView.java +++ b/app/src/main/java/net/sourceforge/opencamera/ui/PopupView.java @@ -44,6 +44,7 @@ import android.widget.ScrollView; import android.widget.TextView; import android.widget.ImageView.ScaleType; +import androidx.appcompat.widget.AppCompatImageButton; import androidx.appcompat.widget.SwitchCompat; /** This defines the UI for the "popup" button, that provides quick access to a @@ -1844,8 +1845,8 @@ public class PopupView extends LinearLayout { @SuppressLint("InflateParams") final View ll2 = LayoutInflater.from(this.getContext()).inflate(R.layout.popupview_arrayoptions, null); final TextView text_view = ll2.findViewById(R.id.text_view); - final ImageButton prev_button = ll2.findViewById(R.id.button_left); - final ImageButton next_button = ll2.findViewById(R.id.button_right); + final AppCompatImageButton prev_button = ll2.findViewById(R.id.button_left); + final AppCompatImageButton next_button = ll2.findViewById(R.id.button_right); setArrayOptionsText(supported_options, title, text_view, title_in_options, title_in_options_first_only, current_index); //text_view.setBackgroundColor(Color.GRAY); // debug @@ -1861,8 +1862,6 @@ public class PopupView extends LinearLayout { final float scale = getResources().getDisplayMetrics().density; final int padding = (int) (0 * scale + 0.5f); // convert dps to pixels - prev_button.setBackgroundColor(Color.TRANSPARENT); // workaround for Android 6 crash! - prev_button.setImageDrawable(this.getResources().getDrawable(R.drawable.ic_arrow_left)); prev_button.setPadding(padding, padding, padding, padding); ViewGroup.LayoutParams vg_params = prev_button.getLayoutParams(); vg_params.width = arrow_button_w; @@ -1875,8 +1874,6 @@ public class PopupView extends LinearLayout { //ll2.addView(text_view); main_activity.getMainUI().getTestUIButtonsMap().put(test_key, text_view); - next_button.setBackgroundColor(Color.TRANSPARENT); // workaround for Android 6 crash! - next_button.setImageDrawable(this.getResources().getDrawable(R.drawable.ic_arrow_right)); next_button.setPadding(padding, padding, padding, padding); vg_params = next_button.getLayoutParams(); vg_params.width = arrow_button_w; diff --git a/app/src/main/res/drawable/ic_arrow_right.xml b/app/src/main/res/drawable/ic_arrow_right.xml index 0c95084abf7dec5a652f7be0133ab2bab68c72a5..206dd4fdedab2fce1bc90d13de43d63becd1ddb2 100644 --- a/app/src/main/res/drawable/ic_arrow_right.xml +++ b/app/src/main/res/drawable/ic_arrow_right.xml @@ -1,6 +1,6 @@ + android:layout_height="wrap_content" + android:background="@color/navigation_background"> @@ -74,10 +67,6 @@ android:id="@+id/switch_camera" android:layout_width="@dimen/onscreen_bottom_button_size" android:layout_height="@dimen/onscreen_bottom_button_size" - app:layout_constraintTop_toBottomOf="@id/gallery" - app:layout_constraintBottom_toTopOf="@id/take_photo" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent" android:background="@null" android:contentDescription="@string/switch_to_front_camera" android:onClick="clickedSwitchCamera" @@ -88,10 +77,6 @@ android:id="@+id/pause_video" android:layout_width="@dimen/onscreen_bottom_button_size" android:layout_height="@dimen/onscreen_bottom_button_size" - app:layout_constraintTop_toBottomOf="@id/gallery" - app:layout_constraintBottom_toTopOf="@id/take_photo" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent" android:background="@null" android:contentDescription="@string/pause_video" android:onClick="clickedPauseVideo" @@ -103,10 +88,6 @@ android:id="@+id/cancel_panorama" android:layout_width="@dimen/onscreen_bottom_panorama_button_size" android:layout_height="@dimen/onscreen_bottom_panorama_button_size" - app:layout_constraintBottom_toTopOf="@id/place_holder_center_view" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent" - android:layout_marginBottom="13dp" android:background="@null" android:contentDescription="@string/cancel_panorama" android:onClick="clickedCancelPanorama" @@ -118,10 +99,6 @@ android:id="@+id/finish_panorama" android:layout_width="@dimen/onscreen_bottom_panorama_button_size" android:layout_height="@dimen/onscreen_bottom_panorama_button_size" - app:layout_constraintTop_toBottomOf="@id/place_holder_center_view" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent" - android:layout_marginTop="13dp" android:background="@null" android:contentDescription="@string/finish_panorama" android:onClick="clickedFinishPanorama" @@ -133,10 +110,6 @@ android:id="@+id/switch_video" android:layout_width="@dimen/onscreen_bottom_button_size" android:layout_height="@dimen/onscreen_bottom_button_size" - app:layout_constraintBottom_toTopOf="@id/place_holder_view" - app:layout_constraintTop_toBottomOf="@id/take_photo" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent" android:background="@null" android:contentDescription="@string/switch_to_video" android:onClick="clickedSwitchVideo" @@ -147,10 +120,6 @@ android:id="@+id/take_photo_when_video_recording" android:layout_width="@dimen/onscreen_bottom_button_size" android:layout_height="@dimen/onscreen_bottom_button_size" - app:layout_constraintBottom_toTopOf="@id/place_holder_view" - app:layout_constraintTop_toBottomOf="@id/take_photo" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent" android:background="@null" android:contentDescription="@string/take_photo" android:onClick="clickedTakePhotoVideoSnapshot" @@ -162,19 +131,13 @@ - - + android:gravity="center" + android:layout_centerHorizontal="true" + android:layout_alignParentBottom="true" + android:layout_marginBottom="-300dp"> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toStartOf="@id/zoom_seekbar" + android:contentDescription="@string/zoom" /> - + app:layout_constraintStart_toEndOf="@id/zoom_seekbar_icon" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" /> + + @@ -274,13 +249,10 @@ android:id="@+id/focus_bracketing_target_seekbar" android:layout_width="150dp" android:layout_height="50dp" - android:layout_marginLeft="135dp" - android:layout_marginTop="0dp" - android:layout_marginRight="0dp" - android:layout_marginBottom="0dp" android:background="@drawable/bg_rounded_corner" android:contentDescription="@string/focus_bracketing_target_distance" android:visibility="gone" /> +