Hedgeroid: Fix argument passing to ChatFragment, small layout fixes
authorMedo <smaxein@googlemail.com>
Wed, 01 Aug 2012 21:13:39 +0200
changeset 7455 8e86d8d2927d
parent 7452 915f824039ba
child 7458 fec6fa1e460e
Hedgeroid: Fix argument passing to ChatFragment, small layout fixes
project_files/Android-build/SDL-android-project/AndroidManifest.xml
project_files/Android-build/SDL-android-project/res/layout-large/activity_lobby.xml
project_files/Android-build/SDL-android-project/res/layout/activity_lobby.xml
project_files/Android-build/SDL-android-project/res/layout/activity_netroom.xml
project_files/Android-build/SDL-android-project/res/layout/listview_player.xml
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/ChatFragment.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/LobbyActivity.java
--- a/project_files/Android-build/SDL-android-project/AndroidManifest.xml	Wed Aug 01 20:56:32 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/AndroidManifest.xml	Wed Aug 01 21:13:39 2012 +0200
@@ -70,7 +70,7 @@
             android:name=".netplay.LobbyActivity"
             android:label="@string/title_activity_lobby"
             android:screenOrientation="landscape"
-            android:windowSoftInputMode="adjustResize" >
+            android:windowSoftInputMode="adjustPan" >
         </activity>
     </application>
 </manifest>
\ No newline at end of file
--- a/project_files/Android-build/SDL-android-project/res/layout-large/activity_lobby.xml	Wed Aug 01 20:56:32 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/res/layout-large/activity_lobby.xml	Wed Aug 01 21:13:39 2012 +0200
@@ -36,7 +36,7 @@
 	
 	        <FrameLayout
 	            android:id="@+id/playerFrame"
-	            android:layout_width="200dp"
+	            android:layout_width="250dp"
 	            android:layout_height="fill_parent"
 	            android:layout_alignParentRight="true"
 	            android:background="@drawable/box" >
@@ -61,8 +61,8 @@
 	                android:id="@+id/chatFragment"
 	                android:layout_width="fill_parent"
 	                android:layout_height="fill_parent"
-	                class="org.hedgewars.hedgeroid.netplay.LobbyChatFragment"
-	                tools:layout="@layout/lobby_chat_fragment" />
+	                class="org.hedgewars.hedgeroid.netplay.ChatFragment"
+	                tools:layout="@layout/fragment_chat" />
 	        </FrameLayout>
 	    </RelativeLayout>
 	
--- a/project_files/Android-build/SDL-android-project/res/layout/activity_lobby.xml	Wed Aug 01 20:56:32 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/res/layout/activity_lobby.xml	Wed Aug 01 21:13:39 2012 +0200
@@ -40,7 +40,7 @@
                     android:id="@+id/chatFragment"
                     android:layout_width="fill_parent"
                     android:layout_height="fill_parent"
-                    class="org.hedgewars.hedgeroid.netplay.LobbyChatFragment"
+                    class="org.hedgewars.hedgeroid.netplay.ChatFragment"
                     tools:layout="@layout/fragment_chat" />
 
                 <fragment
--- a/project_files/Android-build/SDL-android-project/res/layout/activity_netroom.xml	Wed Aug 01 20:56:32 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/res/layout/activity_netroom.xml	Wed Aug 01 21:13:39 2012 +0200
@@ -96,7 +96,7 @@
                 android:id="@+id/chatFragment"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
-                class="org.hedgewars.hedgeroid.netplay.LobbyChatFragment"
+                class="org.hedgewars.hedgeroid.netplay.ChatFragment"
                 tools:layout="@layout/fragment_chat" />
         </FrameLayout>
     </RelativeLayout>
--- a/project_files/Android-build/SDL-android-project/res/layout/listview_player.xml	Wed Aug 01 20:56:32 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/res/layout/listview_player.xml	Wed Aug 01 21:13:39 2012 +0200
@@ -8,4 +8,5 @@
     android:drawablePadding="5dp"
     android:drawableLeft="@drawable/playerlist_player"
     android:gravity="center_vertical|left"
+    android:singleLine="true"
     android:textAppearance="?android:attr/textAppearanceMedium" />
\ No newline at end of file
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/ChatFragment.java	Wed Aug 01 20:56:32 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/ChatFragment.java	Wed Aug 01 21:13:39 2012 +0200
@@ -19,22 +19,31 @@
 	private ChatlogAdapter adapter;
 	private Netplay netconn;
 	private MessageLog messageLog;
+	private boolean inRoom;
+	
+	public void setInRoom(boolean inRoom) {
+		this.inRoom = inRoom;
+	}
 	
 	@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;
+	}
+	
+	@Override
+	public void onStart() {
+		super.onStart();
+		messageLog = inRoom ? netconn.roomChatlog : netconn.lobbyChatlog;
     	adapter.setLog(messageLog.getLog());
     	messageLog.registerObserver(adapter);
 	}
 	
 	@Override
-	public void onStart() {
-		super.onStart();
+	public void onStop() {
+		super.onStop();
+		messageLog.unregisterObserver(adapter);
 	}
 	
 	@Override
@@ -54,12 +63,6 @@
 		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();
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/LobbyActivity.java	Wed Aug 01 20:56:32 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/LobbyActivity.java	Wed Aug 01 21:13:39 2012 +0200
@@ -5,7 +5,6 @@
 import android.content.Context;
 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.app.FragmentTransaction;
 import android.view.LayoutInflater;
@@ -27,8 +26,8 @@
         super.onCreate(icicle);
         
         setContentView(R.layout.activity_lobby);
-        Fragment chatFragment = getSupportFragmentManager().findFragmentById(R.id.chatFragment);
-        chatFragment.getArguments().putBoolean(ChatFragment.ARGUMENT_INROOM, false);
+        ChatFragment chatFragment = (ChatFragment)getSupportFragmentManager().findFragmentById(R.id.chatFragment);
+        chatFragment.setInRoom(false);
         
         FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
         trans.add(new NetplayStateFragment(), "netplayFragment");