cm: New boot animation from Cameron Behzadpour
* Promo video here: http://www.youtube.com/watch?v=ogp9f4_yEoU
* It looks *way* better on a device, though :)
* The animation is square, so the names have changed.
Change-Id: I8eebdf29a7d30632d75210a6d3975d7ea17d5246
diff --git a/config/common.mk b/config/common.mk
index 289ee4b..fc32ec7 100644
--- a/config/common.mk
+++ b/config/common.mk
@@ -1,8 +1,49 @@
PRODUCT_BRAND ?= cyanogenmod
+# To deal with CM9 specifications
+# TODO: remove once all devices have been switched
ifneq ($(TARGET_BOOTANIMATION_NAME),)
- PRODUCT_COPY_FILES += \
- vendor/cm/prebuilt/common/bootanimation/$(TARGET_BOOTANIMATION_NAME).zip:system/media/bootanimation.zip
+TARGET_SCREEN_DIMENSIONS := $(subst -, $(space), $(subst x, $(space), $(TARGET_BOOTANIMATION_NAME)))
+ifeq ($(TARGET_SCREEN_WIDTH),)
+TARGET_SCREEN_WIDTH := $(word 2, $(TARGET_SCREEN_DIMENSIONS))
+endif
+ifeq ($(TARGET_SCREEN_HEIGHT),)
+TARGET_SCREEN_HEIGHT := $(word 3, $(TARGET_SCREEN_DIMENSIONS))
+endif
+endif
+
+ifneq ($(TARGET_SCREEN_WIDTH) $(TARGET_SCREEN_HEIGHT),$(space))
+
+# clear TARGET_BOOTANIMATION_NAME in case it was set for CM9 purposes
+TARGET_BOOTANIMATION_NAME :=
+
+# determine the smaller dimension
+TARGET_BOOTANIMATION_SIZE := $(shell \
+ if [ $(TARGET_SCREEN_WIDTH) -lt $(TARGET_SCREEN_HEIGHT) ]; then \
+ echo $(TARGET_SCREEN_WIDTH); \
+ else \
+ echo $(TARGET_SCREEN_HEIGHT); \
+ fi )
+
+# get a sorted list of the sizes
+bootanimation_sizes := $(subst .zip,, $(shell ls vendor/cm/prebuilt/common/bootanimation))
+bootanimation_sizes := $(shell echo -e $(subst $(space),'\n',$(bootanimation_sizes)) | sort -rn)
+
+# find the appropriate size and set
+define check_and_set_bootanimation
+$(eval TARGET_BOOTANIMATION_NAME := $(shell \
+ if [ -z "$(TARGET_BOOTANIMATION_NAME)" ]; then
+ if [ $(1) -le $(TARGET_BOOTANIMATION_SIZE) ]; then \
+ echo $(1); \
+ exit 0; \
+ fi;
+ fi;
+ echo $(TARGET_BOOTANIMATION_NAME); ))
+endef
+$(foreach size,$(bootanimation_sizes), $(call check_and_set_bootanimation,$(size)))
+
+PRODUCT_COPY_FILES += \
+ vendor/cm/prebuilt/common/bootanimation/$(TARGET_BOOTANIMATION_NAME).zip:system/media/bootanimation.zip
endif
ifdef CM_NIGHTLY