merge increase/reduce column into 1 for quick changes
This commit is contained in:
parent
f126a27809
commit
bfb6b2dfa1
4 changed files with 54 additions and 30 deletions
|
@ -16,9 +16,11 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog
|
import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.models.Release
|
import com.simplemobiletools.commons.models.Release
|
||||||
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
|
@ -303,8 +305,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
private fun refreshMenuItems() {
|
private fun refreshMenuItems() {
|
||||||
if (!mIsThirdPartyIntent) {
|
if (!mIsThirdPartyIntent) {
|
||||||
main_menu.getToolbar().menu.apply {
|
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.column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID
|
||||||
findItem(R.id.reduce_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt > 1
|
|
||||||
findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty()
|
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)
|
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.temporarily_show_excluded -> tryToggleTemporarilyShowExcluded()
|
||||||
R.id.stop_showing_excluded -> tryToggleTemporarilyShowExcluded()
|
R.id.stop_showing_excluded -> tryToggleTemporarilyShowExcluded()
|
||||||
R.id.create_new_folder -> createNewFolder()
|
R.id.create_new_folder -> createNewFolder()
|
||||||
R.id.increase_column_count -> increaseColumnCount()
|
R.id.column_count -> changeColumnCount()
|
||||||
R.id.reduce_column_count -> reduceColumnCount()
|
|
||||||
R.id.set_as_default_folder -> setAsDefaultFolder()
|
R.id.set_as_default_folder -> setAsDefaultFolder()
|
||||||
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||||
R.id.settings -> launchSettings()
|
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() {
|
private fun increaseColumnCount() {
|
||||||
config.dirColumnCnt = ++(directories_grid.layoutManager as MyGridLayoutManager).spanCount
|
config.dirColumnCnt += 1
|
||||||
columnCountChanged()
|
columnCountChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reduceColumnCount() {
|
private fun reduceColumnCount() {
|
||||||
config.dirColumnCnt = --(directories_grid.layoutManager as MyGridLayoutManager).spanCount
|
config.dirColumnCnt -= 1
|
||||||
columnCountChanged()
|
columnCountChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun columnCountChanged() {
|
private fun columnCountChanged() {
|
||||||
|
(directories_grid.layoutManager as MyGridLayoutManager).spanCount = config.dirColumnCnt
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
notifyItemRangeChanged(0, dirs.size)
|
notifyItemRangeChanged(0, dirs.size)
|
||||||
|
|
|
@ -16,9 +16,11 @@ import com.bumptech.glide.request.RequestOptions
|
||||||
import com.bumptech.glide.request.target.SimpleTarget
|
import com.bumptech.glide.request.target.SimpleTarget
|
||||||
import com.bumptech.glide.request.transition.Transition
|
import com.bumptech.glide.request.transition.Transition
|
||||||
import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog
|
import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog
|
||||||
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
@ -248,8 +250,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
findItem(R.id.unset_as_default_folder).isVisible = isDefaultFolder
|
findItem(R.id.unset_as_default_folder).isVisible = isDefaultFolder
|
||||||
|
|
||||||
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
|
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.column_count).isVisible = viewType == VIEW_TYPE_GRID
|
||||||
findItem(R.id.reduce_column_count).isVisible = viewType == VIEW_TYPE_GRID && config.mediaColumnCnt > 1
|
|
||||||
findItem(R.id.toggle_filename).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.create_new_folder -> createNewFolder()
|
||||||
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
|
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
|
||||||
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
|
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
|
||||||
R.id.increase_column_count -> increaseColumnCount()
|
R.id.column_count -> changeColumnCount()
|
||||||
R.id.reduce_column_count -> reduceColumnCount()
|
|
||||||
R.id.set_as_default_folder -> setAsDefaultFolder()
|
R.id.set_as_default_folder -> setAsDefaultFolder()
|
||||||
R.id.unset_as_default_folder -> unsetAsDefaultFolder()
|
R.id.unset_as_default_folder -> unsetAsDefaultFolder()
|
||||||
R.id.slideshow -> startSlideshow()
|
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() {
|
private fun increaseColumnCount() {
|
||||||
config.mediaColumnCnt = ++(media_grid.layoutManager as MyGridLayoutManager).spanCount
|
config.mediaColumnCnt += 1
|
||||||
columnCountChanged()
|
columnCountChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reduceColumnCount() {
|
private fun reduceColumnCount() {
|
||||||
config.mediaColumnCnt = --(media_grid.layoutManager as MyGridLayoutManager).spanCount
|
config.mediaColumnCnt -= 1
|
||||||
columnCountChanged()
|
columnCountChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun columnCountChanged() {
|
private fun columnCountChanged() {
|
||||||
|
(media_grid.layoutManager as MyGridLayoutManager).spanCount = config.mediaColumnCnt
|
||||||
handleGridSpacing()
|
handleGridSpacing()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
getMediaAdapter()?.apply {
|
getMediaAdapter()?.apply {
|
||||||
|
|
|
@ -59,15 +59,10 @@
|
||||||
android:title="@string/create_new_folder"
|
android:title="@string/create_new_folder"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/increase_column_count"
|
android:id="@+id/column_count"
|
||||||
android:showAsAction="never"
|
android:icon="@drawable/ic_column_count_vector"
|
||||||
android:title="@string/increase_column_count"
|
android:title="@string/column_count"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="ifRoom" />
|
||||||
<item
|
|
||||||
android:id="@+id/reduce_column_count"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/reduce_column_count"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/settings"
|
android:id="@+id/settings"
|
||||||
android:icon="@drawable/ic_settings_cog_vector"
|
android:icon="@drawable/ic_settings_cog_vector"
|
||||||
|
|
|
@ -79,15 +79,10 @@
|
||||||
android:title="@string/create_new_folder"
|
android:title="@string/create_new_folder"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/increase_column_count"
|
android:id="@+id/column_count"
|
||||||
android:showAsAction="never"
|
android:icon="@drawable/ic_column_count_vector"
|
||||||
android:title="@string/increase_column_count"
|
android:title="@string/column_count"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="ifRoom" />
|
||||||
<item
|
|
||||||
android:id="@+id/reduce_column_count"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/reduce_column_count"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/slideshow"
|
android:id="@+id/slideshow"
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
|
|
Loading…
Reference in a new issue