Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77d81dc6 authored by kwaky's avatar kwaky
Browse files

Merge CarFacetButton and CarNavigationButton into a single class and add test coverage

Test: Manual - Manually verified that navigation button functionalities are working as expected.
      Unit Tests
Bug: 145827784
Bug: 145604656

Change-Id: Ib8f837ba34afbb8d66092a8b851b93c50fa20b26
parent d4fe2476
Loading
Loading
Loading
Loading
+0 −51
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2018, 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.
*/
-->

<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/car_facet_button"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:animateLayoutChanges="true"
        android:orientation="vertical">

        <com.android.keyguard.AlphaOptimizedImageButton
            android:id="@+id/car_nav_button_icon"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:animateLayoutChanges="true"
            android:background="@android:color/transparent"
            android:scaleType="fitCenter">
        </com.android.keyguard.AlphaOptimizedImageButton>

        <com.android.keyguard.AlphaOptimizedImageButton
            android:id="@+id/car_nav_button_more_icon"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:animateLayoutChanges="true"
            android:src="@drawable/car_ic_arrow"
            android:background="@android:color/transparent"
            android:scaleType="fitCenter">
        </com.android.keyguard.AlphaOptimizedImageButton>

    </LinearLayout>
</merge>
+10 −12
Original line number Diff line number Diff line
@@ -33,14 +33,14 @@
        android:paddingEnd="20dp"
        android:gravity="center">

        <com.android.systemui.navigationbar.car.CarFacetButton
        <com.android.systemui.navigationbar.car.CarNavigationButton
            android:id="@+id/home"
            style="@style/NavigationBarButton"
            systemui:componentNames="com.android.car.carlauncher/.CarLauncher"
            systemui:icon="@drawable/car_ic_overview"
            systemui:intent="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.HOME;launchFlags=0x14000000;end"
            systemui:selectedIcon="@drawable/car_ic_overview_selected"
            systemui:useMoreIcon="false"
            systemui:highlightWhenSelected="true"
        />

        <Space
@@ -48,14 +48,14 @@
            android:layout_height="match_parent"
            android:layout_weight="1"/>

        <com.android.systemui.navigationbar.car.CarFacetButton
        <com.android.systemui.navigationbar.car.CarNavigationButton
            android:id="@+id/maps_nav"
            style="@style/NavigationBarButton"
            systemui:categories="android.intent.category.APP_MAPS"
            systemui:icon="@drawable/car_ic_navigation"
            systemui:intent="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MAPS;launchFlags=0x14000000;end"
            systemui:selectedIcon="@drawable/car_ic_navigation_selected"
            systemui:useMoreIcon="false"
            systemui:highlightWhenSelected="true"
        />

        <Space
@@ -63,7 +63,7 @@
            android:layout_height="match_parent"
            android:layout_weight="1"/>

        <com.android.systemui.navigationbar.car.CarFacetButton
        <com.android.systemui.navigationbar.car.CarNavigationButton
            android:id="@+id/music_nav"
            style="@style/NavigationBarButton"
            systemui:categories="android.intent.category.APP_MUSIC"
@@ -71,7 +71,7 @@
            systemui:intent="intent:#Intent;action=android.car.intent.action.MEDIA_TEMPLATE;launchFlags=0x10000000;end"
            systemui:packages="com.android.car.media"
            systemui:selectedIcon="@drawable/car_ic_music_selected"
            systemui:useMoreIcon="false"
            systemui:highlightWhenSelected="true"
        />

        <Space
@@ -79,14 +79,14 @@
            android:layout_height="match_parent"
            android:layout_weight="1"/>

        <com.android.systemui.navigationbar.car.CarFacetButton
        <com.android.systemui.navigationbar.car.CarNavigationButton
            android:id="@+id/phone_nav"
            style="@style/NavigationBarButton"
            systemui:icon="@drawable/car_ic_phone"
            systemui:intent="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;package=com.android.car.dialer;launchFlags=0x10000000;end"
            systemui:packages="com.android.car.dialer"
            systemui:selectedIcon="@drawable/car_ic_phone_selected"
            systemui:useMoreIcon="false"
            systemui:highlightWhenSelected="true"
        />

        <Space
