# HG changeset patch
# User Xeli
# Date 1309363764 -7200
# Node ID cb217271f344f51a23c624c6713d4204522d70e3
# Parent 8f95038f3f756c7a16c9921b6045391526c212d1
Added *.properties in Android project dirs to hgignore
Added a new project which will move resources from it's own apk to the sdcard
diff -r 8f95038f3f75 -r cb217271f344 .hgignore
--- a/.hgignore Wed Jun 29 18:05:04 2011 +0200
+++ b/.hgignore Wed Jun 29 18:09:24 2011 +0200
@@ -47,5 +47,10 @@
glob:project_files/Android-build/SDL-android-project/libs
glob:project_files/Android-build/SDL-android-project/bin
glob:project_files/Android-build/SDL-android-project/gen
+glob:project_files/Android-build/SDL-android-project/local.properties
+glob:project_files/Android-build/SDL-android-project/default.properties
glob:project_files/Android-build/out
glob:project_files/Android-build/DataPackage/assets/Data/*
+glob:project_files/Android-build/DataPackage/local.properties
+glob:project_files/Android-build/DataPackage/default.properties
+
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/AndroidManifest.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/DataPackage/AndroidManifest.xml Wed Jun 29 18:09:24 2011 +0200
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/TODO
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/DataPackage/TODO Wed Jun 29 18:09:24 2011 +0200
@@ -0,0 +1,6 @@
+Start Thread from service
+Communicate storage path with Hedgewars app
+use better package name
+check available space
+allow user to choose external or internal sdcard (is this even possible?)
+Suggest uninstall once Hedgewars has moved the files
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/build.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/DataPackage/build.properties Wed Jun 29 18:09:24 2011 +0200
@@ -0,0 +1,1 @@
+asset.dir=assets
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/build.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/DataPackage/build.xml Wed Jun 29 18:09:24 2011 +0200
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Packaging resource=================================================s
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/res/drawable-hdpi/icon.png
Binary file project_files/Android-build/DataPackage/res/drawable-hdpi/icon.png has changed
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/res/drawable-ldpi/icon.png
Binary file project_files/Android-build/DataPackage/res/drawable-ldpi/icon.png has changed
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/res/drawable-mdpi/icon.png
Binary file project_files/Android-build/DataPackage/res/drawable-mdpi/icon.png has changed
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/res/layout/main.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/DataPackage/res/layout/main.xml Wed Jun 29 18:09:24 2011 +0200
@@ -0,0 +1,18 @@
+
+
+
+
+
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/res/values/strings.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/DataPackage/res/values/strings.xml Wed Jun 29 18:09:24 2011 +0200
@@ -0,0 +1,5 @@
+
+
+ Hello World, MainActivity!vasasv
+ DataPackage
+
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/src/org/xeli/dataapk/AssetsToSDCard.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/DataPackage/src/org/xeli/dataapk/AssetsToSDCard.java Wed Jun 29 18:09:24 2011 +0200
@@ -0,0 +1,71 @@
+package org.xeli.dataapk;
+
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import android.content.Context;
+import android.content.res.AssetManager;
+import android.util.Log;
+
+public class AssetsToSDCard implements Runnable {
+
+ public int INTERNAL_SDCARD = 0;
+ public int EXTERNAL_SDCARD = 1;
+
+ private Context context;
+ private File outputDir;
+ public AssetsToSDCard(Context c, boolean verifiedFreeSpace, String _outputDir){
+ context = c;
+ outputDir = c.getExternalFilesDir("Data").getParentFile();
+ }
+
+ private void copyFile(InputStream in, OutputStream out) throws IOException {
+ byte[] buffer = new byte[1024];
+ int read;
+ while((read = in.read(buffer)) != -1){
+ out.write(buffer, 0, read);
+ }
+ }
+
+ private void visitAllFiles(AssetManager assManager, String[] childs, String file){
+ try {
+ InputStream in;
+ OutputStream out;
+ if(childs.length == 0){ //file = a non directory file
+ in = assManager.open(file);
+ File f = new File(outputDir, file);
+ out = new FileOutputStream(f);
+ copyFile(in, out);
+ }else{ //file = a directory
+ for(String s : childs){
+ File f = new File(outputDir, file);
+ f.mkdir();
+ String tmp = file + '/' + s;
+ visitAllFiles(assManager, assManager.list(tmp), tmp);
+ }
+ }
+
+ } catch (IOException e) {
+ //TODO handle correctly
+ Log.e("fail", file);
+ e.printStackTrace();
+ }
+ }
+
+ public void run() {//Runs in it's own thread
+ AssetManager assManager = context.getAssets();
+
+ try {
+ Log.e("DataDownloader", "Starting to copy files");
+ visitAllFiles(assManager, assManager.list("Data"), "Data");
+ Log.e("DataDownloader", "Done copying files");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/DataPackage/src/org/xeli/dataapk/MainActivity.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/DataPackage/src/org/xeli/dataapk/MainActivity.java Wed Jun 29 18:09:24 2011 +0200
@@ -0,0 +1,30 @@
+package org.xeli.dataapk;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+
+public class MainActivity extends Activity {
+
+ private MainActivity thisActivity = this;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ Button b = (Button)findViewById(R.id.startCopy);
+ b.setOnClickListener(startCopyClicker);
+ }
+
+ private OnClickListener startCopyClicker = new OnClickListener(){
+ public void onClick(View arg0) {
+ AssetsToSDCard runnable = new AssetsToSDCard(thisActivity, false, "/sdcard");
+ Thread t = new Thread(runnable, "Assets2SDCard - Thread");
+ t.start();
+ }
+
+ };
+
+}
\ No newline at end of file
diff -r 8f95038f3f75 -r cb217271f344 project_files/Android-build/SDL-android-project/TODO
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/TODO Wed Jun 29 18:09:24 2011 +0200
@@ -0,0 +1,3 @@
+-communicate with DataPackage where Data is stored and move it to our own cache
+
+-Loads more