Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added --activity-class-name and --activity-package parameters #2248

Merged
merged 1 commit into from
Jun 28, 2020

Conversation

vesellov
Copy link
Contributor

to make possible to use custom PythonActivity java class

Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, looking good!
I left some minor suggestion. Also I'm wondering if part of it could be unit tested in tests/test_toolchain.py showing the newly provided arguments get used later on. I haven't looked if it was a painful thing to do.
Note the linter is complaining:

pythonforandroid/recipes/android/src/android/permissions.py:12:1: F401 'android.config.JAVA_NAMESPACE' imported but unused
pythonforandroid/recipes/android/src/android/activity.py:2:1: F401 'android.config.JAVA_NAMESPACE' imported but unused
pythonforandroid/recipes/android/src/android/activity.py:2:1: F401 'android.config.JNI_NAMESPACE' imported but unused
pythonforandroid/recipes/android/src/android/runnable.py:7:1: F401 'android.config.JAVA_NAMESPACE' imported but unused


generic_parser.add_argument(
'--activity-class-name', '--activity_class_name',
dest='activity_class_name', default='PythonActivity',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if both default couldn't be shared with the one defined in build.py to keep a single source of truth. Maybe using a const somewhere.
Also matter of taste but I would ditch the underscored version of the argument

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will check about unit tests Andre. i was a bit in the rush when started it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we have pretty low coverage in both p4a and buildozer, but I'm trying to push for increasing it slowly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some basic assertion in the existing unit test to check that Context was populated properly with new value of activity_class_name

@@ -431,7 +434,7 @@ class _onRequestPermissionsCallback(PythonJavaClass):
"""Callback class for registering a Python callback from
onRequestPermissionsResult in PythonActivity.
"""
__javainterfaces__ = ['org.kivy.android.PythonActivity$PermissionsCallback']
__javainterfaces__ = [ACTIVITY_NAMESPACE + '/' + ACTIVITY_CLASS_NAME + '$PermissionsCallback']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we got that wrong since the beginning , but it seems that both doted and slashed notation are working then, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. exactly... i was in doubt, but checked with py-jnius docs and it says it must be '/'

@@ -51,6 +51,9 @@ def prebuild_arch(self, arch):
'PY2': 0,
'JAVA_NAMESPACE': java_ns,
'JNI_NAMESPACE': jni_ns,
'ACTIVITY_CLASS_NAME': self.ctx.activity_class_name,
'ACTIVITY_PACKAGE': self.ctx.activity_package,
'ACTIVITY_NAMESPACE': self.ctx.activity_package.replace('.', '/'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about introducing a ACTIVITY_FULL_CLASS_NAME value that is already concatenating both activity_class_name and activity_package?
e.g.

{
    "ACTIVITY_FULL_CLASS_NAME": f"{self.ctx.activity_package}.{self.ctx.activity_class_name}",
}

That way you don't need to carry over the concatenation all over later in the code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 i will check that!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok... now i just added one input parameter activity_class_name which must be a full name of the Java class.

@vesellov vesellov force-pushed the master branch 3 times, most recently from bec6d11 to ac476cc Compare June 28, 2020 20:34
Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice 👏
Thank you for addressing the comments and thanks for the unit tests 💪
Will merge after the build turns green

@@ -376,6 +376,11 @@ def __init__(self):
dest='local_recipes', default='./p4a-recipes',
help='Directory to look for local recipes')

generic_parser.add_argument(
'--activity-class-name',
dest='activity_class_name', default='org.kivy.android.PythonActivity',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we had a single source of truth shared with https://github.com/kivy/python-for-android/pull/2248/files#diff-c439e980dc587602fda87459815f09feR450 for the org.kivy.android.PythonActivity value, but I can live without

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreMiras you mean that there are two settings now that are storing same value? : android.entrypoint and android.activity_class_name ?

@AndreMiras
Copy link
Member

CI happy, I've also tried the bdist_test_app_unittests__armeabi-v7a-debug-1.1.apk artifact on device, looking good, merging

@AndreMiras AndreMiras merged commit 392d57f into kivy:develop Jun 28, 2020
@vesellov
Copy link
Contributor Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants