From 6c43750290f9a1f63978724f308650f357e3ba0d Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Tue, 11 Aug 2020 20:40:14 +0200 Subject: [PATCH] Camera HDR, grid & filters & Directory size calculation --- app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 2 +- .../sushi/hardcore/droidfs/CameraActivity.kt | 57 ++++++++++++++++++- .../adapters/ExplorerElementAdapter.kt | 13 +++-- .../droidfs/explorers/BaseExplorerActivity.kt | 18 ++++-- .../droidfs/explorers/ExplorerActivity.kt | 3 +- .../droidfs/explorers/ExplorerElement.kt | 2 +- .../droidfs/file_viewers/ImageViewer.kt | 1 + .../sushi/hardcore/droidfs/util/MiscUtils.kt | 2 +- app/src/main/res/drawable/icon_grid_on.xml | 5 ++ app/src/main/res/drawable/icon_hdr_off.xml | 5 ++ app/src/main/res/drawable/icon_hdr_on.xml | 5 ++ .../main/res/drawable/icon_photo_filter.xml | 5 ++ app/src/main/res/layout/activity_camera.xml | 48 ++++++++++++++-- app/src/main/res/values/strings.xml | 6 ++ 15 files changed, 151 insertions(+), 25 deletions(-) create mode 100644 app/src/main/res/drawable/icon_grid_on.xml create mode 100644 app/src/main/res/drawable/icon_hdr_off.xml create mode 100644 app/src/main/res/drawable/icon_hdr_on.xml create mode 100644 app/src/main/res/drawable/icon_photo_filter.xml diff --git a/app/build.gradle b/app/build.gradle index fad5dd9..737e3ec 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,7 @@ android { minSdkVersion 21 targetSdkVersion 29 versionCode 1 - versionName "1.1.4" + versionName "1.1.5" ndk { abiFilters 'x86_64', 'armeabi-v7a', 'arm64-v8a' @@ -41,7 +41,7 @@ dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "androidx.core:core-ktx:1.3.1" - implementation "androidx.appcompat:appcompat:1.1.0" + implementation "androidx.appcompat:appcompat:1.2.0" implementation "androidx.constraintlayout:constraintlayout:1.1.3" implementation "androidx.sqlite:sqlite:2.1.0" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 324019b..63a706d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -20,7 +20,7 @@ android:requestLegacyExternalStorage="true" android:supportsRtl="true" android:theme="@style/AppTheme"> - + { + image_hdr.setImageResource(R.drawable.icon_hdr_off) + Hdr.OFF + } + Hdr.OFF -> { + image_hdr.setImageResource(R.drawable.icon_hdr_on) + Hdr.ON + } + } + } + fun onClickTimer(view: View) { val dialogEditTextView = layoutInflater.inflate(R.layout.dialog_edit_text, null) val dialogEditText = dialogEditTextView.findViewById(R.id.dialog_edit_text) dialogEditText.inputType = InputType.TYPE_CLASS_NUMBER val dialog = ColoredAlertDialogBuilder(this) .setView(dialogEditTextView) - .setTitle("Enter the timer duration (in s)") + .setTitle(getString(R.string.enter_timer_duration)) .setPositiveButton(R.string.ok) { _, _ -> timerDuration = dialogEditText.text.toString().toInt() } @@ -134,6 +162,29 @@ class CameraActivity : BaseActivity() { dialog.show() } + fun onClickGrid(view: View) { + ColoredAlertDialogBuilder(this) + .setTitle(getString(R.string.choose_grid)) + .setSingleChoiceItems(gridTitles.map { getString(it) as CharSequence }.toTypedArray(), gridValues.indexOf(camera.grid)){ dialog, which -> + camera.grid = gridValues[which] + dialog.dismiss() + } + .setNegativeButton(R.string.cancel, null) + .show() + } + + fun onClickFilter(view: View) { + ColoredAlertDialogBuilder(this) + .setTitle(getString(R.string.choose_filter)) + .setSingleChoiceItems(filterNames, currentFilterIndex){ dialog, which -> + camera.filter = Filters.values()[which].newInstance() + currentFilterIndex = which + dialog.dismiss() + } + .setNegativeButton(R.string.cancel, null) + .show() + } + override fun onDestroy() { super.onDestroy() if (!isFinishingIntentionally) { diff --git a/app/src/main/java/sushi/hardcore/droidfs/adapters/ExplorerElementAdapter.kt b/app/src/main/java/sushi/hardcore/droidfs/adapters/ExplorerElementAdapter.kt index cfff818..5a28216 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/adapters/ExplorerElementAdapter.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/adapters/ExplorerElementAdapter.kt @@ -12,15 +12,15 @@ import android.widget.ImageView import android.widget.TextView import androidx.core.content.ContextCompat import sushi.hardcore.droidfs.ConstValues.Companion.getAssociatedDrawable -import sushi.hardcore.droidfs.explorers.ExplorerElement import sushi.hardcore.droidfs.R +import sushi.hardcore.droidfs.explorers.ExplorerElement import sushi.hardcore.droidfs.util.PathUtils import sushi.hardcore.droidfs.widgets.ThemeColor import java.text.DateFormat import java.util.* class ExplorerElementAdapter(private val context: Context) : BaseAdapter() { - private val dateFormat: DateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, context.resources.configuration.locale) + private val dateFormat: DateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.getDefault()) private lateinit var explorerElements: List private val inflater: LayoutInflater = LayoutInflater.from(context) val selectedItems: MutableList = ArrayList() @@ -44,7 +44,11 @@ class ExplorerElementAdapter(private val context: Context) : BaseAdapter() { textElementName.text = currentElement.name val textElementMtime = view.findViewById(R.id.text_element_mtime) val textElementSize = view.findViewById(R.id.text_element_size) - textElementSize.text = "" + if (!currentElement.isParentFolder){ + textElementSize.text = PathUtils.formatSize(currentElement.size) + } else { + textElementSize.text = "" + } var drawableId = R.drawable.icon_folder when { currentElement.isDirectory -> { @@ -55,12 +59,11 @@ class ExplorerElementAdapter(private val context: Context) : BaseAdapter() { } else -> { textElementMtime.text = dateFormat.format(currentElement.mTime) - textElementSize.text = PathUtils.formatSize(currentElement.size) drawableId = getAssociatedDrawable(currentElement.name) } } val elementIcon = view.findViewById(R.id.icon_element) - val icon = context.getDrawable(drawableId) + val icon = ContextCompat.getDrawable(context, drawableId) icon?.colorFilter = PorterDuffColorFilter(themeColor, PorterDuff.Mode.SRC_IN) elementIcon.setImageDrawable(icon) if (selectedItems.contains(position)) { diff --git a/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt index 97ed57c..5a25184 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt @@ -141,7 +141,6 @@ open class BaseExplorerActivity : BaseActivity() { } .setTitle(getString(R.string.open_as)) .setNegativeButton(R.string.cancel, null) - .create() .show() } } @@ -180,9 +179,18 @@ open class BaseExplorerActivity : BaseActivity() { current_path_text.text = getString(R.string.location, currentDirectoryPath) Thread{ var totalSize: Long = 0 - for (e in gocryptfsVolume.recursiveMapFiles(currentDirectoryPath)){ - if (e.isRegularFile){ - totalSize += e.size + for (element in explorerElements){ + if (element.isDirectory){ + var dirSize: Long = 0 + for (subFile in gocryptfsVolume.recursiveMapFiles(element.fullPath)){ + if (subFile.isRegularFile){ + dirSize += subFile.size + } + } + element.size = dirSize + totalSize += dirSize + } else if (element.isRegularFile) { + totalSize += element.size } } total_size_text.text = getString(R.string.total_size, PathUtils.formatSize(totalSize)) @@ -432,4 +440,4 @@ open class BaseExplorerActivity : BaseActivity() { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt index 64b36a5..3f5864f 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt @@ -129,7 +129,6 @@ class ExplorerActivity : BaseExplorerActivity() { } .setTitle(getString(R.string.fab_dialog_title)) .setNegativeButton(R.string.cancel, null) - .create() .show() } } @@ -728,4 +727,4 @@ class ExplorerActivity : BaseExplorerActivity() { unselectAll() setCurrentPath(currentDirectoryPath) //refresh } -} \ No newline at end of file +} diff --git a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerElement.kt b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerElement.kt index 173f5d4..796b0dd 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerElement.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerElement.kt @@ -3,7 +3,7 @@ package sushi.hardcore.droidfs.explorers import sushi.hardcore.droidfs.util.PathUtils import java.util.* -class ExplorerElement(val name: String, val elementType: Short, val size: Long, mtime: Long, private val parentPath: String) { +class ExplorerElement(val name: String, val elementType: Short, var size: Long, mtime: Long, parentPath: String) { val mTime = Date((mtime * 1000).toString().toLong()) val fullPath: String = PathUtils.path_join(parentPath, name) diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt index 897992e..4b4d81d 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt @@ -65,6 +65,7 @@ class ImageViewer: FileViewerActivity() { for ((i, e) in mappedImages.withIndex()){ if (filePath == e.fullPath){ currentMappedImageIndex = i + break } } wasMapped = true diff --git a/app/src/main/java/sushi/hardcore/droidfs/util/MiscUtils.kt b/app/src/main/java/sushi/hardcore/droidfs/util/MiscUtils.kt index 3abe8df..46f3fe0 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/util/MiscUtils.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/util/MiscUtils.kt @@ -10,7 +10,7 @@ object MiscUtils { } fun decrementIndex(index: Int, list: List): Int { var i = index-1 - if (i <= 0){ + if (i < 0){ i = list.size-1 } return i diff --git a/app/src/main/res/drawable/icon_grid_on.xml b/app/src/main/res/drawable/icon_grid_on.xml new file mode 100644 index 0000000..7bfc825 --- /dev/null +++ b/app/src/main/res/drawable/icon_grid_on.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/icon_hdr_off.xml b/app/src/main/res/drawable/icon_hdr_off.xml new file mode 100644 index 0000000..550f633 --- /dev/null +++ b/app/src/main/res/drawable/icon_hdr_off.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/icon_hdr_on.xml b/app/src/main/res/drawable/icon_hdr_on.xml new file mode 100644 index 0000000..4e10da5 --- /dev/null +++ b/app/src/main/res/drawable/icon_hdr_on.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/icon_photo_filter.xml b/app/src/main/res/drawable/icon_photo_filter.xml new file mode 100644 index 0000000..81dc7e1 --- /dev/null +++ b/app/src/main/res/drawable/icon_photo_filter.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/activity_camera.xml b/app/src/main/res/layout/activity_camera.xml index f751227..afe5493 100644 --- a/app/src/main/res/layout/activity_camera.xml +++ b/app/src/main/res/layout/activity_camera.xml @@ -11,24 +11,62 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:cameraGesturePinch="zoom" + app:cameraGestureTap="autoFocus" + app:cameraAutoFocusMarker="@string/cameraview_default_autofocus_marker" + app:cameraHdr="on" app:cameraPictureFormat="jpeg" app:cameraAudio="off"/> - + + + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@id/image_grid" + app:layout_constraintStart_toEndOf="@id/image_hdr" + app:layout_constraintTop_toTopOf="parent" /> - + + + + + Move of %s failed. The selected items have been successfully moved. Move successful ! + Enter the timer duration (in s) + None + 3x3 + 4x4 + Choose grid + Choose filter