Changed config.defaultFolder to String

This commit is contained in:
Roland Kister 2020-11-03 22:48:51 +01:00
parent 1543c43102
commit f817755a04
3 changed files with 8 additions and 8 deletions

View file

@ -292,7 +292,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
findItem(R.id.reduce_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt > 1 findItem(R.id.reduce_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt > 1
findItem(R.id.hide_the_recycle_bin).isVisible = useBin && config.showRecycleBinAtFolders findItem(R.id.hide_the_recycle_bin).isVisible = useBin && config.showRecycleBinAtFolders
findItem(R.id.show_the_recycle_bin).isVisible = useBin && !config.showRecycleBinAtFolders findItem(R.id.show_the_recycle_bin).isVisible = useBin && !config.showRecycleBinAtFolders
findItem(R.id.set_as_default_folder).isVisible = config.defaultFolder != null findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty()
setupSearch(this) setupSearch(this)
} }
} }
@ -1399,19 +1399,19 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
} }
private fun setAsDefaultFolder() { private fun setAsDefaultFolder() {
config.defaultFolder = null config.defaultFolder = ""
invalidateOptionsMenu() invalidateOptionsMenu()
} }
private fun openDefaultFolder() { private fun openDefaultFolder() {
if (config.defaultFolder == null) { if (config.defaultFolder.isEmpty()) {
return; return;
} }
val defaultDir = File(config.defaultFolder!!) val defaultDir = File(config.defaultFolder!!)
if (!defaultDir.exists() || !defaultDir.isDirectory) { if (!defaultDir.exists() || !defaultDir.isDirectory) {
config.defaultFolder = null config.defaultFolder = ""
return; return;
} }

View file

@ -219,7 +219,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_media, menu) menuInflater.inflate(R.menu.menu_media, menu)
val isDefaultFolder = config.defaultFolder != null && File(config.defaultFolder!!).compareTo(File(mPath)) == 0 val isDefaultFolder = !config.defaultFolder.isEmpty() && File(config.defaultFolder).compareTo(File(mPath)) == 0
menu.apply { menu.apply {
findItem(R.id.group).isVisible = !config.scrollHorizontally findItem(R.id.group).isVisible = !config.scrollHorizontally
@ -951,7 +951,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
} }
private fun unsetAsDefaultFolder() { private fun unsetAsDefaultFolder() {
config.defaultFolder = null config.defaultFolder = ""
invalidateOptionsMenu() invalidateOptionsMenu()
} }
} }

View file

@ -198,8 +198,8 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(getDirectoryColumnsField(), getDefaultDirectoryColumnCount()) get() = prefs.getInt(getDirectoryColumnsField(), getDefaultDirectoryColumnCount())
set(dirColumnCnt) = prefs.edit().putInt(getDirectoryColumnsField(), dirColumnCnt).apply() set(dirColumnCnt) = prefs.edit().putInt(getDirectoryColumnsField(), dirColumnCnt).apply()
var defaultFolder: String? var defaultFolder: String
get() = prefs.getString(DEFAULT_FOLDER, null) get() = prefs.getString(DEFAULT_FOLDER, "")!!
set(defaultFolder) = prefs.edit().putString(DEFAULT_FOLDER, defaultFolder).apply() set(defaultFolder) = prefs.edit().putString(DEFAULT_FOLDER, defaultFolder).apply()
var allowInstantChange: Boolean var allowInstantChange: Boolean