aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-09-21 22:06:38 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-09-21 22:06:38 +0000
commit0cbe1eaaac96058d29f7c6605c75c9fa4e60ba2f (patch)
tree5ec539f50963fb576ecfce3d8cc2098116772e14
parent9059b297634e46c5f6ed886e2e67928a646a0f37 (diff)
parentcf5f6c63917fa0fe30ebd91718f53c7f4228f1b7 (diff)
downloadlayoutlib-0cbe1eaaac96058d29f7c6605c75c9fa4e60ba2f.tar.gz
Snap for 10843824 from cf5f6c63917fa0fe30ebd91718f53c7f4228f1b7 to 24Q1-release
Change-Id: Ifa2f3bba38aa522ea5d6697fa3f248b1efb4c567
-rw-r--r--Android.bp2
-rw-r--r--bridge/src/android/view/SurfaceView.java73
-rw-r--r--bridge/src/android/view/WindowManagerImpl.java13
-rw-r--r--bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java2
-rw-r--r--bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java2
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java2
-rw-r--r--create/Android.bp2
-rw-r--r--validator/resources/strings.properties14
-rw-r--r--validator/src/com/android/tools/idea/validator/ValidatorUtil.java3
-rw-r--r--validator/src/com/android/tools/idea/validator/hierarchy/CustomHierarchyHelper.java18
10 files changed, 116 insertions, 15 deletions
diff --git a/Android.bp b/Android.bp
index 76bc916b23..5fd342d124 100644
--- a/Android.bp
+++ b/Android.bp
@@ -30,7 +30,7 @@ java_genrule_host {
tools: ["layoutlib_create"],
out: ["temp_layoutlib.jar"],
srcs: [
- ":atf-prebuilt-502584086{.jar}",
+ ":atf-prebuilt-557133692{.jar}",
":core-icu4j-for-host{.jar}",
":core-libart-for-host{.jar}",
":framework-all{.jar}",
diff --git a/bridge/src/android/view/SurfaceView.java b/bridge/src/android/view/SurfaceView.java
index ebb2af4532..2c1d6747e7 100644
--- a/bridge/src/android/view/SurfaceView.java
+++ b/bridge/src/android/view/SurfaceView.java
@@ -18,11 +18,17 @@ package android.view;
import com.android.layoutlib.bridge.MockView;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Region;
+import android.os.IBinder;
import android.util.AttributeSet;
+import android.view.SurfaceControl.Transaction;
+
+import java.util.function.Consumer;
/**
* Mock version of the SurfaceView.
@@ -50,6 +56,11 @@ public class SurfaceView extends MockView {
super(context, attrs, defStyleAttr, defStyleRes);
}
+ public SurfaceView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr,
+ int defStyleRes, boolean disableBackgroundLayer) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
public boolean gatherTransparentRegion(Region region) {
return false;
}
@@ -60,6 +71,14 @@ public class SurfaceView extends MockView {
public void setZOrderOnTop(boolean onTop) {
}
+ public boolean isZOrderedOnTop() {
+ return false;
+ }
+
+ public boolean setZOrderedOnTop(boolean onTop, boolean allowDynamicChange) {
+ return true;
+ }
+
public void setSecure(boolean isSecure) {
}
@@ -67,6 +86,60 @@ public class SurfaceView extends MockView {
return mSurfaceHolder;
}
+ public void setUseAlpha() {
+ }
+
+ public void setEnableSurfaceClipping(boolean enabled) {
+ }
+
+ public void setCornerRadius(float cornerRadius) {
+ }
+
+ public float getCornerRadius() {
+ return 0;
+ }
+
+ public void setSurfaceLifecycle(int lifecycleStrategy) {
+ }
+
+ public String getName() {
+ return "MockSurfaceView";
+ }
+
+ public void requestUpdateSurfacePositionAndScale() {
+ }
+
+ public @NonNull Rect getSurfaceRenderPosition() {
+ return new Rect();
+ }
+
+ public boolean isFixedSize() {
+ return true;
+ }
+
+ public void setResizeBackgroundColor(int bgColor) {
+ }
+
+ public void setResizeBackgroundColor(@NonNull SurfaceControl.Transaction t, int bgColor) {
+ }
+
+ public SurfaceControl getSurfaceControl() {
+ return null;
+ }
+
+ public @Nullable IBinder getHostToken() {
+ return null;
+ }
+
+ public void setChildSurfacePackage(@NonNull SurfaceControlViewHost.SurfacePackage p) {
+ }
+
+ public void syncNextFrame(Consumer<Transaction> t) {
+ }
+
+ public void applyTransactionToFrame(@NonNull SurfaceControl.Transaction transaction) {
+ }
+
private SurfaceHolder mSurfaceHolder = new SurfaceHolder() {
@Override
diff --git a/bridge/src/android/view/WindowManagerImpl.java b/bridge/src/android/view/WindowManagerImpl.java
index e8b9fcf802..eb1e22c736 100644
--- a/bridge/src/android/view/WindowManagerImpl.java
+++ b/bridge/src/android/view/WindowManagerImpl.java
@@ -272,16 +272,15 @@ public class WindowManagerImpl implements WindowManager {
private WindowInsets computeWindowInsets() {
try {
final InsetsState insetsState = new InsetsState();
- final boolean alwaysConsumeSystemBars =
- WindowManagerGlobal.getWindowManagerService().getWindowInsets(
- mContext.getDisplayId(), null /* token */, insetsState);
+ WindowManagerGlobal.getWindowManagerService().getWindowInsets(mContext.getDisplayId(),
+ null /* token */, insetsState);
final Configuration config = mContext.getResources().getConfiguration();
final boolean isScreenRound = config.isScreenRound();
- final int windowingMode = config.windowConfiguration.getWindowingMode();
+ final int activityType = config.windowConfiguration.getActivityType();
return insetsState.calculateInsets(getCurrentBounds(mContext),
- null /* ignoringVisibilityState*/, isScreenRound, alwaysConsumeSystemBars,
- SOFT_INPUT_ADJUST_NOTHING, 0, SYSTEM_UI_FLAG_VISIBLE, TYPE_APPLICATION,
- windowingMode, null /* typeSideMap */);
+ null /* ignoringVisibilityState */, isScreenRound, SOFT_INPUT_ADJUST_NOTHING,
+ 0 /* legacySystemUiFlags */, SYSTEM_UI_FLAG_VISIBLE, TYPE_APPLICATION,
+ activityType, null /* typeSideMap */);
} catch (RemoteException ignore) {
}
return null;
diff --git a/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 0efe9a0c86..65cf9619d3 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -1546,7 +1546,7 @@ public class BridgeContext extends Context {
@Override
public ContentResolver getContentResolver() {
if (mContentResolver == null) {
- mContentResolver = new BridgeContentResolver(this);
+ mContentResolver = new BridgeContentResolver(getApplicationContext());
}
return mContentResolver;
}
diff --git a/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java b/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
index c39ec8b704..68423337a0 100644
--- a/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
+++ b/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
@@ -74,7 +74,7 @@ public class StatusBar extends CustomBar {
@SuppressWarnings("UnusedParameters")
public StatusBar(Context context, AttributeSet attrs) {
this((BridgeContext) context,
- Density.getEnum(((BridgeContext) context).getMetrics().densityDpi),
+ Density.create(((BridgeContext) context).getMetrics().densityDpi),
((BridgeContext) context).getConfiguration().getLayoutDirection() ==
View.LAYOUT_DIRECTION_RTL,
(context.getApplicationInfo().flags & ApplicationInfo.FLAG_SUPPORTS_RTL) != 0,
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index 87bed3d967..4200537f40 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -368,7 +368,7 @@ public final class ResourceHelper {
if (value instanceof DensityBasedResourceValue) {
density = ((DensityBasedResourceValue) value).getResourceDensity();
if (density == Density.NODPI || density == Density.ANYDPI) {
- density = Density.getEnum(context.getConfiguration().densityDpi);
+ density = Density.create(context.getConfiguration().densityDpi);
}
}
diff --git a/create/Android.bp b/create/Android.bp
index 13a00a878f..a8dcdaa5eb 100644
--- a/create/Android.bp
+++ b/create/Android.bp
@@ -30,7 +30,7 @@ java_binary_host {
"guava",
"layoutlib-common",
"layoutlib_create-classpath",
- "atf-prebuilt-502584086",
+ "atf-prebuilt-557133692",
"libprotobuf-java-lite",
],
}
diff --git a/validator/resources/strings.properties b/validator/resources/strings.properties
index 27f310cfa3..3a07104c0c 100644
--- a/validator/resources/strings.properties
+++ b/validator/resources/strings.properties
@@ -16,6 +16,7 @@
#
result_message_not_important_for_accessibility = This item was not found to be important for accessibility.
result_message_no_content_desc = This item has no <tt>android:contentDescription</tt>.
+result_message_no_content_desc_generic = This item has no content description.
result_message_not_visible = This item is not visible.
result_message_not_enabled = This item isn\'t enabled.
result_message_not_text_view = This item is not a <tt>TextView</tt>.
@@ -38,6 +39,7 @@ non_clickable = non-clickable
long_clickable = long clickable
clickable_and_long_clickable = clickable and long clickable
actionable = actionable
+result_message_addendum_conflicting_elements_list = Conflicting element(s): <tt>%1$s</tt>.
check_title_duplicate_speakable_text = Item descriptions
result_message_brief_same_speakable_text = Multiple items have the same description.
result_message_same_speakable_text = This %1$s item\'s speakable text: \"<tt>%2$s</tt>\" is identical to that of %3$d other item(s).
@@ -55,10 +57,14 @@ result_message_image_customized_contrast_not_sufficient_confirmed = The image\'s
check_title_redundant_description = Item type label
result_message_english_locale_only = This check only runs on devices with locales set to English.
result_message_brief_content_desc_contains_redundant_word = This item\'s <tt>android:contentDescription</tt> might contain unnecessary text.
+result_message_brief_content_desc_contains_redundant_word_generic = This item\'s content description might contain unnecessary text.
result_message_content_desc_ends_with_view_type = This item\'s <tt>android:contentDescription</tt>, \"<tt>%1$s</tt>\" ends with the item\'s type.
result_message_content_desc_contains_redundant_word = This item\'s <tt>android:contentDescription</tt>, \"<tt>%1$s</tt>\" contains the item type \"<tt>%2$s</tt>\".
+result_message_content_desc_contains_redundant_word_generic = This item\'s content description, \"<tt>%1$s</tt>\" contains the item type \"<tt>%2$s</tt>\".
result_message_content_desc_contains_action = This item\'s <tt>android:contentDescription</tt>, \"<tt>%1$s</tt>\", contains the action \"<tt>%2$s</tt>\".
+result_message_content_desc_contains_action_generic = This item\'s content description, \"<tt>%1$s</tt>\", contains the action \"<tt>%2$s</tt>\".
result_message_content_desc_contains_state = This item\'s <tt>android:contentDescription</tt>, \"<tt>%1$s</tt>\", contains the state \"<tt>%2$s</tt>\".
+result_message_content_desc_contains_state_generic = This item\'s content description, \"<tt>%1$s</tt>\", contains the state \"<tt>%2$s</tt>\".
button_item_type = button
checkbox_item_type = checkbox
checkbox_item_type_separate_words = check box
@@ -73,6 +79,7 @@ check_title_speakable_text_present = Item label
result_message_should_not_focus = This item would not be focused by a screen reader.
result_message_web_content = Web content is not evaluated.
result_message_unsupported_compose_content = Composable content is not evaluated in this environment.
+result_message_unsupported_flutter_content = Flutter content is not evaluated in this environment.
result_message_missing_speakable_text = This item may not have a label readable by screen readers.
check_title_text_contrast = Text contrast
result_message_textview_empty = This <tt>TextView</tt> is empty.
@@ -158,12 +165,19 @@ result_message_item_type_with_text_size_unit = <tt>%1$s</tt> with text size unit
result_message_small_fixed_text_size = This text is small and may be difficult for some users to read. Consider using a larger size or specifying the text size in scaled pixels (<tt>sp</tt>).
result_message_fixed_text_size = Consider specifying the text size in scaled pixels (<tt>sp</tt>).
result_message_brief_fixed_width_text_view_with_scaled_text = This <tt>TextView</tt> has a fixed width and scalable text.
+result_message_brief_fixed_width_text_view_with_scaled_text_compose = This <tt>Text</tt> has a fixed width and scalable text.
result_message_brief_fixed_height_text_view_with_scaled_text = This <tt>TextView</tt> has a fixed height and scalable text.
+result_message_brief_fixed_height_text_with_scaled_text_compose = This <tt>Text</tt> has a fixed height and scalable text.
result_message_brief_fixed_size_text_view_with_scaled_text = This <tt>TextView</tt> has a fixed size and scalable text.
+result_message_brief_fixed_size_text_with_scaled_text_compose = This <tt>Text</tt> has a fixed size and scalable text.
result_message_brief_fixed_width_view_group_with_scaled_text = This <tt>ViewGroup</tt> has a fixed width and contains a <tt>TextView</tt> with scalable text.
+result_message_brief_fixed_width_parent_with_scaled_text_compose = This element has a fixed width and contains a <tt>Text</tt> element with scalable text.
result_message_brief_fixed_height_view_group_with_scaled_text = This <tt>ViewGroup</tt> has a fixed height and contains a <tt>TextView</tt> with scalable text.
+result_message_brief_fixed_height_parent_with_scaled_text_compose = This element has a fixed height and contains a <tt>Text</tt> element with scalable text.
result_message_brief_fixed_size_view_group_with_scaled_text = This <tt>ViewGroup</tt> has a fixed size and contains a <tt>TextView</tt> with scalable text.
+result_message_brief_fixed_size_parent_with_scaled_text_compose = This element has a fixed size and contains a <tt>Text</tt> element with scalable text.
result_message_fixed_size_text_view_with_scaled_text = Consider modifying the <tt>LayoutParams</tt> to allow for text expansion.
+result_message_fixed_size_text_with_scaled_text_compose = Consider modifying the size modifiers using <tt>sizeIn</tt> to allow for text expansion.
check_title_unexposed_text = Unexposed Text
result_message_unexposed_text = Ensure this item's accessibility label includes its visible text.
result_message_text_detected_in_image_view = OCR results were detected inside this ImageView.
diff --git a/validator/src/com/android/tools/idea/validator/ValidatorUtil.java b/validator/src/com/android/tools/idea/validator/ValidatorUtil.java
index f3a52e0c53..fa2862d191 100644
--- a/validator/src/com/android/tools/idea/validator/ValidatorUtil.java
+++ b/validator/src/com/android/tools/idea/validator/ValidatorUtil.java
@@ -83,8 +83,6 @@ public class ValidatorUtil {
* uses be redirected.
*/
StringManager.setResourceBundleProvider(locale -> ResourceBundle.getBundle("strings"));
- // Enable using AccessibilityNodeInfo in addition to View for accessibility testing
- AccessibilityHierarchyAndroid.viewOverlayEnabled = true;
}
// Visible for testing.
@@ -130,6 +128,7 @@ public class ValidatorUtil {
try {
hierarchy.mView = AccessibilityHierarchyAndroid
.newBuilder(view)
+ .enableViewOverlay()
.setViewOriginMap(builder.mSrcMap)
.setNodeInfoOriginMap(builder.mNodeInfoMap)
.setObtainCharacterLocations(LayoutValidator.obtainCharacterLocations())
diff --git a/validator/src/com/android/tools/idea/validator/hierarchy/CustomHierarchyHelper.java b/validator/src/com/android/tools/idea/validator/hierarchy/CustomHierarchyHelper.java
index eee2f32c36..5c8b2e9a39 100644
--- a/validator/src/com/android/tools/idea/validator/hierarchy/CustomHierarchyHelper.java
+++ b/validator/src/com/android/tools/idea/validator/hierarchy/CustomHierarchyHelper.java
@@ -48,13 +48,29 @@ public class CustomHierarchyHelper {
// This is required as layoutlib does not know the support library such as
// MaterialButton. LayoutlibCallback calls for studio which understands all the maven
// pulled library.
- Class button = callback.findClass(
+ Class<?> button = callback.findClass(
"com.google.android.material.button.MaterialButton");
if (button.isInstance(fromView)) {
Method isCheckable = button.getMethod("isCheckable");
Object toReturn = isCheckable.invoke(fromView);
return (toReturn instanceof Boolean) && ((Boolean) toReturn);
}
+
+ Class<?> card = callback.findClass(
+ "com.google.android.material.card.MaterialCardView");
+ if (card.isInstance(fromView)) {
+ Method isCheckable = card.getMethod("isCheckable");
+ Object toReturn = isCheckable.invoke(fromView);
+ return (toReturn instanceof Boolean) && ((Boolean) toReturn);
+ }
+
+ Class<?> chip = callback.findClass(
+ "com.google.android.material.chip.Chip");
+ if (chip.isInstance(fromView)) {
+ Method isCheckable = chip.getMethod("isCheckable");
+ Object toReturn = isCheckable.invoke(fromView);
+ return (toReturn instanceof Boolean) && ((Boolean) toReturn);
+ }
} catch (ClassNotFoundException |
NoSuchMethodException |
IllegalAccessException |