merge increase/reduce column into 1 for quick changes

This commit is contained in:
tibbi 2023-01-10 18:37:43 +01:00
parent f126a27809
commit bfb6b2dfa1
4 changed files with 54 additions and 30 deletions

View file

@ -16,9 +16,11 @@ import androidx.recyclerview.widget.RecyclerView
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.models.Release
import com.simplemobiletools.commons.views.MyGridLayoutManager
import com.simplemobiletools.commons.views.MyRecyclerView
@ -303,8 +305,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun refreshMenuItems() {
if (!mIsThirdPartyIntent) {
main_menu.getToolbar().menu.apply {
findItem(R.id.increase_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt < MAX_COLUMN_COUNT
findItem(R.id.reduce_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt > 1
findItem(R.id.column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID
findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty()
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
}
@ -349,8 +350,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
R.id.temporarily_show_excluded -> tryToggleTemporarilyShowExcluded()
R.id.stop_showing_excluded -> tryToggleTemporarilyShowExcluded()
R.id.create_new_folder -> createNewFolder()
R.id.increase_column_count -> increaseColumnCount()
R.id.reduce_column_count -> reduceColumnCount()
R.id.column_count -> changeColumnCount()
R.id.set_as_default_folder -> setAsDefaultFolder()
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
R.id.settings -> launchSettings()
@ -727,17 +727,34 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
}
}
private fun changeColumnCount() {
val items = ArrayList<RadioItem>()
for (i in 1..MAX_COLUMN_COUNT) {
items.add(RadioItem(i, resources.getQuantityString(R.plurals.column_counts, i, i)))
}
val currentColumnCount = (directories_grid.layoutManager as MyGridLayoutManager).spanCount
RadioGroupDialog(this, items, currentColumnCount) {
val newColumnCount = it as Int
if (currentColumnCount != newColumnCount) {
config.dirColumnCnt = newColumnCount
columnCountChanged()
}
}
}
private fun increaseColumnCount() {
config.dirColumnCnt = ++(directories_grid.layoutManager as MyGridLayoutManager).spanCount
config.dirColumnCnt += 1
columnCountChanged()
}
private fun reduceColumnCount() {
config.dirColumnCnt = --(directories_grid.layoutManager as MyGridLayoutManager).spanCount
config.dirColumnCnt -= 1
columnCountChanged()
}
private fun columnCountChanged() {
(directories_grid.layoutManager as MyGridLayoutManager).spanCount = config.dirColumnCnt
refreshMenuItems()
getRecyclerAdapter()?.apply {
notifyItemRangeChanged(0, dirs.size)

View file

@ -16,9 +16,11 @@ import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition
import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.views.MyGridLayoutManager
import com.simplemobiletools.commons.views.MyRecyclerView
import com.simplemobiletools.gallery.pro.R
@ -248,8 +250,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
findItem(R.id.unset_as_default_folder).isVisible = isDefaultFolder
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
findItem(R.id.increase_column_count).isVisible = viewType == VIEW_TYPE_GRID && config.mediaColumnCnt < MAX_COLUMN_COUNT
findItem(R.id.reduce_column_count).isVisible = viewType == VIEW_TYPE_GRID && config.mediaColumnCnt > 1
findItem(R.id.column_count).isVisible = viewType == VIEW_TYPE_GRID
findItem(R.id.toggle_filename).isVisible = viewType == VIEW_TYPE_GRID
}
}
@ -280,8 +281,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
R.id.create_new_folder -> createNewFolder()
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
R.id.increase_column_count -> increaseColumnCount()
R.id.reduce_column_count -> reduceColumnCount()
R.id.column_count -> changeColumnCount()
R.id.set_as_default_folder -> setAsDefaultFolder()
R.id.unset_as_default_folder -> unsetAsDefaultFolder()
R.id.slideshow -> startSlideshow()
@ -731,17 +731,34 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
}
}
private fun changeColumnCount() {
val items = ArrayList<RadioItem>()
for (i in 1..MAX_COLUMN_COUNT) {
items.add(RadioItem(i, resources.getQuantityString(R.plurals.column_counts, i, i)))
}
val currentColumnCount = (media_grid.layoutManager as MyGridLayoutManager).spanCount
RadioGroupDialog(this, items, currentColumnCount) {
val newColumnCount = it as Int
if (currentColumnCount != newColumnCount) {
config.mediaColumnCnt = newColumnCount
columnCountChanged()
}
}
}
private fun increaseColumnCount() {
config.mediaColumnCnt = ++(media_grid.layoutManager as MyGridLayoutManager).spanCount
config.mediaColumnCnt += 1
columnCountChanged()
}
private fun reduceColumnCount() {
config.mediaColumnCnt = --(media_grid.layoutManager as MyGridLayoutManager).spanCount
config.mediaColumnCnt -= 1
columnCountChanged()
}
private fun columnCountChanged() {
(media_grid.layoutManager as MyGridLayoutManager).spanCount = config.mediaColumnCnt
handleGridSpacing()
refreshMenuItems()
getMediaAdapter()?.apply {

View file

@ -59,15 +59,10 @@
android:title="@string/create_new_folder"
app:showAsAction="never" />
<item
android:id="@+id/increase_column_count"
android:showAsAction="never"
android:title="@string/increase_column_count"
app:showAsAction="never" />
<item
android:id="@+id/reduce_column_count"
android:showAsAction="never"
android:title="@string/reduce_column_count"
app:showAsAction="never" />
android:id="@+id/column_count"
android:icon="@drawable/ic_column_count_vector"
android:title="@string/column_count"
app:showAsAction="ifRoom" />
<item
android:id="@+id/settings"
android:icon="@drawable/ic_settings_cog_vector"

View file

@ -79,15 +79,10 @@
android:title="@string/create_new_folder"
app:showAsAction="never" />
<item
android:id="@+id/increase_column_count"
android:showAsAction="never"
android:title="@string/increase_column_count"
app:showAsAction="never" />
<item
android:id="@+id/reduce_column_count"
android:showAsAction="never"
android:title="@string/reduce_column_count"
app:showAsAction="never" />
android:id="@+id/column_count"
android:icon="@drawable/ic_column_count_vector"
android:title="@string/column_count"
app:showAsAction="ifRoom" />
<item
android:id="@+id/slideshow"
android:showAsAction="never"