Added *.properties in Android project dirs to hgignore hedgeroid
authorXeli
Wed, 29 Jun 2011 18:09:24 +0200
branchhedgeroid
changeset 5383 cb217271f344
parent 5381 8f95038f3f75
child 5385 a864a0aeed96
Added *.properties in Android project dirs to hgignore Added a new project which will move resources from it's own apk to the sdcard
.hgignore
project_files/Android-build/DataPackage/AndroidManifest.xml
project_files/Android-build/DataPackage/TODO
project_files/Android-build/DataPackage/build.properties
project_files/Android-build/DataPackage/build.xml
project_files/Android-build/DataPackage/res/drawable-hdpi/icon.png
project_files/Android-build/DataPackage/res/drawable-ldpi/icon.png
project_files/Android-build/DataPackage/res/drawable-mdpi/icon.png
project_files/Android-build/DataPackage/res/layout/main.xml
project_files/Android-build/DataPackage/res/values/strings.xml
project_files/Android-build/DataPackage/src/org/xeli/dataapk/AssetsToSDCard.java
project_files/Android-build/DataPackage/src/org/xeli/dataapk/MainActivity.java
project_files/Android-build/SDL-android-project/TODO
--- 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
+
--- /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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+      package="org.xeli.dataapk"
+      android:versionCode="1"
+      android:versionName="1.0">
+    <uses-sdk android:minSdkVersion="4" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
+
+    <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
+        <activity android:name="MainActivity"
+                  android:label="@string/app_name">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+    </application>
+</manifest>
\ No newline at end of file
--- /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
--- /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
--- /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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="MainActivity" default="help">
+
+<!-- The local.properties file is created and updated by the 'android'
+     tool.
+     It contains the path to the SDK. It should *NOT* be checked into
+     Version Control Systems. -->
+    <property file="local.properties" />
+
+    <!-- The build.properties file can be created by you and is never touched
+         by the 'android' tool. This is the place to change some of the
+         default property values used by the Ant rules.
+         Here are some properties you may want to change/update:
+
+         source.dir
+             The name of the source directory. Default is 'src'.
+         out.dir
+             The name of the output directory. Default is 'bin'.
+
+         Properties related to the SDK location or the project target should
+         be updated using the 'android' tool with the 'update' action.
+
+         This file is an integral part of the build system for your
+         application and should be checked into Version Control Systems.
+
+         -->
+    <property file="build.properties" />
+
+    <!-- The default.properties file is created and updated by the 'android'
+         tool, as well as ADT.
+         This file is an integral part of the build system for your
+         application and should be checked into Version Control Systems. -->
+    <property file="default.properties" />
+
+
+    <!-- Required pre-setup import -->
+    <import file="${sdk.dir}/tools/ant/pre_setup.xml" />
+
+
+<!-- extension targets. Uncomment the ones where you want to do custom work
+     in between standard targets -->
+<!--
+    <target name="-pre-build">
+    </target>
+    <target name="-pre-compile">
+    </target>
+
+    [This is typically used for code obfuscation.
+     Compiled code location: ${out.classes.absolute.dir}
+     If this is not done in place, override ${out.dex.input.absolute.dir}]
+    <target name="-post-compile">
+    </target>
+-->
+
+    <!-- Execute the Android Setup task that will setup some properties
+         specific to the target, and import the build rules files.
+
+         The rules file is imported from
+            <SDK>/tools/ant/
+         Depending on the project type it can be either:
+         - main_rules.xml
+         - lib_rules.xml
+         - test_rules.xml
+
+         To customize existing targets, there are two options:
+         - Customize only one target:
+             - copy/paste the target into this file, *before* the
+               <setup> task.
+             - customize it to your needs.
+         - Customize the whole script.
+             - copy/paste the content of the rules files (minus the top node)
+               into this file, *after* the <setup> task
+             - disable the import of the rules by changing the setup task
+               below to <setup import="false" />.
+             - customize to your needs.
+    -->
+
+    <target name="-package-resources">
+    <echo>Packaging resource=================================================s</echo>
+        <aapt executable="${aapt}"
+                command="package"
+                versioncode="${version.code}"
+                debug="${build.packaging.debug}"
+                manifest="AndroidManifest.xml"
+                assets="${asset.absolute.dir}"
+                androidjar="${android.jar}"
+                apkfolder="${out.absolute.dir}"
+                resourcefilename="${resource.package.file.name}"
+                resourcefilter="${aapt.resource.filter}">
+            <res path="${resource.absolute.dir}" />
+            <!-- Xeli: This is needed because if the assets are compressed they will be uncompressed by android who has some random limit set on the max file size. That limit is about 1mb -->
+            <nocompress /> <!--forces no compression on any files in assets or res/raw -->
+            <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
+        </aapt>
+    </target>
+
+
+   <setup />
+
+</project>
Binary file project_files/Android-build/DataPackage/res/drawable-hdpi/icon.png has changed
Binary file project_files/Android-build/DataPackage/res/drawable-ldpi/icon.png has changed
Binary file project_files/Android-build/DataPackage/res/drawable-mdpi/icon.png has changed
--- /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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    >
+<TextView  
+    android:layout_width="fill_parent" 
+    android:layout_height="wrap_content" 
+    android:text="@string/hello"
+    />
+<Button
+	android:id="@+id/startCopy"
+	android:layout_width="wrap_content"
+	android:layout_height="wrap_content"
+	android:text="@string/hello"
+	/>
+</LinearLayout>
--- /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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="hello">Hello World, MainActivity!vasasv</string>
+    <string name="app_name">DataPackage</string>
+</resources>
--- /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();
+		}
+	}
+
+}
--- /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
--- /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