simplify column count customization
This commit is contained in:
parent
f01bcb0f35
commit
51c38109e9
|
@ -190,9 +190,7 @@ class MainActivity : SimpleActivity() {
|
||||||
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden && currentFragment !is StorageFragment
|
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden && currentFragment !is StorageFragment
|
||||||
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden && currentFragment !is StorageFragment
|
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden && currentFragment !is StorageFragment
|
||||||
|
|
||||||
findItem(R.id.increase_column_count).isVisible =
|
findItem(R.id.column_count).isVisible = currentViewType == VIEW_TYPE_GRID && currentFragment !is StorageFragment
|
||||||
currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt < MAX_COLUMN_COUNT && currentFragment !is StorageFragment
|
|
||||||
findItem(R.id.reduce_column_count).isVisible = currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt > 1 && currentFragment !is StorageFragment
|
|
||||||
|
|
||||||
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)
|
||||||
findItem(R.id.settings).isVisible = !isCreateDocumentIntent
|
findItem(R.id.settings).isVisible = !isCreateDocumentIntent
|
||||||
|
@ -235,8 +233,7 @@ class MainActivity : SimpleActivity() {
|
||||||
R.id.change_view_type -> changeViewType()
|
R.id.change_view_type -> changeViewType()
|
||||||
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.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||||
R.id.settings -> launchSettings()
|
R.id.settings -> launchSettings()
|
||||||
R.id.about -> launchAbout()
|
R.id.about -> launchAbout()
|
||||||
|
@ -568,15 +565,21 @@ class MainActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun increaseColumnCount() {
|
private fun changeColumnCount() {
|
||||||
getAllFragments().forEach {
|
val items = ArrayList<RadioItem>()
|
||||||
(it as? ItemOperationsListener)?.increaseColumnCount()
|
for (i in 1..MAX_COLUMN_COUNT) {
|
||||||
|
items.add(RadioItem(i, resources.getQuantityString(R.plurals.column_counts, i, i)))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun reduceColumnCount() {
|
val currentColumnCount = config.fileColumnCnt
|
||||||
getAllFragments().forEach {
|
RadioGroupDialog(this, items, config.fileColumnCnt) {
|
||||||
(it as? ItemOperationsListener)?.reduceColumnCount()
|
val newColumnCount = it as Int
|
||||||
|
if (currentColumnCount != newColumnCount) {
|
||||||
|
config.fileColumnCnt = newColumnCount
|
||||||
|
getAllFragments().forEach {
|
||||||
|
(it as? ItemOperationsListener)?.columnCountChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,14 @@ import android.view.MenuItem
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.view.MenuItemCompat
|
import androidx.core.view.MenuItemCompat
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
|
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
|
||||||
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
|
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
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.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
@ -85,8 +87,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
||||||
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden
|
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden
|
||||||
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden
|
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden
|
||||||
|
|
||||||
findItem(R.id.increase_column_count).isVisible = currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt < MAX_COLUMN_COUNT
|
findItem(R.id.column_count).isVisible = currentViewType == VIEW_TYPE_GRID
|
||||||
findItem(R.id.reduce_column_count).isVisible = currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt > 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +100,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
||||||
R.id.change_view_type -> changeViewType()
|
R.id.change_view_type -> changeViewType()
|
||||||
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()
|
|
||||||
else -> return@setOnMenuItemClickListener false
|
else -> return@setOnMenuItemClickListener false
|
||||||
}
|
}
|
||||||
return@setOnMenuItemClickListener true
|
return@setOnMenuItemClickListener true
|
||||||
|
@ -166,20 +166,44 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
||||||
getRecyclerAdapter()?.updateDisplayFilenamesInGrid()
|
getRecyclerAdapter()?.updateDisplayFilenamesInGrid()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = config.fileColumnCnt
|
||||||
|
RadioGroupDialog(this, items, config.fileColumnCnt) {
|
||||||
|
val newColumnCount = it as Int
|
||||||
|
if (currentColumnCount != newColumnCount) {
|
||||||
|
config.fileColumnCnt = newColumnCount
|
||||||
|
columnCountChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun increaseColumnCount() {
|
override fun increaseColumnCount() {
|
||||||
if (currentViewType == VIEW_TYPE_GRID) {
|
if (currentViewType == VIEW_TYPE_GRID) {
|
||||||
config.fileColumnCnt = ++(mimetypes_list.layoutManager as MyGridLayoutManager).spanCount
|
config.fileColumnCnt += 1
|
||||||
columnCountChanged()
|
columnCountChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reduceColumnCount() {
|
override fun reduceColumnCount() {
|
||||||
if (currentViewType == VIEW_TYPE_GRID) {
|
if (currentViewType == VIEW_TYPE_GRID) {
|
||||||
config.fileColumnCnt = --(mimetypes_list.layoutManager as MyGridLayoutManager).spanCount
|
config.fileColumnCnt -= 1
|
||||||
columnCountChanged()
|
columnCountChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun columnCountChanged() {
|
||||||
|
(mimetypes_list.layoutManager as MyGridLayoutManager).spanCount = config.fileColumnCnt
|
||||||
|
refreshMenuItems()
|
||||||
|
getRecyclerAdapter()?.apply {
|
||||||
|
notifyItemRangeChanged(0, listItems.size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun finishActMode() {}
|
override fun finishActMode() {}
|
||||||
|
|
||||||
private fun setupSearch(menu: Menu) {
|
private fun setupSearch(menu: Menu) {
|
||||||
|
@ -370,13 +394,6 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun columnCountChanged() {
|
|
||||||
refreshMenuItems()
|
|
||||||
getRecyclerAdapter()?.apply {
|
|
||||||
notifyItemRangeChanged(0, listItems.size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupLayoutManager() {
|
private fun setupLayoutManager() {
|
||||||
if (config.getFolderViewType(currentMimeType) == VIEW_TYPE_GRID) {
|
if (config.getFolderViewType(currentMimeType) == VIEW_TYPE_GRID) {
|
||||||
currentViewType = VIEW_TYPE_GRID
|
currentViewType = VIEW_TYPE_GRID
|
||||||
|
|
|
@ -488,19 +488,20 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
||||||
|
|
||||||
override fun increaseColumnCount() {
|
override fun increaseColumnCount() {
|
||||||
if (currentViewType == VIEW_TYPE_GRID) {
|
if (currentViewType == VIEW_TYPE_GRID) {
|
||||||
context?.config?.fileColumnCnt = ++(items_list.layoutManager as MyGridLayoutManager).spanCount
|
context!!.config.fileColumnCnt += 1
|
||||||
columnCountChanged()
|
columnCountChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reduceColumnCount() {
|
override fun reduceColumnCount() {
|
||||||
if (currentViewType == VIEW_TYPE_GRID) {
|
if (currentViewType == VIEW_TYPE_GRID) {
|
||||||
context?.config?.fileColumnCnt = --(items_list.layoutManager as MyGridLayoutManager).spanCount
|
context!!.config.fileColumnCnt -= 1
|
||||||
columnCountChanged()
|
columnCountChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun columnCountChanged() {
|
override fun columnCountChanged() {
|
||||||
|
(items_list.layoutManager as MyGridLayoutManager).spanCount = context!!.config.fileColumnCnt
|
||||||
(activity as? MainActivity)?.refreshMenuItems()
|
(activity as? MainActivity)?.refreshMenuItems()
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
notifyItemRangeChanged(0, listItems.size)
|
notifyItemRangeChanged(0, listItems.size)
|
||||||
|
|
|
@ -178,19 +178,20 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
||||||
|
|
||||||
override fun increaseColumnCount() {
|
override fun increaseColumnCount() {
|
||||||
if (currentViewType == VIEW_TYPE_GRID) {
|
if (currentViewType == VIEW_TYPE_GRID) {
|
||||||
context?.config?.fileColumnCnt = ++(recents_list.layoutManager as MyGridLayoutManager).spanCount
|
context!!.config.fileColumnCnt += 1
|
||||||
columnCountChanged()
|
columnCountChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reduceColumnCount() {
|
override fun reduceColumnCount() {
|
||||||
if (currentViewType == VIEW_TYPE_GRID) {
|
if (currentViewType == VIEW_TYPE_GRID) {
|
||||||
context?.config?.fileColumnCnt = --(recents_list.layoutManager as MyGridLayoutManager).spanCount
|
context!!.config.fileColumnCnt -= 1
|
||||||
columnCountChanged()
|
columnCountChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun columnCountChanged() {
|
override fun columnCountChanged() {
|
||||||
|
(recents_list.layoutManager as MyGridLayoutManager).spanCount = context!!.config.fileColumnCnt
|
||||||
(activity as? MainActivity)?.refreshMenuItems()
|
(activity as? MainActivity)?.refreshMenuItems()
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
notifyItemRangeChanged(0, listItems.size)
|
notifyItemRangeChanged(0, listItems.size)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.simplemobiletools.commons.helpers.TAB_RECENT_FILES
|
||||||
import com.simplemobiletools.commons.helpers.TAB_STORAGE_ANALYSIS
|
import com.simplemobiletools.commons.helpers.TAB_STORAGE_ANALYSIS
|
||||||
|
|
||||||
const val PATH = "path"
|
const val PATH = "path"
|
||||||
const val MAX_COLUMN_COUNT = 20
|
const val MAX_COLUMN_COUNT = 15
|
||||||
|
|
||||||
// shared preferences
|
// shared preferences
|
||||||
const val SHOW_HIDDEN = "show_hidden"
|
const val SHOW_HIDDEN = "show_hidden"
|
||||||
|
|
|
@ -18,6 +18,8 @@ interface ItemOperationsListener {
|
||||||
|
|
||||||
fun toggleFilenameVisibility()
|
fun toggleFilenameVisibility()
|
||||||
|
|
||||||
|
fun columnCountChanged()
|
||||||
|
|
||||||
fun increaseColumnCount()
|
fun increaseColumnCount()
|
||||||
|
|
||||||
fun reduceColumnCount()
|
fun reduceColumnCount()
|
||||||
|
|
|
@ -54,14 +54,9 @@
|
||||||
android:title="@string/stop_showing_hidden"
|
android:title="@string/stop_showing_hidden"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/increase_column_count"
|
android:id="@+id/column_count"
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
android:title="@string/increase_column_count"
|
android:title="@string/column_count"
|
||||||
app:showAsAction="never" />
|
|
||||||
<item
|
|
||||||
android:id="@+id/reduce_column_count"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/reduce_column_count"
|
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/more_apps_from_us"
|
android:id="@+id/more_apps_from_us"
|
||||||
|
|
|
@ -35,13 +35,8 @@
|
||||||
android:title="@string/stop_showing_hidden"
|
android:title="@string/stop_showing_hidden"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/increase_column_count"
|
android:id="@+id/column_count"
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
android:title="@string/increase_column_count"
|
android:title="@string/column_count"
|
||||||
app:showAsAction="never" />
|
|
||||||
<item
|
|
||||||
android:id="@+id/reduce_column_count"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/reduce_column_count"
|
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
||||||
|
|
Loading…
Reference in New Issue