mirror of
				https://github.com/SimpleMobileTools/Simple-App-Launcher.git
				synced 2025-06-05 21:49:21 +02:00 
			
		
		
		
	store portrait and landscape column count separately
This commit is contained in:
		| @@ -77,9 +77,15 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { | ||||
|  | ||||
|     override fun onCreateOptionsMenu(menu: Menu): Boolean { | ||||
|         menuInflater.inflate(R.menu.menu, menu) | ||||
|         val currentColumnCount = if (portrait) { | ||||
|             config.portraitColumnCnt | ||||
|         } else { | ||||
|             config.landscapeColumnCnt | ||||
|         } | ||||
|  | ||||
|         menu.apply { | ||||
|             findItem(R.id.increase_column_count).isVisible = config.columnCnt < MAX_COLUMN_COUNT | ||||
|             findItem(R.id.reduce_column_count).isVisible = config.columnCnt > 1 | ||||
|             findItem(R.id.increase_column_count).isVisible = currentColumnCount < MAX_COLUMN_COUNT | ||||
|             findItem(R.id.reduce_column_count).isVisible = currentColumnCount > 1 | ||||
|             updateMenuItemColors(menu) | ||||
|         } | ||||
|         return true | ||||
| @@ -162,12 +168,22 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { | ||||
|     } | ||||
|  | ||||
|     private fun increaseColumnCount() { | ||||
|         config.columnCnt = ++(launchers_grid.layoutManager as MyGridLayoutManager).spanCount | ||||
|         val newColumnCount = ++(launchers_grid.layoutManager as MyGridLayoutManager).spanCount | ||||
|         if (portrait) { | ||||
|             config.portraitColumnCnt = newColumnCount | ||||
|         } else { | ||||
|             config.landscapeColumnCnt = newColumnCount | ||||
|         } | ||||
|         columnCountChanged() | ||||
|     } | ||||
|  | ||||
|     private fun reduceColumnCount() { | ||||
|         config.columnCnt = --(launchers_grid.layoutManager as MyGridLayoutManager).spanCount | ||||
|         val newColumnCount = --(launchers_grid.layoutManager as MyGridLayoutManager).spanCount | ||||
|         if (portrait) { | ||||
|             config.portraitColumnCnt = newColumnCount | ||||
|         } else { | ||||
|             config.landscapeColumnCnt = newColumnCount | ||||
|         } | ||||
|         columnCountChanged() | ||||
|     } | ||||
|  | ||||
| @@ -181,7 +197,11 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { | ||||
|  | ||||
|     private fun setupGridLayoutManager() { | ||||
|         val layoutManager = launchers_grid.layoutManager as MyGridLayoutManager | ||||
|         layoutManager.spanCount = config.columnCnt | ||||
|         if (portrait) { | ||||
|             layoutManager.spanCount = config.portraitColumnCnt | ||||
|         } else { | ||||
|             layoutManager.spanCount = config.landscapeColumnCnt | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun initZoomListener() { | ||||
|   | ||||
| @@ -15,10 +15,7 @@ import com.simplemobiletools.applauncher.extensions.dbHelper | ||||
| import com.simplemobiletools.applauncher.models.AppLauncher | ||||
| import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter | ||||
| import com.simplemobiletools.commons.dialogs.ConfirmationDialog | ||||
| import com.simplemobiletools.commons.extensions.applyColorFilter | ||||
| import com.simplemobiletools.commons.extensions.beInvisibleIf | ||||
| import com.simplemobiletools.commons.extensions.beVisibleIf | ||||
| import com.simplemobiletools.commons.extensions.realScreenSize | ||||
| import com.simplemobiletools.commons.extensions.* | ||||
| import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM | ||||
| import com.simplemobiletools.commons.helpers.ensureBackgroundThread | ||||
| import com.simplemobiletools.commons.interfaces.ItemMoveCallback | ||||
| @@ -134,7 +131,13 @@ class LaunchersAdapter( | ||||
|     } | ||||
|  | ||||
|     fun calculateIconWidth() { | ||||
|         val iconWidth = activity.realScreenSize.x / activity.config.columnCnt | ||||
|         val currentColumnCount = if (activity.portrait) { | ||||
|             activity.config.portraitColumnCnt | ||||
|         } else { | ||||
|             activity.config.landscapeColumnCnt | ||||
|         } | ||||
|  | ||||
|         val iconWidth = activity.realScreenSize.x / currentColumnCount | ||||
|         iconPadding = (iconWidth * 0.1f).toInt() | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -17,7 +17,11 @@ class Config(context: Context) : BaseConfig(context) { | ||||
|         get() = prefs.getBoolean(CLOSE_APP, true) | ||||
|         set(closeApp) = prefs.edit().putBoolean(CLOSE_APP, closeApp).apply() | ||||
|  | ||||
|     var columnCnt: Int | ||||
|         get() = prefs.getInt(COLUMN_CNT, context.resources.getInteger(R.integer.column_count)) | ||||
|         set(columnCnt) = prefs.edit().putInt(COLUMN_CNT, columnCnt).apply() | ||||
|     var portraitColumnCnt: Int | ||||
|         get() = prefs.getInt(PORTRAIT_COLUMN_COUNT, context.resources.getInteger(R.integer.portrait_column_count)) | ||||
|         set(portraitColumnCnt) = prefs.edit().putInt(PORTRAIT_COLUMN_COUNT, portraitColumnCnt).apply() | ||||
|  | ||||
|     var landscapeColumnCnt: Int | ||||
|         get() = prefs.getInt(LANDSCAPE_COLUMN_COUNT, context.resources.getInteger(R.integer.landscape_column_count)) | ||||
|         set(landscapeColumnCnt) = prefs.edit().putInt(LANDSCAPE_COLUMN_COUNT, landscapeColumnCnt).apply() | ||||
| } | ||||
|   | ||||
| @@ -2,7 +2,8 @@ package com.simplemobiletools.applauncher.helpers | ||||
|  | ||||
| const val WAS_REMOVE_INFO_SHOWN = "was_remove_info_shown" | ||||
| const val CLOSE_APP = "close_app" | ||||
| const val COLUMN_CNT = "column_cnt" | ||||
| const val PORTRAIT_COLUMN_COUNT = "portrait_column_count" | ||||
| const val LANDSCAPE_COLUMN_COUNT = "landscape_column_count" | ||||
|  | ||||
| val predefinedPackageNames = arrayListOf( | ||||
|     "com.simplemobiletools.calculator", | ||||
|   | ||||
| @@ -21,7 +21,7 @@ | ||||
|                 android:layout_height="match_parent" | ||||
|                 android:clipToPadding="false" | ||||
|                 app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" | ||||
|                 app:spanCount="@integer/column_count" /> | ||||
|                 app:spanCount="@integer/portrait_column_count" /> | ||||
|  | ||||
|         </com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller> | ||||
|     </RelativeLayout> | ||||
|   | ||||
| @@ -1,3 +1,4 @@ | ||||
| <resources> | ||||
|     <integer name="column_count">6</integer> | ||||
|     <integer name="portrait_column_count">6</integer> | ||||
|     <integer name="landscape_column_count">10</integer> | ||||
| </resources> | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| <resources> | ||||
|     <integer name="default_sorting">2048</integer> | ||||
|     <integer name="column_count">5</integer> | ||||
|     <integer name="portrait_column_count">5</integer> | ||||
|     <integer name="landscape_column_count">8</integer> | ||||
| </resources> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user