Binary file project_files/Android-build/SDL-android-project/res/drawable-mdpi/button.9.png has changed
Binary file project_files/Android-build/SDL-android-project/res/drawable-mdpi/playerlist_player.png has changed
--- a/project_files/Android-build/SDL-android-project/res/layout-large/activity_lobby.xml Fri Jul 27 01:38:24 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/res/layout-large/activity_lobby.xml Wed Aug 01 20:41:54 2012 +0200
@@ -27,7 +27,7 @@
tools:layout="@layout/lobby_rooms_fragment" />
</FrameLayout>
- <LinearLayout
+ <RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
@@ -35,10 +35,26 @@
android:orientation="horizontal" >
<FrameLayout
+ android:id="@+id/playerFrame"
+ android:layout_width="200dp"
+ android:layout_height="fill_parent"
+ android:layout_alignParentRight="true"
+ android:background="@drawable/box" >
+
+ <fragment
+ android:id="@+id/playerListFragment"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ class="org.hedgewars.hedgeroid.netplay.PlayerlistFragment"
+ tools:layout="@layout/lobby_players_fragment" />
+ </FrameLayout>
+
+ <FrameLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
+ android:layout_alignParentLeft="true"
+ android:layout_toLeftOf="@id/playerFrame"
android:layout_marginRight="10dp"
- android:layout_weight="0.7"
android:background="@drawable/box" >
<fragment
@@ -48,21 +64,7 @@
class="org.hedgewars.hedgeroid.netplay.LobbyChatFragment"
tools:layout="@layout/lobby_chat_fragment" />
</FrameLayout>
-
- <FrameLayout
- android:layout_width="0dp"
- android:layout_height="fill_parent"
- android:layout_weight="0.3"
- android:background="@drawable/box" >
-
- <fragment
- android:id="@+id/playerListFragment"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- class="org.hedgewars.hedgeroid.netplay.PlayerlistFragment"
- tools:layout="@layout/lobby_players_fragment" />
- </FrameLayout>
- </LinearLayout>
+ </RelativeLayout>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
--- a/project_files/Android-build/SDL-android-project/res/layout/activity_lobby.xml Fri Jul 27 01:38:24 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/res/layout/activity_lobby.xml Wed Aug 01 20:41:54 2012 +0200
@@ -41,7 +41,7 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="org.hedgewars.hedgeroid.netplay.LobbyChatFragment"
- tools:layout="@layout/lobby_chat_fragment" />
+ tools:layout="@layout/fragment_chat" />
<fragment
android:id="@+id/playerListFragment"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/layout/activity_netroom.xml Wed Aug 01 20:41:54 2012 +0200
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" >
+
+ <include layout="@layout/background" />
+
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:padding="5dp" >
+
+ <LinearLayout
+ android:id="@+id/upperFrame"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentTop="true"
+ android:layout_marginBottom="10dp"
+ android:baselineAligned="false"
+ android:minHeight="200dp" >
+
+ <FrameLayout
+ android:id="@+id/mapFrame"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_marginRight="10dp"
+ android:background="@drawable/box" >
+
+ <fragment
+ android:id="@+id/mapFragment"
+ class="org.hedgewars.hedgeroid.netplay.MapFragment"
+ tools:layout="@layout/fragment_map" />
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/settingsFrame"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="10dp"
+ android:layout_weight="1"
+ android:background="@drawable/box" >
+
+ <fragment
+ android:id="@+id/settingsFragment"
+ class="org.hedgewars.hedgeroid.netplay.SettingsFragment"
+ tools:layout="@layout/fragment_settings" />
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/teamsFrame"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:background="@drawable/box" >
+
+ <fragment
+ android:id="@+id/teamsFragment"
+ class="org.hedgewars.hedgeroid.netplay.TeamsFragment"
+ tools:layout="@layout/fragment_teamlist" />
+
+ </FrameLayout>
+ </LinearLayout>
+
+ <FrameLayout
+ android:id="@+id/playerFrame"
+ android:layout_width="200dp"
+ android:layout_height="fill_parent"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentRight="true"
+ android:layout_below="@id/upperFrame"
+ android:background="@drawable/box" >
+
+ <fragment
+ android:id="@+id/playerListFragment"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ class="org.hedgewars.hedgeroid.netplay.PlayerlistFragment"
+ tools:layout="@layout/lobby_players_fragment" />
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@id/upperFrame"
+ android:layout_marginRight="10dp"
+ android:layout_toLeftOf="@id/playerFrame"
+ android:background="@drawable/box" >
+
+ <fragment
+ android:id="@+id/chatFragment"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ class="org.hedgewars.hedgeroid.netplay.LobbyChatFragment"
+ tools:layout="@layout/fragment_chat" />
+ </FrameLayout>
+ </RelativeLayout>
+
+</FrameLayout>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/layout/fragment_chat.xml Wed Aug 01 20:41:54 2012 +0200
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <ListView
+ android:id="@+id/chatConsole"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:clickable="false"
+ android:cacheColorHint="@android:color/transparent"
+ android:transcriptMode="normal"
+ android:focusableInTouchMode="false"
+ android:focusable="false"
+ android:longClickable="false"
+ android:stackFromBottom="true"
+ />
+
+ <EditText
+ android:id="@+id/chatInput"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:hint="@string/chat_hint"
+ android:imeOptions="actionSend"
+ android:inputType="text" />
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/layout/fragment_map.xml Wed Aug 01 20:41:54 2012 +0200
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingBottom="3dp"
+ android:paddingLeft="5dp"
+ android:paddingRight="3dp"
+ android:paddingTop="3dp" >
+
+ <ImageView
+ android:id="@+id/mapPreview"
+ android:layout_width="256dip"
+ android:layout_height="128dip"
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true"
+ android:layout_margin="5dip"
+ android:background="@drawable/box"
+ android:scaleType="fitXY"
+ android:src="@drawable/backbutton" />
+
+ <TableLayout
+ android:id="@+id/gameOptions"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/mapPreview"
+ android:stretchColumns="1" >
+
+ <TableRow>
+
+ <TextView
+ android:id="@+id/txtMap"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/map_map" />
+
+ <Spinner
+ android:id="@+id/spinMaps"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/dropdown" />
+ </TableRow>
+
+ <TableRow>
+
+ <TextView
+ android:id="@+id/txtType"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/map_type" />
+
+ <Spinner
+ android:id="@+id/spinType"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/dropdown" />
+ </TableRow>
+ </TableLayout>
+
+</RelativeLayout>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/layout/fragment_settings.xml Wed Aug 01 20:41:54 2012 +0200
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingBottom="3dp"
+ android:paddingLeft="5dp"
+ android:paddingRight="3dp"
+ android:paddingTop="3dp" >
+
+ <TableLayout
+ android:id="@+id/gameOptions"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:stretchColumns="1" >
+
+ <TableRow>
+
+ <TextView
+ android:id="@+id/txtGameplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/start_gameplay" />
+
+ <Spinner
+ android:id="@+id/spinGameplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/dropdown" />
+ </TableRow>
+
+ <TableRow>
+
+ <TextView
+ android:id="@+id/txtGamescheme"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/start_gamescheme" />
+
+ <Spinner
+ android:id="@+id/spinGamescheme"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/dropdown" />
+ </TableRow>
+
+ <TableRow>
+
+ <TextView
+ android:id="@+id/txtweapons"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/start_weapons" />
+
+ <Spinner
+ android:id="@+id/spinweapons"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/dropdown" />
+ </TableRow>
+ </TableLayout>
+
+ <ImageView
+ android:id="@+id/imgTheme"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBottom="@+id/spinTheme"
+ android:layout_alignLeft="@id/gameOptions"
+ android:layout_alignTop="@id/spinTheme"
+ android:adjustViewBounds="true" />
+
+ <Spinner
+ android:id="@id/spinTheme"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_below="@id/gameOptions"
+ android:layout_toRightOf="@+id/imgTheme"
+ android:background="@drawable/dropdown" />
+
+</RelativeLayout>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/layout/fragment_teamlist.xml Wed Aug 01 20:41:54 2012 +0200
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <ListView
+ android:id="@+id/teamList"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:cacheColorHint="@android:color/transparent"
+ />
+
+ <Button
+ android:id="@+id/addTeamButton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/teamlist_addteam"
+ android:background="@drawable/button" />
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/layout/listview_player.xml Wed Aug 01 20:41:54 2012 +0200
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/text1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:drawablePadding="5dp"
+ android:drawableLeft="@drawable/playerlist_player"
+ android:gravity="center_vertical|left"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
\ No newline at end of file
--- a/project_files/Android-build/SDL-android-project/res/layout/lobby_chat_fragment.xml Fri Jul 27 01:38:24 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <ListView
- android:id="@+id/lobbyConsole"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:clickable="false"
- android:cacheColorHint="@android:color/transparent"
- android:transcriptMode="normal"
- android:focusableInTouchMode="false"
- android:focusable="false"
- android:longClickable="false"
- android:stackFromBottom="true"
- />
-
- <EditText
- android:id="@+id/lobbyChatInput"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="@string/chat_hint"
- android:imeOptions="actionSend"
- android:inputType="text" />
-
-</LinearLayout>
\ No newline at end of file
--- a/project_files/Android-build/SDL-android-project/res/layout/lobby_players_fragment.xml Fri Jul 27 01:38:24 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/res/layout/lobby_players_fragment.xml Wed Aug 01 20:41:54 2012 +0200
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -11,7 +11,7 @@
android:layout_height="match_parent"
android:drawSelectorOnTop="false"
android:cacheColorHint="@android:color/transparent"
- tools:listitem="@android:layout/simple_list_item_1" />
+ tools:listitem="@layout/listview_player" />
<TextView
android:id="@id/android:empty"
@@ -19,5 +19,4 @@
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/no_players_in_list" />
-
-</LinearLayout>
\ No newline at end of file
+</FrameLayout>
\ No newline at end of file
--- a/project_files/Android-build/SDL-android-project/res/values/strings.xml Fri Jul 27 01:38:24 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/res/values/strings.xml Wed Aug 01 20:41:54 2012 +0200
@@ -40,7 +40,6 @@
<string name="start_weapons">Weapons</string>
<string name="start_map">Map</string>
<string name="start_filter">Filter</string>
- <string name="start_themes">Themes</string>
<!-- Teams -->
<string name="not_enough_teams">Not enough teams</string>
@@ -64,13 +63,18 @@
<string name="title_activity_lobby">Hedgewars Server Lobby</string>
<string name="chat_hint">Type here to chat</string>
-
- <!-- Room list -->
- <string name="no_rooms_in_list">No rooms</string>
+
+ <!-- Map settings -->
+ <string name="map_map">Map</string>
+ <string name="map_type">Type</string>
+ <string name="map_seed">Change seed</string>
<!-- Player list -->
<string name="no_players_in_list">No players</string>
+ <!-- Teamlist -->
+ <string name="teamlist_addteam">Add team</string>
+
<!-- Roomlist -->
<string name="roomlist_header_roomname">Room Name</string>
<string name="roomlist_header_clients">C</string>
@@ -79,6 +83,7 @@
<string name="roomlist_header_map">Map</string>
<string name="roomlist_header_scheme">Rules</string>
<string name="roomlist_header_weapons">Weapons</string>
+ <string name="no_rooms_in_list">No rooms</string>
<string name="roomlist_owner">by %1$s</string>
<string name="roomlist_map">Map: %1$s</string>
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/EngineProtocolNetwork.java Fri Jul 27 01:38:24 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/EngineProtocolNetwork.java Wed Aug 01 20:41:54 2012 +0200
@@ -26,7 +26,7 @@
import java.net.Socket;
import java.net.UnknownHostException;
-public class EngineProtocolNetwork extends Thread{
+public class EngineProtocolNetwork extends Thread {
public static final String GAMEMODE_LOCAL = "TL";
public static final String GAMEMODE_DEMO = "TD";
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java Fri Jul 27 01:38:24 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java Wed Aug 01 20:41:54 2012 +0200
@@ -414,8 +414,8 @@
*/
class SDLMain implements Runnable {
- private int surfaceWidth, surfaceHeight;
- private GameConfig config;
+ private final int surfaceWidth, surfaceHeight;
+ private final GameConfig config;
public SDLMain(int width, int height, GameConfig _config) {
config = _config;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/ChatFragment.java Wed Aug 01 20:41:54 2012 +0200
@@ -0,0 +1,73 @@
+package org.hedgewars.hedgeroid.netplay;
+
+import org.hedgewars.hedgeroid.R;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.TextView.OnEditorActionListener;
+
+public class ChatFragment extends Fragment {
+ public static final String ARGUMENT_INROOM = "inRoom";
+
+ private ChatlogAdapter adapter;
+ private Netplay netconn;
+ private MessageLog messageLog;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Bundle bundle = getArguments();
+ netconn = Netplay.getAppInstance(getActivity().getApplicationContext());
+ adapter = new ChatlogAdapter(getActivity());
+ messageLog = bundle.getBoolean(ARGUMENT_INROOM) ? netconn.roomChatlog : netconn.lobbyChatlog;
+ adapter.setLog(messageLog.getLog());
+ messageLog.registerObserver(adapter);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_chat, container, false);
+
+ ListView listView = (ListView) view.findViewById(R.id.chatConsole);
+ listView.setAdapter(adapter);
+ listView.setDivider(null);
+ listView.setDividerHeight(0);
+ listView.setVerticalFadingEdgeEnabled(true);
+
+ EditText editText = (EditText) view.findViewById(R.id.chatInput);
+ editText.setOnEditorActionListener(new ChatSendListener());
+
+ return view;
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ messageLog.unregisterObserver(adapter);
+ }
+
+ private final class ChatSendListener implements OnEditorActionListener {
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ String text = v.getText().toString();
+ if(text.length()>0) {
+ v.setText("");
+ netconn.sendChat(text);
+ }
+ return true;
+ }
+ }
+}
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/LobbyActivity.java Fri Jul 27 01:38:24 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/LobbyActivity.java Wed Aug 01 20:41:54 2012 +0200
@@ -2,14 +2,12 @@
import org.hedgewars.hedgeroid.R;
-import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
-import android.support.v4.content.LocalBroadcastManager;
+import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -22,27 +20,22 @@
public class LobbyActivity extends FragmentActivity {
private TabHost tabHost;
- private Netplay netconn;
- private boolean isInForeground;
-
- private final BroadcastReceiver disconnectReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if(isInForeground && intent.getBooleanExtra(Netplay.EXTRA_HAS_ERROR, true)) {
- String message = intent.getStringExtra(Netplay.EXTRA_MESSAGE);
- Toast.makeText(getApplicationContext(), "Disconnected: "+message, Toast.LENGTH_LONG).show();
- }
- finish();
- }
- };
+ private Netplay netplay;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
- LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(disconnectReceiver, new IntentFilter(Netplay.ACTION_DISCONNECTED));
- netconn = Netplay.getAppInstance(getApplicationContext());
setContentView(R.layout.activity_lobby);
+ Fragment chatFragment = getSupportFragmentManager().findFragmentById(R.id.chatFragment);
+ chatFragment.getArguments().putBoolean(ChatFragment.ARGUMENT_INROOM, false);
+
+ FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+ trans.add(new NetplayStateFragment(), "netplayFragment");
+ trans.commit();
+
+ netplay = Netplay.getAppInstance(getApplicationContext());
+
tabHost = (TabHost)findViewById(android.R.id.tabhost);
if(tabHost != null) {
tabHost.setup();
@@ -58,12 +51,6 @@
}
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(disconnectReceiver);
- }
-
private View createIndicatorView(TabHost tabHost, int label, Drawable icon) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -81,20 +68,6 @@
return tabIndicator;
}
-
- @Override
- protected void onStart() {
- super.onStart();
- isInForeground = true;
- Netplay.getAppInstance(getApplicationContext()).requestFastTicks();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- isInForeground = false;
- Netplay.getAppInstance(getApplicationContext()).unrequestFastTicks();
- }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
@@ -110,7 +83,7 @@
Toast.makeText(this, R.string.not_implemented_yet, Toast.LENGTH_SHORT).show();
return true;
case R.id.disconnect:
- netconn.disconnect();
+ netplay.disconnect();
return true;
default:
return super.onOptionsItemSelected(item);
@@ -119,8 +92,8 @@
@Override
public void onBackPressed() {
- netconn.disconnect();
super.onBackPressed();
+ netplay.disconnect();
}
@Override
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/LobbyChatFragment.java Fri Jul 27 01:38:24 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-package org.hedgewars.hedgeroid.netplay;
-
-
-import org.hedgewars.hedgeroid.R;
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.inputmethod.EditorInfo;
-import android.widget.EditText;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.TextView.OnEditorActionListener;
-
-public class LobbyChatFragment extends Fragment {
- private ChatlogAdapter adapter;
- private Netplay netconn;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- netconn = Netplay.getAppInstance(getActivity().getApplicationContext());
- adapter = new ChatlogAdapter(getActivity());
- adapter.setLog(netconn.lobbyChatlog.getLog());
- netconn.lobbyChatlog.registerObserver(adapter);
- }
-
- @Override
- public void onStart() {
- super.onStart();
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.lobby_chat_fragment, container, false);
-
- ListView listView = (ListView) view.findViewById(R.id.lobbyConsole);
- listView.setAdapter(adapter);
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setVerticalFadingEdgeEnabled(true);
-
- EditText editText = (EditText) view.findViewById(R.id.lobbyChatInput);
- editText.setOnEditorActionListener(new ChatSendListener());
-
- return view;
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- netconn.lobbyChatlog.unregisterObserver(adapter);
- }
-
- private final class ChatSendListener implements OnEditorActionListener {
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- String text = v.getText().toString();
- if(text.length()>0) {
- v.setText("");
- netconn.sendChat(text);
- }
- return true;
- }
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/NetplayStateFragment.java Wed Aug 01 20:41:54 2012 +0200
@@ -0,0 +1,65 @@
+package org.hedgewars.hedgeroid.netplay;
+
+import org.hedgewars.hedgeroid.netplay.Netplay.State;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.content.LocalBroadcastManager;
+import android.widget.Toast;
+
+/**
+ * Fragment for use by an activity that depends on the state of the network
+ * connection.
+ *
+ * This fragment manages a few aspects of the netplay connection: Requesting
+ * the network system loop to run at high frequency while the activity is in
+ * the foreground, and reacting to changes in the networking state by switching
+ * to the appropriate activity or finishing the activity if the network connection
+ * is closed.
+ */
+public class NetplayStateFragment extends Fragment {
+ private Netplay netplay;
+ private Context appContext;
+ private LocalBroadcastManager broadcastManager;
+
+ private final BroadcastReceiver disconnectReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if(intent.getBooleanExtra(Netplay.EXTRA_HAS_ERROR, true)) {
+ String message = intent.getStringExtra(Netplay.EXTRA_MESSAGE);
+ Toast.makeText(appContext, "Disconnected: "+message, Toast.LENGTH_LONG).show();
+ }
+ getActivity().finish();
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ appContext = getActivity().getApplicationContext();
+ broadcastManager = LocalBroadcastManager.getInstance(appContext);
+ netplay = Netplay.getAppInstance(appContext);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ broadcastManager.registerReceiver(disconnectReceiver, new IntentFilter(Netplay.ACTION_DISCONNECTED));
+ netplay.requestFastTicks();
+
+ if(netplay.getState() == State.NOT_CONNECTED) {
+ getActivity().finish();
+ }
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ broadcastManager.unregisterReceiver(disconnectReceiver);
+ netplay.unrequestFastTicks();
+ }
+}
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/PlayerListAdapter.java Fri Jul 27 01:38:24 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/PlayerListAdapter.java Wed Aug 01 20:41:54 2012 +0200
@@ -80,10 +80,7 @@
View v = convertView;
if (v == null) {
LayoutInflater vi = LayoutInflater.from(context);
- v = vi.inflate(android.R.layout.simple_list_item_1, null);
- TextView tv = (TextView)v.findViewById(android.R.id.text1);
- tv.setCompoundDrawablePadding(5);
- tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.human, 0, 0, 0);
+ v = vi.inflate(R.layout.listview_player, null);
}
String player = players.get(position).first.name;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/RoomActivity.java Wed Aug 01 20:41:54 2012 +0200
@@ -0,0 +1,48 @@
+package org.hedgewars.hedgeroid.netplay;
+
+import org.hedgewars.hedgeroid.R;
+import org.hedgewars.hedgeroid.netplay.JnaFrontlib.NetconnPtr;
+
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.content.LocalBroadcastManager;
+import android.widget.LinearLayout;
+import android.widget.TabHost;
+
+public class RoomActivity extends FragmentActivity {
+ private TabHost tabHost;
+ private Netplay netconn;
+
+ @Override
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ netconn = Netplay.getAppInstance(getApplicationContext());
+
+ setContentView(R.layout.activity_lobby);
+ Fragment chatFragment = getSupportFragmentManager().findFragmentById(R.id.chatFragment);
+ chatFragment.getArguments().putBoolean(ChatFragment.ARGUMENT_INROOM, true);
+
+ tabHost = (TabHost)findViewById(android.R.id.tabhost);
+ if(tabHost != null) {
+ tabHost.setup();
+ tabHost.getTabWidget().setOrientation(LinearLayout.VERTICAL);
+
+ //tabHost.addTab(tabHost.newTabSpec("chat").setIndicator(createIndicatorView(tabHost, R.string.lobby_tab_chat, getResources().getDrawable(R.drawable.edit))).setContent(R.id.chatFragment));
+ //tabHost.addTab(tabHost.newTabSpec("players").setIndicator(createIndicatorView(tabHost, R.string.lobby_tab_players, getResources().getDrawable(R.drawable.human))).setContent(R.id.playerListFragment));
+
+ if (icicle != null) {
+ tabHost.setCurrentTabByTag(icicle.getString("currentTab"));
+ }
+ }
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle icicle) {
+ super.onSaveInstanceState(icicle);
+ if(tabHost != null) {
+ icicle.putString("currentTab", tabHost.getCurrentTabTag());
+ }
+ }
+}