summaryrefslogtreecommitdiff
path: root/same-android
diff options
context:
space:
mode:
Diffstat (limited to 'same-android')
-rw-r--r--same-android/AndroidManifest.xml5
-rw-r--r--same-android/res/layout/controller.xml48
-rw-r--r--same-android/res/layout/main.xml33
-rw-r--r--same-android/res/menu/main_menu.xml8
-rw-r--r--same-android/src/main/java/com/orbekk/MainActivity.java29
-rw-r--r--same-android/src/main/java/com/orbekk/SameControllerActivity.java22
6 files changed, 97 insertions, 48 deletions
diff --git a/same-android/AndroidManifest.xml b/same-android/AndroidManifest.xml
index 339fb73..a839f8c 100644
--- a/same-android/AndroidManifest.xml
+++ b/same-android/AndroidManifest.xml
@@ -10,13 +10,14 @@
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
- <activity android:name=".SameControllerActivity" >
+ <activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
-
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+
+ <activity android:name=".SameControllerActivity"/>
<service android:name=".discovery.SameService" />
</application>
diff --git a/same-android/res/layout/controller.xml b/same-android/res/layout/controller.xml
new file mode 100644
index 0000000..c3c4717
--- /dev/null
+++ b/same-android/res/layout/controller.xml
@@ -0,0 +1,48 @@
+<?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:id="@+id/textView1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Commands"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ <Button
+ android:id="@+id/button1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="createNetwork"
+ android:text="Create" />
+
+ <EditText
+ android:id="@+id/editText1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <Button
+ android:id="@+id/button2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="joinNetwork"
+ android:text="Search" />
+
+ <Button
+ android:id="@+id/button3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="doneClicked"
+ android:text="Done" />
+
+ <TextView
+ android:id="@+id/ipAddress"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+</LinearLayout>
diff --git a/same-android/res/layout/main.xml b/same-android/res/layout/main.xml
index 4ddd343..f6f0090 100644
--- a/same-android/res/layout/main.xml
+++ b/same-android/res/layout/main.xml
@@ -1,41 +1,14 @@
<?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"
- >
+ android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Commands"
+ android:text="See menu."
android:textAppearance="?android:attr/textAppearanceLarge" />
- <Button
- android:id="@+id/button1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:onClick="createNetwork"
- android:text="Create" />
-
- <EditText
- android:id="@+id/editText1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:onClick="joinNetwork"
- android:text="Search" />
-
- <TextView
- android:id="@+id/ipAddress"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=""
- android:textAppearance="?android:attr/textAppearanceLarge" />
-
-</LinearLayout>
+</LinearLayout> \ No newline at end of file
diff --git a/same-android/res/menu/main_menu.xml b/same-android/res/menu/main_menu.xml
new file mode 100644
index 0000000..6d63008
--- /dev/null
+++ b/same-android/res/menu/main_menu.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:id="@+id/same_settings"
+ android:title="Same settings"/>
+
+</menu> \ No newline at end of file
diff --git a/same-android/src/main/java/com/orbekk/MainActivity.java b/same-android/src/main/java/com/orbekk/MainActivity.java
new file mode 100644
index 0000000..80c4f6e
--- /dev/null
+++ b/same-android/src/main/java/com/orbekk/MainActivity.java
@@ -0,0 +1,29 @@
+package com.orbekk;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.widget.Toast;
+
+public class MainActivity extends Activity {
+ @Override public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+ }
+
+ @Override public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.main_menu, menu);
+ return true;
+ }
+
+ @Override public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == R.id.same_settings) {
+ startActivity(new Intent(this, SameControllerActivity.class));
+ }
+ return true;
+ }
+}
diff --git a/same-android/src/main/java/com/orbekk/SameControllerActivity.java b/same-android/src/main/java/com/orbekk/SameControllerActivity.java
index 975a1df..fb9b103 100644
--- a/same-android/src/main/java/com/orbekk/SameControllerActivity.java
+++ b/same-android/src/main/java/com/orbekk/SameControllerActivity.java
@@ -46,6 +46,10 @@ public class SameControllerActivity extends Activity {
t.setText(new Broadcaster(this).getBroadcastAddress().getHostAddress());
}
+ public void doneClicked(View unused) {
+ finish();
+ }
+
/**
* Called when the activity is first created.
* @param savedInstanceState If the activity is being re-initialized after
@@ -59,22 +63,8 @@ public class SameControllerActivity extends Activity {
System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("java.net.preferIPv6Addresses", "false");
- setContentView(R.layout.main);
- showIpAddress();
- // showBroadcastAddress();
-
-// ClientApp client = new ClientApp();
-// SameInterface client_ = client.getClient(10015, "ClientNetwork",
-// "http://10.0.0.6:10010/");
-// GameController controller = GameController.create(
-// GameController.newPlayer(), client_);
-// setContentView(new GameView(this, controller));
-
-// Broadcast broadcast = new Broadcast(this);
-// broadcast.sendBroadcast("Broadcast test".getBytes(), 10010);
-// Broadcaster broadcaster = new Broadcaster();
-// Log.i(TAG, "Broadcast success: " + broadcaster.sendBroadcast(10010, "Broadcast test from Android".getBytes()));
-//
+ setContentView(R.layout.controller);
+ showIpAddress();
}
@Override