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