mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-24 07:58:34 +01:00
replace send button with menuitem, and add icons for it and clear
This commit is contained in:
parent
ec6b7207b4
commit
d08e82220d
3 changed files with 35 additions and 42 deletions
|
@ -22,24 +22,11 @@
|
||||||
/>
|
/>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<LinearLayout android:orientation="horizontal"
|
<EditText android:id="@+id/chat_edit"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
>
|
|
||||||
|
|
||||||
<EditText android:id="@+id/chat_edit"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:singleLine="false"
|
|
||||||
android:layout_weight="1"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button android:id="@+id/send_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/chat_send"
|
android:singleLine="false"
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@+id/chat_menu_send"
|
||||||
|
android:title="@string/chat_send"
|
||||||
|
android:showAsAction="ifRoom"
|
||||||
|
android:icon="@drawable/send__gen"
|
||||||
|
/>
|
||||||
<item android:id="@+id/chat_menu_clear"
|
<item android:id="@+id/chat_menu_clear"
|
||||||
android:title="@string/chat_menu_clear"
|
android:title="@string/chat_menu_clear"
|
||||||
|
android:showAsAction="ifRoom"
|
||||||
|
android:icon="@drawable/content_discard__gen"
|
||||||
/>
|
/>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -24,10 +24,8 @@ 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.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
@ -35,8 +33,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
|
|
||||||
public class ChatDelegate extends DelegateBase
|
public class ChatDelegate extends DelegateBase {
|
||||||
implements View.OnClickListener {
|
|
||||||
|
|
||||||
private long m_rowid;
|
private long m_rowid;
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
|
@ -76,9 +73,6 @@ public class ChatDelegate extends DelegateBase
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
((Button)findViewById( R.id.send_button ))
|
|
||||||
.setOnClickListener( this );
|
|
||||||
|
|
||||||
String title = getString( R.string.chat_title_fmt,
|
String title = getString( R.string.chat_title_fmt,
|
||||||
GameUtils.getName( m_activity, m_rowid ) );
|
GameUtils.getName( m_activity, m_rowid ) );
|
||||||
setTitle( title );
|
setTitle( title );
|
||||||
|
@ -91,29 +85,34 @@ public class ChatDelegate extends DelegateBase
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected( MenuItem item )
|
public boolean onOptionsItemSelected( MenuItem item )
|
||||||
{
|
{
|
||||||
boolean handled = R.id.chat_menu_clear == item.getItemId();
|
boolean handled = true;
|
||||||
if ( handled ) {
|
switch ( item.getItemId() ) {
|
||||||
showConfirmThen( R.string.confirm_clear_chat, Action.CLEAR_ACTION );
|
case R.id.chat_menu_clear:
|
||||||
|
if ( handled ) {
|
||||||
|
showConfirmThen( R.string.confirm_clear_chat, Action.CLEAR_ACTION );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.chat_menu_send:
|
||||||
|
EditText edit = (EditText)findViewById( R.id.chat_edit );
|
||||||
|
String text = edit.getText().toString();
|
||||||
|
if ( null == text || text.length() == 0 ) {
|
||||||
|
setResult( Activity.RESULT_CANCELED );
|
||||||
|
} else {
|
||||||
|
DBUtils.appendChatHistory( m_activity, m_rowid, text, true );
|
||||||
|
|
||||||
|
Intent result = new Intent();
|
||||||
|
result.putExtra( BoardDelegate.INTENT_KEY_CHAT, text );
|
||||||
|
setResult( Activity.RESULT_OK, result );
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
handled = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick( View view )
|
|
||||||
{
|
|
||||||
EditText edit = (EditText)findViewById( R.id.chat_edit );
|
|
||||||
String text = edit.getText().toString();
|
|
||||||
if ( null == text || text.length() == 0 ) {
|
|
||||||
setResult( Activity.RESULT_CANCELED );
|
|
||||||
} else {
|
|
||||||
DBUtils.appendChatHistory( m_activity, m_rowid, text, true );
|
|
||||||
|
|
||||||
Intent result = new Intent();
|
|
||||||
result.putExtra( BoardDelegate.INTENT_KEY_CHAT, text );
|
|
||||||
setResult( Activity.RESULT_OK, result );
|
|
||||||
}
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dlgButtonClicked( Action action, int which, Object[] params )
|
public void dlgButtonClicked( Action action, int which, Object[] params )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue