add support for orientation and fullscreen (working on android only right now.)

This commit is contained in:
Mathieu Virbel 2013-05-05 18:30:47 +02:00
parent 5474accca1
commit 6639efa8b0
3 changed files with 32 additions and 1 deletions

View file

@ -66,6 +66,7 @@ class Buildozer(object):
self.config = SafeConfigParser()
self.config.getlist = self._get_config_list
self.config.getdefault = self._get_config_default
self.config.getbooldefault = self._get_config_bool
if exists(filename):
self.config.read(filename)
@ -289,6 +290,10 @@ class Buildozer(object):
adderror('[app] "version.filename" is missing'
', required by "version.regex"')
orientation = get('app', 'orientation', 'landscape')
if orientation not in ('landscape', 'portrait', 'all'):
adderror('[app] "orientation" have an invalid value')
if errors:
self.error('{0} error(s) found in the buildozer.spec'.format(
len(errors)))
@ -781,6 +786,14 @@ class Buildozer(object):
return default
return self.config.get(section, token)
def _get_config_bool(self, section, token, default=False):
# monkey-patch method for ConfigParser
# get a key in a section, or the default
if not self.config.has_section(section):
return default
if not self.config.has_option(section, token):
return default
return self.config.getboolean(section, token)
class BuildozerRemote(Buildozer):
def run_command(self, args):

View file

@ -26,7 +26,7 @@ version.filename = %(source.dir)s/main.py
# version = 1.2.0
# (list) Application requirements
requirements = twisted,kivy
requirements = kivy
# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png
@ -34,6 +34,13 @@ requirements = twisted,kivy
# (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png
# (str) Supported orientation (one of landscape, portrait or all)
orientation = landscape
# (bool) Indicate if the application should be fullscreen or not
fullscreen = 1
#
# Android specific
#

View file

@ -386,6 +386,17 @@ class TargetAndroid(Target):
if icon:
build_cmd += ' --icon {}'.format(join(self.buildozer.root_dir, icon))
# add orientation
orientation = config.getdefault('app', 'orientation', 'landscape')
if orientation == 'all':
orientation = 'sensor'
build_cmd += ' --orientation {}'.format(orientation)
# fullscreen ?
fullscreen = config.getbooldefault('app', 'fullscreen', True)
if not fullscreen:
build_cmd += ' --window'
# build only in debug right now.
if self.build_mode == 'debug':
build_cmd += ' debug'