diff --git a/charger/Android.mk b/charger/Android.mk new file mode 100644 index 00000000..2fce7c43 --- /dev/null +++ b/charger/Android.mk @@ -0,0 +1,58 @@ +# +# Copyright (C) 2021 The LineageOS 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. +# + +LOCAL_PATH := $(call my-dir) + +# Set lineage_charger_density to the density bucket of the device. +lineage_charger_density := mdpi +ifneq (,$(TARGET_SCREEN_DENSITY)) +lineage_charger_density := $(strip \ + $(or $(if $(filter $(shell echo $$(($(TARGET_SCREEN_DENSITY) >= 560))),1),xxxhdpi),\ + $(if $(filter $(shell echo $$(($(TARGET_SCREEN_DENSITY) >= 400))),1),xxhdpi),\ + $(if $(filter $(shell echo $$(($(TARGET_SCREEN_DENSITY) >= 280))),1),xhdpi),\ + $(if $(filter $(shell echo $$(($(TARGET_SCREEN_DENSITY) >= 200))),1),hdpi,mdpi))) +else ifneq (,$(filter mdpi hdpi xhdpi xxhdpi xxxhdpi,$(PRODUCT_AAPT_PREF_CONFIG))) +# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value. +lineage_charger_density := $(PRODUCT_AAPT_PREF_CONFIG) +endif + +include $(CLEAR_VARS) +LOCAL_MODULE := lineage_charger_battery_scale +LOCAL_MODULE_STEM := battery_scale.png +LOCAL_SRC_FILES := $(lineage_charger_density)/battery_scale.png +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT_ETC)/res/images/charger +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := lineage_charger_battery_fail +LOCAL_MODULE_STEM := battery_fail.png +LOCAL_SRC_FILES := $(lineage_charger_density)/battery_fail.png +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT_ETC)/res/images/charger +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := lineage_charger_animation +LOCAL_MODULE_STEM := animation.txt +LOCAL_SRC_FILES := animation.txt +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT_ETC)/res/values/charger +LOCAL_REQUIRED_MODULES := lineage_charger_battery_scale lineage_charger_battery_fail +include $(BUILD_PREBUILT) diff --git a/charger/animation.txt b/charger/animation.txt new file mode 100644 index 00000000..f7951f9a --- /dev/null +++ b/charger/animation.txt @@ -0,0 +1,26 @@ +# animation: num_cycles, first_frame_repeats, animation_file +animation: 7 1 charger/battery_scale + +# frame: disp_time min_level max_level +frame: 500 0 4 +frame: 500 0 9 +frame: 500 5 14 +frame: 500 10 19 +frame: 500 15 24 +frame: 500 20 29 +frame: 500 25 34 +frame: 500 30 39 +frame: 500 35 44 +frame: 500 40 49 +frame: 500 45 54 +frame: 500 50 59 +frame: 500 55 64 +frame: 500 60 69 +frame: 500 65 74 +frame: 500 70 79 +frame: 500 75 84 +frame: 500 80 89 +frame: 500 85 94 +frame: 500 90 99 +frame: 500 95 99 +frame: 1000 100 100 \ No newline at end of file diff --git a/charger/hdpi/battery_fail.png b/charger/hdpi/battery_fail.png new file mode 100644 index 00000000..572d8eff Binary files /dev/null and b/charger/hdpi/battery_fail.png differ diff --git a/charger/hdpi/battery_scale.png b/charger/hdpi/battery_scale.png new file mode 100644 index 00000000..92cd5b6e Binary files /dev/null and b/charger/hdpi/battery_scale.png differ diff --git a/charger/images/battery_fail.svg b/charger/images/battery_fail.svg new file mode 100644 index 00000000..f80b074f --- /dev/null +++ b/charger/images/battery_fail.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/charger/mdpi/battery_fail.png b/charger/mdpi/battery_fail.png new file mode 100644 index 00000000..2b5d91cb Binary files /dev/null and b/charger/mdpi/battery_fail.png differ diff --git a/charger/mdpi/battery_scale.png b/charger/mdpi/battery_scale.png new file mode 100644 index 00000000..5683aa41 Binary files /dev/null and b/charger/mdpi/battery_scale.png differ diff --git a/charger/regenerate.sh b/charger/regenerate.sh new file mode 100644 index 00000000..4ea011f8 --- /dev/null +++ b/charger/regenerate.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +if [ -z "$(which convert)" ] || [ -z "$(which pngcrush)" ]; then + echo "Please install imagemagick and pngcrush" + exit 1 +fi + +for DENSITY in mdpi:160 hdpi:240 xhdpi:320 xxhdpi:480 xxxhdpi:640; do + DPI=$(echo $DENSITY | cut -f1 -d ':') + WIDTH=$(echo $DENSITY | cut -f2 -d ':') + + rm -rf $DPI + mkdir $DPI + + for SVG in svg/*.svg; do + PNG="$DPI/$(basename $SVG | cut -f1 -d '.').png" + convert -density $WIDTH -resize ${WIDTH}x${WIDTH} $SVG $PNG + done + + SCALEFILE="$DPI/battery_scale.png" + SCALEFILES="$(ls $DPI/battery_scale_*.png)" + FRAMES="$(ls -l $SCALEFILES | wc -l)" + SCALEHEIGHT=$(($WIDTH * $FRAMES)) + + convert -size ${WIDTH}x${SCALEHEIGHT} canvas:black $SCALEFILES -fx "u[j%$FRAMES+1].p{i,int(j/$FRAMES)}" png24:$SCALEFILE.tmp + pngcrush -text b "Frames" "$FRAMES" $SCALEFILE.tmp $SCALEFILE + rm $SCALEFILES $SCALEFILE.tmp +done diff --git a/charger/svg/battery_fail.svg b/charger/svg/battery_fail.svg new file mode 100644 index 00000000..f80b074f --- /dev/null +++ b/charger/svg/battery_fail.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/charger/svg/battery_scale_00.svg b/charger/svg/battery_scale_00.svg new file mode 100644 index 00000000..4bf3798c --- /dev/null +++ b/charger/svg/battery_scale_00.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/charger/svg/battery_scale_01.svg b/charger/svg/battery_scale_01.svg new file mode 100644 index 00000000..c5fbec4f --- /dev/null +++ b/charger/svg/battery_scale_01.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_02.svg b/charger/svg/battery_scale_02.svg new file mode 100644 index 00000000..b533904b --- /dev/null +++ b/charger/svg/battery_scale_02.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_03.svg b/charger/svg/battery_scale_03.svg new file mode 100644 index 00000000..c147769e --- /dev/null +++ b/charger/svg/battery_scale_03.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_04.svg b/charger/svg/battery_scale_04.svg new file mode 100644 index 00000000..1bb0a693 --- /dev/null +++ b/charger/svg/battery_scale_04.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_05.svg b/charger/svg/battery_scale_05.svg new file mode 100644 index 00000000..929ed577 --- /dev/null +++ b/charger/svg/battery_scale_05.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_06.svg b/charger/svg/battery_scale_06.svg new file mode 100644 index 00000000..d13aea2d --- /dev/null +++ b/charger/svg/battery_scale_06.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_07.svg b/charger/svg/battery_scale_07.svg new file mode 100644 index 00000000..6860f5d2 --- /dev/null +++ b/charger/svg/battery_scale_07.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_08.svg b/charger/svg/battery_scale_08.svg new file mode 100644 index 00000000..346360fc --- /dev/null +++ b/charger/svg/battery_scale_08.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_09.svg b/charger/svg/battery_scale_09.svg new file mode 100644 index 00000000..645ebb15 --- /dev/null +++ b/charger/svg/battery_scale_09.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_10.svg b/charger/svg/battery_scale_10.svg new file mode 100644 index 00000000..9a27608a --- /dev/null +++ b/charger/svg/battery_scale_10.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_11.svg b/charger/svg/battery_scale_11.svg new file mode 100644 index 00000000..ccf1485a --- /dev/null +++ b/charger/svg/battery_scale_11.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_12.svg b/charger/svg/battery_scale_12.svg new file mode 100644 index 00000000..5946ab3f --- /dev/null +++ b/charger/svg/battery_scale_12.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_13.svg b/charger/svg/battery_scale_13.svg new file mode 100644 index 00000000..fa64d390 --- /dev/null +++ b/charger/svg/battery_scale_13.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_14.svg b/charger/svg/battery_scale_14.svg new file mode 100644 index 00000000..1ae78346 --- /dev/null +++ b/charger/svg/battery_scale_14.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_15.svg b/charger/svg/battery_scale_15.svg new file mode 100644 index 00000000..2ad0cda4 --- /dev/null +++ b/charger/svg/battery_scale_15.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_16.svg b/charger/svg/battery_scale_16.svg new file mode 100644 index 00000000..38130aa5 --- /dev/null +++ b/charger/svg/battery_scale_16.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_17.svg b/charger/svg/battery_scale_17.svg new file mode 100644 index 00000000..c09c488f --- /dev/null +++ b/charger/svg/battery_scale_17.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_18.svg b/charger/svg/battery_scale_18.svg new file mode 100644 index 00000000..09507d59 --- /dev/null +++ b/charger/svg/battery_scale_18.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_19.svg b/charger/svg/battery_scale_19.svg new file mode 100644 index 00000000..fd66a719 --- /dev/null +++ b/charger/svg/battery_scale_19.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_20.svg b/charger/svg/battery_scale_20.svg new file mode 100644 index 00000000..5fda9a14 --- /dev/null +++ b/charger/svg/battery_scale_20.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/svg/battery_scale_21.svg b/charger/svg/battery_scale_21.svg new file mode 100644 index 00000000..b540507b --- /dev/null +++ b/charger/svg/battery_scale_21.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/charger/xhdpi/battery_fail.png b/charger/xhdpi/battery_fail.png new file mode 100644 index 00000000..94c87791 Binary files /dev/null and b/charger/xhdpi/battery_fail.png differ diff --git a/charger/xhdpi/battery_scale.png b/charger/xhdpi/battery_scale.png new file mode 100644 index 00000000..6eded503 Binary files /dev/null and b/charger/xhdpi/battery_scale.png differ diff --git a/charger/xxhdpi/battery_fail.png b/charger/xxhdpi/battery_fail.png new file mode 100644 index 00000000..4fd90b6c Binary files /dev/null and b/charger/xxhdpi/battery_fail.png differ diff --git a/charger/xxhdpi/battery_scale.png b/charger/xxhdpi/battery_scale.png new file mode 100644 index 00000000..ab82b38c Binary files /dev/null and b/charger/xxhdpi/battery_scale.png differ diff --git a/charger/xxxhdpi/battery_fail.png b/charger/xxxhdpi/battery_fail.png new file mode 100644 index 00000000..f637dce7 Binary files /dev/null and b/charger/xxxhdpi/battery_fail.png differ diff --git a/charger/xxxhdpi/battery_scale.png b/charger/xxxhdpi/battery_scale.png new file mode 100644 index 00000000..52819b0b Binary files /dev/null and b/charger/xxxhdpi/battery_scale.png differ diff --git a/config/common_mobile.mk b/config/common_mobile.mk index 5080c360..1f1c2414 100644 --- a/config/common_mobile.mk +++ b/config/common_mobile.mk @@ -58,6 +58,11 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ charger_res_images +ifneq ($(WITH_LINEAGE_CHARGER),false) +PRODUCT_PACKAGES += \ + lineage_charger_animation +endif + # Customizations PRODUCT_PACKAGES += \ IconShapeSquareOverlay \