add a menu button for easier new folder creating

This commit is contained in:
tibbi 2017-09-05 21:11:50 +02:00
parent 8ea418dad6
commit 2aab1ba5e5
3 changed files with 24 additions and 1 deletions

View File

@ -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'

View File

@ -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()

View File

@ -28,6 +28,10 @@
android:id="@+id/stop_showing_hidden"
android:title="@string/stop_showing_hidden"
app:showAsAction="never"/>
<item
android:id="@+id/create_new_folder"
android:title="@string/create_new_folder"
app:showAsAction="never"/>
<item
android:id="@+id/increase_column_count"
android:title="@string/increase_column_count"