Skip to content

Commit

Permalink
Bump to dev SDL2 for touch fix & extract .java from SDL2 tarball
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Thiem authored and Jonas Thiem committed Apr 10, 2019
1 parent 637814b commit c5fe89e
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 5,158 deletions.
24 changes: 23 additions & 1 deletion pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,23 @@ def name(self):
modname = self.__class__.__module__
return modname.split(".", 2)[-1]

def _copy_in_final_files(self):
if self.name == "sdl2":
# Get the paths for copying SDL2's java source code:
sdl2_recipe = Recipe.get_recipe("sdl2", self.ctx)
sdl2_build_dir = sdl2_recipe.get_jni_dir()
src_dir = join(sdl2_build_dir, "SDL", "android-project",
"app", "src", "main", "java",
"org", "libsdl", "app")
target_dir = join(self.dist_dir, 'src', 'main', 'java', 'org',
'libsdl', 'app')

# Do actual copying:
info('Copying in SDL2 .java files from: ' + str(src_dir))
if not os.path.exists(target_dir):
os.makedirs(target_dir)
copy_files(src_dir, target_dir, override=True)

def prepare_build_dir(self):
'''Ensure that a build dir exists for the recipe. This same single
dir will be used for building all different archs.'''
Expand All @@ -134,7 +151,12 @@ def prepare_build_dir(self):
def prepare_dist_dir(self, name):
ensure_dir(self.dist_dir)

def run_distribute(self):
def assemble_distribution(self):
''' Copies all the files into the distribution (this function is
overridden by the specific bootstrap classes to do this)
and add in the distribution info.
'''
self._copy_in_final_files()
self.distribution.save_info(self.dist_dir)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/bootstraps/empty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class EmptyBootstrap(Bootstrap):

can_be_chosen_automatically = False

def run_distribute(self):
def assemble_distribution(self):
print('empty bootstrap has no distribute')
exit(1)

Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/bootstraps/pygame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PygameBootstrap(Bootstrap):
recipe_depends = ['hostpython2legacy', 'python2legacy', 'pyjnius',
'sdl', 'pygame', 'android', 'kivy']

def run_distribute(self):
def assemble_distribution(self):
info_main('# Creating Android project from build and {} bootstrap'.format(
self.name))

Expand Down Expand Up @@ -68,7 +68,7 @@ def run_distribute(self):

self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super(PygameBootstrap, self).run_distribute()
super(PygameBootstrap, self).assemble_distribution()


bootstrap = PygameBootstrap()
4 changes: 2 additions & 2 deletions pythonforandroid/bootstraps/sdl2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SDL2GradleBootstrap(Bootstrap):
set(Bootstrap.recipe_depends).union({'sdl2'})
)

def run_distribute(self):
def assemble_distribution(self):
info_main("# Creating Android project ({})".format(self.name))

arch = self.ctx.archs[0]
Expand Down Expand Up @@ -54,7 +54,7 @@ def run_distribute(self):

self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super(SDL2GradleBootstrap, self).run_distribute()
super(SDL2GradleBootstrap, self).assemble_distribution()


bootstrap = SDL2GradleBootstrap()
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ public void considerLoadingScreenRemoval() {
return;
runOnUiThread(new Runnable() {
public void run() {
if (((PythonActivity)PythonActivity.mSingleton).mAppConfirmedActive &&
if (((PythonActivity)PythonActivity.mSingleton) != null &&
((PythonActivity)PythonActivity.mSingleton).mAppConfirmedActive &&
loadingScreenRemovalTimer == null) {
// Remove loading screen but with a delay.
// (app can use p4a's android.loadingscreen module to
Expand Down Expand Up @@ -568,6 +569,7 @@ protected void onResume() {
} catch (UnsatisfiedLinkError e) {
// Catch resume while still in loading screen failing to
// call native function (since it's not yet loaded)
return; // no point in barging further
}
considerLoadingScreenRemoval();
}
Expand All @@ -579,6 +581,7 @@ public void onWindowFocusChanged(boolean hasFocus) {
} catch (UnsatisfiedLinkError e) {
// Catch window focus while still in loading screen failing to
// call native function (since it's not yet loaded)
return; // no point in barging further
}
considerLoadingScreenRemoval();
}
Expand Down

This file was deleted.

Loading

0 comments on commit c5fe89e

Please sign in to comment.