create a new type for shortcuts
This commit is contained in:
parent
e76b2dcc51
commit
55f243c401
|
@ -17,6 +17,7 @@ import com.simplemobiletools.commons.helpers.isRPlus
|
|||
import com.simplemobiletools.launcher.activities.MainActivity
|
||||
import com.simplemobiletools.launcher.adapters.WidgetsAdapter
|
||||
import com.simplemobiletools.launcher.helpers.COLUMN_COUNT
|
||||
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_SHORTCUT
|
||||
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_WIDGET
|
||||
import com.simplemobiletools.launcher.helpers.ROW_COUNT
|
||||
import com.simplemobiletools.launcher.interfaces.WidgetsFragmentListener
|
||||
|
@ -221,6 +222,12 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||
}
|
||||
|
||||
override fun onWidgetLongPressed(appWidget: AppWidget) {
|
||||
val type = if (appWidget.isShortcut) {
|
||||
ITEM_TYPE_SHORTCUT
|
||||
} else {
|
||||
ITEM_TYPE_WIDGET
|
||||
}
|
||||
|
||||
val gridItem = HomeScreenGridItem(
|
||||
null,
|
||||
-1,
|
||||
|
@ -231,7 +238,7 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||
appWidget.heightCells,
|
||||
appWidget.appPackageName,
|
||||
"",
|
||||
ITEM_TYPE_WIDGET,
|
||||
type,
|
||||
appWidget.shortClassName,
|
||||
appWidget.widgetPreviewImage
|
||||
)
|
||||
|
|
|
@ -15,4 +15,4 @@ const val REQUEST_CONFIGURE_WIDGET = 51
|
|||
|
||||
const val ITEM_TYPE_ICON = 0
|
||||
const val ITEM_TYPE_WIDGET = 1
|
||||
|
||||
const val ITEM_TYPE_SHORTCUT = 2
|
||||
|
|
|
@ -114,10 +114,14 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||
return
|
||||
}
|
||||
|
||||
if (draggedItem!!.type == ITEM_TYPE_ICON) {
|
||||
addAppIcon()
|
||||
} else if (draggedItem!!.type == ITEM_TYPE_WIDGET) {
|
||||
addWidget()
|
||||
when (draggedItem!!.type) {
|
||||
ITEM_TYPE_ICON -> addAppIcon()
|
||||
ITEM_TYPE_WIDGET -> addWidget()
|
||||
ITEM_TYPE_SHORTCUT -> {
|
||||
// replace this with real shortcut handling
|
||||
draggedItem = null
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,7 +331,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||
}
|
||||
|
||||
if (draggedItem != null && draggedItemCurrentCoords.first != -1 && draggedItemCurrentCoords.second != -1) {
|
||||
if (draggedItem!!.type == ITEM_TYPE_ICON) {
|
||||
if (draggedItem!!.type == ITEM_TYPE_ICON || draggedItem!!.type == ITEM_TYPE_SHORTCUT) {
|
||||
// draw a circle under the current cell
|
||||
val center = gridCenters.minBy {
|
||||
Math.abs(it.first - draggedItemCurrentCoords.first + sideMargins.left) + Math.abs(it.second - draggedItemCurrentCoords.second + sideMargins.top)
|
||||
|
|
Loading…
Reference in New Issue