store the amount of columns
This commit is contained in:
parent
72381ba53d
commit
9bb9e3496c
8 changed files with 24 additions and 11 deletions
|
@ -62,7 +62,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
mToBeDeleted = ArrayList<String>()
|
||||
directories_holder.setOnRefreshListener({ getDirectories() })
|
||||
mDirs = ArrayList<Directory>()
|
||||
handleZooming()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
@ -120,6 +119,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
showAllMedia()
|
||||
else
|
||||
getDirectories()
|
||||
handleZooming()
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION)
|
||||
}
|
||||
|
@ -234,17 +234,18 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
|
||||
private fun handleZooming() {
|
||||
val layoutManager = directories_grid.layoutManager as GridLayoutManager
|
||||
layoutManager.spanCount = mConfig.dirColumnCnt
|
||||
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener {
|
||||
override fun zoomIn() {
|
||||
if (layoutManager.spanCount > 1) {
|
||||
layoutManager.spanCount--
|
||||
mConfig.dirColumnCnt = --layoutManager.spanCount
|
||||
DirectoryAdapter.actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun zoomOut() {
|
||||
if (layoutManager.spanCount < 10) {
|
||||
layoutManager.spanCount++
|
||||
mConfig.dirColumnCnt = ++layoutManager.spanCount
|
||||
DirectoryAdapter.actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
mIsGetAnyIntent = getBooleanExtra(GET_ANY_INTENT, false)
|
||||
}
|
||||
|
||||
handleZooming()
|
||||
media_holder.setOnRefreshListener({ getMedia() })
|
||||
mPath = intent.getStringExtra(DIRECTORY)
|
||||
mMedia = ArrayList<Medium>()
|
||||
|
@ -69,6 +68,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
val dirName = getHumanizedFilename(mPath)
|
||||
title = if (mShowAll) resources.getString(R.string.all_folders) else dirName
|
||||
getMedia()
|
||||
handleZooming()
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
@ -203,17 +203,18 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
|
||||
private fun handleZooming() {
|
||||
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
||||
layoutManager.spanCount = mConfig.mediaColumnCnt
|
||||
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener {
|
||||
override fun zoomIn() {
|
||||
if (layoutManager.spanCount > 1) {
|
||||
layoutManager.spanCount--
|
||||
mConfig.mediaColumnCnt = --layoutManager.spanCount
|
||||
MediaAdapter.actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun zoomOut() {
|
||||
if (layoutManager.spanCount < 10) {
|
||||
layoutManager.spanCount++
|
||||
mConfig.mediaColumnCnt = ++layoutManager.spanCount
|
||||
MediaAdapter.actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,10 @@ package com.simplemobiletools.gallery.helpers
|
|||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.simplemobiletools.gallery.R
|
||||
import java.util.*
|
||||
|
||||
class Config private constructor(context: Context) {
|
||||
class Config private constructor(val context: Context) {
|
||||
private val mPrefs: SharedPreferences
|
||||
|
||||
companion object {
|
||||
|
@ -100,4 +101,12 @@ class Config private constructor(context: Context) {
|
|||
var showMedia: Int
|
||||
get() = mPrefs.getInt(SHOW_MEDIA, IMAGES_AND_VIDEOS)
|
||||
set(showMedia) = mPrefs.edit().putInt(SHOW_MEDIA, showMedia).apply()
|
||||
|
||||
var dirColumnCnt: Int
|
||||
get() = mPrefs.getInt(DIR_COLUMN_CNT, context.resources.getInteger(R.integer.directory_columns))
|
||||
set(dirColumnCnt) = mPrefs.edit().putInt(DIR_COLUMN_CNT, dirColumnCnt).apply()
|
||||
|
||||
var mediaColumnCnt: Int
|
||||
get() = mPrefs.getInt(MEDIA_COLUMN_CNT, context.resources.getInteger(R.integer.media_columns))
|
||||
set(mediaColumnCnt) = mPrefs.edit().putInt(MEDIA_COLUMN_CNT, mediaColumnCnt).apply()
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ val AUTOPLAY_VIDEOS = "autoplay_videos"
|
|||
val TREE_URI = "tree_uri"
|
||||
val DISPLAY_FILE_NAMES = "display_file_names"
|
||||
val PINNED_FOLDERS = "pinned_folders"
|
||||
val DIR_COLUMN_CNT = "dir_column_cnt"
|
||||
val MEDIA_COLUMN_CNT = "media_column_cnt"
|
||||
val SHOW_ALL = "show_all" // display images and videos from all folders together
|
||||
val SHOW_MEDIA = "show_media"
|
||||
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
app:layoutManager="android.support.v7.widget.GridLayoutManager"
|
||||
app:spanCount="@integer/photo_columns"/>
|
||||
app:spanCount="@integer/media_columns"/>
|
||||
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<resources>
|
||||
<integer name="directory_columns">3</integer>
|
||||
<integer name="photo_columns">5</integer>
|
||||
<integer name="media_columns">5</integer>
|
||||
</resources>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<resources>
|
||||
<integer name="directory_columns">4</integer>
|
||||
<integer name="photo_columns">7</integer>
|
||||
<integer name="media_columns">7</integer>
|
||||
</resources>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<resources>
|
||||
<integer name="directory_columns">2</integer>
|
||||
<integer name="photo_columns">3</integer>
|
||||
<integer name="media_columns">3</integer>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue