mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
in chat window, don't show send menu item unless text is non-empty
This commit is contained in:
parent
b8822f72bc
commit
db1f569430
1 changed files with 25 additions and 2 deletions
|
@ -24,6 +24,9 @@ import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -37,6 +40,7 @@ public class ChatDelegate extends DelegateBase {
|
||||||
|
|
||||||
private long m_rowid;
|
private long m_rowid;
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
|
private EditText mEdit;
|
||||||
|
|
||||||
public ChatDelegate( Delegator delegator, Bundle savedInstanceState )
|
public ChatDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
|
@ -48,6 +52,17 @@ public class ChatDelegate extends DelegateBase {
|
||||||
protected void init( Bundle savedInstanceState )
|
protected void init( Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
if ( BuildConstants.CHAT_SUPPORTED ) {
|
if ( BuildConstants.CHAT_SUPPORTED ) {
|
||||||
|
mEdit = (EditText)findViewById( R.id.chat_edit );
|
||||||
|
mEdit.addTextChangedListener( new TextWatcher() {
|
||||||
|
public void afterTextChanged( Editable s ) {
|
||||||
|
invalidateOptionsMenuIf();
|
||||||
|
}
|
||||||
|
public void beforeTextChanged( CharSequence s, int st,
|
||||||
|
int cnt, int a ) {}
|
||||||
|
public void onTextChanged( CharSequence s, int start,
|
||||||
|
int before, int count ) {}
|
||||||
|
} );
|
||||||
|
|
||||||
m_rowid = getIntent().getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
m_rowid = getIntent().getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
|
||||||
|
|
||||||
DBUtils.HistoryPair[] pairs = DBUtils.getChatHistory( m_activity, m_rowid );
|
DBUtils.HistoryPair[] pairs = DBUtils.getChatHistory( m_activity, m_rowid );
|
||||||
|
@ -82,6 +97,15 @@ public class ChatDelegate extends DelegateBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPrepareOptionsMenu( Menu menu )
|
||||||
|
{
|
||||||
|
String text = mEdit.getText().toString();
|
||||||
|
boolean haveText = null != text && 0 < text.length();
|
||||||
|
Utils.setItemVisible( menu, R.id.chat_menu_send, haveText );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected( MenuItem item )
|
public boolean onOptionsItemSelected( MenuItem item )
|
||||||
{
|
{
|
||||||
|
@ -93,8 +117,7 @@ public class ChatDelegate extends DelegateBase {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.chat_menu_send:
|
case R.id.chat_menu_send:
|
||||||
EditText edit = (EditText)findViewById( R.id.chat_edit );
|
String text = mEdit.getText().toString();
|
||||||
String text = edit.getText().toString();
|
|
||||||
if ( null == text || text.length() == 0 ) {
|
if ( null == text || text.length() == 0 ) {
|
||||||
setResult( Activity.RESULT_CANCELED );
|
setResult( Activity.RESULT_CANCELED );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue