Fix differences from our scuba tests
* Change the number of collumns in the grid view activity
from 3 back to 4, like it used to be
* Remove the car_ui_activity_background from the recyclerviews
and instead put it on views wrapping them, so the background
doesn't show up in a scuba screenshot of just the recyclerview
* Don't disable the switch preference because the scuba tests
were flipping it on and checking it's on state.
* Update copyPreference() to include the attributes of
TwoStatePreference and SwitchPreference, because we were
testing changing the subtitle of a SwitchPreference but
the off/on subtitles weren't copied to the
CarUiSwitchPreference
Bug: 169105299
Test: Manually
Change-Id: Ic8a5c36de19263ea110f038c5909fdab63c257a3
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/PreferenceFragment.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/PreferenceFragment.java
index 1e6ef01..fbd6856 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/PreferenceFragment.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/PreferenceFragment.java
@@ -37,6 +37,7 @@
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
+import androidx.preference.TwoStatePreference;
import androidx.recyclerview.widget.RecyclerView;
import com.android.car.ui.FocusArea;
@@ -366,6 +367,18 @@
toMulti.setEntries(fromMulti.getEntries());
toMulti.setEntryValues(fromMulti.getEntryValues());
toMulti.setValues(fromMulti.getValues());
+ } else if (from instanceof TwoStatePreference) {
+ TwoStatePreference fromTwoState = (TwoStatePreference) from;
+ TwoStatePreference toTwoState = (TwoStatePreference) to;
+ toTwoState.setSummaryOn(fromTwoState.getSummaryOn());
+ toTwoState.setSummaryOff(fromTwoState.getSummaryOff());
+
+ if (from instanceof SwitchPreference) {
+ SwitchPreference fromSwitch = (SwitchPreference) from;
+ SwitchPreference toSwitch = (SwitchPreference) to;
+ toSwitch.setSwitchTextOn(fromSwitch.getSwitchTextOn());
+ toSwitch.setSwitchTextOff(fromSwitch.getSwitchTextOff());
+ }
}
// We don't need to add checks for things that we will never replace,
diff --git a/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/caruirecyclerview/GridCarUiRecyclerViewActivity.java b/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/caruirecyclerview/GridCarUiRecyclerViewActivity.java
index a691bf0..5d51d4c 100644
--- a/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/caruirecyclerview/GridCarUiRecyclerViewActivity.java
+++ b/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/caruirecyclerview/GridCarUiRecyclerViewActivity.java
@@ -20,7 +20,6 @@
import android.os.Bundle;
import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.GridLayoutManager;
import com.android.car.ui.baselayout.Insets;
import com.android.car.ui.baselayout.InsetsChangedListener;
@@ -48,7 +47,6 @@
toolbar.setState(Toolbar.State.SUBPAGE);
CarUiRecyclerView recyclerView = findViewById(R.id.list);
- recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
RecyclerViewAdapter adapter = new RecyclerViewAdapter(generateSampleData());
recyclerView.setAdapter(adapter);
diff --git a/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/preferences/PreferenceDemoFragment.java b/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/preferences/PreferenceDemoFragment.java
index 233c873..e9f990d 100644
--- a/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/preferences/PreferenceDemoFragment.java
+++ b/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/preferences/PreferenceDemoFragment.java
@@ -20,7 +20,6 @@
import com.android.car.ui.paintbooth.R;
import com.android.car.ui.preference.CarUiPreference;
-import com.android.car.ui.preference.CarUiSwitchPreference;
import com.android.car.ui.preference.PreferenceFragment;
/**
@@ -45,10 +44,5 @@
preferenceDisabledWithRipple.setMessageToShowWhenDisabledPreferenceClicked(
"I am disabled because...");
preferenceDisabledWithRipple.setShouldShowRippleOnDisabledPreference(true);
-
- CarUiSwitchPreference carUiSwitchPreference = findPreference("switch");
- carUiSwitchPreference.setEnabled(false);
- carUiSwitchPreference.setMessageToShowWhenDisabledPreferenceClicked(
- "I am disabled because...");
}
}
diff --git a/car-ui-lib/paintbooth/src/main/res/layout/car_ui_recycler_view_activity.xml b/car-ui-lib/paintbooth/src/main/res/layout/car_ui_recycler_view_activity.xml
index 5ae7e7f..89a73d8 100644
--- a/car-ui-lib/paintbooth/src/main/res/layout/car_ui_recycler_view_activity.xml
+++ b/car-ui-lib/paintbooth/src/main/res/layout/car_ui_recycler_view_activity.xml
@@ -14,9 +14,15 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<com.android.car.ui.recyclerview.CarUiRecyclerView
+<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/car_ui_activity_background"/>
+ android:background="@drawable/car_ui_activity_background">
+ <com.android.car.ui.recyclerview.CarUiRecyclerView
+ android:id="@+id/list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+</FrameLayout>
+
+
diff --git a/car-ui-lib/paintbooth/src/main/res/layout/grid_car_ui_recycler_view_activity.xml b/car-ui-lib/paintbooth/src/main/res/layout/grid_car_ui_recycler_view_activity.xml
index 622ffa3..233c148 100644
--- a/car-ui-lib/paintbooth/src/main/res/layout/grid_car_ui_recycler_view_activity.xml
+++ b/car-ui-lib/paintbooth/src/main/res/layout/grid_car_ui_recycler_view_activity.xml
@@ -14,11 +14,16 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<com.android.car.ui.recyclerview.CarUiRecyclerView
+<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/list"
- app:numOfColumns="4"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/car_ui_activity_background" />
+ android:background="@drawable/car_ui_activity_background">
+ <com.android.car.ui.recyclerview.CarUiRecyclerView
+ android:id="@+id/list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:numOfColumns="4"
+ app:layoutStyle="grid"/>
+</FrameLayout>