import os
import shutil
import sys
-
-from manifest_json_parser import ManifestJsonParser
-
+import tempfile
def CopyToPathWithName(root, name, final_path, rename):
if name == '':
def CopyDrawables(image_dict, orientation, sanitized_name, name, app_root):
- drawable = os.path.join(sanitized_name, 'res', 'drawable')
+ drawable = os.path.join(tempfile.gettempdir(), sanitized_name, 'res',
+ 'drawable')
if orientation == 'landscape':
drawable = drawable + '-land'
elif orientation == 'portrait':
orientation,
sanitized_name,
app_root):
- background_path = os.path.join(sanitized_name, 'res',
+ background_path = os.path.join(tempfile.gettempdir(), sanitized_name, 'res',
'drawable', 'launchscreen_bg.xml')
if not os.path.isfile(background_path):
print('Error: launchscreen_bg.xml is missing in the build tool.')
content = content.replace('<!-- Background Image -->', tmp, 1)
has_background = True
if has_background:
- background_file = file(background_path, 'w')
+ background_file = open(background_path, 'w')
background_file.write(content)
background_file.close()
return has_background
-def CustomizeByOrientation(parser, orientation, sanitized_name, app_root):
- background_color = parser.GetLaunchScreenBackgroundColor(orientation)
- background_image = parser.GetLaunchScreenBackgroundImage(orientation)
- image = parser.GetLaunchScreenImage(orientation)
+def CustomizeByOrientation(manifest, orientation, sanitized_name, app_root):
+ background_color = manifest.GetLaunchScreenBackgroundColor(orientation)
+ background_image = manifest.GetLaunchScreenBackgroundImage(orientation)
+ image = manifest.GetLaunchScreenImage(orientation)
# Customize background: background_color, background_image.
has_background = CustomizeBackground(background_color, background_image,
orientation, sanitized_name, app_root)
return has_background
-def CustomizeLaunchScreen(app_manifest, sanitized_name):
- if not app_manifest:
+def CustomizeLaunchScreen(manifest, sanitized_name):
+ if manifest is None:
return False
- parser = ManifestJsonParser(os.path.expanduser(app_manifest))
- app_root = os.path.dirname(parser.input_path)
- default = CustomizeByOrientation(parser, 'default',
+ app_root = os.path.dirname(manifest.input_path)
+ default = CustomizeByOrientation(manifest, 'default',
sanitized_name, app_root)
- portrait = CustomizeByOrientation(parser, 'portrait',
+ portrait = CustomizeByOrientation(manifest, 'portrait',
sanitized_name, app_root)
- landscape = CustomizeByOrientation(parser, 'landscape',
+ landscape = CustomizeByOrientation(manifest, 'landscape',
sanitized_name, app_root)
return default or portrait or landscape