Upstream version 10.38.208.0
[platform/framework/web/crosswalk.git] / src / xwalk / app / tools / android / customize_launch_screen.py
index fcfd4c0..c85d0fd 100755 (executable)
@@ -7,9 +7,7 @@
 import os
 import shutil
 import sys
-
-from manifest_json_parser import ManifestJsonParser
-
+import tempfile
 
 def CopyToPathWithName(root, name, final_path, rename):
   if name == '':
@@ -31,7 +29,8 @@ def CopyToPathWithName(root, name, final_path, rename):
 
 
 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':
@@ -115,7 +114,7 @@ def CustomizeBackground(background_color,
                         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.')
@@ -142,16 +141,16 @@ def CustomizeBackground(background_color,
     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)
@@ -160,15 +159,14 @@ def CustomizeByOrientation(parser, 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