summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2021-02-21 09:25:06 -0800
committerXin Li <delphij@google.com>2021-02-21 09:25:06 -0800
commitb3ea6a7297000b0a48f1bebb68cb2a4d003db19b (patch)
treeb4b1c585ea72c13c1ccb515349abcb1095279cc9
parentbd324ec9323f914de057677ebc9e2fe3265df09d (diff)
parentb753ce46ef7fe6da28c82bb7de1b2cf11d4da55d (diff)
downloadsetupwizard-b3ea6a7297000b0a48f1bebb68cb2a4d003db19b.tar.gz
Merge ab/7061308 into stage.temp_RQ2A.210305.007
Bug: 180401296 Merged-In: I7cbcdca91f5e23d20811e8ffc77706207282f487 Change-Id: I3d24fec09eacf1ca9bb632356e2abf3a33c04678
-rw-r--r--library/main/res/values-w1280dp-land/config.xml (renamed from library/main/res/values-w1280dp/config.xml)0
-rw-r--r--library/main/res/values-w1280dp-land/dimens.xml22
-rw-r--r--library/main/res/values-w1280dp/dimens.xml20
-rw-r--r--library/main/res/values-w1920dp-land/dimens.xml22
-rw-r--r--library/main/res/values/colors.xml13
-rw-r--r--library/main/res/values/dimens.xml30
-rw-r--r--library/main/res/values/integers.xml26
-rw-r--r--library/main/src/com/android/car/setupwizardlib/CarSetupWizardBaseLayout.java22
-rw-r--r--library/main/src/com/android/car/setupwizardlib/partner/PartnerConfig.java3
-rw-r--r--library/main/src/com/android/car/setupwizardlib/partner/PartnerConfigKey.java4
-rw-r--r--library/main/src/com/android/car/setupwizardlib/util/CarDrivingStateMonitor.java13
-rw-r--r--library/main/src/com/android/car/setupwizardlib/util/CarSetupWizardUiUtils.java6
-rw-r--r--library/main/tests/robotests/src/com/android/car/setupwizardlib/CarSetupWizardCompatLayoutTest.java27
-rw-r--r--library/main/tests/robotests/src/com/android/car/setupwizardlib/shadows/ShadowConfiguration.java51
14 files changed, 250 insertions, 9 deletions
diff --git a/library/main/res/values-w1280dp/config.xml b/library/main/res/values-w1280dp-land/config.xml
index 98343f3..98343f3 100644
--- a/library/main/res/values-w1280dp/config.xml
+++ b/library/main/res/values-w1280dp-land/config.xml
diff --git a/library/main/res/values-w1280dp-land/dimens.xml b/library/main/res/values-w1280dp-land/dimens.xml
new file mode 100644
index 0000000..1ed491e
--- /dev/null
+++ b/library/main/res/values-w1280dp-land/dimens.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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
+ -->
+
+<resources>
+ <dimen name="suw_page_margin_horizontal">80dp</dimen>
+ <!-- The column inner padding of a two-column layout -->
+ <dimen name="suw_column_inner_padding_horizontal">48dp</dimen>
+</resources> \ No newline at end of file
diff --git a/library/main/res/values-w1280dp/dimens.xml b/library/main/res/values-w1280dp/dimens.xml
new file mode 100644
index 0000000..1a3d98e
--- /dev/null
+++ b/library/main/res/values-w1280dp/dimens.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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
+ -->
+
+<resources>
+ <dimen name="suw_page_margin_horizontal">148dp</dimen>
+</resources> \ No newline at end of file
diff --git a/library/main/res/values-w1920dp-land/dimens.xml b/library/main/res/values-w1920dp-land/dimens.xml
new file mode 100644
index 0000000..6e5add0
--- /dev/null
+++ b/library/main/res/values-w1920dp-land/dimens.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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
+ -->
+
+<resources>
+ <dimen name="suw_page_margin_horizontal">132dp</dimen>
+ <!-- The column inner padding of a two-column layout -->
+ <dimen name="suw_column_inner_padding_horizontal">80dp</dimen>
+</resources> \ No newline at end of file
diff --git a/library/main/res/values/colors.xml b/library/main/res/values/colors.xml
index 6767e03..a3df84d 100644
--- a/library/main/res/values/colors.xml
+++ b/library/main/res/values/colors.xml
@@ -23,4 +23,17 @@
<color name="blue_400">#6BA5ED</color>
<color name="car_suw_tint">@color/blue_400</color>
+
+ <!-- White -->
+ <color name="suw_color_primary">@android:color/white</color>
+ <!-- Material grey500 -->
+ <color name="suw_color_secondary">#9AA0A6</color>
+ <!-- Material blue300 -->
+ <color name="suw_color_accent">#8AB4F8</color>
+ <!-- Material grey200 -->
+ <color name="suw_color_list_icon">#E8EAED</color>
+ <!-- Material grey800 -->
+ <color name="suw_color_divider">#3C4043</color>
+ <!-- Material grey900 -->
+ <color name="suw_color_background">#202124</color>
</resources>
diff --git a/library/main/res/values/dimens.xml b/library/main/res/values/dimens.xml
new file mode 100644
index 0000000..db6c833
--- /dev/null
+++ b/library/main/res/values/dimens.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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
+ -->
+
+<resources>
+ <dimen name="suw_padding_3">16dp</dimen>
+ <dimen name="suw_padding_4">24dp</dimen>
+ <dimen name="suw_padding_5">32dp</dimen>
+ <dimen name="suw_padding_6">48dp</dimen>
+ <dimen name="suw_padding_7">64dp</dimen>
+ <dimen name="suw_padding_8">96dp</dimen>
+ <dimen name="suw_padding_9">128dp</dimen>
+
+ <dimen name="suw_page_margin_horizontal">112dp</dimen>
+ <!-- The column inner padding of a two-column layout. N/A in portrait -->
+ <dimen name="suw_column_inner_padding_horizontal">0dp</dimen>
+</resources> \ No newline at end of file
diff --git a/library/main/res/values/integers.xml b/library/main/res/values/integers.xml
new file mode 100644
index 0000000..f7c13cd
--- /dev/null
+++ b/library/main/res/values/integers.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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
+ -->
+
+<resources>
+ <!-- The layout_weight of two-column layout -->
+ <integer name="suw_title_column_weight">5</integer>
+ <integer name="suw_content_column_weight">7</integer>
+
+ <!-- The layout_weight of single-column layout -->
+ <integer name="suw_page_content_weight">3</integer>
+ <integer name="suw_page_filler_weight">1</integer>
+</resources> \ No newline at end of file
diff --git a/library/main/src/com/android/car/setupwizardlib/CarSetupWizardBaseLayout.java b/library/main/src/com/android/car/setupwizardlib/CarSetupWizardBaseLayout.java
index 7a7808d..6e6013f 100644
--- a/library/main/src/com/android/car/setupwizardlib/CarSetupWizardBaseLayout.java
+++ b/library/main/src/com/android/car/setupwizardlib/CarSetupWizardBaseLayout.java
@@ -59,6 +59,8 @@ import java.util.Objects;
class CarSetupWizardBaseLayout extends LinearLayout {
private static final String TAG = CarSetupWizardBaseLayout.class.getSimpleName();
private static final int INVALID_COLOR = 0;
+ // For mirroring an image
+ private static final float IMAGE_MIRROR_ROTATION = 180.0f;
private View mBackButton;
private View mTitleBar;
@@ -164,14 +166,22 @@ class CarSetupWizardBaseLayout extends LinearLayout {
LayoutInflater inflater = LayoutInflater.from(getContext());
inflater.inflate(R.layout.car_setup_wizard_layout, this);
+ View toolbar = findViewById(R.id.application_bar);
+ // The toolbar will not be mirrored in RTL
+ toolbar.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
- // Set the back button visibility based on the custom attribute.
setBackButton(findViewById(R.id.back_button));
Drawable drawable = mPartnerConfigHelper.getDrawable(
getContext(), PartnerConfig.CONFIG_TOOLBAR_BUTTON_ICON_BACK);
if (drawable != null) {
((ImageView) mBackButton).setImageDrawable(drawable);
}
+
+ if (shouldMirrorNavIcons()) {
+ Log.v(TAG, "Mirroring navigation icons");
+ mBackButton.setRotation(IMAGE_MIRROR_ROTATION);
+ }
+
setBackButtonVisible(showBackButton);
// Se the title bar.
@@ -519,7 +529,6 @@ class CarSetupWizardBaseLayout extends LinearLayout {
return;
}
int direction = TextUtils.getLayoutDirectionFromLocale(locale);
- setLayoutDirection(direction);
mToolbarTitle.setTextLocale(locale);
mToolbarTitle.setLayoutDirection(direction);
@@ -622,6 +631,15 @@ class CarSetupWizardBaseLayout extends LinearLayout {
}
}
+ @VisibleForTesting
+ boolean shouldMirrorNavIcons() {
+ return getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL
+ && mPartnerConfigHelper.getBoolean(
+ getContext(),
+ PartnerConfig.CONFIG_TOOLBAR_NAV_ICON_MIRRORING_IN_RTL,
+ true);
+ }
+
/** Sets button type face with partner overlay if exists */
private void setButtonTypeFace(TextView button) {
String fontFamily = mPartnerConfigHelper.getString(
diff --git a/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfig.java b/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfig.java
index 00c0ea3..27ea753 100644
--- a/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfig.java
+++ b/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfig.java
@@ -28,6 +28,9 @@ public enum PartnerConfig {
CONFIG_TOOLBAR_BUTTON_ICON_BACK(
PartnerConfigKey.KEY_TOOLBAR_BUTTON_ICON_BACK, ResourceType.DRAWABLE),
+ CONFIG_TOOLBAR_NAV_ICON_MIRRORING_IN_RTL(
+ PartnerConfigKey.KEY_TOOLBAR_NAV_BUTTON_MIRRORING_IN_RTL, ResourceType.BOOLEAN),
+
CONFIG_TOOLBAR_BUTTON_FONT_FAMILY(
PartnerConfigKey.KEY_TOOLBAR_BUTTON_FONT_FAMILY, ResourceType.STRING),
diff --git a/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfigKey.java b/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfigKey.java
index 32caceb..8556fa7 100644
--- a/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfigKey.java
+++ b/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfigKey.java
@@ -26,6 +26,7 @@ import java.lang.annotation.RetentionPolicy;
PartnerConfigKey.KEY_IMMERSIVE_MODE,
PartnerConfigKey.KEY_TOOLBAR_BG_COLOR,
PartnerConfigKey.KEY_TOOLBAR_BUTTON_ICON_BACK,
+ PartnerConfigKey.KEY_TOOLBAR_NAV_BUTTON_MIRRORING_IN_RTL,
PartnerConfigKey.KEY_TOOLBAR_BUTTON_FONT_FAMILY,
PartnerConfigKey.KEY_TOOLBAR_BUTTON_PADDING_HORIZONTAL,
PartnerConfigKey.KEY_TOOLBAR_BUTTON_PADDING_VERTICAL,
@@ -54,6 +55,9 @@ public @interface PartnerConfigKey {
String KEY_TOOLBAR_BUTTON_ICON_BACK = "suw_compat_toolbar_button_icon_back";
+ String KEY_TOOLBAR_NAV_BUTTON_MIRRORING_IN_RTL =
+ "suw_compat_toolbar_nav_button_mirroring_in_rtl";
+
String KEY_TOOLBAR_BUTTON_FONT_FAMILY = "suw_compat_toolbar_button_font_family";
String KEY_TOOLBAR_BUTTON_TEXT_SIZE = "suw_compat_toolbar_button_text_size";
diff --git a/library/main/src/com/android/car/setupwizardlib/util/CarDrivingStateMonitor.java b/library/main/src/com/android/car/setupwizardlib/util/CarDrivingStateMonitor.java
index 759dd81..affdd7c 100644
--- a/library/main/src/com/android/car/setupwizardlib/util/CarDrivingStateMonitor.java
+++ b/library/main/src/com/android/car/setupwizardlib/util/CarDrivingStateMonitor.java
@@ -79,14 +79,14 @@ public class CarDrivingStateMonitor implements
* Starts the monitor listening to driving state changes.
*/
public synchronized void startMonitor() {
- if (isVerboseLoggable()) {
- Log.v(TAG, "Starting monitor");
- }
mMonitorStartedCount++;
if (mMonitorStartedCount == 0) {
+ Log.w(TAG, "MonitorStartedCount was negative");
return;
}
mHandler.removeCallbacks(mDisconnectRunnable);
+ Log.i(TAG, String.format(
+ "Starting monitor, MonitorStartedCount = %d", mMonitorStartedCount));
if (mCar != null) {
if (mCar.isConnected()) {
try {
@@ -169,12 +169,13 @@ public class CarDrivingStateMonitor implements
}
private void disconnectCarMonitor() {
- if (isVerboseLoggable()) {
- Log.v(TAG, "Timeout finished, disconnecting Car Monitor");
- }
if (mMonitorStartedCount > 0) {
+ if (isVerboseLoggable()) {
+ Log.v(TAG, "MonitorStartedCount > 0, do nothing");
+ }
return;
}
+ Log.i(TAG, "Disconnecting Car Monitor");
try {
if (mRestrictionsManager != null) {
mRestrictionsManager.unregisterListener();
diff --git a/library/main/src/com/android/car/setupwizardlib/util/CarSetupWizardUiUtils.java b/library/main/src/com/android/car/setupwizardlib/util/CarSetupWizardUiUtils.java
index 3611931..4e1d8ca 100644
--- a/library/main/src/com/android/car/setupwizardlib/util/CarSetupWizardUiUtils.java
+++ b/library/main/src/com/android/car/setupwizardlib/util/CarSetupWizardUiUtils.java
@@ -31,9 +31,13 @@ import androidx.core.util.Preconditions;
public final class CarSetupWizardUiUtils {
private static final String TAG = CarSetupWizardUiUtils.class.getSimpleName();
- /** Key for immersive mode value pased to 1P apps */
+ /** Key for immersive mode value passed to 1P apps */
public static final String IMMERSIVE_MODE_TYPE = "immersiveModeType";
+ /** Key indicating whether 1P apps should switch to the new landscape design */
+ public static final String EXTRA_NEW_LANDSCAPE_LAYOUT_SUPPORTED =
+ "extra_new_landscape_layout_supported";
+
/** Hide system UI */
public static void hideSystemUI(Activity activity) {
maybeHideSystemUI(activity);
diff --git a/library/main/tests/robotests/src/com/android/car/setupwizardlib/CarSetupWizardCompatLayoutTest.java b/library/main/tests/robotests/src/com/android/car/setupwizardlib/CarSetupWizardCompatLayoutTest.java
index 6ec0c28..541cf4c 100644
--- a/library/main/tests/robotests/src/com/android/car/setupwizardlib/CarSetupWizardCompatLayoutTest.java
+++ b/library/main/tests/robotests/src/com/android/car/setupwizardlib/CarSetupWizardCompatLayoutTest.java
@@ -37,6 +37,7 @@ import com.android.car.setupwizardlib.partner.PartnerConfig;
import com.android.car.setupwizardlib.partner.ResourceEntry;
import com.android.car.setupwizardlib.robolectric.BaseRobolectricTest;
import com.android.car.setupwizardlib.robolectric.TestHelper;
+import com.android.car.setupwizardlib.shadows.ShadowConfiguration;
import org.junit.Before;
import org.junit.Test;
@@ -45,6 +46,7 @@ import org.mockito.Mockito;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
+import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowTextView;
import org.robolectric.util.ReflectionHelpers;
@@ -56,6 +58,7 @@ import java.util.Locale;
* Tests for the CarSetupWizardCompatLayout
*/
@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowConfiguration.class)
public class CarSetupWizardCompatLayoutTest extends BaseRobolectricTest {
private static final Locale LOCALE_EN_US = new Locale("en", "US");
// Hebrew locale can be used to test RTL.
@@ -532,6 +535,30 @@ public class CarSetupWizardCompatLayoutTest extends BaseRobolectricTest {
assertThat(secondaryButton.getTextSize()).isWithin(TOLERANCE).of(EXCEPTED_TEXT_SIZE);
}
+ @Test
+ public void test_shouldNotMirrorNavIcons_inLtr() {
+ Activity activity = Robolectric.buildActivity(CarSetupWizardLayoutTestActivity.class)
+ .create()
+ .get();
+
+ CarSetupWizardCompatLayout layout = activity.findViewById(R.id.car_setup_wizard_layout);
+ assertThat(layout.shouldMirrorNavIcons()).isFalse();
+ }
+
+ @Test
+ public void test_shouldMirrorNavIcons_inRtl() {
+ application.getResources().getConfiguration().setLocale(LOCALE_IW_IL);
+
+ Activity activity = Robolectric.buildActivity(CarSetupWizardLayoutTestActivity.class)
+ .create()
+ .get();
+
+ CarSetupWizardCompatLayout layout = activity.findViewById(R.id.car_setup_wizard_layout);
+ View toolbar = layout.findViewById(R.id.application_bar);
+ assertThat(toolbar.getTextDirection()).isEqualTo(View.TEXT_DIRECTION_LTR);
+ assertThat(layout.shouldMirrorNavIcons()).isTrue();
+ }
+
private void setupFakeContentProvider() {
FakeOverrideContentProvider.installDefaultProvider();
}
diff --git a/library/main/tests/robotests/src/com/android/car/setupwizardlib/shadows/ShadowConfiguration.java b/library/main/tests/robotests/src/com/android/car/setupwizardlib/shadows/ShadowConfiguration.java
new file mode 100644
index 0000000..39057be
--- /dev/null
+++ b/library/main/tests/robotests/src/com/android/car/setupwizardlib/shadows/ShadowConfiguration.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2020 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.car.setupwizardlib.shadows;
+
+import android.content.res.Configuration;
+import android.view.View;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+import java.util.Locale;
+
+/**
+ * Shadow class for {@link Configuration}.
+ */
+@Implements(Configuration.class)
+public class ShadowConfiguration {
+
+ private static final Locale HEBREW_LOCALE = new Locale("iw", "IL");
+ private int mLayoutDir = View.LAYOUT_DIRECTION_LTR;
+
+ /**
+ * Set the layout direction from a {@link Locale}.
+ */
+ @Implementation
+ public void setLayoutDirection(Locale locale) {
+ if (locale.getLanguage().equals(HEBREW_LOCALE.getLanguage())) {
+ mLayoutDir = View.LAYOUT_DIRECTION_RTL;
+ }
+ }
+
+ /** Returs the layout direction */
+ @Implementation
+ public int getLayoutDirection() {
+ return mLayoutDir;
+ }
+}