diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 852be6f43..4ca04cf25 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -62,7 +62,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mToBeDeleted = ArrayList() directories_holder.setOnRefreshListener({ getDirectories() }) mDirs = ArrayList() - 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() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index f94bd388b..28671a4be 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -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() @@ -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() } } 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 452408ea9..8e30adf37 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -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() } 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 63b6b530f..8650e7d06 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -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" diff --git a/app/src/main/res/layout/activity_media.xml b/app/src/main/res/layout/activity_media.xml index a5de62425..5f50f279b 100644 --- a/app/src/main/res/layout/activity_media.xml +++ b/app/src/main/res/layout/activity_media.xml @@ -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"/> diff --git a/app/src/main/res/values-w480dp/integers.xml b/app/src/main/res/values-w480dp/integers.xml index e64fab620..2bfaa32f7 100644 --- a/app/src/main/res/values-w480dp/integers.xml +++ b/app/src/main/res/values-w480dp/integers.xml @@ -1,4 +1,4 @@ 3 - 5 + 5 diff --git a/app/src/main/res/values-w600dp/integers.xml b/app/src/main/res/values-w600dp/integers.xml index 78dfa5f41..a98204fd4 100644 --- a/app/src/main/res/values-w600dp/integers.xml +++ b/app/src/main/res/values-w600dp/integers.xml @@ -1,4 +1,4 @@ 4 - 7 + 7 diff --git a/app/src/main/res/values/integers.xml b/app/src/main/res/values/integers.xml index 17083bdab..3d424225f 100644 --- a/app/src/main/res/values/integers.xml +++ b/app/src/main/res/values/integers.xml @@ -1,4 +1,4 @@ 2 - 3 + 3