@@ -94,14 +94,14 @@
            android:layout_height="match_parent"
            android:layout_weight="1"/>

        <com.android.systemui.navigationbar.car.CarFacetButton
        <com.android.systemui.navigationbar.car.CarNavigationButton
            android:id="@+id/grid_nav"
            style="@style/NavigationBarButton"
            systemui:componentNames="com.android.car.carlauncher/.AppGridActivity"
            systemui:icon="@drawable/car_ic_apps"
            systemui:intent="intent:#Intent;component=com.android.car.carlauncher/.AppGridActivity;launchFlags=0x24000000;end"
            systemui:selectedIcon="@drawable/car_ic_apps_selected"
            systemui:useMoreIcon="false"
            systemui:highlightWhenSelected="true"
        />

        <Space
@@ -115,7 +115,6 @@
            systemui:icon="@drawable/car_ic_notification"
            systemui:longIntent="intent:#Intent;component=com.android.car.bugreport/.BugReportActivity;end"
            systemui:selectedIcon="@drawable/car_ic_notification_selected"
            systemui:useMoreIcon="false"
        />

        <Space
@@ -127,7 +126,6 @@
            android:id="@+id/assist"
            style="@style/NavigationBarButton"
            systemui:icon="@drawable/ic_mic_white"
            systemui:useMoreIcon="false"
        />

    </LinearLayout>
+3 −2
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
        android:paddingStart="@*android:dimen/car_padding_5"
        android:paddingEnd="@*android:dimen/car_padding_5">

        <com.android.systemui.navigationbar.car.CarFacetButton
        <com.android.systemui.navigationbar.car.CarNavigationButton
            android:id="@+id/home"
            android:layout_width="@*android:dimen/car_touch_target_size"
            android:layout_height="match_parent"
@@ -39,7 +39,8 @@
            systemui:icon="@drawable/car_ic_overview"
            systemui:intent="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.HOME;launchFlags=0x14000000;end"
            systemui:selectedIcon="@drawable/car_ic_overview_selected"
            systemui:useMoreIcon="false"/>
            systemui:highlightWhenSelected="true"
        />
    </LinearLayout>
</com.android.systemui.navigationbar.car.CarNavigationBarView>
+28 −6
Original line number Diff line number Diff line
@@ -18,12 +18,34 @@
-->

<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <com.android.keyguard.AlphaOptimizedImageButton
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/car_nav_button_icon"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:animateLayoutChanges="true"
        android:orientation="vertical">

        <com.android.keyguard.AlphaOptimizedImageButton
            android:id="@+id/car_nav_button_icon_image"
            android:layout_height="wrap_content"
        android:layout_width="@dimen/car_navigation_button_width"
        android:layout_centerInParent="true"
            android:layout_width="match_parent"
            android:animateLayoutChanges="true"
            android:background="@android:color/transparent"
            android:scaleType="fitCenter">
        </com.android.keyguard.AlphaOptimizedImageButton>

        <com.android.keyguard.AlphaOptimizedImageButton
            android:id="@+id/car_nav_button_more_icon"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:animateLayoutChanges="true"
            android:src="@drawable/car_ic_arrow"
            android:background="@android:color/transparent"
            android:scaleType="fitCenter">
        </com.android.keyguard.AlphaOptimizedImageButton>

    </LinearLayout>
</merge>
+3 −3
Original line number Diff line number Diff line
@@ -30,9 +30,9 @@ import com.android.internal.app.IVoiceInteractionSessionShowCallback;
/**
 * AssitantButton is a ui component that will trigger the Voice Interaction Service.
 */
public class AssitantButton extends CarFacetButton {
public class AssitantButton extends CarNavigationButton {

    private static final String TAG = "CarFacetButton";
    private static final String TAG = "AssistantButton";
    private final AssistUtils mAssistUtils;
    private IVoiceInteractionSessionShowCallback mShowCallback =
            new IVoiceInteractionSessionShowCallback.Stub() {
@@ -62,7 +62,7 @@ public class AssitantButton extends CarFacetButton {
    }

    @Override
    protected void setupIntents(TypedArray typedArray) {
    protected void setUpIntents(TypedArray typedArray) {
        // left blank because for the assistant button Intent will not be passed from the layout.
    }
}
Loading