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

View file

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

View file

@ -1,11 +1,32 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" 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_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/editor_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/activity_edit_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<ImageView <ImageView
android:id="@+id/default_image_view" android:id="@+id/default_image_view"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -75,3 +96,4 @@
android:visibility="gone" /> android:visibility="gone" />
</RelativeLayout> </RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,53 +1,57 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/save_as_holder" android:id="@+id/save_as_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:padding="@dimen/activity_margin"> android:padding="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextInputLayout
android:id="@+id/save_as_path_label" android:id="@+id/folder_hint"
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"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin" android:layout_marginBottom="@dimen/activity_margin"
android:hint="@string/path">
<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.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: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:singleLine="true"
android:textCursorDrawable="@null" android:textCursorDrawable="@null"
android:textSize="@dimen/normal_text_size" /> android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView </com.simplemobiletools.commons.views.MyTextInputLayout>
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.simplemobiletools.commons.views.MyEditText <com.simplemobiletools.commons.views.MyTextInputLayout
android:id="@+id/save_as_extension" 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_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:singleLine="true" android:singleLine="true"
android:textCursorDrawable="@null" android:textCursorDrawable="@null"
android:textSize="@dimen/normal_text_size" /> android:textSize="@dimen/bigger_text_size" />
</com.simplemobiletools.commons.views.MyTextInputLayout>
</LinearLayout> </LinearLayout>