Skip to content

Commit 810043d

Browse files
committed
Replace icon shape string literals with constants
1 parent 34939b3 commit 810043d

2 files changed

Lines changed: 28 additions & 15 deletions

File tree

Omega/src/com/neoapps/neolauncher/icons/IconShape.kt

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import android.util.Log
2727
import com.android.launcher3.R
2828
import com.android.launcher3.Utilities
2929
import com.android.launcher3.shapes.IconShapeModel
30+
import com.neoapps.neolauncher.util.Config
3031

3132
open class IconShape(
3233
private val topLeft: Corner,
@@ -424,21 +425,19 @@ open class IconShape(
424425
}
425426

426427
fun fromString(value: String): IconShape = when (value) {
427-
// TODO add constants instead of string literals
428-
"circle" -> Circle
429-
"square" -> Square
430-
"sharpSquare" -> SharpSquare
431-
"roundedSquare" -> RoundedSquare
432-
"squircle" -> Squircle
433-
"sammy" -> Sammy
434-
"teardrop" -> Teardrop
435-
"cylinder" -> Cylinder
436-
"cupertino" -> Cupertino
437-
"hexagon" -> Hexagon
438-
"octagon" -> Octagon
439-
"egg" -> Egg
440-
"" -> Circle
441-
else -> runCatching { parseCustomShape(value) }.getOrDefault(Circle)
428+
Config.SHAPE_CIRCLE -> Circle
429+
Config.SHAPE_SQUARE -> Square
430+
Config.SHAPE_SHARP_SQUARE -> SharpSquare
431+
Config.SHAPE_ROUNDED_SQUARE -> RoundedSquare
432+
Config.SHAPE_SQUIRCLE -> Squircle
433+
Config.SHAPE_SAMMY -> Sammy
434+
Config.SHAPE_TEARDROP -> Teardrop
435+
Config.SHAPE_CYLINDER -> Cylinder
436+
Config.SHAPE_CUPERTINO -> Cupertino
437+
Config.SHAPE_HEXAGON -> Hexagon
438+
Config.SHAPE_OCTAGON -> Octagon
439+
Config.SHAPE_EGG -> Egg
440+
else -> runCatching { parseCustomShape(value) }.getOrDefault(Circle)
442441
}
443442

444443
private fun parseCustomShape(value: String): IconShape {

Omega/src/com/neoapps/neolauncher/util/Config.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ class Config(val context: Context) {
115115
const val BS_CREATE_GROUP = 1
116116
const val BS_EDIT_GROUP = 2
117117

118+
//ICON SHAPE
119+
const val SHAPE_CIRCLE = "circle"
120+
const val SHAPE_SQUARE = "square"
121+
const val SHAPE_SHARP_SQUARE = "sharpSquare"
122+
const val SHAPE_ROUNDED_SQUARE = "roundedSquare"
123+
const val SHAPE_SQUIRCLE = "squircle"
124+
const val SHAPE_SAMMY = "sammy"
125+
const val SHAPE_TEARDROP = "teardrop"
126+
const val SHAPE_CYLINDER = "cylinder"
127+
const val SHAPE_CUPERTINO = "cupertino"
128+
const val SHAPE_HEXAGON = "hexagon"
129+
const val SHAPE_OCTAGON = "octagon"
130+
const val SHAPE_EGG = "egg"
131+
118132
val drawerSortOptions = mutableMapOf(
119133
SORT_AZ to R.string.title__sort_alphabetical_az,
120134
SORT_ZA to R.string.title__sort_alphabetical_za,

0 commit comments

Comments
 (0)