1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.car.app.menu;
17 
18 import android.os.Bundle;
19 
20 /**
21  * The callbacks that a car app needs to pass to a car ui provider for car menu interactions.
22  */
23 public abstract class CarMenuCallbacks {
24     /**
25      * Called when the car menu wants to get the root.
26      *
27      * @param hints Hints that the Drawer can use to modify behavior. It can be null.
28      * @return The {@link RootMenu} which contains the root id and any hints
29      */
getRootMenu(Bundle hints)30     public abstract RootMenu getRootMenu(Bundle hints);
31 
32     /**
33      * Query for information about the menu items that are contained within
34      * the specified id and subscribes to receive updates when they change.
35      *
36      * @param parentId The id of the parent menu item whose list of children
37      *            will be subscribed.
38      * @param callback The callback to receive the list of children.
39      */
subscribe(String parentId, SubscriptionCallbacks callback)40     public abstract void subscribe(String parentId, SubscriptionCallbacks callback);
41 
42     /**
43      * Unsubscribe for changes to the children of the specified id.
44      * @param parentId The id of the parent menu item whose list of children
45      *            will be unsubscribed.
46      */
unsubscribe(String parentId, SubscriptionCallbacks callbacks)47     public abstract void unsubscribe(String parentId, SubscriptionCallbacks callbacks);
48 
49     /**
50      * Called when the car menu has been opened.
51      */
onCarMenuOpened()52     public abstract void onCarMenuOpened();
53 
54     /**
55      * Called when the car menu has been closed.
56      */
onCarMenuClosed()57     public abstract void onCarMenuClosed();
58 
59     /**
60      * Called when a car menu item with the specified id has been clicked.
61      */
onItemClicked(String id)62     public abstract void onItemClicked(String id);
63 
64     /**
65      * Called when a car menu item with the specified id has been long clicked.
66      */
onItemLongClicked(String id)67     public abstract boolean onItemLongClicked(String id);
68 
69     /**
70      * Called when the menu button is clicked.
71      */
onMenuClicked()72     public abstract boolean onMenuClicked();
73 
74     /**
75      * Called when the menu is opening.
76      */
onCarMenuOpening()77     public abstract void onCarMenuOpening();
78 
79     /**
80      * Called when the menu is closing.
81      */
onCarMenuClosing()82     public abstract void onCarMenuClosing();
83 }
84