Skip to content

Commit

Permalink
Image edit functionality customized.
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed Aug 5, 2024
1 parent cf222d4 commit 172f653
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.nextcloud.client.editimage

import android.graphics.Bitmap
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
Expand All @@ -16,9 +17,6 @@ import android.view.MenuItem
import android.view.View
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import com.canhub.cropper.CropImageView
import com.nextcloud.client.di.Injectable
import com.nextcloud.client.jobs.upload.FileUploadHelper
Expand Down Expand Up @@ -73,21 +71,25 @@ class EditImageActivity :
file = intent.extras?.getParcelableArgument(EXTRA_FILE, OCFile::class.java)
?: throw IllegalArgumentException("Missing file argument")

setSupportActionBar(binding.toolbar)
supportActionBar?.apply {
title = file.fileName
setDisplayHomeAsUpEnabled(true)
}

val windowInsetsController = WindowCompat.getInsetsController(window, window.decorView)
windowInsetsController.hide(WindowInsetsCompat.Type.statusBars())

window.statusBarColor = ContextCompat.getColor(this, R.color.black)
window.navigationBarColor = getColor(R.color.black)
//NMC Customization
setupToolbar()
setupActionBar()

setupCropper()
}

//NMC Customization
private fun setupActionBar() {
supportActionBar?.let {
viewThemeUtils.platform.themeStatusBar(this)
it.setDisplayHomeAsUpEnabled(true)
it.setDisplayShowTitleEnabled(true)
//custom color for back arrow for NMC
viewThemeUtils.files.themeActionBar(this, it, file.fileName)
it.setBackgroundDrawable(ColorDrawable(resources.getColor(R.color.bg_default, null)))
}
}

override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
if (!result.isSuccessful) {
DisplayUtils.showSnackMessage(this, getString(R.string.image_editor_unable_to_edit_image))
Expand Down Expand Up @@ -124,14 +126,20 @@ class EditImageActivity :
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
// add save button to action bar
menuInflater.inflate(R.menu.custom_menu_placeholder, menu)
val saveIcon = AppCompatResources.getDrawable(this, R.drawable.ic_check)?.also {
DrawableCompat.setTint(it, resources.getColor(R.color.white, theme))
}
//No need to apply NC tint here as we will be doing it later in code
val saveIcon = AppCompatResources.getDrawable(this, R.drawable.ic_tick)
menu?.findItem(R.id.custom_menu_placeholder_item)?.apply {
icon = saveIcon
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
contentDescription = getString(R.string.common_save)
}
//NMC customization
icon = icon?.let {
viewThemeUtils.platform.colorDrawable(
it,
ContextCompat.getColor(this@EditImageActivity, R.color.fontAppbar)
)
}
}
return true
}
Expand Down
15 changes: 5 additions & 10 deletions app/src/main/res/layout/activity_edit_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@
android:layout_height="match_parent"
android:background="@color/black">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black"
android:elevation="4dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/Theme.ownCloud.Toolbar.AppWidgetContainer"
app:layout_constraintTop_toTopOf="parent" />
<!-- NMC Customization -->
<include
layout="@layout/toolbar_standard"
android:theme="@style/Theme.ownCloud.Toolbar.AppWidgetContainer" />

<com.canhub.cropper.CropImageView
android:id="@+id/cropImageView"
Expand All @@ -30,7 +25,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
app:layout_constraintTop_toBottomOf="@+id/appbar" />

<LinearLayout
android:layout_width="wrap_content"
Expand Down

0 comments on commit 172f653

Please sign in to comment.