From 2aab1ba5e56219e0aa36f745b03cea2856ed395a Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 5 Sep 2017 21:11:50 +0200 Subject: [PATCH] add a menu button for easier new folder creating --- app/build.gradle | 2 +- .../gallery/activities/MainActivity.kt | 19 +++++++++++++++++++ app/src/main/res/menu/menu_main.xml | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index ffaf9879e..ace0d079e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.27.8' + compile 'com.simplemobiletools:commons:2.27.9' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index d148a13d1..0d68ab3fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -17,6 +17,8 @@ import android.view.MenuItem import android.view.ViewGroup import android.widget.FrameLayout import com.google.gson.Gson +import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog +import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.models.Release import com.simplemobiletools.commons.views.MyScalableRecyclerView @@ -55,6 +57,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private var mLoadedInitialPhotos = false private var mLastMediaModified = 0 private var mLastMediaHandler = Handler() + private var mNewFolderPath = "" private var mCurrAsyncTask: GetDirectoriesAsynctask? = null @@ -105,6 +108,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { R.id.show_all -> showAllMedia() R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden() R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden() + R.id.create_new_folder -> createNewFolder() R.id.increase_column_count -> increaseColumnCount() R.id.reduce_column_count -> reduceColumnCount() R.id.settings -> launchSettings() @@ -155,6 +159,13 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { override fun onDestroy() { super.onDestroy() config.temporarilyShowHidden = false + + val newFolder = File(mNewFolderPath) + if (newFolder.exists() && newFolder.isDirectory) { + if (newFolder.list()?.isEmpty() == true) { + deleteFileBg(newFolder, true) { } + } + } } private fun tryloadGallery() { @@ -300,6 +311,14 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } + private fun createNewFolder() { + FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden) { + CreateNewFolderDialog(this, it) { + mNewFolderPath = it + } + } + } + private fun increaseColumnCount() { config.dirColumnCnt = ++(directories_grid.layoutManager as GridLayoutManager).spanCount invalidateOptionsMenu() diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 93770fe35..e94eacea7 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -28,6 +28,10 @@ android:id="@+id/stop_showing_hidden" android:title="@string/stop_showing_hidden" app:showAsAction="never"/> +