From 9f8e1f1e04733b6c5f0ffcaad8050b65095f9926 Mon Sep 17 00:00:00 2001 From: Matthieu <24-artectrex@users.noreply.shinice.net> Date: Fri, 21 Oct 2022 17:08:57 +0200 Subject: [PATCH] Fix background and back button function --- .../photoEdit/VideoEditActivity.kt | 9 +++--- .../photoEdit/cropper/CropOverlayView.java | 30 ++++++++++++++++++- .../main/res/drawable/ic_crop_black_24dp.xml | 2 +- .../main/res/layout/activity_photo_edit.xml | 1 + .../main/res/layout/activity_video_edit.xml | 1 - 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/pixeldroid/app/postCreation/photoEdit/VideoEditActivity.kt b/app/src/main/java/org/pixeldroid/app/postCreation/photoEdit/VideoEditActivity.kt index d0312e1a..c330f0d9 100644 --- a/app/src/main/java/org/pixeldroid/app/postCreation/photoEdit/VideoEditActivity.kt +++ b/app/src/main/java/org/pixeldroid/app/postCreation/photoEdit/VideoEditActivity.kt @@ -173,8 +173,6 @@ class VideoEditActivity : BaseThemedWithBarActivity() { relativeY = y/fullImageRect.height() ) - binding.cropSavedCard.isVisible = !cropRelativeDimensions.notCropped() - // If a crop was saved, change the color of the crop button to give a visual indication if(!cropRelativeDimensions.notCropped()){ val typedValue = TypedValue() @@ -258,7 +256,6 @@ class VideoEditActivity : BaseThemedWithBarActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { when(item.itemId) { - android.R.id.home -> onBackPressed() R.id.action_save -> { returnWithValues() } @@ -271,7 +268,9 @@ class VideoEditActivity : BaseThemedWithBarActivity() { } override fun onBackPressed() { - if (noEdits()) super.onBackPressed() + if(binding.cropImageView.isVisible) { + showCropInterface(false) + } else if (noEdits()) super.onBackPressed() else { val builder = AlertDialog.Builder(this) builder.apply { @@ -304,8 +303,8 @@ class VideoEditActivity : BaseThemedWithBarActivity() { if(show) mediaPlayer.pause() - // Only hide: showing happens on save only if necessary if(show) binding.cropSavedCard.visibility = View.GONE + else if(!cropRelativeDimensions.notCropped()) binding.cropSavedCard.visibility = View.VISIBLE binding.muter.visibility = visibilityOfOthers binding.speeder.visibility = visibilityOfOthers diff --git a/app/src/main/java/org/pixeldroid/app/postCreation/photoEdit/cropper/CropOverlayView.java b/app/src/main/java/org/pixeldroid/app/postCreation/photoEdit/cropper/CropOverlayView.java index de76dcce..bc3a6b1b 100644 --- a/app/src/main/java/org/pixeldroid/app/postCreation/photoEdit/cropper/CropOverlayView.java +++ b/app/src/main/java/org/pixeldroid/app/postCreation/photoEdit/cropper/CropOverlayView.java @@ -264,8 +264,36 @@ public class CropOverlayView extends View { private void drawBackground(Canvas canvas) { RectF rect = mCropWindowHandler.getRect(); + Paint background = getNewPaint(Color.argb(119, 0, 0, 0)); - canvas.drawRect(rect.left, rect.top, rect.right, rect.bottom, getNewPaint(Color.argb(119, 0, 0, 0))); + canvas.drawRect( + mInitialCropWindowRect.left, + mInitialCropWindowRect.top, + rect.left, + mInitialCropWindowRect.bottom, + background + ); + canvas.drawRect( + rect.left, + rect.bottom, + mInitialCropWindowRect.right, + mInitialCropWindowRect.bottom, + background + ); + canvas.drawRect( + rect.right, + mInitialCropWindowRect.top, + mInitialCropWindowRect.right, + rect.bottom, + background + ); + canvas.drawRect( + rect.left, + mInitialCropWindowRect.top, + rect.right, + rect.top, + background + ); } /** diff --git a/app/src/main/res/drawable/ic_crop_black_24dp.xml b/app/src/main/res/drawable/ic_crop_black_24dp.xml index 0238ec6e..6875a20b 100644 --- a/app/src/main/res/drawable/ic_crop_black_24dp.xml +++ b/app/src/main/res/drawable/ic_crop_black_24dp.xml @@ -4,6 +4,6 @@ android:viewportWidth="24.0" android:viewportHeight="24.0"> diff --git a/app/src/main/res/layout/activity_photo_edit.xml b/app/src/main/res/layout/activity_photo_edit.xml index 279f9d8b..0544616a 100644 --- a/app/src/main/res/layout/activity_photo_edit.xml +++ b/app/src/main/res/layout/activity_photo_edit.xml @@ -79,6 +79,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="411dp" + android:tint="?attr/colorOnBackground" android:src="@drawable/ic_crop_black_24dp" app:layout_constraintLeft_toLeftOf="@+id/left_guideline" app:layout_constraintRight_toRightOf="@+id/right_guideline" diff --git a/app/src/main/res/layout/activity_video_edit.xml b/app/src/main/res/layout/activity_video_edit.xml index 2e775637..cd018b28 100644 --- a/app/src/main/res/layout/activity_video_edit.xml +++ b/app/src/main/res/layout/activity_video_edit.xml @@ -78,7 +78,6 @@ android:contentDescription="@string/video_crop" android:background="?attr/selectableItemBackgroundBorderless" android:padding="4dp" - app:tint="@android:color/white" android:src="@drawable/ic_crop_black_24dp" app:layout_constraintBottom_toTopOf="@+id/thumbnail1" app:layout_constraintStart_toEndOf="@+id/speeder" />