mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
update the way of retrieving default column counts
This commit is contained in:
parent
a2e9c53d8e
commit
a3876f67cd
4 changed files with 41 additions and 7 deletions
|
@ -161,22 +161,52 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
set(showMedia) = prefs.edit().putInt(SHOW_MEDIA, showMedia).apply()
|
set(showMedia) = prefs.edit().putInt(SHOW_MEDIA, showMedia).apply()
|
||||||
|
|
||||||
var dirColumnCnt: Int
|
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()
|
set(dirColumnCnt) = prefs.edit().putInt(getDirectoryColumnsField(), dirColumnCnt).apply()
|
||||||
|
|
||||||
private fun getDirectoryColumnsField(): String {
|
private fun getDirectoryColumnsField(): String {
|
||||||
val isPortrait = context.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
|
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
|
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()
|
set(mediaColumnCnt) = prefs.edit().putInt(getMediaColumnsField(), mediaColumnCnt).apply()
|
||||||
|
|
||||||
private fun getMediaColumnsField(): String {
|
private fun getMediaColumnsField(): String {
|
||||||
val isPortrait = context.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
|
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
|
var directories: String
|
||||||
get() = prefs.getString(DIRECTORIES, "")
|
get() = prefs.getString(DIRECTORIES, "")
|
||||||
|
|
|
@ -17,8 +17,12 @@ val DARK_BACKGROUND = "dark_background"
|
||||||
val PINNED_FOLDERS = "pinned_folders"
|
val PINNED_FOLDERS = "pinned_folders"
|
||||||
val DIR_COLUMN_CNT = "dir_column_cnt"
|
val DIR_COLUMN_CNT = "dir_column_cnt"
|
||||||
val DIR_LANDSCAPE_COLUMN_CNT = "dir_landscape_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_COLUMN_CNT = "media_column_cnt"
|
||||||
val MEDIA_LANDSCAPE_COLUMN_CNT = "media_landscape_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_ALL = "show_all" // display images and videos from all folders together
|
||||||
val SHOW_MEDIA = "show_media"
|
val SHOW_MEDIA = "show_media"
|
||||||
val SAVE_FOLDER_PREFIX = "folder2_"
|
val SAVE_FOLDER_PREFIX = "folder2_"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<integer name="directory_columns_vertical_scroll">3</integer>
|
<integer name="directory_columns_vertical_scroll">3</integer>
|
||||||
<integer name="directory_columns_horizontal_scroll">5</integer>
|
<integer name="directory_columns_horizontal_scroll">3</integer>
|
||||||
<integer name="media_columns_vertical_scroll">5</integer>
|
<integer name="media_columns_vertical_scroll">5</integer>
|
||||||
<integer name="media_columns_horizontal_scroll">6</integer>
|
<integer name="media_columns_horizontal_scroll">5</integer>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<integer name="directory_columns_vertical_scroll">2</integer>
|
<integer name="directory_columns_vertical_scroll">2</integer>
|
||||||
<integer name="directory_columns_horizontal_scroll">4</integer>
|
<integer name="directory_columns_horizontal_scroll">3</integer>
|
||||||
<integer name="media_columns_vertical_scroll">3</integer>
|
<integer name="media_columns_vertical_scroll">3</integer>
|
||||||
<integer name="media_columns_horizontal_scroll">4</integer>
|
<integer name="media_columns_horizontal_scroll">4</integer>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue