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.hide_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)
}
}
@ -1399,19 +1399,19 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
}
private fun setAsDefaultFolder() {
config.defaultFolder = null
config.defaultFolder = ""
invalidateOptionsMenu()
}
private fun openDefaultFolder() {
if (config.defaultFolder == null) {
if (config.defaultFolder.isEmpty()) {
return;
}
val defaultDir = File(config.defaultFolder!!)
if (!defaultDir.exists() || !defaultDir.isDirectory) {
config.defaultFolder = null
config.defaultFolder = ""
return;
}

View file

@ -219,7 +219,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
override fun onCreateOptionsMenu(menu: Menu): Boolean {
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 {
findItem(R.id.group).isVisible = !config.scrollHorizontally
@ -951,7 +951,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
}
private fun unsetAsDefaultFolder() {
config.defaultFolder = null
config.defaultFolder = ""
invalidateOptionsMenu()
}
}

View file

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