Skip to content

Commit c6d3e31

Browse files
committed
Moved private and public archives to res/raw/ for dealing with android library projects.
1 parent 55d291e commit c6d3e31

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

distribute.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ function run_distribute() {
559559
cd "$DIST_PATH"
560560

561561
debug "Create initial layout"
562-
try mkdir assets bin private res templates
562+
try mkdir assets bin private res res/raw templates
563563

564564
debug "Copy default files"
565565
try cp -a $SRC_PATH/default.properties .

src/build.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,24 +264,24 @@ def make_package(args):
264264
sys.exit(-1)
265265

266266
# Delete the old assets.
267-
if os.path.exists('assets/public.mp3'):
268-
os.unlink('assets/public.mp3')
267+
if os.path.exists('res/raw/public_pack.tar'):
268+
os.unlink('res/raw/public_pack.tar')
269269

270-
if os.path.exists('assets/private.mp3'):
271-
os.unlink('assets/private.mp3')
270+
if os.path.exists('res/raw/private_pack.tar'):
271+
os.unlink('res/raw/private_pack.tar')
272272

273273
# In order to speedup import and initial depack,
274274
# construct a python27.zip
275275
make_pythonzip()
276276

277277
# Package up the private and public data.
278278
if args.private:
279-
make_tar('assets/private.mp3', ['private', args.private])
279+
make_tar('res/raw/private_pack.tar', ['private', args.private])
280280
else:
281-
make_tar('assets/private.mp3', ['private'])
281+
make_tar('res/raw/private_pack.tar', ['private'])
282282

283283
if args.dir:
284-
make_tar('assets/public.mp3', [args.dir], args.ignore_path)
284+
make_tar('res/raw/public_pack.tar', [args.dir], args.ignore_path)
285285

286286
# Copy over the icon and presplash files.
287287
shutil.copy(args.icon or default_icon, 'res/drawable/icon.png')

src/src/org/renpy/android/AssetExtract.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@
1717

1818
import java.util.zip.GZIPInputStream;
1919

20-
import android.content.res.AssetManager;
20+
import android.content.Context;
21+
import android.content.res.Resources;
2122

2223
import org.xeustechnologies.jtar.*;
2324

2425
class AssetExtract {
2526

26-
private AssetManager mAssetManager = null;
2727
private Activity mActivity = null;
2828

2929
AssetExtract(Activity act) {
3030
mActivity = act;
31-
mAssetManager = act.getAssets();
3231
}
3332

3433
public boolean extractTar(String asset, String target) {
@@ -38,8 +37,12 @@ public boolean extractTar(String asset, String target) {
3837
InputStream assetStream = null;
3938
TarInputStream tis = null;
4039

40+
Context appContext = mActivity.getApplicationContext();
41+
Resources res = appContext.getResources();
42+
int resId = res.getIdentifier(asset, "raw", appContext.getPackageName());
43+
4144
try {
42-
assetStream = mAssetManager.open(asset, AssetManager.ACCESS_STREAMING);
45+
assetStream = res.openRawResource(resId);
4346
tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new BufferedInputStream(assetStream, 8192)), 8192));
4447
} catch (IOException e) {
4548
Log.e("python", "opening up extract tar", e);

src/src/org/renpy/android/PythonActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public void unpackData(final String resource, File target) {
189189
target.mkdirs();
190190

191191
AssetExtract ae = new AssetExtract(this);
192-
if (!ae.extractTar(resource + ".mp3", target.getAbsolutePath())) {
192+
if (!ae.extractTar(resource + "_pack", target.getAbsolutePath())) {
193193
toastError("Could not extract " + resource + " data.");
194194
}
195195

0 commit comments

Comments
 (0)