mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-04-24 14:48:43 +02:00
Remove landscape orientation settings
This commit is contained in:
parent
f4adf578d4
commit
ee914d889a
@ -11,7 +11,7 @@ import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
|||||||
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
import com.simplemobiletools.launcher.adapters.HiddenIconsAdapter
|
import com.simplemobiletools.launcher.adapters.HiddenIconsAdapter
|
||||||
import com.simplemobiletools.launcher.extensions.getDrawerColumnCount
|
import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
||||||
import com.simplemobiletools.launcher.extensions.hiddenIconsDB
|
import com.simplemobiletools.launcher.extensions.hiddenIconsDB
|
||||||
import com.simplemobiletools.launcher.models.HiddenIcon
|
import com.simplemobiletools.launcher.models.HiddenIcon
|
||||||
@ -28,7 +28,7 @@ class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
setupMaterialScrollListener(manage_hidden_icons_list, manage_hidden_icons_toolbar)
|
setupMaterialScrollListener(manage_hidden_icons_list, manage_hidden_icons_toolbar)
|
||||||
|
|
||||||
val layoutManager = manage_hidden_icons_list.layoutManager as MyGridLayoutManager
|
val layoutManager = manage_hidden_icons_list.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = getDrawerColumnCount()
|
layoutManager.spanCount = config.drawerColumnCount
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -11,7 +11,6 @@ import com.simplemobiletools.commons.models.RadioItem
|
|||||||
import com.simplemobiletools.launcher.BuildConfig
|
import com.simplemobiletools.launcher.BuildConfig
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
import com.simplemobiletools.launcher.extensions.config
|
import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.extensions.getDrawerColumnCount
|
|
||||||
import com.simplemobiletools.launcher.helpers.MAX_COLUMN_COUNT
|
import com.simplemobiletools.launcher.helpers.MAX_COLUMN_COUNT
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
@ -88,7 +87,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDrawerColumnCount() {
|
private fun setupDrawerColumnCount() {
|
||||||
val currentColumnCount = getDrawerColumnCount()
|
val currentColumnCount = config.drawerColumnCount
|
||||||
settings_drawer_column_count.text = currentColumnCount.toString()
|
settings_drawer_column_count.text = currentColumnCount.toString()
|
||||||
settings_drawer_column_count_holder.setOnClickListener {
|
settings_drawer_column_count_holder.setOnClickListener {
|
||||||
val items = ArrayList<RadioItem>()
|
val items = ArrayList<RadioItem>()
|
||||||
@ -99,11 +98,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
RadioGroupDialog(this, items, currentColumnCount) {
|
RadioGroupDialog(this, items, currentColumnCount) {
|
||||||
val newColumnCount = it as Int
|
val newColumnCount = it as Int
|
||||||
if (currentColumnCount != newColumnCount) {
|
if (currentColumnCount != newColumnCount) {
|
||||||
if (portrait) {
|
config.drawerColumnCount = newColumnCount
|
||||||
config.portraitDrawerColumnCount = newColumnCount
|
|
||||||
} else {
|
|
||||||
config.landscapeDrawerColumnCount = newColumnCount
|
|
||||||
}
|
|
||||||
setupDrawerColumnCount()
|
setupDrawerColumnCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import com.simplemobiletools.commons.extensions.getProperTextColor
|
|||||||
import com.simplemobiletools.commons.extensions.realScreenSize
|
import com.simplemobiletools.commons.extensions.realScreenSize
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
import com.simplemobiletools.launcher.activities.SimpleActivity
|
import com.simplemobiletools.launcher.activities.SimpleActivity
|
||||||
import com.simplemobiletools.launcher.extensions.getDrawerColumnCount
|
import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.interfaces.AllAppsListener
|
import com.simplemobiletools.launcher.interfaces.AllAppsListener
|
||||||
import com.simplemobiletools.launcher.models.AppLauncher
|
import com.simplemobiletools.launcher.models.AppLauncher
|
||||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||||
@ -47,7 +47,7 @@ class LaunchersAdapter(
|
|||||||
override fun getItemCount() = launchers.size
|
override fun getItemCount() = launchers.size
|
||||||
|
|
||||||
private fun calculateIconWidth() {
|
private fun calculateIconWidth() {
|
||||||
val currentColumnCount = activity.getDrawerColumnCount()
|
val currentColumnCount = activity.config.drawerColumnCount
|
||||||
|
|
||||||
val iconWidth = activity.realScreenSize.x / currentColumnCount
|
val iconWidth = activity.realScreenSize.x / currentColumnCount
|
||||||
iconPadding = (iconWidth * 0.1f).toInt()
|
iconPadding = (iconWidth * 0.1f).toInt()
|
||||||
|
@ -6,9 +6,7 @@ import android.content.pm.LauncherApps
|
|||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import android.util.Size
|
import android.util.Size
|
||||||
import com.simplemobiletools.commons.extensions.portrait
|
|
||||||
import com.simplemobiletools.commons.helpers.isSPlus
|
import com.simplemobiletools.commons.helpers.isSPlus
|
||||||
import com.simplemobiletools.launcher.R
|
|
||||||
import com.simplemobiletools.launcher.databases.AppsDatabase
|
import com.simplemobiletools.launcher.databases.AppsDatabase
|
||||||
import com.simplemobiletools.launcher.helpers.Config
|
import com.simplemobiletools.launcher.helpers.Config
|
||||||
import com.simplemobiletools.launcher.interfaces.AppLaunchersDao
|
import com.simplemobiletools.launcher.interfaces.AppLaunchersDao
|
||||||
@ -23,14 +21,6 @@ val Context.homeScreenGridItemsDB: HomeScreenGridItemsDao get() = AppsDatabase.g
|
|||||||
|
|
||||||
val Context.hiddenIconsDB: HiddenIconsDao get() = AppsDatabase.getInstance(applicationContext).HiddenIconsDao()
|
val Context.hiddenIconsDB: HiddenIconsDao get() = AppsDatabase.getInstance(applicationContext).HiddenIconsDao()
|
||||||
|
|
||||||
fun Context.getDrawerColumnCount(): Int {
|
|
||||||
return if (portrait) {
|
|
||||||
config.portraitDrawerColumnCount
|
|
||||||
} else {
|
|
||||||
config.landscapeDrawerColumnCount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Context.getDrawableForPackageName(packageName: String): Drawable? {
|
fun Context.getDrawableForPackageName(packageName: String): Drawable? {
|
||||||
var drawable: Drawable? = null
|
var drawable: Drawable? = null
|
||||||
try {
|
try {
|
||||||
|
@ -13,7 +13,7 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager
|
|||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
import com.simplemobiletools.launcher.activities.MainActivity
|
import com.simplemobiletools.launcher.activities.MainActivity
|
||||||
import com.simplemobiletools.launcher.adapters.LaunchersAdapter
|
import com.simplemobiletools.launcher.adapters.LaunchersAdapter
|
||||||
import com.simplemobiletools.launcher.extensions.getDrawerColumnCount
|
import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.extensions.launchApp
|
import com.simplemobiletools.launcher.extensions.launchApp
|
||||||
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_ICON
|
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_ICON
|
||||||
import com.simplemobiletools.launcher.interfaces.AllAppsListener
|
import com.simplemobiletools.launcher.interfaces.AllAppsListener
|
||||||
@ -47,7 +47,7 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
val layoutManager = all_apps_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = all_apps_grid.layoutManager as MyGridLayoutManager
|
||||||
if (layoutManager.spanCount != context.getDrawerColumnCount()) {
|
if (layoutManager.spanCount != context.config.drawerColumnCount) {
|
||||||
onConfigurationChanged()
|
onConfigurationChanged()
|
||||||
// Force redraw due to changed item size
|
// Force redraw due to changed item size
|
||||||
(all_apps_grid.adapter as LaunchersAdapter).notifyDataSetChanged()
|
(all_apps_grid.adapter as LaunchersAdapter).notifyDataSetChanged()
|
||||||
@ -64,7 +64,7 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||||||
setupViews()
|
setupViews()
|
||||||
|
|
||||||
val layoutManager = all_apps_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = all_apps_grid.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = context.getDrawerColumnCount()
|
layoutManager.spanCount = context.config.drawerColumnCount
|
||||||
val launchers = (all_apps_grid.adapter as LaunchersAdapter).launchers
|
val launchers = (all_apps_grid.adapter as LaunchersAdapter).launchers
|
||||||
setupAdapter(launchers)
|
setupAdapter(launchers)
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||||||
private fun setupAdapter(launchers: ArrayList<AppLauncher>) {
|
private fun setupAdapter(launchers: ArrayList<AppLauncher>) {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
val layoutManager = all_apps_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = all_apps_grid.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = context.getDrawerColumnCount()
|
layoutManager.spanCount = context.config.drawerColumnCount
|
||||||
|
|
||||||
val currAdapter = all_apps_grid.adapter
|
val currAdapter = all_apps_grid.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
|
@ -13,11 +13,7 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
get() = prefs.getBoolean(WAS_HOME_SCREEN_INIT, false)
|
get() = prefs.getBoolean(WAS_HOME_SCREEN_INIT, false)
|
||||||
set(wasHomeScreenInit) = prefs.edit().putBoolean(WAS_HOME_SCREEN_INIT, wasHomeScreenInit).apply()
|
set(wasHomeScreenInit) = prefs.edit().putBoolean(WAS_HOME_SCREEN_INIT, wasHomeScreenInit).apply()
|
||||||
|
|
||||||
var portraitDrawerColumnCount: Int
|
var drawerColumnCount: Int
|
||||||
get() = prefs.getInt(PORTRAIT_DRAWER_COLUMN_COUNT, context.resources.getInteger(R.integer.portrait_column_count))
|
get() = prefs.getInt(DRAWER_COLUMN_COUNT, context.resources.getInteger(R.integer.portrait_column_count))
|
||||||
set(portraitDrawerColumnCount) = prefs.edit().putInt(PORTRAIT_DRAWER_COLUMN_COUNT, portraitDrawerColumnCount).apply()
|
set(drawerColumnCount) = prefs.edit().putInt(DRAWER_COLUMN_COUNT, drawerColumnCount).apply()
|
||||||
|
|
||||||
var landscapeDrawerColumnCount: Int
|
|
||||||
get() = prefs.getInt(LANDSCAPE_DRAWER_COLUMN_COUNT, context.resources.getInteger(R.integer.landscape_column_count))
|
|
||||||
set(landscapeDrawerColumnCount) = prefs.edit().putInt(LANDSCAPE_DRAWER_COLUMN_COUNT, landscapeDrawerColumnCount).apply()
|
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,7 @@ const val WIDGET_LIST_ITEMS_HOLDER = 1
|
|||||||
|
|
||||||
// shared prefs
|
// shared prefs
|
||||||
const val WAS_HOME_SCREEN_INIT = "was_home_screen_init"
|
const val WAS_HOME_SCREEN_INIT = "was_home_screen_init"
|
||||||
const val PORTRAIT_DRAWER_COLUMN_COUNT = "portrait_drawer_column_count"
|
const val DRAWER_COLUMN_COUNT = "drawer_column_count"
|
||||||
const val LANDSCAPE_DRAWER_COLUMN_COUNT = "landscape_drawer_column_count"
|
|
||||||
|
|
||||||
// default home screen grid size
|
// default home screen grid size
|
||||||
const val ROW_COUNT = 6
|
const val ROW_COUNT = 6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user