diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 316041b11..37c0fff99 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -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; } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index 93e394b3d..31275b592 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -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() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt index b294ef35e..b42801596 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt @@ -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