Adding interfaces for long press menu updates
Bug: 416087474 Test: EXEMPT adding interfaces only Flag: EXEMPT adding interfaces only Change-Id: I50d73b655622a249ce293e1dc456b6a2a27fe810
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher3
|
||||
|
||||
import com.android.launcher3.model.data.ItemInfo
|
||||
|
||||
/**
|
||||
* Data class containing which cells should be highlighted and the container in which we are trying
|
||||
* to highlight the cell. Depending on the container we may or may not want to show the highlight.
|
||||
*/
|
||||
data class CellsToHighlight(val cells: List<CellPosition>, val container: Int)
|
||||
|
||||
/** Data class for the position of a cell which we would want to highlight. */
|
||||
data class CellPosition(val col: Int, val row: Int)
|
||||
|
||||
/** Interface for highlighting items on the home screen grid. */
|
||||
interface GridHighlighter {
|
||||
/** Show the highlight when called. */
|
||||
fun showHighlight()
|
||||
|
||||
/** Dismiss the highlight when called. */
|
||||
fun dismissHighlight()
|
||||
|
||||
/** Factory for creating a GridHighlighter to highlight certain cells in a grid. */
|
||||
companion object GridHighlighterFactory {
|
||||
|
||||
/**
|
||||
* Creates a highlighter for the grid cell we want to highlight.
|
||||
*
|
||||
* @param cellsToHighlight is the cells that we should highlight, along with the container
|
||||
* to which they belong.
|
||||
* @param shouldAddPadding tells us whether we want to add padding to the highlighted cells.
|
||||
* @param cellLayout is used to add/remove the highlights inside of the correct CellLayout
|
||||
* @return GridHighlighter that we create when calling this function.
|
||||
*/
|
||||
fun createGridHighlighter(
|
||||
cellsToHighlight: CellsToHighlight,
|
||||
shouldAddPadding: Boolean,
|
||||
cellLayout: CellLayout,
|
||||
): GridHighlighter? {
|
||||
return TODO("Provide the return value")
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a highlighter for the grid item we want to highlight. This would be used to
|
||||
* highlight items that might have a different highlighting logic, such as widgets where we
|
||||
* would open their AppWidgetResizeFrame instead of using the general grid highlighting
|
||||
* logic.
|
||||
*
|
||||
* @param itemInfo is used to get certain specifics about the item we are trying to
|
||||
* highlight, such as its spanX, spanY.
|
||||
* @return GridHighlighter that we create when calling this function.
|
||||
*/
|
||||
fun createGridHighlighter(itemInfo: ItemInfo): GridHighlighter? {
|
||||
return TODO("Provide the return value")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.popup
|
||||
|
||||
/** Enum for the type of poppable. Based on this we want to show different shortcuts */
|
||||
enum class PoppableType {
|
||||
APP,
|
||||
FOLDER,
|
||||
WIDGET,
|
||||
APP_PAIR,
|
||||
}
|
||||
|
||||
/** Items for which we can trigger a popup menu would implement this interface. */
|
||||
interface Poppable {
|
||||
|
||||
/** @return a controller to handle actions for the popup. */
|
||||
fun getPopupController(): PopupController?
|
||||
|
||||
/** Sets the popup controller to help us handle actions for the popup. */
|
||||
fun setPopupController(popupController: PopupController)
|
||||
|
||||
/** @return the type of poppable that this item is. */
|
||||
fun getPoppableType(): PoppableType
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.popup
|
||||
|
||||
import com.android.launcher3.dragndrop.DragOptions
|
||||
|
||||
/** Interface that handles drag related actions. */
|
||||
interface Popup {
|
||||
|
||||
/**
|
||||
* Creates a PreDragCondition and returns it.
|
||||
*
|
||||
* @return a PreDragCondition which helps handle dragging behavior.
|
||||
*/
|
||||
fun createPreDragCondition(): DragOptions.PreDragCondition?
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.popup
|
||||
|
||||
import com.android.launcher3.model.data.ItemInfo
|
||||
|
||||
/**
|
||||
* Controller interface for popups. It handles actions for the popups such as showing and dismissing
|
||||
* popups.
|
||||
*/
|
||||
interface PopupController {
|
||||
/**
|
||||
* Shows the popup when called.
|
||||
*
|
||||
* @param popupDataRepository is the repository which has all the data we need to show the
|
||||
* correct long press menu shortcuts.
|
||||
* @return PopupDragController which handles drag related actions due to showing the popup.
|
||||
*/
|
||||
fun show(popupDataRepository: PopupDataRepository): Popup?
|
||||
|
||||
/** Dismisses the popup when called. */
|
||||
fun dismiss()
|
||||
|
||||
/** Factory for making a popup controller. */
|
||||
companion object PopupControllerFactory {
|
||||
/**
|
||||
* Creates a popup controller.
|
||||
*
|
||||
* @param itemInfo is the item info for the popup controller for which we create the popup
|
||||
* controller.
|
||||
* @return a new PopupController.
|
||||
*/
|
||||
fun createPopupControllerFactory(itemInfo: ItemInfo): PopupController {
|
||||
return TODO("Provide the return value")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.popup
|
||||
|
||||
import android.content.Intent
|
||||
import com.android.launcher3.model.data.ItemInfo
|
||||
import java.util.stream.Stream
|
||||
|
||||
/**
|
||||
* Enum for the category of popup we have, as we handle different categories of shortcuts
|
||||
* differently depending on the category.
|
||||
*/
|
||||
enum class PopupCategory {
|
||||
SYSTEM_SHORTCUT,
|
||||
SYSTEM_SHORTCUT_FIXED,
|
||||
}
|
||||
|
||||
/** Data class which stores all the values we need to create a long press menu shortcut. */
|
||||
data class PopupData(
|
||||
val iconResId: Int,
|
||||
val labelResId: Int,
|
||||
val intent: Intent,
|
||||
val category: PopupCategory,
|
||||
)
|
||||
|
||||
/** Repository to get all the popup data needed for the long press menu. */
|
||||
interface PopupDataRepository {
|
||||
/**
|
||||
* @return a map where we the key is the type of poppable and the value is a stream of popup
|
||||
* data belonging to that type.
|
||||
*/
|
||||
fun getAllPopupData(): Map<PoppableType, Stream<PopupData>>
|
||||
|
||||
/**
|
||||
* @param type of PoppableType is what we use to filter shortcuts to only show the ones for that
|
||||
* type of shortcut (e.g: only show long press shortcuts that belong to Folder type).
|
||||
* @return a stream of popup data belonging to that type.
|
||||
*/
|
||||
fun getPopupDataByType(type: PoppableType): Stream<PopupData>
|
||||
|
||||
/** Factory for creating a popup data repository */
|
||||
companion object PopupDataRepositoryFactory {
|
||||
/**
|
||||
* Creates a popup data repository.
|
||||
*
|
||||
* @param itemInfo is all the items for which we want to aggregate their popup data.
|
||||
* @return a new PopupDataRepository.
|
||||
*/
|
||||
fun createRepository(vararg itemInfo: ItemInfo): PopupDataRepository {
|
||||
return TODO("Provide the return value")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user