From 07e97107ce5e6cc4864a78835df08ba0185f492a Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 20 Aug 2015 07:37:30 -0700 Subject: [PATCH 1/5] confirm before deleting chat history Conflicts: xwords4/android/XWords4/res/values/strings.xml --- .../android/XWords4/res/values/strings.xml | 3 ++ .../org/eehouse/android/xw4/ChatDelegate.java | 34 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 8e51f1607..590a624f0 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -2538,4 +2538,7 @@ %1$s messages sent + Are you sure you want to delete + all chat history for this game?\n\n(This action cannot be + undone.) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java index 82d6572eb..bb2cbcd67 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java @@ -21,16 +21,18 @@ package org.eehouse.android.xw4; import android.app.Activity; +import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TextView; -import android.view.View; import android.view.Menu; import android.view.MenuItem; -import android.view.MenuInflater; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; import android.widget.LinearLayout; +import android.widget.TextView; + +import org.eehouse.android.xw4.DlgDelegate.Action; public class ChatDelegate extends DelegateBase implements View.OnClickListener { @@ -82,10 +84,7 @@ public class ChatDelegate extends DelegateBase { boolean handled = R.id.chat_menu_clear == item.getItemId(); if ( handled ) { - DBUtils.clearChatHistory( m_activity, m_rowid ); - LinearLayout layout = - (LinearLayout)findViewById( R.id.chat_history ); - layout.removeAllViews(); + showConfirmThen( R.string.confirm_clear_chat, Action.CLEAR_ACTION ); } return handled; } @@ -105,4 +104,21 @@ public class ChatDelegate extends DelegateBase } finish(); } + + @Override + public void dlgButtonClicked( Action action, int which, Object[] params ) + { + switch ( action ) { + case CLEAR_ACTION: + if ( AlertDialog.BUTTON_POSITIVE == which ) { + DBUtils.clearChatHistory( m_activity, m_rowid ); + LinearLayout layout = + (LinearLayout)findViewById( R.id.chat_history ); + layout.removeAllViews(); + } + break; + default: + super.dlgButtonClicked( action, which, params ); + } + } } From 6b455bf743ed7e1cb2b54a9aafa69e0f68122aeb Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 20 Aug 2015 07:15:20 -0700 Subject: [PATCH 2/5] make chat compose space multi-line; scroll chat history to bottom on open --- xwords4/android/XWords4/res/layout/chat.xml | 5 +++-- .../src/org/eehouse/android/xw4/ChatDelegate.java | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/xwords4/android/XWords4/res/layout/chat.xml b/xwords4/android/XWords4/res/layout/chat.xml index e1f02e40b..2ac2bff36 100644 --- a/xwords4/android/XWords4/res/layout/chat.xml +++ b/xwords4/android/XWords4/res/layout/chat.xml @@ -9,7 +9,8 @@ - diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java index bb2cbcd67..fa834906e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java @@ -30,6 +30,7 @@ import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; +import android.widget.ScrollView; import android.widget.TextView; import org.eehouse.android.xw4.DlgDelegate.Action; @@ -67,6 +68,14 @@ public class ChatDelegate extends DelegateBase } } + final ScrollView scroll = (ScrollView)findViewById( R.id.scroll ); + scroll.post(new Runnable() { + @Override + public void run() { + scroll.fullScroll(View.FOCUS_DOWN); + } + }); + ((Button)findViewById( R.id.send_button )) .setOnClickListener( this ); From 79ab1214e71beec97a8e7894f9bcd0553fc1b02b Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 20 Aug 2015 07:35:01 -0700 Subject: [PATCH 3/5] replace send button with menuitem, and add icons for it and clear --- xwords4/android/XWords4/res/layout/chat.xml | 19 ++----- .../android/XWords4/res/menu/chat_menu.xml | 7 +++ .../org/eehouse/android/xw4/ChatDelegate.java | 51 +++++++++---------- 3 files changed, 35 insertions(+), 42 deletions(-) diff --git a/xwords4/android/XWords4/res/layout/chat.xml b/xwords4/android/XWords4/res/layout/chat.xml index 2ac2bff36..422ccfcd7 100644 --- a/xwords4/android/XWords4/res/layout/chat.xml +++ b/xwords4/android/XWords4/res/layout/chat.xml @@ -22,24 +22,11 @@ /> - - - - -