Skip to content

Commit 72b98ab

Browse files
committed
custom bootanimation path
add support for custom bootanimation path
1 parent 5ca38ab commit 72b98ab

10 files changed

+36
-3
lines changed

PackageMake.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def module_pack(bootani_zip_path: str, module_media_dir_path: str, placeholder_p
141141
:param module_export_file_path:
142142
:return: None
143143
"""
144-
os.mkdir(module_media_dir_path)
144+
os.makedirs(module_media_dir_path)
145145
shutil.move(bootani_zip_path, module_media_dir_path)
146146
os.remove(placeholder_path)
147147
utils.dir2zipfile(template_dir_path, module_export_file_path)

config_template.yml

+7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# Boot Animation Maker config template
22
#
3+
34
# Magisk Module output filename
45
'module_export_filename': 'BootAniMagiskModule.zip'
6+
57
# Screen size [w x h], use the maximum size
68
'device_size': [1080, 1920]
9+
10+
# For some phone model,the location of Bootanimation.zip may be different e.g. Google Pixel
11+
# Uncomment it when use custom path
12+
#'media_dir_path': ['system', 'product', 'media']
13+
714
# Specify the FPS, it should be matched to gif,
815
# For animation contains only one part, If it doesn't match, the script will ask if to replace the this FPS with the actual FPS.
916
# For animation contains more than one part, each gif needs to have the same or similar FPS (diff<=5), the script will use the average of FPS instead,If the difference is too large, stop generating.

config_template_CN.yml

+7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# Boot Animation Maker 配置文件模板
22
#
3+
34
# Magisk Module 输出的文件名
45
'module_export_filename': 'BootAniMagiskModule.zip'
6+
57
# 设备尺寸 [w x h],异形屏考虑使用最大外边框尺寸
68
'device_size': [1080, 1920]
9+
10+
# 对于某些机型,Bootanimation.zip 的路径可能会不同,比如 Google Pixel
11+
# 清除注释以自定义路径
12+
# 'media_dir_path': ['system', 'product', 'media']
13+
714
# 指定播放动画的帧率,注意与 gif 相匹配,
815
# 对于单 part 的动画,如果不匹配则脚本运行过程中会提示是否以实际 FPS 代替指定的 FPS
916
# 对于多个 part 的动画,各个 gif 需要 FPS 数相同或相近(diff<=5),如果相近则会提示使用两者的平均值代替指定的 FPS,如果 FPS 相差过大则停止生成

example/1/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
'device_size': [1080, 1920]
77
# 指定播放动画的帧率,注意与 gif 相匹配
88
'fps': 10
9+
# 对于某些机型,Bootanimation.zip 的路径可能会不同,比如 Google Pixel
10+
# 清除注释以自定义路径
11+
# 'media_dir_path': ['system', 'product', 'media']
912
# ******************************************************
1013
# 图层设定 'anime'
1114
# - {part0}

example/2/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
'device_size': [1080, 1920]
77
# 指定播放动画的帧率,注意与 gif 相匹配
88
'fps': 10
9+
# 对于某些机型,Bootanimation.zip 的路径可能会不同,比如 Google Pixel
10+
# 清除注释以自定义路径
11+
# 'media_dir_path': ['system', 'product', 'media']
912
# ******************************************************
1013
# 图层设定 'anime'
1114
# - {part0}

example/3/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
'device_size': [1080, 1920]
77
# 指定播放动画的帧率,注意与 gif 相匹配
88
'fps': 10
9+
# 对于某些机型,Bootanimation.zip 的路径可能会不同,比如 Google Pixel
10+
# 清除注释以自定义路径
11+
# 'media_dir_path': ['system', 'product', 'media']
912
# ******************************************************
1013
# 图层设定 'anime'
1114
# - {part0}

example/4/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
'device_size': [1080, 1920]
77
# 指定播放动画的帧率,注意与 gif 相匹配
88
'fps': 10
9+
# 对于某些机型,Bootanimation.zip 的路径可能会不同,比如 Google Pixel
10+
# 清除注释以自定义路径
11+
# 'media_dir_path': ['system', 'product', 'media']
912
# ******************************************************
1013
# 图层设定 'anime'
1114
# - {part0}

example/5/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
'device_size': [1080, 1920]
77
# 指定播放动画的帧率,注意与 gif 相匹配
88
'fps': 15
9+
# 对于某些机型,Bootanimation.zip 的路径可能会不同,比如 Google Pixel
10+
# 清除注释以自定义路径
11+
# 'media_dir_path': ['system', 'product', 'media']
912
# ******************************************************
1013
# 图层设定 'anime'
1114
# - {part0}

example/6/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
'device_size': [1080, 1920]
77
# 指定播放动画的帧率,注意与 gif 相匹配
88
'fps': 15
9+
# 对于某些机型,Bootanimation.zip 的路径可能会不同,比如 Google Pixel
10+
# 清除注释以自定义路径
11+
# 'media_dir_path': ['system', 'product', 'media']
912
# ******************************************************
1013
# 图层设定 'anime'
1114
# - {part0}

run.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def main(config):
8181
all_config = dict()
8282
try:
8383
with open(config_file_path, 'r', encoding='utf-8') as f:
84-
all_config = yaml.load(f)
84+
all_config = yaml.load(f, Loader=yaml.Loader)
8585

8686
except FileNotFoundError:
8787
pt.error(show_text.get('CONFIG_NOT_FOUND'))
@@ -113,7 +113,8 @@ def main(config):
113113
update_binary_file_path = os.path.join(template_dir_path, 'META-INF', 'com', 'google', 'android', 'update-binary')
114114
module_prop_file_path = os.path.join(template_dir_path, 'module.prop')
115115
module_install_file_path = os.path.join(template_dir_path, 'install.sh')
116-
module_media_dir_path = os.path.join(template_dir_path, 'system', 'media')
116+
media_dir_path = all_config.get('media_dir_path', ['system', 'media'])
117+
module_media_dir_path = os.path.join(template_dir_path, *media_dir_path)
117118
module_placeholder_file_path = os.path.join(template_dir_path, 'system', 'placeholder')
118119
module_export_file_path = os.path.join(export_dir_path, module_export_filename)
119120

0 commit comments

Comments
 (0)