-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reviewed By: oprisnik Differential Revision: D64345016 fbshipit-source-id: f7b689df02c3f18c1a67401ce48df227c9b866de
- Loading branch information
1 parent
f997d51
commit de0c977
Showing
12 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
imagepipeline-base/src/test/resources/com/facebook/imageformat/xmls/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.facebook.imageformat.xmls" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
</manifest> |
14 changes: 14 additions & 0 deletions
14
imagepipeline-base/src/test/resources/com/facebook/imageformat/xmls/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# XMLs | ||
|
||
## Context | ||
|
||
Android compiles raw XML to binary XML during app build as layout inflation at runtime does not support parsing raw XML files. As a result, Fresco only supports loading binary XML files since it relies on the Android to perform layout inflation. Therefore, we need to mock the build step that performs this compilation with the Android packaging tool. This directory houses raw, uncompiled files and their compiled counterparts in respective directories so we can test against them. | ||
|
||
## How to add/update assets | ||
|
||
These instructions are for POSIX devices. If you are on Windows, you will have to manually run these steps or use Android Studio to generate an APK | ||
|
||
1. Install Android's command-line tools by [following these instructions](https://developer.android.com/tools). Make sure you have `$ANDROID_HOME` set in your PATH by running `echo $ANDROID_HOME` | ||
1. Install the latest packages of Android's build tools and platform. For example, you can run `sdkmanager "build-tools;34.0.0"` or `sdkmanager "platforms;android-33"`. [More instructions for sdkmanager can be found here](https://developer.android.com/tools/sdkmanager) | ||
1. Run `./convert.sh` to automatically compile and extract resources into the `compiled` folder. It will use the latest available version of your build-tools and platforms. | ||
1. That's it! |
Binary file added
BIN
+692 Bytes
imagepipeline-base/src/test/resources/com/facebook/imageformat/xmls/compiled/layer_list.xml
Binary file not shown.
Binary file added
BIN
+624 Bytes
imagepipeline-base/src/test/resources/com/facebook/imageformat/xmls/compiled/level_list.xml
Binary file not shown.
Binary file added
BIN
+660 Bytes
imagepipeline-base/src/test/resources/com/facebook/imageformat/xmls/compiled/state_list.xml
Binary file not shown.
Binary file added
BIN
+496 Bytes
...peline-base/src/test/resources/com/facebook/imageformat/xmls/compiled/vector_drawable.xml
Binary file not shown.
51 changes: 51 additions & 0 deletions
51
imagepipeline-base/src/test/resources/com/facebook/imageformat/xmls/convert.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/sh | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
if [ -z "$ANDROID_HOME" ]; then | ||
echo "Environment variable ANDROID_HOME is not set" | ||
exit 1 | ||
fi | ||
|
||
SCRIPT_DIR="$(readlink -f "$(dirname "$0")")" | ||
cd "$SCRIPT_DIR" || exit | ||
|
||
# Use the latest available AAPT binary | ||
BUILD_TOOLS_DIR="$ANDROID_HOME/build-tools" | ||
LATEST_TOOLS_DIR=$(find "$BUILD_TOOLS_DIR" -maxdepth 1 -type d -print | sort -rn --key=4.1 | head -1) | ||
|
||
if [ ! -d "$LATEST_TOOLS_DIR" ]; then | ||
echo "Could not find build tools in $BUILD_TOOLS_DIR" | ||
exit 1 | ||
fi | ||
|
||
# Use the latest available Android version | ||
ANDROID_PLATFORMS_DIR="$ANDROID_HOME/platforms" | ||
LATEST_PLATFORM_DIR=$(find "$ANDROID_PLATFORMS_DIR" -maxdepth 1 -type d -print | sort -rn --key=4.1 | head -1) | ||
|
||
if [ ! -d "$LATEST_PLATFORM_DIR" ]; then | ||
echo "Could not find any platforms in $ANDROID_PLATFORMS_DIR" | ||
exit 1 | ||
fi | ||
|
||
# Define a temporary directory for the APK | ||
TMP_DIR=$(mktemp -d) | ||
APK_OUTPUT="$TMP_DIR/app.apk" | ||
|
||
# Build an APK with our raw resources | ||
"$LATEST_TOOLS_DIR/aapt" package -f -m -M AndroidManifest.xml -S raw -0 "" -I "$LATEST_PLATFORM_DIR/android.jar" -F "$APK_OUTPUT" || exit 1 | ||
|
||
# Unzip all APK artifacts | ||
cd "$TMP_DIR" || exit | ||
unzip -q "app.apk" | ||
|
||
# Copy all compiled resources from the base drawable folder | ||
cd "$SCRIPT_DIR" || exit | ||
rm -rf compiled | ||
mkdir compiled | ||
cp -R "$TMP_DIR/res/drawable/" ./compiled | ||
|
||
# Remove the temporary folder | ||
rm -rf "$TMP_DIR" |
15 changes: 15 additions & 0 deletions
15
...ipeline-base/src/test/resources/com/facebook/imageformat/xmls/raw/drawable/layer_list.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item | ||
android:drawable="@drawable/vector_drawable" | ||
android:gravity="center" | ||
android:top="100dp" | ||
android:left="10dp" | ||
/> | ||
<item | ||
android:drawable="@drawable/vector_drawable" | ||
android:gravity="center" | ||
android:top="5dp" | ||
android:left="30dp" | ||
/> | ||
</layer-list> |
12 changes: 12 additions & 0 deletions
12
...ipeline-base/src/test/resources/com/facebook/imageformat/xmls/raw/drawable/level_list.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<level-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item | ||
android:drawable="@drawable/vector_drawable" | ||
android:minLevel="1" | ||
/> | ||
<item | ||
android:drawable="@drawable/vector_drawable" | ||
android:maxLevel="1" | ||
android:minLevel="0" | ||
/> | ||
</level-list> |
5 changes: 5 additions & 0 deletions
5
...ipeline-base/src/test/resources/com/facebook/imageformat/xmls/raw/drawable/state_list.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:drawable="@drawable/layer_list" android:state_checked="false" android:state_pressed="false" /> | ||
<item android:drawable="@drawable/level_list" android:state_checked="true" android:state_pressed="false" /> | ||
</selector> |
13 changes: 13 additions & 0 deletions
13
...ne-base/src/test/resources/com/facebook/imageformat/xmls/raw/drawable/vector_drawable.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:tint="#a4c639" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
> | ||
<path | ||
android:fillColor="#000" | ||
android:pathData="M17.6,11.48 L19.44,8.3a0.63,0.63 0,0 0,-1.09 -0.63l-1.88,3.24a11.43,11.43 0,0 0,-8.94 0L5.65,7.67a0.63,0.63 0,0 0,-1.09 0.63L6.4,11.48A10.81,10.81 0,0 0,1 20L23,20A10.81,10.81 0,0 0,17.6 11.48ZM7,17.25A1.25,1.25 0,1 1,8.25 16,1.25 1.25,0 0,1 7,17.25ZM17,17.25A1.25,1.25 0,1 1,18.25 16,1.25 1.25,0 0,1 17,17.25Z" | ||
/> | ||
</vector> |