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

Commit 7417f49e authored by Menghan Li's avatar Menghan Li Committed by Automerger Merge Worker
Browse files

Merge "Show one line of footer content change in Accessibility button page...

Merge "Show one line of footer content change in Accessibility button page when the user is in gesture nav." into sc-dev am: b2d7b6e5

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15056863

Change-Id: I7541fd4c196c947912f1afd7cc19d0a8bb7f4272
parents 4cbdf9d1 b2d7b6e5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5403,8 +5403,8 @@
    <string name="accessibility_button_intro">Using the accessibility button. The gesture isn\u2019t available with 3-button navigation.</string>
    <!-- Summary text for the accessibility button preference. [CHAR LIMIT=50] -->
    <string name="accessibility_button_summary">Quickly access accessibility features</string>
    <!-- Description for the accessibility button & gesture page. Explain how this page works. [CHAR LIMIT=NONE] -->
    <string name="accessibility_button_gesture_description">Quickly access accessibility features from any screen. \n\nTo get started, go to accessibility settings and select a feature. Tap on the shortcut and select the accessibility button or gesture.</string>
    <!-- Description for the accessibility button in gesture navigation. Explain how this page works. [CHAR LIMIT=NONE] -->
    <string name="accessibility_button_gesture_description">Quickly access accessibility features from any screen.\n\nTo get started, go to accessibility settings and select a feature. Tap on the shortcut and select the accessibility button.\n\nTo use the accessibility button in the navigation bar instead, switch to 2-button navigation or 3-button navigation.</string>
    <!-- Description for the accessibility button page. Explain how this page works. [CHAR LIMIT=NONE] -->
    <string name="accessibility_button_description">Quickly access accessibility features from any screen. \n\nTo get started, go to accessibility settings and select a feature. Tap on the shortcut and select the accessibility button.</string>
    <!-- Title for the button or gesture of the accessibility button. [CHAR LIMIT=35] -->
+0 −1
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@

    <com.android.settings.accessibility.AccessibilityFooterPreference
        android:key="accessibility_button_footer"
        android:title="@string/accessibility_button_description"
        android:persistent="false"
        android:selectable="false"
        settings:searchable="false"
+7 −0
Original line number Diff line number Diff line
@@ -34,4 +34,11 @@ public class AccessibilityButtonFooterPreferenceController extends
    protected String getLabelName() {
        return mContext.getString(R.string.accessibility_button_title);
    }

    @Override
    public CharSequence getSummary() {
        return AccessibilityUtil.isGestureNavigateEnabled(mContext)
                ? mContext.getString(R.string.accessibility_button_gesture_description)
                : mContext.getString(R.string.accessibility_button_description);
    }
}
+79 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.settings.accessibility;

import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Mockito.when;

import android.content.Context;
import android.content.res.Resources;

import androidx.test.core.app.ApplicationProvider;

import com.android.settings.R;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;

/** Tests for {@link AccessibilityButtonFooterPreferenceController}. */
@RunWith(RobolectricTestRunner.class)
public class AccessibilityButtonFooterPreferenceControllerTest {

    @Rule
    public final MockitoRule mockito = MockitoJUnit.rule();

    @Spy
    private final Context mContext = ApplicationProvider.getApplicationContext();
    @Spy
    private final Resources mResources = mContext.getResources();
    private AccessibilityButtonFooterPreferenceController mController;

    @Before
    public void setUp() {
        mController = new AccessibilityButtonFooterPreferenceController(mContext,
                "test_key");
        when(mContext.getResources()).thenReturn(mResources);
    }

    @Test
    public void getSummary_navigationGestureEnabled_shouldReturnButtonAndGestureSummary() {
        when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
                    .thenReturn(NAV_BAR_MODE_GESTURAL);

        assertThat(mController.getSummary()).isEqualTo(
                mContext.getText(R.string.accessibility_button_gesture_description));
    }

    @Test
    public void getSummary_navigationGestureDisabled_shouldReturnButtonSummary() {
        when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
                .thenReturn(NAV_BAR_MODE_2BUTTON);

        assertThat(mController.getSummary()).isEqualTo(
                mContext.getText(R.string.accessibility_button_description));
    }
}