updating the editor style

This commit is contained in:
tibbi 2022-07-27 15:52:58 +02:00
parent 592b8133a6
commit 970eb5a035
4 changed files with 142 additions and 123 deletions

View file

@ -12,8 +12,6 @@ import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.provider.MediaStore
import android.view.Menu
import android.view.MenuItem
import android.widget.RelativeLayout
import androidx.exifinterface.media.ExifInterface
import androidx.recyclerview.widget.LinearLayoutManager
@ -28,10 +26,7 @@ import com.bumptech.glide.request.target.Target
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.gallery.pro.BuildConfig
import com.simplemobiletools.gallery.pro.R
@ -102,6 +97,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
return
}
setupOptionsMenu()
handlePermission(PERMISSION_WRITE_STORAGE) {
if (!it) {
toast(R.string.no_storage_permissions)
@ -115,6 +111,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
super.onResume()
isEditingWithThirdParty = false
bottom_draw_width.setColors(getProperTextColor(), getProperPrimaryColor(), getProperBackgroundColor())
setupToolbar(editor_toolbar, NavigationIcon.Arrow)
}
override fun onStop() {
@ -124,20 +121,16 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_editor, menu)
updateMenuItemColors(menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.save_as -> saveImage()
R.id.edit -> editWith()
R.id.share -> shareImage()
else -> return super.onOptionsItemSelected(item)
private fun setupOptionsMenu() {
editor_toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.save_as -> saveImage()
R.id.edit -> editWith()
R.id.share -> shareImage()
else -> return@setOnMenuItemClickListener false
}
return@setOnMenuItemClickListener true
}
return true
}
private fun initEditActivity() {

View file

@ -21,7 +21,7 @@ class SaveAsDialog(
}
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
save_as_path.text = "${activity.humanizePath(realPath).trimEnd('/')}/"
folder_value.setText("${activity.humanizePath(realPath).trimEnd('/')}/")
val fullName = path.getFilenameFromPath()
val dotAt = fullName.lastIndexOf(".")
@ -30,18 +30,18 @@ class SaveAsDialog(
if (dotAt > 0) {
name = fullName.substring(0, dotAt)
val extension = fullName.substring(dotAt + 1)
save_as_extension.setText(extension)
extension_value.setText(extension)
}
if (appendFilename) {
name += "_1"
}
save_as_name.setText(name)
save_as_path.setOnClickListener {
activity.hideKeyboard(save_as_path)
filename_value.setText(name)
folder_value.setOnClickListener {
activity.hideKeyboard(folder_value)
FilePickerDialog(activity, realPath, false, false, true, true) {
save_as_path.text = activity.humanizePath(it)
folder_value.setText(activity.humanizePath(it))
realPath = it
}
}
@ -53,10 +53,10 @@ class SaveAsDialog(
.setOnCancelListener { cancelCallback?.invoke() }
.apply {
activity.setupDialogStuff(view, this, R.string.save_as) { alertDialog ->
alertDialog.showKeyboard(view.save_as_name)
alertDialog.showKeyboard(view.filename_value)
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.save_as_name.value
val extension = view.save_as_extension.value
val filename = view.filename_value.value
val extension = view.extension_value.value
if (filename.isEmpty()) {
activity.toast(R.string.filename_cannot_be_empty)

View file

@ -1,77 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_edit_holder"
android:id="@+id/editor_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/default_image_view"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/editor_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_editor_crop_rotate_actions"
android:layout_marginBottom="@dimen/bottom_filters_height_with_margin"/>
android:layout_height="wrap_content">
<com.theartofdev.edmodo.cropper.CropImageView
android:id="@+id/crop_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/bottom_actions_height_bigger"
android:visibility="gone"
app:cropBackgroundColor="@color/crop_image_view_background"
app:cropInitialCropWindowPaddingRatio="0"/>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/editor_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu_editor"
app:title="@string/editor"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
<com.simplemobiletools.gallery.pro.views.EditorDrawCanvas
android:id="@+id/editor_draw_canvas"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/bottom_actions_height_double"
android:background="@android:color/transparent"
android:visibility="gone"/>
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/bottom_editor_actions_background"
android:id="@+id/activity_edit_holder"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_editor_actions_shadow_height"
android:layout_alignParentBottom="true"
android:background="@drawable/gradient_background"/>
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include
android:id="@+id/bottom_editor_primary_actions"
layout="@layout/bottom_editor_primary_actions"/>
<ImageView
android:id="@+id/default_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_editor_crop_rotate_actions"
android:layout_marginBottom="@dimen/bottom_filters_height_with_margin" />
<include
android:id="@+id/bottom_aspect_ratios"
layout="@layout/bottom_actions_aspect_ratio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_editor_crop_rotate_actions"
android:visibility="gone"/>
<com.theartofdev.edmodo.cropper.CropImageView
android:id="@+id/crop_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/bottom_actions_height_bigger"
android:visibility="gone"
app:cropBackgroundColor="@color/crop_image_view_background"
app:cropInitialCropWindowPaddingRatio="0" />
<include
android:id="@+id/bottom_editor_filter_actions"
layout="@layout/bottom_editor_actions_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_editor_primary_actions"
android:visibility="gone"/>
<com.simplemobiletools.gallery.pro.views.EditorDrawCanvas
android:id="@+id/editor_draw_canvas"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/bottom_actions_height_double"
android:background="@android:color/transparent"
android:visibility="gone" />
<include
android:id="@+id/bottom_editor_crop_rotate_actions"
layout="@layout/bottom_editor_crop_rotate_actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_editor_primary_actions"
android:visibility="gone"/>
<RelativeLayout
android:id="@+id/bottom_editor_actions_background"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_editor_actions_shadow_height"
android:layout_alignParentBottom="true"
android:background="@drawable/gradient_background" />
<include
android:id="@+id/bottom_editor_draw_actions"
layout="@layout/bottom_editor_draw_actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_editor_primary_actions"
android:visibility="gone"/>
<include
android:id="@+id/bottom_editor_primary_actions"
layout="@layout/bottom_editor_primary_actions" />
</RelativeLayout>
<include
android:id="@+id/bottom_aspect_ratios"
layout="@layout/bottom_actions_aspect_ratio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_editor_crop_rotate_actions"
android:visibility="gone" />
<include
android:id="@+id/bottom_editor_filter_actions"
layout="@layout/bottom_editor_actions_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_editor_primary_actions"
android:visibility="gone" />
<include
android:id="@+id/bottom_editor_crop_rotate_actions"
layout="@layout/bottom_editor_crop_rotate_actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_editor_primary_actions"
android:visibility="gone" />
<include
android:id="@+id/bottom_editor_draw_actions"
layout="@layout/bottom_editor_draw_actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_editor_primary_actions"
android:visibility="gone" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,53 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/save_as_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/save_as_path_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/tiny_margin"
android:text="@string/path"
android:textSize="@dimen/smaller_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/save_as_path"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/tiny_margin"
android:layout_marginBottom="@dimen/activity_margin"
android:paddingTop="@dimen/small_margin"
android:paddingEnd="@dimen/small_margin"
tools:text="@string/internal" />
<com.simplemobiletools.commons.views.MyEditText
android:id="@+id/save_as_name"
<com.simplemobiletools.commons.views.MyTextInputLayout
android:id="@+id/folder_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:singleLine="true"
android:textCursorDrawable="@null"
android:textSize="@dimen/normal_text_size" />
android:hint="@string/path">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/save_as_extension_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/tiny_margin"
android:text="@string/extension" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/folder_value"
style="@style/UnclickableEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.simplemobiletools.commons.views.MyEditText
android:id="@+id/save_as_extension"
</com.simplemobiletools.commons.views.MyTextInputLayout>
<com.simplemobiletools.commons.views.MyTextInputLayout
android:id="@+id/filename_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:singleLine="true"
android:textCursorDrawable="@null"
android:textSize="@dimen/normal_text_size" />
android:hint="@string/filename">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/filename_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapSentences"
android:singleLine="true"
android:textCursorDrawable="@null"
android:textSize="@dimen/bigger_text_size" />
</com.simplemobiletools.commons.views.MyTextInputLayout>
<com.simplemobiletools.commons.views.MyTextInputLayout
android:id="@+id/extension_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/extension">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/extension_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textCursorDrawable="@null"
android:textSize="@dimen/bigger_text_size" />
</com.simplemobiletools.commons.views.MyTextInputLayout>
</LinearLayout>