Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nmc/2374 Image edit functionality theming #121

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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