-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Android library #2092
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
Merged
Merged
Android library #2092
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,7 +225,7 @@ def compile_dir(dfn, optimize_python=True): | |
def make_package(args): | ||
# If no launcher is specified, require a main.py/main.pyo: | ||
if (get_bootstrap_name() != "sdl" or args.launcher is None) and \ | ||
get_bootstrap_name() != "webview": | ||
get_bootstrap_name() not in ["webview", "service_library"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This look like it should be a setting on the bootstrap. |
||
# (webview doesn't need an entrypoint, apparently) | ||
if args.private is None or ( | ||
not exists(join(realpath(args.private), 'main.py')) and | ||
|
@@ -479,6 +479,7 @@ def make_package(args): | |
android_api=android_api, | ||
build_tools_version=build_tools_version, | ||
debug_build="debug" in args.build_mode, | ||
is_library=(get_bootstrap_name() == 'service_library'), | ||
) | ||
|
||
# ant build templates | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pythonforandroid.bootstraps.service_only import ServiceOnlyBootstrap | ||
|
||
|
||
class ServiceLibraryBootstrap(ServiceOnlyBootstrap): | ||
|
||
name = 'service_library' | ||
|
||
|
||
bootstrap = ServiceLibraryBootstrap() |
6 changes: 6 additions & 0 deletions
6
pythonforandroid/bootstraps/service_library/build/jni/application/src/bootstrap_name.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
#define BOOTSTRAP_NAME_LIBRARY | ||
#define BOOTSTRAP_USES_NO_SDL_HEADERS | ||
|
||
const char bootstrap_name[] = "service_library"; | ||
|
9 changes: 9 additions & 0 deletions
9
...droid/bootstraps/service_library/build/src/main/java/org/kivy/android/PythonActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.kivy.android; | ||
|
||
import android.app.Activity; | ||
|
||
// Required by PythonService class | ||
public class PythonActivity extends Activity { | ||
|
||
} | ||
|
115 changes: 115 additions & 0 deletions
115
...ndroid/bootstraps/service_library/build/src/main/java/org/renpy/android/AssetExtract.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// This string is autogenerated by ChangeAppSettings.sh, do not change | ||
// spaces amount | ||
package org.renpy.android; | ||
|
||
import java.io.*; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
|
||
import java.io.BufferedInputStream; | ||
import java.io.BufferedOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.File; | ||
|
||
import java.util.zip.GZIPInputStream; | ||
|
||
import android.content.res.AssetManager; | ||
|
||
import org.kamranzafar.jtar.*; | ||
|
||
public class AssetExtract { | ||
|
||
private AssetManager mAssetManager = null; | ||
private Context ctx = null; | ||
|
||
public AssetExtract(Context context) { | ||
ctx = context; | ||
mAssetManager = ctx.getAssets(); | ||
} | ||
|
||
public boolean extractTar(String asset, String target) { | ||
|
||
byte buf[] = new byte[1024 * 1024]; | ||
|
||
InputStream assetStream = null; | ||
TarInputStream tis = null; | ||
|
||
try { | ||
assetStream = mAssetManager.open(asset, AssetManager.ACCESS_STREAMING); | ||
tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new BufferedInputStream(assetStream, 8192)), 8192)); | ||
} catch (IOException e) { | ||
Log.e("python", "opening up extract tar", e); | ||
return false; | ||
} | ||
|
||
while (true) { | ||
TarEntry entry = null; | ||
|
||
try { | ||
entry = tis.getNextEntry(); | ||
} catch ( java.io.IOException e ) { | ||
Log.e("python", "extracting tar", e); | ||
return false; | ||
} | ||
|
||
if ( entry == null ) { | ||
break; | ||
} | ||
|
||
Log.v("python", "extracting " + entry.getName()); | ||
|
||
if (entry.isDirectory()) { | ||
|
||
try { | ||
new File(target +"/" + entry.getName()).mkdirs(); | ||
} catch ( SecurityException e ) { }; | ||
|
||
continue; | ||
} | ||
|
||
OutputStream out = null; | ||
String path = target + "/" + entry.getName(); | ||
|
||
try { | ||
out = new BufferedOutputStream(new FileOutputStream(path), 8192); | ||
} catch ( FileNotFoundException e ) { | ||
} catch ( SecurityException e ) { }; | ||
|
||
if ( out == null ) { | ||
Log.e("python", "could not open " + path); | ||
return false; | ||
} | ||
|
||
try { | ||
while (true) { | ||
int len = tis.read(buf); | ||
|
||
if (len == -1) { | ||
break; | ||
} | ||
|
||
out.write(buf, 0, len); | ||
} | ||
|
||
out.flush(); | ||
out.close(); | ||
} catch ( java.io.IOException e ) { | ||
Log.e("python", "extracting zip", e); | ||
return false; | ||
} | ||
} | ||
|
||
try { | ||
tis.close(); | ||
assetStream.close(); | ||
} catch (IOException e) { | ||
// pass | ||
} | ||
|
||
return true; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
pythonforandroid/bootstraps/service_library/build/templates/AndroidManifest.tmpl.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="{{ args.package }}" | ||
android:versionCode="{{ args.numeric_version }}" | ||
android:versionName="{{ args.version }}"> | ||
|
||
<!-- Android 2.3.3 --> | ||
<uses-sdk android:minSdkVersion="{{ args.min_sdk_version }}" android:targetSdkVersion="{{ android_api }}" /> | ||
|
||
<application> | ||
{% for name in service_names %} | ||
<service android:name="{{ args.package }}.Service{{ name|capitalize }}" | ||
android:process=":service_{{ name }}" | ||
android:exported="true" /> | ||
{% endfor %} | ||
</application> | ||
|
||
</manifest> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.