diff --git a/app/src/main/java/com/nextcloud/client/editimage/EditImageActivity.kt b/app/src/main/java/com/nextcloud/client/editimage/EditImageActivity.kt
index 3ccadd3ba52d..deb954a98bfe 100644
--- a/app/src/main/java/com/nextcloud/client/editimage/EditImageActivity.kt
+++ b/app/src/main/java/com/nextcloud/client/editimage/EditImageActivity.kt
@@ -32,6 +32,9 @@ import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import com.canhub.cropper.CropImageView
import com.nextcloud.client.di.Injectable
+import com.nextcloud.utils.extensions.getParcelableArgument
+import com.nextcloud.utils.extensions.navBarHeight
+import com.nextcloud.utils.extensions.shiftUp
import com.owncloud.android.R
import com.owncloud.android.databinding.ActivityEditImageBinding
import com.owncloud.android.datamodel.OCFile
@@ -80,7 +83,8 @@ class EditImageActivity :
binding = ActivityEditImageBinding.inflate(layoutInflater)
setContentView(binding.root)
- file = intent.extras?.getParcelable(EXTRA_FILE) ?: throw IllegalArgumentException("Missing file argument")
+ file = intent.extras?.getParcelableArgument(EXTRA_FILE, OCFile::class.java)
+ ?: throw IllegalArgumentException("Missing file argument")
setSupportActionBar(binding.toolbar)
supportActionBar?.apply {
@@ -90,9 +94,25 @@ class EditImageActivity :
window.statusBarColor = ContextCompat.getColor(this, R.color.black)
window.navigationBarColor = getColor(R.color.black)
- window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ window.setDecorFitsSystemWindows(false)
+ } else {
+ @Suppress("DEPRECATION")
+ window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
+ }
setupCropper()
+ shiftLayout()
+ }
+
+ private fun shiftLayout() {
+ val navBarHeight: Float = resources.navBarHeight().toFloat()
+
+ @Suppress("MagicNumber")
+ val imageShiftValue = DisplayUtils.convertDpToPixel(60f, this).toFloat()
+
+ binding.cropImageView.shiftUp(imageShiftValue)
+ binding.editButtonsLayout.shiftUp(navBarHeight)
}
override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
@@ -105,17 +125,19 @@ class EditImageActivity :
" " + getString(R.string.image_editor_file_edited_suffix) +
resultUri?.substring(resultUri.lastIndexOf('.'))
- FilesUploadHelper().uploadNewFiles(
- user = storageManager.user,
- localPaths = arrayOf(resultUri!!),
- remotePaths = arrayOf(file.parentRemotePath + File.separator + newFileName),
- createRemoteFolder = false,
- createdBy = UploadFileOperation.CREATED_BY_USER,
- requiresWifi = false,
- requiresCharging = false,
- nameCollisionPolicy = NameCollisionPolicy.RENAME,
- localBehavior = FileUploader.LOCAL_BEHAVIOUR_DELETE
- )
+ resultUri?.let {
+ FilesUploadHelper().uploadNewFiles(
+ user = storageManager.user,
+ localPaths = arrayOf(it),
+ remotePaths = arrayOf(file.parentRemotePath + File.separator + newFileName),
+ createRemoteFolder = false,
+ createdBy = UploadFileOperation.CREATED_BY_USER,
+ requiresWifi = false,
+ requiresCharging = false,
+ nameCollisionPolicy = NameCollisionPolicy.RENAME,
+ localBehavior = FileUploader.LOCAL_BEHAVIOUR_DELETE
+ )
+ }
}
override fun onSetImageUriComplete(view: CropImageView, uri: Uri, error: Exception?) {
@@ -147,6 +169,7 @@ class EditImageActivity :
finish()
true
}
+
else -> {
finish()
true
@@ -184,7 +207,15 @@ class EditImageActivity :
// determine output file format
format = when (file.mimeType) {
MimeType.PNG -> Bitmap.CompressFormat.PNG
- MimeType.WEBP -> Bitmap.CompressFormat.WEBP
+ MimeType.WEBP -> {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ Bitmap.CompressFormat.WEBP_LOSSLESS
+ } else {
+ @Suppress("DEPRECATION")
+ Bitmap.CompressFormat.WEBP
+ }
+ }
+
else -> Bitmap.CompressFormat.JPEG
}
}
diff --git a/app/src/main/java/com/nextcloud/utils/extensions/ResourcesExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/ResourcesExtensions.kt
new file mode 100644
index 000000000000..21b9f53f59c2
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/utils/extensions/ResourcesExtensions.kt
@@ -0,0 +1,36 @@
+/*
+ * Nextcloud Android client application
+ *
+ * @author Alper Ozturk
+ * Copyright (C) 2023 Alper Ozturk
+ * Copyright (C) 2023 Nextcloud GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.nextcloud.utils.extensions
+
+import android.annotation.SuppressLint
+import android.content.res.Resources
+
+@SuppressLint("DiscouragedApi", "InternalInsetResource")
+fun Resources.navBarHeight(): Int {
+ val resourceId: Int = getIdentifier("navigation_bar_height", "dimen", "android")
+
+ return if (resourceId > 0) {
+ getDimensionPixelSize(resourceId)
+ } else {
+ 0
+ }
+}
diff --git a/app/src/main/java/com/nextcloud/utils/extensions/ViewExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/ViewExtensions.kt
new file mode 100644
index 000000000000..f189dada5075
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/utils/extensions/ViewExtensions.kt
@@ -0,0 +1,30 @@
+/*
+ * Nextcloud Android client application
+ *
+ * @author Alper Ozturk
+ * Copyright (C) 2023 Alper Ozturk
+ * Copyright (C) 2023 Nextcloud GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.nextcloud.utils.extensions
+
+import android.view.View
+
+fun View.shiftUp(value: Float) {
+ post {
+ translationY = -value
+ }
+}
diff --git a/app/src/main/res/layout/activity_edit_image.xml b/app/src/main/res/layout/activity_edit_image.xml
index 931bb15d19be..00c2071dc1d2 100644
--- a/app/src/main/res/layout/activity_edit_image.xml
+++ b/app/src/main/res/layout/activity_edit_image.xml
@@ -18,9 +18,11 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-->
-
@@ -31,32 +33,27 @@
android:background="@color/black"
android:elevation="4dp"
android:minHeight="?attr/actionBarSize"
- android:theme="@style/Theme.ownCloud.Toolbar.AppWidgetContainer"
- app:layout_constraintTop_toTopOf="parent" />
+ android:theme="@style/Theme.ownCloud.Toolbar.AppWidgetContainer" />
+ android:layout_gravity="center"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"/>
+ android:paddingRight="8dp">
-
\ No newline at end of file
+