Remove landscape row and column counts
This commit is contained in:
parent
1cbc887c3c
commit
3ed5119129
|
@ -152,8 +152,8 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||
}
|
||||
}
|
||||
|
||||
for (checkedYCell in 0 until getHomeColumnCount()) {
|
||||
for (checkedXCell in 0 until getHomeRowCount() - 1) {
|
||||
for (checkedYCell in 0 until config.homeColumnCount) {
|
||||
for (checkedXCell in 0 until config.homeRowCount - 1) {
|
||||
val wantedCell = Pair(checkedXCell, checkedYCell)
|
||||
if (!occupiedCells.contains(wantedCell)) {
|
||||
return Rect(wantedCell.first, wantedCell.second, wantedCell.first, wantedCell.second)
|
||||
|
@ -210,8 +210,8 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||
}
|
||||
|
||||
home_screen_grid?.resizeGrid(
|
||||
newRowCount = getHomeRowCount(),
|
||||
newColumnCount = getHomeColumnCount()
|
||||
newRowCount = config.homeRowCount,
|
||||
newColumnCount = config.homeColumnCount
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||
mLongPressedIcon = gridItem
|
||||
val anchorY = if (isOnAllAppsFragment || gridItem.type == ITEM_TYPE_WIDGET) {
|
||||
y
|
||||
} else if (gridItem.top == getHomeRowCount() - 1) {
|
||||
} else if (gridItem.top == config.homeRowCount - 1) {
|
||||
home_screen_grid.sideMargins.top + (gridItem.top * home_screen_grid.cellHeight.toFloat())
|
||||
} else {
|
||||
(gridItem.top * home_screen_grid.cellHeight.toFloat())
|
||||
|
@ -704,7 +704,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||
val defaultDialerPackage = (getSystemService(Context.TELECOM_SERVICE) as TelecomManager).defaultDialerPackage
|
||||
appLaunchers.firstOrNull { it.packageName == defaultDialerPackage }?.apply {
|
||||
val dialerIcon =
|
||||
HomeScreenGridItem(null, 0, getHomeRowCount() - 1, 0, getHomeRowCount() - 1, defaultDialerPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null)
|
||||
HomeScreenGridItem(null, 0, config.homeRowCount - 1, 0, config.homeRowCount - 1, defaultDialerPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null)
|
||||
homeScreenGridItems.add(dialerIcon)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
@ -714,7 +714,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||
val defaultSMSMessengerPackage = Telephony.Sms.getDefaultSmsPackage(this)
|
||||
appLaunchers.firstOrNull { it.packageName == defaultSMSMessengerPackage }?.apply {
|
||||
val SMSMessengerIcon =
|
||||
HomeScreenGridItem(null, 1, getHomeRowCount() - 1, 1, getHomeRowCount() - 1, defaultSMSMessengerPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null)
|
||||
HomeScreenGridItem(null, 1, config.homeRowCount - 1, 1, config.homeRowCount - 1, defaultSMSMessengerPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null)
|
||||
homeScreenGridItems.add(SMSMessengerIcon)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
@ -726,7 +726,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||
val defaultBrowserPackage = resolveInfo!!.activityInfo.packageName
|
||||
appLaunchers.firstOrNull { it.packageName == defaultBrowserPackage }?.apply {
|
||||
val browserIcon =
|
||||
HomeScreenGridItem(null, 2, getHomeRowCount() - 1, 2, getHomeRowCount() - 1, defaultBrowserPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null)
|
||||
HomeScreenGridItem(null, 2, config.homeRowCount - 1, 2, config.homeRowCount - 1, defaultBrowserPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null)
|
||||
homeScreenGridItems.add(browserIcon)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
@ -737,7 +737,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||
val storePackage = potentialStores.firstOrNull { isPackageInstalled(it) && appLaunchers.map { it.packageName }.contains(it) }
|
||||
if (storePackage != null) {
|
||||
appLaunchers.firstOrNull { it.packageName == storePackage }?.apply {
|
||||
val storeIcon = HomeScreenGridItem(null, 3, getHomeRowCount() - 1, 3, getHomeRowCount() - 1, storePackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null)
|
||||
val storeIcon = HomeScreenGridItem(null, 3, config.homeRowCount - 1, 3, config.homeRowCount - 1, storePackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null)
|
||||
homeScreenGridItems.add(storeIcon)
|
||||
}
|
||||
}
|
||||
|
@ -750,7 +750,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||
val defaultCameraPackage = resolveInfo!!.activityInfo.packageName
|
||||
appLaunchers.firstOrNull { it.packageName == defaultCameraPackage }?.apply {
|
||||
val cameraIcon =
|
||||
HomeScreenGridItem(null, 4, getHomeRowCount() - 1, 4, getHomeRowCount() - 1, defaultCameraPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null)
|
||||
HomeScreenGridItem(null, 4, config.homeRowCount - 1, 4, config.homeRowCount - 1, defaultCameraPackage, "", title, ITEM_TYPE_ICON, "", -1, "", "", null)
|
||||
homeScreenGridItems.add(cameraIcon)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
|
|
@ -11,8 +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.getHomeColumnCount
|
||||
import com.simplemobiletools.launcher.extensions.getHomeRowCount
|
||||
import com.simplemobiletools.launcher.helpers.MAX_COLUMN_COUNT
|
||||
import com.simplemobiletools.launcher.helpers.MAX_ROW_COUNT
|
||||
import com.simplemobiletools.launcher.helpers.MIN_COLUMN_COUNT
|
||||
|
@ -93,7 +91,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupHomeRowCount() {
|
||||
val currentRowCount = getHomeRowCount()
|
||||
val currentRowCount = config.homeRowCount
|
||||
settings_home_screen_row_count.text = currentRowCount.toString()
|
||||
settings_home_screen_row_count_holder.setOnClickListener {
|
||||
val items = ArrayList<RadioItem>()
|
||||
|
@ -104,11 +102,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
RadioGroupDialog(this, items, currentRowCount) {
|
||||
val newRowCount = it as Int
|
||||
if (currentRowCount != newRowCount) {
|
||||
if (portrait) {
|
||||
config.portraitHomeRowCount = newRowCount
|
||||
} else {
|
||||
config.landscapeHomeRowCount = newRowCount
|
||||
}
|
||||
config.homeRowCount = newRowCount
|
||||
setupHomeRowCount()
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +110,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupHomeColumnCount() {
|
||||
val currentColumnCount = getHomeColumnCount()
|
||||
val currentColumnCount = config.homeColumnCount
|
||||
settings_home_screen_column_count.text = currentColumnCount.toString()
|
||||
settings_home_screen_column_count_holder.setOnClickListener {
|
||||
val items = ArrayList<RadioItem>()
|
||||
|
@ -127,11 +121,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
RadioGroupDialog(this, items, currentColumnCount) {
|
||||
val newColumnCount = it as Int
|
||||
if (currentColumnCount != newColumnCount) {
|
||||
if (portrait) {
|
||||
config.portraitHomeColumnCount = newColumnCount
|
||||
} else {
|
||||
config.landscapeHomeColumnCount = newColumnCount
|
||||
}
|
||||
config.homeColumnCount = newColumnCount
|
||||
setupHomeColumnCount()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,22 +31,6 @@ fun Context.getColumnCount(): Int {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.getHomeRowCount(): Int {
|
||||
return if (portrait) {
|
||||
config.portraitHomeRowCount
|
||||
} else {
|
||||
config.landscapeHomeRowCount
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getHomeColumnCount(): Int {
|
||||
return if (portrait) {
|
||||
config.portraitHomeColumnCount
|
||||
} else {
|
||||
config.landscapeHomeColumnCount
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getDrawableForPackageName(packageName: String): Drawable? {
|
||||
var drawable: Drawable? = null
|
||||
try {
|
||||
|
|
|
@ -12,19 +12,11 @@ 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 portraitHomeColumnCount: Int
|
||||
get() = prefs.getInt(PORTRAIT_HOME_COLUMN_COUNT, COLUMN_COUNT)
|
||||
set(portraitHomeColumnCount) = prefs.edit().putInt(PORTRAIT_HOME_COLUMN_COUNT, portraitHomeColumnCount).apply()
|
||||
var homeColumnCount: Int
|
||||
get() = prefs.getInt(HOME_COLUMN_COUNT, COLUMN_COUNT)
|
||||
set(homeColumnCount) = prefs.edit().putInt(HOME_COLUMN_COUNT, homeColumnCount).apply()
|
||||
|
||||
var landscapeHomeColumnCount: Int
|
||||
get() = prefs.getInt(LANDSCAPE_HOME_COLUMN_COUNT, COLUMN_COUNT)
|
||||
set(landscapeHomeColumnCount) = prefs.edit().putInt(LANDSCAPE_HOME_COLUMN_COUNT, landscapeHomeColumnCount).apply()
|
||||
|
||||
var portraitHomeRowCount: Int
|
||||
get() = prefs.getInt(PORTRAIT_HOME_ROW_COUNT, ROW_COUNT)
|
||||
set(portraitHomeRowCount) = prefs.edit().putInt(PORTRAIT_HOME_ROW_COUNT, portraitHomeRowCount).apply()
|
||||
|
||||
var landscapeHomeRowCount: Int
|
||||
get() = prefs.getInt(LANDSCAPE_HOME_ROW_COUNT, ROW_COUNT)
|
||||
set(landscapeHomeRowCount) = prefs.edit().putInt(LANDSCAPE_HOME_ROW_COUNT, landscapeHomeRowCount).apply()
|
||||
var homeRowCount: Int
|
||||
get() = prefs.getInt(HOME_ROW_COUNT, ROW_COUNT)
|
||||
set(homeRowCount) = prefs.edit().putInt(HOME_ROW_COUNT, homeRowCount).apply()
|
||||
}
|
||||
|
|
|
@ -5,10 +5,8 @@ const val WIDGET_LIST_ITEMS_HOLDER = 1
|
|||
|
||||
// shared prefs
|
||||
const val WAS_HOME_SCREEN_INIT = "was_home_screen_init"
|
||||
const val PORTRAIT_HOME_ROW_COUNT = "portrait_home_row_count"
|
||||
const val LANDSCAPE_HOME_ROW_COUNT = "landscape_home_row_count"
|
||||
const val PORTRAIT_HOME_COLUMN_COUNT = "portrait_home_column_count"
|
||||
const val LANDSCAPE_HOME_COLUMN_COUNT = "landscape_home_column_count"
|
||||
const val HOME_ROW_COUNT = "home_row_count"
|
||||
const val HOME_COLUMN_COUNT = "home_column_count"
|
||||
|
||||
// default home screen grid size
|
||||
const val ROW_COUNT = 6
|
||||
|
|
|
@ -22,9 +22,8 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
|||
import com.simplemobiletools.commons.helpers.isSPlus
|
||||
import com.simplemobiletools.launcher.R
|
||||
import com.simplemobiletools.launcher.activities.MainActivity
|
||||
import com.simplemobiletools.launcher.extensions.config
|
||||
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
||||
import com.simplemobiletools.launcher.extensions.getHomeColumnCount
|
||||
import com.simplemobiletools.launcher.extensions.getHomeRowCount
|
||||
import com.simplemobiletools.launcher.extensions.homeScreenGridItemsDB
|
||||
import com.simplemobiletools.launcher.helpers.*
|
||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||
|
@ -46,8 +45,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||
private var redrawWidgets = false
|
||||
private var iconSize = 0
|
||||
|
||||
private var columnCount = context.getHomeColumnCount()
|
||||
private var rowCount = context.getHomeRowCount()
|
||||
private var columnCount = context.config.homeColumnCount
|
||||
private var rowCount = context.config.homeRowCount
|
||||
private var cellXCoords = ArrayList<Int>(columnCount)
|
||||
private var cellYCoords = ArrayList<Int>(rowCount)
|
||||
var cellWidth = 0
|
||||
|
@ -642,14 +641,14 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||
}
|
||||
|
||||
private fun fillCellSizes() {
|
||||
cellWidth = getFakeWidth() / context.getHomeColumnCount()
|
||||
cellHeight = getFakeHeight() / context.getHomeRowCount()
|
||||
cellWidth = getFakeWidth() / context.config.homeColumnCount
|
||||
cellHeight = getFakeHeight() / context.config.homeRowCount
|
||||
iconSize = min(cellWidth, cellHeight) - 2 * iconMargin
|
||||
for (i in 0 until context.getHomeColumnCount()) {
|
||||
for (i in 0 until context.config.homeColumnCount) {
|
||||
cellXCoords.add(i, i * cellWidth)
|
||||
}
|
||||
|
||||
for (i in 0 until context.getHomeRowCount()) {
|
||||
for (i in 0 until context.config.homeRowCount) {
|
||||
cellYCoords.add(i, i * cellHeight)
|
||||
}
|
||||
|
||||
|
@ -690,15 +689,15 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||
if (rect.left < 0) {
|
||||
rect.right -= rect.left
|
||||
rect.left = 0
|
||||
} else if (rect.right > context.getHomeColumnCount() - 1) {
|
||||
val diff = rect.right - context.getHomeColumnCount() + 1
|
||||
} else if (rect.right > context.config.homeColumnCount - 1) {
|
||||
val diff = rect.right - context.config.homeColumnCount + 1
|
||||
rect.right -= diff
|
||||
rect.left -= diff
|
||||
}
|
||||
|
||||
// do not allow placing widgets at the bottom row, that is for pinned default apps
|
||||
if (rect.bottom >= context.getHomeRowCount() - 1) {
|
||||
val diff = rect.bottom - context.getHomeRowCount() + 2
|
||||
if (rect.bottom >= context.config.homeRowCount - 1) {
|
||||
val diff = rect.bottom - context.config.homeRowCount + 2
|
||||
rect.bottom -= diff
|
||||
rect.top -= diff
|
||||
}
|
||||
|
|
|
@ -9,9 +9,8 @@ import android.util.AttributeSet
|
|||
import android.view.MotionEvent
|
||||
import android.widget.RelativeLayout
|
||||
import com.simplemobiletools.launcher.R
|
||||
import com.simplemobiletools.launcher.extensions.config
|
||||
import com.simplemobiletools.launcher.extensions.getCellCount
|
||||
import com.simplemobiletools.launcher.extensions.getHomeColumnCount
|
||||
import com.simplemobiletools.launcher.extensions.getHomeRowCount
|
||||
import com.simplemobiletools.launcher.helpers.MAX_CLICK_DURATION
|
||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||
|
||||
|
@ -76,8 +75,8 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||
it.provider.className == gridItem.className
|
||||
} ?: return
|
||||
|
||||
minResizeWidthCells = Math.min(context.getHomeColumnCount(), context.getCellCount(providerInfo.minResizeWidth))
|
||||
minResizeHeightCells = Math.min(context.getHomeRowCount(), context.getCellCount(providerInfo.minResizeHeight))
|
||||
minResizeWidthCells = Math.min(context.config.homeColumnCount, context.getCellCount(providerInfo.minResizeWidth))
|
||||
minResizeHeightCells = Math.min(context.config.homeRowCount, context.getCellCount(providerInfo.minResizeHeight))
|
||||
redrawFrame()
|
||||
|
||||
occupiedCells.clear()
|
||||
|
@ -224,7 +223,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||
}
|
||||
}
|
||||
|
||||
if (wantedBottomCellY == context.getHomeRowCount() - 1) {
|
||||
if (wantedBottomCellY == context.config.homeRowCount - 1) {
|
||||
areAllCellsFree = false
|
||||
}
|
||||
|
||||
|
@ -322,7 +321,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||
}
|
||||
}
|
||||
|
||||
if (wantedBottomCellY == context.getHomeRowCount() - 1) {
|
||||
if (wantedBottomCellY == context.config.homeRowCount - 1) {
|
||||
areAllCellsFree = false
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue