From 5c972caccdaca831a652bc3ef8aa13445f04ab96 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 3 Jun 2014 23:34:15 +0200 Subject: [PATCH] [DEV] add capabilities to display the adds upper or down on the GUI interface --- lutinModule.py | 25 ++++++++++--------------- lutinTargetAndroid.py | 32 ++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/lutinModule.py b/lutinModule.py index f3e7bf7..6e0d226 100644 --- a/lutinModule.py +++ b/lutinModule.py @@ -88,7 +88,8 @@ class Module: "ANDROID_RESOURCES" : [], "ANDROID_APPL_TYPE" : "APPL", # the other mode is "WALLPAPER" ... and later "WIDGET" "ANDROID_WALLPAPER_PROPERTIES" : [], # To create properties of the wallpaper (no use of EWOL display) - "RIGHT" : [] + "RIGHT" : [], + "ADMOD_POSITION" : "top" } @@ -654,14 +655,7 @@ class Module: # edu : Education # pri : Private # museum : ... - if "com" != value \ - and "net" != value \ - and "org" != value \ - and "gov" != value \ - and "mil" != value \ - and "edu" != value \ - and "pri" != value \ - and "museum" != value: + if value not in ["com", "net", "org", "gov", "mil", "edu", "pri", "museum"]: debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'") else: self.packageProp[variable] = value @@ -691,11 +685,7 @@ class Module: elif "PRIORITY" == variable: #list = ["required","important","standard","optional","extra"] #if isinstance(value, list): - if "required" != value \ - and "important" != value \ - and "standard" != value \ - and "optional" != value \ - and "extra" != value: + if value not in ["required", "important", "standard", "optional", "extra"]: debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'") else: self.packageProp[variable] = value @@ -721,8 +711,13 @@ class Module: self.packageProp[variable] = value elif "APPLE_APPLICATION_IOS_ID" == variable: self.packageProp[variable] = value + elif "ADMOD_POSITION" == variable: + if value in ["top", "bottom"]: + self.packageProp[variable] = value + else: + debug.error("not know pkg element : '" + variable + "' with value : '" + value + "' must be [top|bottom]") else: - debug.error("not know pak element : '" + variable + "'") + debug.error("not know pkg element : '" + variable + "'") def pkg_add(self, variable, value): # TODO : Check values... diff --git a/lutinTargetAndroid.py b/lutinTargetAndroid.py index 27e6eac..1f0f02d 100644 --- a/lutinTargetAndroid.py +++ b/lutinTargetAndroid.py @@ -226,30 +226,46 @@ class Target(lutinTarget.Target): if "ADMOD_ID" in pkgProperties: tmpFile.write( " mLayout = new LinearLayout(this);\n") tmpFile.write( " mLayout.setOrientation(android.widget.LinearLayout.VERTICAL);\n") - tmpFile.write( " setContentView(mLayout);\n") + tmpFile.write( " LinearLayout.LayoutParams paramsWindows = new LinearLayout.LayoutParams(\n") + tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT,\n") + tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT);\n") tmpFile.write( " \n") - tmpFile.write( " LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(\n") - tmpFile.write( " LinearLayout.LayoutParams.WRAP_CONTENT,\n") + tmpFile.write( " setContentView(mLayout, paramsWindows);\n") + tmpFile.write( " \n") + tmpFile.write( " LinearLayout.LayoutParams paramsAdds = new LinearLayout.LayoutParams(\n") + tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT,\n") tmpFile.write( " LinearLayout.LayoutParams.WRAP_CONTENT);\n") + tmpFile.write( " paramsAdds.weight = 0;\n") tmpFile.write( " \n") - tmpFile.write( " //params1.gravity = Gravity.TOP;\n") + tmpFile.write( " LinearLayout.LayoutParams paramsGLView = new LinearLayout.LayoutParams(\n") + tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT,\n") + tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT);\n") + tmpFile.write( " paramsGLView.weight = 1;\n") + tmpFile.write( " paramsGLView.height = 0;\n") + tmpFile.write( " \n") + tmpFile.write( " mLayout.setGravity(android.view.Gravity.TOP);\n") tmpFile.write( " \n") tmpFile.write( " // Create an adds.\n") tmpFile.write( " adView = new AdView(this);\n") tmpFile.write( " adView.setAdSize(AdSize.SMART_BANNER);\n") tmpFile.write( " adView.setAdUnitId(\"" + pkgProperties["ADMOD_ID"] + "\");\n") tmpFile.write( " \n") - tmpFile.write( " // Add the AdView to the view hierarchy. The view will have no size until the ad is loaded.\n") - tmpFile.write( " mLayout.addView(adView, params1);\n") - tmpFile.write( " \n") tmpFile.write( " // Create an ad request. Check logcat output for the hashed device ID to get test ads on a physical device.\n") tmpFile.write( " AdRequest adRequest = new AdRequest.Builder()\n") tmpFile.write( " .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)\n") tmpFile.write( " .build();\n") tmpFile.write( " \n") + tmpFile.write( " // Add the AdView to the view hierarchy. The view will have no size until the ad is loaded.\n") + if "ADMOD_POSITION" in pkgProperties.keys() \ + and pkgProperties["ADMOD_POSITION"] == "top": + tmpFile.write( " mLayout.addView(adView, paramsAdds);\n") + tmpFile.write( " mLayout.addView(mGLView, paramsGLView);\n") + else: + tmpFile.write( " mLayout.addView(mGLView, paramsGLView);\n") + tmpFile.write( " mLayout.addView(adView, paramsAdds);\n") + tmpFile.write( " \n") tmpFile.write( " // Start loading the ad in the background.\n") tmpFile.write( " adView.loadAd(adRequest);\n") - tmpFile.write( " mLayout.addView(mGLView, params1);\n") tmpFile.write( " }\n") if "ADMOD_ID" in pkgProperties: tmpFile.write( " @Override protected void onResume() {\n")