From be17e5687d175b336c9f47411d259b4e1772ea0b Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Wed, 12 Aug 2020 15:14:38 +0200 Subject: [PATCH] Camera timer & grid icons fix --- .../sushi/hardcore/droidfs/CameraActivity.kt | 31 ++++++++++++++++--- .../sushi/hardcore/droidfs/MainActivity.kt | 2 +- .../droidfs/explorers/BaseExplorerActivity.kt | 1 + .../droidfs/explorers/ExplorerActivity.kt | 2 +- .../file_viewers/FileViewerActivity.kt | 4 +-- .../droidfs/file_viewers/TextEditor.kt | 8 ++--- app/src/main/res/drawable/icon_grid_off.xml | 5 +++ app/src/main/res/drawable/icon_timer.xml | 6 ---- app/src/main/res/drawable/icon_timer_off.xml | 9 ++++++ app/src/main/res/drawable/icon_timer_on.xml | 12 +++++++ app/src/main/res/layout/activity_camera.xml | 4 +-- app/src/main/res/values/strings.xml | 2 ++ 12 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 app/src/main/res/drawable/icon_grid_off.xml delete mode 100644 app/src/main/res/drawable/icon_timer.xml create mode 100644 app/src/main/res/drawable/icon_timer_off.xml create mode 100644 app/src/main/res/drawable/icon_timer_on.xml diff --git a/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt index 7728823..e290d47 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt @@ -1,5 +1,6 @@ package sushi.hardcore.droidfs +import android.content.Intent import android.graphics.Color import android.os.Bundle import android.text.InputType @@ -41,9 +42,9 @@ class CameraActivity : BaseActivity() { set(value) { field = value if (value > 0){ - image_timer.setColorFilter(Color.GREEN) + image_timer.setImageResource(R.drawable.icon_timer_on) } else { - image_timer.clearColorFilter() + image_timer.setImageResource(R.drawable.icon_timer_off) } } private lateinit var gocryptfsVolume: GocryptfsVolume @@ -149,7 +150,12 @@ class CameraActivity : BaseActivity() { .setView(dialogEditTextView) .setTitle(getString(R.string.enter_timer_duration)) .setPositiveButton(R.string.ok) { _, _ -> - timerDuration = dialogEditText.text.toString().toInt() + val enteredValue = dialogEditText.text.toString() + if (enteredValue.isEmpty()){ + Toast.makeText(this, getString(R.string.timer_empty_error_msg), Toast.LENGTH_SHORT).show() + } else { + timerDuration = enteredValue.toInt() + } } .setNegativeButton(R.string.cancel, null) .create() @@ -167,13 +173,14 @@ class CameraActivity : BaseActivity() { .setTitle(getString(R.string.choose_grid)) .setSingleChoiceItems(gridTitles.map { getString(it) as CharSequence }.toTypedArray(), gridValues.indexOf(camera.grid)){ dialog, which -> camera.grid = gridValues[which] + image_grid.setImageResource(if (camera.grid == Grid.OFF){ R.drawable.icon_grid_off } else { R.drawable.icon_grid_on }) dialog.dismiss() } .setNegativeButton(R.string.cancel, null) .show() } - fun onClickFilter(view: View) { + private fun openFilterDialog(){ ColoredAlertDialogBuilder(this) .setTitle(getString(R.string.choose_filter)) .setSingleChoiceItems(filterNames, currentFilterIndex){ dialog, which -> @@ -185,6 +192,22 @@ class CameraActivity : BaseActivity() { .show() } + fun onClickFilter(view: View) { + if (sharedPrefs.getBoolean("filtersFirstOpening", true)){ + ColoredAlertDialogBuilder(this) + .setTitle(R.string.warning) + .setMessage(R.string.filters_warning) + .setPositiveButton(R.string.ok){ _, _ -> + sharedPrefs.edit().putBoolean("filtersFirstOpening", false).apply() + openFilterDialog() + } + .setNegativeButton(R.string.cancel, null) + .show() + } else { + openFilterDialog() + } + } + override fun onDestroy() { super.onDestroy() if (!isFinishingIntentionally) { diff --git a/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt index a40d63d..e8d4c45 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt @@ -43,7 +43,7 @@ class MainActivity : BaseActivity() { .setTitle(R.string.warning) .setMessage(R.string.usf_home_warning_msg) .setCancelable(false) - .setPositiveButton(getString(R.string.see_unsafe_features)){ _, _ -> + .setPositiveButton(R.string.see_unsafe_features){ _, _ -> val intent = Intent(this, SettingsActivity::class.java) intent.putExtra("screen", "UnsafeFeaturesSettingsFragment") startActivity(intent) 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 5a25184..c8fc145 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt @@ -194,6 +194,7 @@ open class BaseExplorerActivity : BaseActivity() { } } total_size_text.text = getString(R.string.total_size, PathUtils.formatSize(totalSize)) + explorerAdapter.notifyDataSetChanged() }.start() } 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 3f5864f..bad2be0 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt @@ -211,7 +211,7 @@ class ExplorerActivity : BaseExplorerActivity() { } } } - .setNegativeButton(getString(R.string.no), null) + .setNegativeButton(R.string.no, null) .show() } } diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt index ee86816..04c311c 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt @@ -69,7 +69,7 @@ abstract class FileViewerActivity: BaseActivity() { .setTitle(R.string.error) .setMessage(R.string.outofmemoryerror_msg) .setCancelable(false) - .setPositiveButton(getString(R.string.ok)) { _, _ -> goBackToExplorer() } + .setPositiveButton(R.string.ok) { _, _ -> goBackToExplorer() } .show() } @@ -106,4 +106,4 @@ abstract class FileViewerActivity: BaseActivity() { super.onBackPressed() isFinishingIntentionally = true } -} \ No newline at end of file +} diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/TextEditor.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/TextEditor.kt index afd49fd..08649ac 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/TextEditor.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/TextEditor.kt @@ -34,7 +34,7 @@ class TextEditor: FileViewerActivity() { .setTitle(R.string.error) .setMessage(R.string.outofmemoryerror_msg) .setCancelable(false) - .setPositiveButton(getString(R.string.ok)) { _, _ -> goBackToExplorer()} + .setPositiveButton(R.string.ok) { _, _ -> goBackToExplorer()} .show() } } @@ -101,12 +101,12 @@ class TextEditor: FileViewerActivity() { ColoredAlertDialogBuilder(this) .setTitle(R.string.warning) .setMessage(R.string.ask_save) - .setPositiveButton(getString(R.string.save)) { _, _ -> + .setPositiveButton(R.string.save) { _, _ -> if (save()){ goBackToExplorer() } } - .setNegativeButton(getString(R.string.discard)){ _, _ -> goBackToExplorer()} + .setNegativeButton(R.string.discard){ _, _ -> goBackToExplorer()} .show() } else { goBackToExplorer() @@ -144,4 +144,4 @@ class TextEditor: FileViewerActivity() { override fun onBackPressed() { checkSaveAndExit() } -} \ No newline at end of file +} diff --git a/app/src/main/res/drawable/icon_grid_off.xml b/app/src/main/res/drawable/icon_grid_off.xml new file mode 100644 index 0000000..e247223 --- /dev/null +++ b/app/src/main/res/drawable/icon_grid_off.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/icon_timer.xml b/app/src/main/res/drawable/icon_timer.xml deleted file mode 100644 index 04584e8..0000000 --- a/app/src/main/res/drawable/icon_timer.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/icon_timer_off.xml b/app/src/main/res/drawable/icon_timer_off.xml new file mode 100644 index 0000000..c325717 --- /dev/null +++ b/app/src/main/res/drawable/icon_timer_off.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/icon_timer_on.xml b/app/src/main/res/drawable/icon_timer_on.xml new file mode 100644 index 0000000..818e299 --- /dev/null +++ b/app/src/main/res/drawable/icon_timer_on.xml @@ -0,0 +1,12 @@ + + + diff --git a/app/src/main/res/layout/activity_camera.xml b/app/src/main/res/layout/activity_camera.xml index afe5493..602e8c4 100644 --- a/app/src/main/res/layout/activity_camera.xml +++ b/app/src/main/res/layout/activity_camera.xml @@ -38,7 +38,7 @@ android:layout_width="30dp" android:layout_height="30dp" android:onClick="onClickTimer" - android:src="@drawable/icon_timer" + android:src="@drawable/icon_timer_off" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@id/image_grid" app:layout_constraintStart_toEndOf="@id/image_hdr" @@ -49,7 +49,7 @@ android:layout_width="30dp" android:layout_height="30dp" android:onClick="onClickGrid" - android:src="@drawable/icon_grid_on" + android:src="@drawable/icon_grid_off" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/image_filter" app:layout_constraintStart_toEndOf="@+id/image_timer" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1a1e34c..12fa7e5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -161,4 +161,6 @@ 4x4 Choose grid Choose filter + Filters can only be applied to reduced quality images. If you want to take high definition photos, do not apply any filters. + Please enter a numeric value