diff --git a/lutinTargetAndroid.py b/lutinTargetAndroid.py index ab1b3b2..2224ce8 100644 --- a/lutinTargetAndroid.py +++ b/lutinTargetAndroid.py @@ -100,6 +100,8 @@ class Target(lutinTarget.Target): #FINAL_FILE_ABSTRACTION self.file_finalAbstraction = self.folder_javaProject + "/" + pkgName + ".java" + compleatePackageName = pkgProperties["COMPAGNY_TYPE"]+"."+pkgProperties["COMPAGNY_NAME2"]+"." + pkgName + debug.printElement("pkg", "absractionFile", "<==", "dynamic file") # Create folder : lutinTools.CreateDirectoryOfFile(self.file_finalAbstraction) @@ -112,12 +114,12 @@ class Target(lutinTarget.Target): tmpFile.write( " * @license BSD v3 (see license file)\n") tmpFile.write( " * @note This file is autogenerate ==> see documantation to generate your own\n") tmpFile.write( " */\n") - tmpFile.write( "package "+pkgProperties["COMPAGNY_TYPE"]+"."+pkgProperties["COMPAGNY_NAME2"]+"." + pkgName + ";\n") + tmpFile.write( "package "+ compleatePackageName + ";\n") tmpFile.write( "import org.ewol.EwolActivity;\n") tmpFile.write( "public class " + pkgName + " extends EwolActivity {\n") tmpFile.write( " public void onCreate(android.os.Bundle savedInstanceState) {\n") tmpFile.write( " super.onCreate(savedInstanceState);\n") - tmpFile.write( " initApkPath(\""+pkgProperties["COMPAGNY_TYPE"]+"\", \""+pkgProperties["COMPAGNY_NAME2"]+"\", \"" + pkgName + "\");\n") + tmpFile.write( " initApkPath(\"" + pkgProperties["COMPAGNY_TYPE"]+"\", \""+pkgProperties["COMPAGNY_NAME2"]+"\", \"" + pkgName + "\");\n") tmpFile.write( " }\n") tmpFile.write( "}\n") else : @@ -128,13 +130,13 @@ class Target(lutinTarget.Target): tmpFile.write( " * @license BSD v3 (see license file)\n") tmpFile.write( " * @note This file is autogenerate ==> see documantation to generate your own\n") tmpFile.write( " */\n") - tmpFile.write( "package "+pkgProperties["COMPAGNY_TYPE"]+"."+pkgProperties["COMPAGNY_NAME2"]+"." + pkgName + ";\n") + tmpFile.write( "package "+ compleatePackageName + ";\n") tmpFile.write( "import org.ewol.EwolWallpaper;\n") tmpFile.write( "public class " + pkgName + " extends EwolWallpaper {\n") tmpFile.write( " public static final String SHARED_PREFS_NAME = \"" + pkgName + "settings\";\n") tmpFile.write( " public Engine onCreateEngine() {\n") tmpFile.write( " Engine tmpEngine = super.onCreateEngine();\n") - tmpFile.write( " initApkPath(\""+pkgProperties["COMPAGNY_TYPE"]+"\", \""+pkgProperties["COMPAGNY_NAME2"]+"\", \"" + pkgName + "\");\n") + tmpFile.write( " initApkPath(\"" + pkgProperties["COMPAGNY_TYPE"]+"\", \""+pkgProperties["COMPAGNY_NAME2"]+"\", \"" + pkgName + "\");\n") tmpFile.write( " return tmpEngine;\n") tmpFile.write( " }\n") tmpFile.write( "}\n") @@ -154,11 +156,11 @@ class Target(lutinTarget.Target): tmpFile.write( "\n") tmpFile.write( "\n") tmpFile.write( " \n") - tmpFile.write( " \n") - tmpFile.write( " \n") + tmpFile.write( " \n") + tmpFile.write( " \n") if pkgProperties["ANDROID_APPL_TYPE"]=="APPL": tmpFile.write( " \n") @@ -178,22 +180,21 @@ class Target(lutinTarget.Target): tmpFile.write( " \n") else: tmpFile.write( " \n") tmpFile.write( " \n") + tmpFile.write( " android:icon=\"@drawable/icon\">\n") tmpFile.write( " \n") tmpFile.write( " \n") tmpFile.write( " \n") - if True: #len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0: - tmpFile.write( " \n") + tmpFile.write( " \n") tmpFile.write( " \n") - if True: #len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0: + if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0: tmpFile.write( " \n") tmpFile.write( " \n") tmpFile.write( " \n") - # TODO : Generate Needed files for configurations - # TODO : Set the configuration properties on the ewol properties - # TODO : Set wallpaper without properties # write package autorisations : if True==self.CheckRightPackage(pkgProperties, "WRITE_EXTERNAL_STORAGE"): tmpFile.write( " \n") @@ -234,8 +232,107 @@ class Target(lutinTarget.Target): tmpFile.write( "\n\n") tmpFile.flush() tmpFile.close() - # end generating android manifest + # end generating android manifest + + if pkgProperties["ANDROID_APPL_TYPE"]!="APPL": + #create the Wallpaper sub files : (main element for the application + debug.printElement("pkg", pkgName + "_resource.xml", "<==", "package configurations") + lutinTools.CreateDirectoryOfFile(self.GetStagingFolder(pkgName) + "/res/xml/" + pkgName + "_resource.xml") + tmpFile = open(self.GetStagingFolder(pkgName) + "/res/xml/" + pkgName + "_resource.xml", 'w') + tmpFile.write( "\n") + tmpFile.write( "\n") + tmpFile.flush() + tmpFile.close() + # create wallpaper setting if needed (class and config file) + if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0: + lutinTools.CreateDirectoryOfFile(self.folder_javaProject + pkgName + "Settings.java") + debug.printElement("pkg", self.folder_javaProject + pkgName + "Settings.java", "<==", "package configurations") + tmpFile = open(self.folder_javaProject + pkgName + "Settings.java", 'w'); + tmpFile.write( "package " + compleatePackageName + ";\n") + tmpFile.write( "\n") + tmpFile.write( "import " + compleatePackageName + ".R;\n") + tmpFile.write( "\n") + tmpFile.write( "import android.content.SharedPreferences;\n") + tmpFile.write( "import android.os.Bundle;\n") + tmpFile.write( "import android.preference.PreferenceActivity;\n") + tmpFile.write( "\n") + tmpFile.write( "public class " + pkgName + "Settings extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener\n") + tmpFile.write( "{\n") + tmpFile.write( " @Override protected void onCreate(Bundle icicle) {\n") + tmpFile.write( " super.onCreate(icicle);\n") + tmpFile.write( " getPreferenceManager().setSharedPreferencesName("+ pkgName + ".SHARED_PREFS_NAME);\n") + tmpFile.write( " addPreferencesFromResource(R.xml."+ pkgName + "_settings);\n") + tmpFile.write( " getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);\n") + tmpFile.write( " }\n") + tmpFile.write( " @Override protected void onResume() {\n") + tmpFile.write( " super.onResume();\n") + tmpFile.write( " }\n") + tmpFile.write( " @Override protected void onDestroy() {\n") + tmpFile.write( " getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);\n") + tmpFile.write( " super.onDestroy();\n") + tmpFile.write( " }\n") + tmpFile.write( " public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key) { }\n") + tmpFile.write( "}\n") + tmpFile.flush() + tmpFile.close() + + debug.printElement("pkg", self.GetStagingFolder(pkgName) + "/res/xml/" + pkgName + "_settings.xml", "<==", "package configurations") + lutinTools.CreateDirectoryOfFile(self.GetStagingFolder(pkgName) + "/res/xml/" + pkgName + "_settings.xml") + tmpFile = open(self.GetStagingFolder(pkgName) + "/res/xml/" + pkgName + "_settings.xml", 'w'); + tmpFile.write( "\n") + tmpFile.write( "\n") + WALL_haveArray = False + for WALL_type, WALL_key, WALL_title, WALL_summary, WALL_other in pkgProperties["ANDROID_WALLPAPER_PROPERTIES"]: + debug.info("find : '" + WALL_type + "'"); + if WALL_type == "list": + debug.info(" create : LIST"); + tmpFile.write( " \n") + WALL_haveArray=True + elif WALL_type == "bool": + debug.info(" create : CHECKBOX"); + tmpFile.write( " \n") + tmpFile.write( "\n") + tmpFile.flush() + tmpFile.close() + if WALL_haveArray==True: + for WALL_type, WALL_key, WALL_title, WALL_summary, WALL_other in pkgProperties["ANDROID_WALLPAPER_PROPERTIES"]: + if WALL_type == "list": + debug.printElement("pkg", self.GetStagingFolder(pkgName) + "/res/values/" + WALL_key + ".xml", "<==", "package configurations") + lutinTools.CreateDirectoryOfFile(self.GetStagingFolder(pkgName) + "/res/values/" + WALL_key + ".xml") + tmpFile = open(self.GetStagingFolder(pkgName) + "/res/values/" + WALL_key + ".xml", 'w'); + tmpFile.write( "\n") + tmpFile.write( "\n") + tmpFile.write( " \n") + for WALL_subKey, WALL_display in WALL_other: + tmpFile.write( " " + WALL_display + "\n") + tmpFile.write( " \n") + tmpFile.write( " \n") + for WALL_subKey, WALL_display in WALL_other: + tmpFile.write( " " + WALL_subKey + "\n") + tmpFile.write( " \n") + tmpFile.write( "\n") + tmpFile.flush() + tmpFile.close() + + #add properties on wallpaper : + # myModule.pkgAdd("ANDROID_WALLPAPER_PROPERTIES", ["list", key, title, summary, [["key","value display"],["key2","value display 2"]]) + # myModule.pkgAdd("ANDROID_WALLPAPER_PROPERTIES", ["list", "testpattern", "Select test pattern", "Choose which test pattern to display", [["key","value display"],["key2","value display 2"]]]) + # myModule.pkgAdd("ANDROID_WALLPAPER_PROPERTIES", ["bool", key, title, summary, ["enable string", "disable String"]) + # myModule.pkgAdd("ANDROID_WALLPAPER_PROPERTIES", ["bool", "movement", "Motion", "Apply movement to test pattern", ["Moving test pattern", "Still test pattern"] #copy needed resources : for res_source, res_dest in pkgProperties["ANDROID_RESOURCES"]: if res_source == "": @@ -277,6 +374,8 @@ class Target(lutinTarget.Target): else: filesString += element + " " + if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0: + filesString += self.folder_javaProject + pkgName + "Settings.java " cmdLine = "javac " \ + "-d " + self.GetStagingFolder(pkgName) + "/build/classes " \