diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt index 8e111a9b4..b144682c4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -161,23 +161,53 @@ class Config(context: Context) : BaseConfig(context) { set(showMedia) = prefs.edit().putInt(SHOW_MEDIA, showMedia).apply() var dirColumnCnt: Int - get() = prefs.getInt(getDirectoryColumnsField(), context.resources.getInteger(R.integer.directory_columns_vertical_scroll)) + get() = prefs.getInt(getDirectoryColumnsField(), getDefaultDirectoryColumnCount()) set(dirColumnCnt) = prefs.edit().putInt(getDirectoryColumnsField(), dirColumnCnt).apply() private fun getDirectoryColumnsField(): String { val isPortrait = context.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT - return if (isPortrait) DIR_COLUMN_CNT else DIR_LANDSCAPE_COLUMN_CNT + return if (isPortrait) { + if (scrollHorizontally) { + DIR_HORIZONTAL_COLUMN_CNT + } else { + DIR_COLUMN_CNT + } + } else { + if (scrollHorizontally) { + DIR_LANDSCAPE_HORIZONTAL_COLUMN_CNT + } else { + DIR_LANDSCAPE_COLUMN_CNT + } + } } + private fun getDefaultDirectoryColumnCount() = context.resources.getInteger(if (scrollHorizontally) R.integer.directory_columns_horizontal_scroll + else R.integer.directory_columns_vertical_scroll) + var mediaColumnCnt: Int - get() = prefs.getInt(getMediaColumnsField(), context.resources.getInteger(R.integer.media_columns_vertical_scroll)) + get() = prefs.getInt(getMediaColumnsField(), getDefaultMediaColumnCount()) set(mediaColumnCnt) = prefs.edit().putInt(getMediaColumnsField(), mediaColumnCnt).apply() private fun getMediaColumnsField(): String { val isPortrait = context.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT - return if (isPortrait) MEDIA_COLUMN_CNT else MEDIA_LANDSCAPE_COLUMN_CNT + return if (isPortrait) { + if (scrollHorizontally) { + MEDIA_HORIZONTAL_COLUMN_CNT + } else { + MEDIA_COLUMN_CNT + } + } else { + if (scrollHorizontally) { + MEDIA_LANDSCAPE_HORIZONTAL_COLUMN_CNT + } else { + MEDIA_LANDSCAPE_COLUMN_CNT + } + } } + private fun getDefaultMediaColumnCount() = context.resources.getInteger(if (scrollHorizontally) R.integer.media_columns_horizontal_scroll + else R.integer.media_columns_vertical_scroll) + var directories: String get() = prefs.getString(DIRECTORIES, "") set(directories) = prefs.edit().putString(DIRECTORIES, directories).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt index 6a16bb9ff..70fe30c1b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -17,8 +17,12 @@ val DARK_BACKGROUND = "dark_background" val PINNED_FOLDERS = "pinned_folders" val DIR_COLUMN_CNT = "dir_column_cnt" val DIR_LANDSCAPE_COLUMN_CNT = "dir_landscape_column_cnt" +val DIR_HORIZONTAL_COLUMN_CNT = "dir_horizontal_column_cnt" +val DIR_LANDSCAPE_HORIZONTAL_COLUMN_CNT = "dir_landscape_horizontal_column_cnt" val MEDIA_COLUMN_CNT = "media_column_cnt" val MEDIA_LANDSCAPE_COLUMN_CNT = "media_landscape_column_cnt" +val MEDIA_HORIZONTAL_COLUMN_CNT = "media_horizontal_column_cnt" +val MEDIA_LANDSCAPE_HORIZONTAL_COLUMN_CNT = "media_landscape_horizontal_column_cnt" val SHOW_ALL = "show_all" // display images and videos from all folders together val SHOW_MEDIA = "show_media" val SAVE_FOLDER_PREFIX = "folder2_" diff --git a/app/src/main/res/values-w480dp/integers.xml b/app/src/main/res/values-w480dp/integers.xml index 1d3ca8c44..2f22506b5 100644 --- a/app/src/main/res/values-w480dp/integers.xml +++ b/app/src/main/res/values-w480dp/integers.xml @@ -1,6 +1,6 @@ 3 - 5 + 3 5 - 6 + 5 diff --git a/app/src/main/res/values/integers.xml b/app/src/main/res/values/integers.xml index 5f21fbd2c..e27e3e8f5 100644 --- a/app/src/main/res/values/integers.xml +++ b/app/src/main/res/values/integers.xml @@ -1,6 +1,6 @@ 2 - 4 + 3 3 4