Skip to content

Allow passing entrypoint and orientation through putExtra/getExtra when starting from another activity. #1976

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,18 @@ protected void onPostExecute(String result) {
File path = new File(getIntent().getData().getSchemeSpecificPart());

Project p = Project.scanDirectory(path);
String custom_orientation = PythonActivity.mActivity.getStringExtra("orientation");

String entry_point = getEntryPoint(p.dir);
SDLActivity.nativeSetenv("ANDROID_ENTRYPOINT", p.dir + "/" + entry_point);
SDLActivity.nativeSetenv("ANDROID_ARGUMENT", p.dir);
SDLActivity.nativeSetenv("ANDROID_APP_PATH", p.dir);

if (p != null) {
if (custom_orientation == "landscape")
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
else if (custom_orientation == "portrait")
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
else if (p != null) {
if (p.landscape) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else {
Expand Down Expand Up @@ -499,9 +505,15 @@ public String getEntryPoint(String search_dir) {
* have a compiled version or not.
*/
List<String> entryPoints = new ArrayList<String>();
entryPoints.add("main.pyo"); // python 2 compiled files
entryPoints.add("main.pyc"); // python 3 compiled files
for (String value : entryPoints) {
String extra = PythonActivity.mActivity.getStringExtra("entrypoint");
if (extra != "")
entryPoints.add(extra); // custom entrypoint

else {
entryPoints.add("main.pyo"); // python 2 compiled files
entryPoints.add("main.pyc"); // python 3 compiled files
}
for (String value : entryPoints) {
File mainFile = new File(search_dir + "/" + value);
if (mainFile.exists()) {
return value;
Expand Down