mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
add chat fragment, which displays ok but can't send. Turn menus off/on
as fragments are made visible.
This commit is contained in:
parent
c35020ef97
commit
0a843bd430
3 changed files with 74 additions and 12 deletions
|
@ -64,6 +64,7 @@ public class ChatDelegate extends DelegateBase {
|
|||
@Override
|
||||
protected void init( Bundle savedInstanceState )
|
||||
{
|
||||
DbgUtils.logf( "ChatDelegate.init()" );
|
||||
if ( BuildConstants.CHAT_SUPPORTED ) {
|
||||
m_edit = (EditText)findViewById( R.id.chat_edit );
|
||||
m_edit.addTextChangedListener( new TextWatcher() {
|
||||
|
@ -76,11 +77,11 @@ public class ChatDelegate extends DelegateBase {
|
|||
int before, int count ) {}
|
||||
} );
|
||||
|
||||
Intent intent = getIntent();
|
||||
m_rowid = intent.getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||
m_curPlayer = intent.getIntExtra( INTENT_KEY_PLAYER, -1 );
|
||||
m_names = intent.getStringArrayExtra( INTENT_KEY_NAMES );
|
||||
boolean[] locals = intent.getBooleanArrayExtra( INTENT_KEY_LOCS );
|
||||
Bundle args = getArguments();
|
||||
m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||
m_curPlayer = args.getInt( INTENT_KEY_PLAYER, -1 );
|
||||
m_names = args.getStringArray( INTENT_KEY_NAMES );
|
||||
boolean[] locals = args.getBooleanArray( INTENT_KEY_LOCS );
|
||||
|
||||
m_scroll = (ScrollView)findViewById( R.id.scroll );
|
||||
m_layout = (TableLayout)findViewById( R.id.chat_history );
|
||||
|
@ -208,11 +209,18 @@ public class ChatDelegate extends DelegateBase {
|
|||
String[] names, boolean[] locs )
|
||||
{
|
||||
Assert.assertFalse( -1 == curPlayer );
|
||||
Intent intent = new Intent( parent, ChatActivity.class );
|
||||
intent.putExtra( GameUtils.INTENT_KEY_ROWID, rowID );
|
||||
intent.putExtra( INTENT_KEY_PLAYER, curPlayer );
|
||||
intent.putExtra( INTENT_KEY_NAMES, names );
|
||||
intent.putExtra( INTENT_KEY_LOCS, locs );
|
||||
parent.startActivityForResult( intent, requestCode.ordinal() );
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong( GameUtils.INTENT_KEY_ROWID, rowID );
|
||||
bundle.putInt( INTENT_KEY_PLAYER, curPlayer );
|
||||
bundle.putStringArray( INTENT_KEY_NAMES, names );
|
||||
bundle.putBooleanArray( INTENT_KEY_LOCS, locs );
|
||||
|
||||
if ( parent instanceof FragActivity ) {
|
||||
FragActivity.addFragment( new ChatFrag(), bundle );
|
||||
} else {
|
||||
Intent intent = new Intent( parent, ChatActivity.class );
|
||||
intent.putExtras( bundle );
|
||||
parent.startActivityForResult( intent, requestCode.ordinal() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2016 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class ChatFrag extends XWFragment {
|
||||
private ChatDelegate m_dlgt;
|
||||
|
||||
@Override
|
||||
public void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
m_dlgt = new ChatDelegate( this, savedInstanceState );
|
||||
super.onCreate( m_dlgt, savedInstanceState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated( Bundle savedInstanceState )
|
||||
{
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
setHasOptionsMenu( true );
|
||||
}
|
||||
}
|
|
@ -171,7 +171,11 @@ public class FragActivity extends FragmentActivity
|
|||
|
||||
if ( !replace && contCount >= m_maxPanes ) {
|
||||
int indx = contCount - m_maxPanes;
|
||||
m_root.getChildAt( indx ).setVisibility( View.GONE );
|
||||
View child = m_root.getChildAt( indx );
|
||||
child.setVisibility( View.GONE );
|
||||
|
||||
setMenuVisibility( child, false );
|
||||
|
||||
DbgUtils.logf( "hiding %dth container", indx );
|
||||
}
|
||||
|
||||
|
@ -191,9 +195,19 @@ public class FragActivity extends FragmentActivity
|
|||
boolean visible = ii >= nPanes - m_maxPanes;
|
||||
DbgUtils.logf( "pane %d: visible=%b", ii, visible );
|
||||
child.setVisibility( visible ? View.VISIBLE : View.GONE );
|
||||
setMenuVisibility( child, visible );
|
||||
}
|
||||
}
|
||||
|
||||
private void setMenuVisibility( View cont, boolean visible )
|
||||
{
|
||||
FrameLayout layout = (FrameLayout)cont;
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
int hidingId = layout.getId();
|
||||
Fragment frag = fm.findFragmentById( hidingId );
|
||||
frag.setMenuVisibility( visible );
|
||||
}
|
||||
|
||||
// Walk all Fragment children and if they care notify of change.
|
||||
private void tellOrientationChanged( int orientation )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue