From b1fe1b09a09eea9e8b183d0812e6fef0c96ce262 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Tue, 24 Mar 2015 22:19:25 +0100 Subject: [PATCH] ConversationActivity: Cardify UI. Add send button. Trigger nick completion on send button long press. --- .../yaaic/activity/ConversationActivity.java | 46 ++++++++++++----- .../main/java/org/yaaic/model/Message.java | 3 -- .../java/org/yaaic/view/MessageListView.java | 3 +- .../main/res/drawable-hdpi/ic_action_send.png | Bin 0 -> 486 bytes .../main/res/drawable-mdpi/ic_action_send.png | Bin 0 -> 356 bytes .../res/drawable-xhdpi/ic_action_send.png | Bin 0 -> 742 bytes .../res/drawable-xxhdpi/ic_action_send.png | Bin 0 -> 808 bytes .../res/drawable/conversation_background.xml | 35 ------------- .../res/layout/activity_conversations.xml | 48 ++++++++++++++---- 9 files changed, 73 insertions(+), 62 deletions(-) create mode 100755 app/src/main/res/drawable-hdpi/ic_action_send.png create mode 100755 app/src/main/res/drawable-mdpi/ic_action_send.png create mode 100755 app/src/main/res/drawable-xhdpi/ic_action_send.png create mode 100755 app/src/main/res/drawable-xxhdpi/ic_action_send.png delete mode 100644 app/src/main/res/drawable/conversation_background.xml diff --git a/app/src/main/java/org/yaaic/activity/ConversationActivity.java b/app/src/main/java/org/yaaic/activity/ConversationActivity.java index bad15c0..9426c98 100644 --- a/app/src/main/java/org/yaaic/activity/ConversationActivity.java +++ b/app/src/main/java/org/yaaic/activity/ConversationActivity.java @@ -49,6 +49,7 @@ import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.EditText; +import android.widget.ImageButton; import android.widget.Toast; import org.yaaic.R; @@ -101,6 +102,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo private ConversationReceiver channelReceiver; private ServerReceiver serverReceiver; + private EditText input; private ViewPager pager; private ConversationPagerAdapter pagerAdapter; private ConversationTabLayout tabLayout; @@ -148,14 +150,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo } if (keyCode == KeyEvent.KEYCODE_ENTER) { - sendMessage(input.getText().toString()); - - // Workaround for a race condition in EditText - // Instead of calling input.setText(""); - // See: - // - https://github.com/pocmo/Yaaic/issues/67 - // - http://code.google.com/p/android/issues/detail?id=17508 - TextKeyListener.clear(input.getText()); + sendCurrentMessage(); return true; } @@ -199,7 +194,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo boolean isLandscape = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); - EditText input = (EditText) findViewById(R.id.input); + input = (EditText) findViewById(R.id.input); input.setOnKeyListener(inputKeyListener); pager = (ViewPager) findViewById(R.id.pager); @@ -220,9 +215,6 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize); } - input.setTextSize(settings.getFontSize()); - input.setTypeface(Typeface.MONOSPACE); - // Optimization : cache field lookups Collection mConversations = server.getConversations(); @@ -253,6 +245,23 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo input.setInputType(input.getInputType() | setInputTypeFlags); + ImageButton sendButton = (ImageButton) findViewById(R.id.send); + sendButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (input.getText().length() > 0) { + sendCurrentMessage(); + } + } + }); + sendButton.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + doNickCompletion(input); + return true; + } + }); + // Create a new scrollback history scrollback = new Scrollback(); } @@ -602,7 +611,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo } binder.getService().getConnection(server.getId()).setAutojoinChannels( server.getCurrentChannelNames() - ); + ); server.setStatus(Status.CONNECTING); binder.connect(server); reconnectDialogActive = false; @@ -737,6 +746,17 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo } } + private void sendCurrentMessage() { + sendMessage(input.getText().toString()); + + // Workaround for a race condition in EditText + // Instead of calling input.setText(""); + // See: + // - https://github.com/pocmo/Yaaic/issues/67 + // - http://code.google.com/p/android/issues/detail?id=17508 + TextKeyListener.clear(input.getText()); + } + /** * Send a message in this conversation * diff --git a/app/src/main/java/org/yaaic/model/Message.java b/app/src/main/java/org/yaaic/model/Message.java index dfd9d30..533201f 100644 --- a/app/src/main/java/org/yaaic/model/Message.java +++ b/app/src/main/java/org/yaaic/model/Message.java @@ -331,9 +331,6 @@ public class Message canvas.setLinkTextColor(COLOR_BLUE); canvas.setText(this.render(context)); - canvas.setTextSize(settings.getFontSize()); - canvas.setTypeface(Typeface.MONOSPACE); - canvas.setTextColor(COLOR_DEFAULT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setupViewForHoneycombAndLater(canvas); diff --git a/app/src/main/java/org/yaaic/view/MessageListView.java b/app/src/main/java/org/yaaic/view/MessageListView.java index d698a4b..be849b7 100644 --- a/app/src/main/java/org/yaaic/view/MessageListView.java +++ b/app/src/main/java/org/yaaic/view/MessageListView.java @@ -47,9 +47,8 @@ public class MessageListView extends ListView setDivider(null); - setCacheColorHint(0x000000); + setCacheColorHint(0xFFFFFFFF); setVerticalFadingEdgeEnabled(false); - setBackgroundResource(R.drawable.conversation_background); setScrollBarStyle(SCROLLBARS_OUTSIDE_INSET); // Scale padding by screen density diff --git a/app/src/main/res/drawable-hdpi/ic_action_send.png b/app/src/main/res/drawable-hdpi/ic_action_send.png new file mode 100755 index 0000000000000000000000000000000000000000..a031ac1172bac1571377eaceca3965408fd69e95 GIT binary patch literal 486 zcmV@P)#}O9h?iL?X3Gr;HgWtVk7~SGj5tOTiy^wouK&!1?Uw z-Ul2IuKa~petw7mp%aV=!~`5C5EXJ9p!4$ok-%s)x}VKvZ_eWqXrPrqQ525=uppwz za=Dy#UH2()7OR#f0KXfoiDAUOIWPLem0bDv= zp64kd-Vu>{Kf)nmMnt!l)}MZ^F2}>+@KjaRyUscmfO8w!riY00{eC}QtyV8>+phoG z!wbM*Fh~JFC1j%CLM7n^Kq<7_?UH`KpK&NeM9*bezOpH#G_aha&KXqA_m_CH*-Vf6by^Dj{2wsst6S^*5EukN{nD6da&8(v0jxC%4dARv5CBe1d;*AQ;sZcb6EOf^ zns5Vn*Mtiom?j(m54z7Lx>qn)oz_LhwV6bp2p}<4lb$gFlW9rR#snm$YSJ?%U@|R< c+N)3C3(Iy%Kvh10P5=M^07*qoM6N<$g5?F!l>h($ literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_action_send.png b/app/src/main/res/drawable-mdpi/ic_action_send.png new file mode 100755 index 0000000000000000000000000000000000000000..4be4be1755ef57b3877332ab2514bddcf5b79ddc GIT binary patch literal 356 zcmV-q0h|7bP)F?2S($gAdoEA996sJ@u3^H5AjN_Gp5$ur~sOc%ROctLAfn9t2>|cTxwo<`FV-Oc0`!82 z_|>-U2NAtCO>?pW84WNHJX^)11?YGz;)w#Vh{psVCZ4MRS(ZI{?-NAa1Au2{kBB>F zmVa9SaJMev*m$%>FY+ zbH7+DcIN~m4*-Ak?uh6+B97PV_073}$P>Wf#;=kj`Isch?R-A}0RRbCR}=+6>($|? zL-N~xzyA=1;b)EziUjbFUPS!Dv3ryT;F$)y?ol=XcHN^&04%x(2LP3J4{iWT?;ach zl-fPm11P$Cqy{h;3|uK?-*w%tQmT!J9i`MIB6>vR>UTtxL}V3o@X2-dNDbhKD9iVK zFG&*Dwry$Kwg&(gMARpuo)F?S5nTbms~n-^GJE6&;3Qo^5L`r2bk%CL+5pf6fW8I= z0P@g5L}Z`zfqx%*P)d#UcpiqK9?eg_qbL=?5mCbTed&3gx7+PJrIag#xU?**Lqu&M zM3;!(0D$`+C|dMSL|n#k{5}lByHg-?0DwUd$fu_#DW!Dx`@Q!90Bc0Ni=yayHk*BA z2SArV9LF61Xxp~k%drFw$M1(KO27(&z};@Qp5r)r2W4$Ta5x+~mSy!F$LUqs28rm? zYPGswE|=R=tbXj7)EV%6Df*J{%(AwyF`7MqqAyZ70x0z=jT?Z{FH<=H$mK|zC0O*D zDgpc+YVu0+a{*9TnzIK`beeMnP->cU15kRJa{y3jnpX*cMVgllfL)rG2B7hOk;zJ$ z>$=n@L9Rlw{w@O`E4jL?GY+WBPG;3%9FUbM#z-O0F*Jj05VjlUa5A Y0=17LUlpdRCjbBd07*qoM6N<$g5Kv!wg3PC literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_send.png b/app/src/main/res/drawable-xxhdpi/ic_action_send.png new file mode 100755 index 0000000000000000000000000000000000000000..733ba28cb1819be023088fd7dd0a46dc76f289cd GIT binary patch literal 808 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>V0!QA;uum9_jZ`ltM+!zb^3UsCGacsANpDvNIdZKmY#E3D+e>=X6)E+I9c^cm8E}81Cd0FuXq&aHTZ%P1$by zhK(~PypcLEne*IE=GQMj|GdE6;5O^)7eS}>3=#gj7&grNvq<%deduPcU0=QjtyMQ= z01|5%CaqMz$`BM`JCi}6*fx?yAk=mytAMxdO!kDm^OBeo*3DbQlCW~#BDREu^MaTb zY??QTdBNIwlUNrlo!7+pfq9nS^6N@Qr#}DDI=yLP$B*+Hi}Pw;24AvU@4ROxH`fF0 z&1#cRR#?dN*~;+0lstFBvi$Dylet@d)tKCqZYX9BpEJ+TTxGPs zx?_PRkoRED@6c&aUsc%H&D*`b_`W+M!;E=J1`=zoz217itoY(YsRsG=|Ni9b6}@@u z%5p)c{}S>QeVZ90bi}sDzM1{=UcsBWvOEoY7rx$+%*0Tvz`(>{%`h#UiG$${L&Q8z t1%?gG36*LM3rfh%rde_s%yMZ}?!PC{xWt~$(69D&TTh0Ig literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/conversation_background.xml b/app/src/main/res/drawable/conversation_background.xml deleted file mode 100644 index 81df62e..0000000 --- a/app/src/main/res/drawable/conversation_background.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_conversations.xml b/app/src/main/res/layout/activity_conversations.xml index 15f40e7..71e6efa 100644 --- a/app/src/main/res/layout/activity_conversations.xml +++ b/app/src/main/res/layout/activity_conversations.xml @@ -38,27 +38,54 @@ along with Yaaic. If not, see . android:layout_height="wrap_content" android:background="@color/primary" /> - + android:layout_margin="4dp" + card_view:cardBackgroundColor="@color/cardview_background"> + + + + + android:orientation="horizontal" + android:gravity="center_vertical"> + android:background="@android:color/transparent" + android:inputType="textShortMessage" /> + +