diff --git a/app/build.gradle b/app/build.gradle
index 0ce1b74b..72c0f441 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -58,7 +58,7 @@ android {
}
dependencies {
- implementation 'com.simplemobiletools:commons:5.31.13'
+ implementation 'com.simplemobiletools:commons:5.31.15'
implementation 'com.github.Stericson:RootTools:df729dcb13'
implementation 'com.github.Stericson:RootShell:1.6'
implementation 'com.alexvasilkov:gesture-views:2.5.2'
diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt
index 3a51f5d7..ae4c4437 100644
--- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt
@@ -21,6 +21,7 @@ import com.simplemobiletools.commons.models.Release
import com.simplemobiletools.filemanager.pro.BuildConfig
import com.simplemobiletools.filemanager.pro.R
import com.simplemobiletools.filemanager.pro.dialogs.ChangeSortingDialog
+import com.simplemobiletools.filemanager.pro.dialogs.ChangeViewTypeDialog
import com.simplemobiletools.filemanager.pro.extensions.config
import com.simplemobiletools.filemanager.pro.extensions.tryOpenPathIntent
import com.simplemobiletools.filemanager.pro.fragments.ItemsFragment
@@ -107,6 +108,7 @@ class MainActivity : SimpleActivity() {
R.id.add_favorite -> addFavorite()
R.id.remove_favorite -> removeFavorite()
R.id.set_as_home -> setAsHome()
+ R.id.change_view_type -> changeViewType()
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
R.id.settings -> startActivity(Intent(applicationContext, SettingsActivity::class.java))
@@ -281,6 +283,12 @@ class MainActivity : SimpleActivity() {
toast(R.string.home_folder_updated)
}
+ private fun changeViewType() {
+ ChangeViewTypeDialog(this, fragment.currentPath) {
+
+ }
+ }
+
private fun tryToggleTemporarilyShowHidden() {
if (config.temporarilyShowHidden) {
toggleTemporarilyShowHidden(false)
diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/ChangeViewTypeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/ChangeViewTypeDialog.kt
new file mode 100644
index 00000000..c22f4977
--- /dev/null
+++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/ChangeViewTypeDialog.kt
@@ -0,0 +1,51 @@
+package com.simplemobiletools.filemanager.pro.dialogs
+
+import android.view.View
+import androidx.appcompat.app.AlertDialog
+import com.simplemobiletools.commons.activities.BaseSimpleActivity
+import com.simplemobiletools.commons.extensions.setupDialogStuff
+import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
+import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
+import com.simplemobiletools.filemanager.pro.R
+import com.simplemobiletools.filemanager.pro.extensions.config
+import kotlinx.android.synthetic.main.dialog_change_view_type.view.*
+
+class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) {
+ private var view: View
+ private var config = activity.config
+
+ init {
+ view = activity.layoutInflater.inflate(R.layout.dialog_change_view_type, null).apply {
+ val currViewType = config.getFolderViewType(this@ChangeViewTypeDialog.path)
+ val viewToCheck = if (currViewType == VIEW_TYPE_GRID) {
+ change_view_type_dialog_radio_grid.id
+ } else {
+ change_view_type_dialog_radio_list.id
+ }
+
+ change_view_type_dialog_radio.check(viewToCheck)
+ change_view_type_dialog_use_for_this_folder.apply {
+ isChecked = config.hasCustomViewType(this@ChangeViewTypeDialog.path)
+ }
+ }
+
+ AlertDialog.Builder(activity)
+ .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
+ .setNegativeButton(R.string.cancel, null)
+ .create().apply {
+ activity.setupDialogStuff(view, this)
+ }
+ }
+
+ private fun dialogConfirmed() {
+ val viewType = if (view.change_view_type_dialog_radio.checkedRadioButtonId == view.change_view_type_dialog_radio_grid.id) VIEW_TYPE_GRID else VIEW_TYPE_LIST
+ if (view.change_view_type_dialog_use_for_this_folder.isChecked) {
+ config.saveFolderViewType(this.path, viewType)
+ } else {
+ config.removeFolderViewType(this.path)
+ config.viewType = viewType
+ }
+
+ callback()
+ }
+}
diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Config.kt
index e690e842..7de38509 100644
--- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Config.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Config.kt
@@ -3,6 +3,7 @@ package com.simplemobiletools.filemanager.pro.helpers
import android.content.Context
import com.simplemobiletools.commons.extensions.getInternalStoragePath
import com.simplemobiletools.commons.helpers.BaseConfig
+import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
import java.io.File
class Config(context: Context) : BaseConfig(context) {
@@ -69,4 +70,24 @@ class Config(context: Context) : BaseConfig(context) {
var editorTextZoom: Float
get() = prefs.getFloat(EDITOR_TEXT_ZOOM, 1.2f)
set(editorTextZoom) = prefs.edit().putFloat(EDITOR_TEXT_ZOOM, editorTextZoom).apply()
+
+ var viewType: Int
+ get() = prefs.getInt(VIEW_TYPE, VIEW_TYPE_LIST)
+ set(viewTypeFiles) = prefs.edit().putInt(VIEW_TYPE, viewTypeFiles).apply()
+
+ fun saveFolderViewType(path: String, value: Int) {
+ if (path.isEmpty()) {
+ viewType = value
+ } else {
+ prefs.edit().putInt(VIEW_TYPE_PREFIX + path.toLowerCase(), value).apply()
+ }
+ }
+
+ fun getFolderViewType(path: String) = prefs.getInt(VIEW_TYPE_PREFIX + path.toLowerCase(), viewType)
+
+ fun removeFolderViewType(path: String) {
+ prefs.edit().remove(VIEW_TYPE_PREFIX + path.toLowerCase()).apply()
+ }
+
+ fun hasCustomViewType(path: String) = prefs.contains(VIEW_TYPE_PREFIX + path.toLowerCase())
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Constants.kt
index 2e43e91c..fdc234f9 100644
--- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Constants.kt
@@ -9,6 +9,8 @@ const val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
const val IS_ROOT_AVAILABLE = "is_root_available"
const val ENABLE_ROOT_ACCESS = "enable_root_access"
const val EDITOR_TEXT_ZOOM = "editor_text_zoom"
+const val VIEW_TYPE = "view_type"
+const val VIEW_TYPE_PREFIX = "view_type_folder_"
// open as
const val OPEN_AS_DEFAULT = 0
diff --git a/app/src/main/res/layout/dialog_change_view_type.xml b/app/src/main/res/layout/dialog_change_view_type.xml
new file mode 100644
index 00000000..9a0474b8
--- /dev/null
+++ b/app/src/main/res/layout/dialog_change_view_type.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/menu/menu.xml b/app/src/main/res/menu/menu.xml
index 35586d4c..c09c8876 100644
--- a/app/src/main/res/menu/menu.xml
+++ b/app/src/main/res/menu/menu.xml
@@ -36,6 +36,10 @@
android:id="@+id/set_as_home"
android:title="@string/set_as_home_folder"
app:showAsAction="never"/>
+