--- a/project_files/Android-build/SDL-android-project/AndroidManifest.xml Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/AndroidManifest.xml Sat Nov 26 11:47:31 2011 +0100
@@ -48,7 +48,8 @@
<activity android:name="TeamCreatorActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
- android:screenOrientation='landscape'>
+ android:screenOrientation='landscape'
+ android:windowSoftInputMode="stateUnchanged">
</activity>
</application>
</manifest>
--- a/project_files/Android-build/SDL-android-project/build.xml Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/build.xml Sat Nov 26 11:47:31 2011 +0100
@@ -1,67 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project name="Hedgewars" default="help">
+<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 in in Version
- Control Systems. -->
- <property file="local.properties" />
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <loadproperties srcFile="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.
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
- application.package
- the name of your application package as defined in the manifest. Used by the
- 'uninstall' rule.
source.dir
- the name of the source directory. Default is 'src'.
+ The name of the source directory. Default is 'src'.
out.dir
- the name of the output directory. Default is 'bin'.
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
- Properties related to the SDK location or the project target should be updated
- using the 'android' tool with the 'update' action.
+ 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 in in Version Control Systems.
+ 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" />
+ <property file="ant.properties" />
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
- <!-- 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 in in Version Control Systems. -->
- <property file="default.properties" />
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
- <!-- Custom Android task to deal with the project target, and import the proper rules.
- This requires ant 1.6.0 or above. -->
- <path id="android.antlibs">
- <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
- <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
- <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
- <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
- <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
- </path>
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
+ unless="sdk.dir"
+ />
+
+
+<!-- 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>
- <taskdef name="setup"
- classname="com.android.ant.SetupTask"
- classpathref="android.antlibs" />
+ /* 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>/platforms/<target_platform>/templates/android_rules.xml
+ <!-- Import the actual build file.
- To customize some build steps for your project:
- - copy the content of the main node <project> from android_rules.xml
- - paste it in this build.xml below the <setup /> task.
- - disable the import by changing the setup task below to <setup import="false" />
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
- This will ensure that the properties are setup correctly but that your customized
- build steps are used.
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
-->
- <setup />
+ <!-- version-tag: 1 -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
</project>
--- a/project_files/Android-build/SDL-android-project/res/layout/download_confirmdialog.xml Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/res/layout/download_confirmdialog.xml Sat Nov 26 11:47:31 2011 +0100
@@ -2,7 +2,7 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
+ android:layout_height="fill_parent"
android:padding="5dip">
<TextView
android:id="@+id/text"
@@ -13,7 +13,7 @@
android:maxWidth="200dip"/>
<LinearLayout
- android:layout_width="match_parent"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:layout_alignLeft="@id/text"
@@ -23,17 +23,17 @@
<Button
android:id="@+id/yes"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@android:string/yes" />
<Button
android:id="@+id/no"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@android:string/no" />
</LinearLayout>
-</RelativeLayout>
\ No newline at end of file
+</RelativeLayout>
--- a/project_files/Android-build/SDL-android-project/res/layout/download_info.xml Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/res/layout/download_info.xml Sat Nov 26 11:47:31 2011 +0100
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/arrow"
- android:layout_width="match_parent"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="8"
android:src="@drawable/arrow"
@@ -14,8 +14,8 @@
<RelativeLayout
android:id="@+id/container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:background="@drawable/box_dark">
@@ -43,4 +43,4 @@
</RelativeLayout>
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
--- a/project_files/Android-build/SDL-android-project/res/layout/download_listactivity.xml Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/res/layout/download_listactivity.xml Sat Nov 26 11:47:31 2011 +0100
@@ -1,39 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
<include layout="@layout/background"/>
<LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@android:color/transparent">
<fragment class="org.hedgewars.hedgeroid.Downloader.DownloadListFragment"
android:id="@+id/downloadList"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:layout_weight="1"/>
<FrameLayout
android:id="@+id/downloadFrameLayout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent">
<ScrollView
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/downloadQueueContainer"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:orientation="vertical"/>
</ScrollView>
</FrameLayout>
</LinearLayout>
-</FrameLayout>
\ No newline at end of file
+</FrameLayout>
--- a/project_files/Android-build/SDL-android-project/res/layout/download_progress.xml Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/res/layout/download_progress.xml Sat Nov 26 11:47:31 2011 +0100
@@ -3,14 +3,15 @@
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:minWidth="250dip"
android:padding="5dp"
android:background="@drawable/box">
<ProgressBar
android:id="@+id/progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignLeft="@+id/background"
- android:layout_alignRight="@+id/cancelDownload"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminate="false"
android:indeterminateOnly="false"/>
@@ -19,25 +20,27 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/progressbar"
- android:layout_alignLeft="@+id/background"
- android:layout_alignRight="@+id/cancelDownload"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
android:text="@string/download_queued"
android:textColor="#FFF"
android:textSize="14dp"
android:gravity="center"/>
- <Button
+ <!-- <Button
android:id="@id/background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/progressbar_sub"
- android:text="@string/download_background"/>
+ android:text="@string/download_background"/>-->
<Button
android:id="@+id/cancelDownload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/progressbar_sub"
- android:layout_toRightOf="@id/background"
+
+ android:layout_centerHorizontal="true"
android:text="@string/download_cancel"/>
+ <!-- android:layout_toRightOf="@id/background"-->
</RelativeLayout>
--- a/project_files/Android-build/SDL-android-project/res/raw/team_two.xml Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/res/raw/team_two.xml Sat Nov 26 11:47:31 2011 +0100
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<team>
<name>Team 2</name>
- <flag>hedgewars</flag>
+ <flag>cm_binary</flag>
<fort>Lego</fort>
<grave>Bone</grave>
<voice>Classic</voice>
@@ -9,41 +9,41 @@
<hog>
<name>Paris</name>
<hat>NoHat</hat>
- <level>0</level>
+ <level>2</level>
</hog>
<hog>
<name>Knut</name>
<hat>NoHat</hat>
- <level>0</level>
+ <level>2</level>
</hog>
<hog>
<name>Ash</name>
<hat>NoHat</hat>
- <level>0</level>
+ <level>2</level>
</hog>
<hog>
<name>Woad</name>
<hat>NoHat</hat>
- <level>0</level>
+ <level>2</level>
</hog>
<hog>
<name>Bob</name>
<hat>NoHat</hat>
- <level>0</level>
+ <level>2</level>
</hog>
<hog>
<name>Corky</name>
<hat>NoHat</hat>
- <level>0</level>
+ <level>2</level>
</hog>
<hog>
<name>Bea</name>
<hat>NoHat</hat>
- <level>0</level>
+ <level>2</level>
</hog>
<hog>
<name>Silvia</name>
<hat>NoHat</hat>
- <level>0</level>
+ <level>2</level>
</hog>
</team>
\ No newline at end of file
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadFragment.java Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadFragment.java Sat Nov 26 11:47:31 2011 +0100
@@ -52,7 +52,7 @@
private TextView progress_sub;
private ProgressBar progress;
- private Button positive, negative;
+ private Button /*positive,*/ negative;
private DownloadPackage pack;
@@ -84,9 +84,9 @@
progress_sub = (TextView)v.findViewById(R.id.progressbar_sub);
progress = (ProgressBar)v.findViewById(R.id.progressbar);
- positive = (Button) v.findViewById(R.id.background);
+ //positive = (Button) v.findViewById(R.id.background);
negative = (Button) v.findViewById(R.id.cancelDownload);
- positive.setOnClickListener(backgroundClicker);
+ //positive.setOnClickListener(backgroundClicker);
negative.setOnClickListener(cancelClicker);
pack = getArguments().getParcelable(DownloadFragment.EXTRA_TASK);
@@ -107,7 +107,7 @@
messengerService.send(message);
} catch (RemoteException e) {}
}
- getActivity().finish();
+ //getActivity().finish();
}
};
private OnClickListener doneClicker = new OnClickListener(){
@@ -181,8 +181,8 @@
case MSG_START:
progress.setMax(msg.arg1);
progress_sub.setText(String.format("%dkb/%dkb\n%s", 0, msg.arg1, ""));
- positive.setText(R.string.download_background);
- positive.setOnClickListener(backgroundClicker);
+ //positive.setText(R.string.download_background);
+ //positive.setOnClickListener(backgroundClicker);
negative.setText(R.string.download_cancel);
negative.setOnClickListener(cancelClicker);
break;
@@ -194,16 +194,16 @@
progress.setProgress(progress.getMax());
progress_sub.setText(R.string.download_done);
- positive.setText(R.string.download_back);
- positive.setOnClickListener(doneClicker);
+ // positive.setText(R.string.download_back);
+ // positive.setOnClickListener(doneClicker);
negative.setVisibility(View.INVISIBLE);
break;
case MSG_FAILED:
progress.setProgress(progress.getMax());
progress_sub.setText(R.string.download_failed);
- positive.setText(R.string.download_back);
- positive.setOnClickListener(doneClicker);
+ // positive.setText(R.string.download_back);
+ // positive.setOnClickListener(doneClicker);
negative.setText(R.string.download_tryagain);
negative.setOnClickListener(tryAgainClicker);
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/FrontendDataUtils.java Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/FrontendDataUtils.java Sat Nov 26 11:47:31 2011 +0100
@@ -176,6 +176,7 @@
for(File s : teamFileNames){
Team t = Team.getTeamFromXml(s.getAbsolutePath());
if(t != null){
+ t.file = s.getName();
ret.add(teamToHashMap(t));
}
}
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Team.java Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Team.java Sat Nov 26 11:47:31 2011 +0100
@@ -19,6 +19,7 @@
package org.hedgewars.hedgeroid.EngineProtocol;
import java.io.BufferedReader;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
@@ -30,6 +31,7 @@
import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlSerializer;
+import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Xml;
@@ -61,6 +63,7 @@
private static final int STATE_HOG_ROOT = 2;
public String name, grave, flag, voice, fort, hash;
+ public String file = null;
public static int maxNumberOfHogs = 0;
public static int maxNumberOfTeams = 0;
@@ -130,6 +133,22 @@
}
}
+ public void setFileName(Context c){
+ if(file == null){
+ file = validFileName(c, name);
+ }
+ }
+ private String validFileName(Context c, String fileName){
+ String absolutePath = String.format("%s/%s", c.getFilesDir(), fileName);
+ File f = new File(absolutePath);
+ if(f.exists()){
+ String newFileName = fileName + (int)(Math.random()*10);
+ return validFileName(c, newFileName);
+ }else{
+ return fileName;
+ }
+ }
+
/*
* XML METHODS
*/
@@ -311,6 +330,7 @@
dest.writeIntArray(levels);
dest.writeInt(color);
dest.writeInt(hogCount);
+ dest.writeString(file);
}
@@ -326,6 +346,7 @@
src.readIntArray(levels);
color = src.readInt();
hogCount = src.readInt();
+ file = src.readString();
}
public static final Parcelable.Creator<Team> CREATOR = new Parcelable.Creator<Team>() {
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java Sat Nov 26 11:47:31 2011 +0100
@@ -64,6 +64,7 @@
private MediaPlayer mp = null;
private boolean settingsChanged = false;
private boolean saved = false;
+ private String fileName = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -197,6 +198,7 @@
hogName.get(i).setText(t.hogNames[i]);
}
+ this.fileName = t.file;
}
}
@@ -242,8 +244,7 @@
saved = true;
Team team = new Team();
team.name = name.getText().toString();
- HashMap<String, Object> hashmap = (HashMap<String, Object>) flag
- .getSelectedItem();
+ HashMap<String, Object> hashmap = (HashMap<String, Object>) flag.getSelectedItem();
team.flag = (String) hashmap.get("txt");
team.fort = fort.getSelectedItem().toString();
@@ -251,6 +252,7 @@
team.grave = hashmap.get("txt").toString();
team.hash = "0";
team.voice = voice.getSelectedItem().toString();
+ team.file = fileName;
hashmap = ((HashMap<String, Object>) difficulty.getSelectedItem());
String levelString = hashmap.get("txt").toString();
@@ -271,18 +273,17 @@
for (int i = 0; i < hogName.size(); i++) {
team.hogNames[i] = hogName.get(i).getText().toString();
- hashmap = (HashMap<String, Object>) hogHat.get(i)
- .getSelectedItem();
+ hashmap = (HashMap<String, Object>) hogHat.get(i).getSelectedItem();
team.hats[i] = hashmap.get("txt").toString();
team.levels[i] = levelInt;
}
try {
- File teamsDir = new File(getFilesDir().getAbsolutePath() + '/'
- + Team.DIRECTORY_TEAMS);
- if (!teamsDir.exists())
- teamsDir.mkdir();
- FileOutputStream fos = new FileOutputStream(String.format(
- "%s/%s.xml", teamsDir.getAbsolutePath(), team.name));
+ File teamsDir = new File(getFilesDir().getAbsolutePath() + '/' + Team.DIRECTORY_TEAMS);
+ if (!teamsDir.exists()) teamsDir.mkdir();
+ if(team.file == null){
+ team.setFileName(TeamCreatorActivity.this);
+ }
+ FileOutputStream fos = new FileOutputStream(String.format("%s/%s", teamsDir.getAbsolutePath(), team.file));
team.writeToXml(fos);
} catch (FileNotFoundException e) {
e.printStackTrace();
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamSelectionActivity.java Sat Nov 26 11:37:25 2011 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamSelectionActivity.java Sat Nov 26 11:47:31 2011 +0100
@@ -241,7 +241,8 @@
selectAvailableTeamsItem(position);
return true;
case 1://delete
- File f = new File(String.format("%s/%s/%s.xml", TeamSelectionActivity.this.getFilesDir(), Team.DIRECTORY_TEAMS, availableTeamsList.get(position).get("txt")));
+ Team team = (Team)availableTeamsList.get(position).get("team");
+ File f = new File(String.format("%s/%s/%s", TeamSelectionActivity.this.getFilesDir(), Team.DIRECTORY_TEAMS, team.file));
f.delete();
availableTeamsList.remove(position);
((SimpleAdapter)availableTeams.getAdapter()).notifyDataSetChanged();