diff options
author | TreeHugger Robot | 2018-06-06 20:11:36 -0500 |
---|---|---|
committer | Android (Google) Code Review | 2018-06-06 20:11:36 -0500 |
commit | 9eb8e1bcd0ef89878328a2a30011b8e572c5a9ff (patch) | |
tree | fb5d86e0a469dbad7fbedd536bd36ea1864a9a63 | |
parent | 894ae00f8f35376edc20c35031730fd6bc79a6d6 (diff) | |
parent | 314150ee784b102877048e8d9e61f87c762e3c79 (diff) | |
download | platform-packages-services-car-9eb8e1bcd0ef89878328a2a30011b8e572c5a9ff.tar.gz platform-packages-services-car-9eb8e1bcd0ef89878328a2a30011b8e572c5a9ff.tar.xz platform-packages-services-car-9eb8e1bcd0ef89878328a2a30011b8e572c5a9ff.zip |
Merge "Add a mic button to use Activity#showAssist." into pi-dev
-rw-r--r-- | tests/EmbeddedKitchenSinkApp/res/layout/car_assistant.xml | 9 | ||||
-rw-r--r-- | tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/assistant/CarAssistantFragment.java | 17 |
2 files changed, 21 insertions, 5 deletions
diff --git a/tests/EmbeddedKitchenSinkApp/res/layout/car_assistant.xml b/tests/EmbeddedKitchenSinkApp/res/layout/car_assistant.xml index 759a73e1..89d67bea 100644 --- a/tests/EmbeddedKitchenSinkApp/res/layout/car_assistant.xml +++ b/tests/EmbeddedKitchenSinkApp/res/layout/car_assistant.xml | |||
@@ -17,8 +17,13 @@ | |||
17 | android:orientation="vertical" android:layout_width="match_parent" | 17 | android:orientation="vertical" android:layout_width="match_parent" |
18 | android:layout_height="match_parent"> | 18 | android:layout_height="match_parent"> |
19 | <ImageView | 19 | <ImageView |
20 | android:id="@+id/voice_button" | 20 | android:id="@+id/voice_button_intent" |
21 | android:layout_gravity="center" | 21 | android:layout_gravity="center" |
22 | android:src="@drawable/ic_voice_assistant_mic" | 22 | android:src="@drawable/ic_voice_assistant_mic" |
23 | style="@style/OverviewButton"/> | 23 | style="@style/OverviewButton"/> |
24 | </LinearLayout> \ No newline at end of file | 24 | <ImageView |
25 | android:id="@+id/voice_button_service" | ||
26 | android:layout_gravity="center" | ||
27 | android:src="@drawable/ic_voice_assistant_mic" | ||
28 | style="@style/OverviewButton"/> | ||
29 | </LinearLayout> | ||
diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/assistant/CarAssistantFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/assistant/CarAssistantFragment.java index 147b017b..4bee4532 100644 --- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/assistant/CarAssistantFragment.java +++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/assistant/CarAssistantFragment.java | |||
@@ -31,15 +31,18 @@ import com.google.android.car.kitchensink.R; | |||
31 | 31 | ||
32 | public class CarAssistantFragment extends Fragment { | 32 | public class CarAssistantFragment extends Fragment { |
33 | 33 | ||
34 | private ImageView mMic; | 34 | private ImageView mMicIntent; |
35 | private ImageView mMicService; | ||
35 | 36 | ||
36 | @Override | 37 | @Override |
37 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, | 38 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, |
38 | @Nullable Bundle savedInstanceState) { | 39 | @Nullable Bundle savedInstanceState) { |
39 | View v = inflater.inflate(R.layout.car_assistant, container, false); | 40 | View v = inflater.inflate(R.layout.car_assistant, container, false); |
40 | mMic = (ImageView) v.findViewById(R.id.voice_button); | 41 | mMicIntent = (ImageView) v.findViewById(R.id.voice_button_intent); |
42 | mMicService = (ImageView) v.findViewById(R.id.voice_button_service); | ||
41 | Context context = getContext(); | 43 | Context context = getContext(); |
42 | mMic.setOnClickListener(new View.OnClickListener() { | 44 | |
45 | mMicIntent.setOnClickListener(new View.OnClickListener() { | ||
43 | @Override | 46 | @Override |
44 | public void onClick(View v) { | 47 | public void onClick(View v) { |
45 | v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); | 48 | v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); |
@@ -54,6 +57,14 @@ public class CarAssistantFragment extends Fragment { | |||
54 | } | 57 | } |
55 | } | 58 | } |
56 | }); | 59 | }); |
60 | mMicService.setOnClickListener(v1 -> { | ||
61 | v1.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); | ||
62 | boolean success = getActivity().showAssist(null); | ||
63 | if (!success) { | ||
64 | Toast.makeText(context, | ||
65 | "Assistant app is not available.", Toast.LENGTH_SHORT).show(); | ||
66 | } | ||
67 | }); | ||
57 | return v; | 68 | return v; |
58 | } | 69 | } |
59 | } | 70 | } |