From 7fe0aefc3861b52002d77f0dccb272223e5c4c15 Mon Sep 17 00:00:00 2001 From: unreg Date: Sun, 11 Sep 2016 18:55:13 +0300 Subject: [PATCH 1/2] Fix first time typing "/" --- .../conversation/mentions/AutocompleteFragment.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/mentions/AutocompleteFragment.java b/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/mentions/AutocompleteFragment.java index 949098a07c..12f325ab5e 100644 --- a/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/mentions/AutocompleteFragment.java +++ b/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/mentions/AutocompleteFragment.java @@ -144,9 +144,13 @@ public void onDestroyView() { private void expandMentions(final BottomSheetListView list, final int oldRowsCount, final int newRowsCount) { list.post(() -> { - if (newRowsCount == oldRowsCount) { - return; - } + + // I dont understand for what it. + // But when its not comment, not work first time typing "/", only next. + // + //if (newRowsCount == oldRowsCount) { + // return; + //} list.setMinHeight(newRowsCount == 0 ? 0 : newRowsCount == 1 ? Screen.dp(48) + 1 : newRowsCount == 2 ? Screen.dp(96) + 2 : Screen.dp(122)); From a503c20fc2b4de6f6fc42343c6eb49655fc5c179 Mon Sep 17 00:00:00 2001 From: unreg Date: Sun, 11 Sep 2016 21:13:55 +0300 Subject: [PATCH 2/2] Add on inputbar "slash" image button for quick access to slashCommand --- .../conversation/ChatFragment.java | 11 ++++++ .../inputbar/InputBarCallback.java | 2 + .../inputbar/InputBarFragment.java | 36 ++++++++++++++++++ .../src/main/res/drawable-hdpi/conv_slash.png | Bin 0 -> 380 bytes .../src/main/res/drawable-mdpi/conv_slash.png | Bin 0 -> 307 bytes .../main/res/drawable-xhdpi/conv_slash.png | Bin 0 -> 521 bytes .../main/res/drawable-xxhdpi/conv_slash.png | Bin 0 -> 882 bytes .../src/main/res/drawable/button_slash.xml | 10 +++++ .../src/main/res/layout/fragment_inputbar.xml | 22 +++++++++++ 9 files changed, 81 insertions(+) create mode 100644 actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable-hdpi/conv_slash.png create mode 100644 actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable-mdpi/conv_slash.png create mode 100644 actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable-xhdpi/conv_slash.png create mode 100644 actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable-xxhdpi/conv_slash.png create mode 100644 actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable/button_slash.xml diff --git a/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/ChatFragment.java b/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/ChatFragment.java index a0c1ebb1c5..113b2649b4 100644 --- a/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/ChatFragment.java +++ b/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/ChatFragment.java @@ -348,6 +348,15 @@ public void onAttachPressed() { } } + @Override + public void onSlashPressed() { + if (findInputBar().getText() == "/") { + findInputBar().setText("", true); + } else { + findInputBar().setText("/", true); + } + } + @Override public void onAvatarClick(int uid) { ActorSDKLauncher.startProfileActivity(getActivity(), uid); @@ -460,6 +469,7 @@ private void hideQuote() { findInputBar().setDisableOnEmptyText(true); findInputBar().setAudioEnabled(true); findInputBar().setAttachEnabled(true); + findInputBar().setSlashEnabled(true); } private void showQuote(String text, boolean isQuote) { @@ -468,5 +478,6 @@ private void showQuote(String text, boolean isQuote) { findInputBar().setDisableOnEmptyText(false); findInputBar().setAudioEnabled(false); findInputBar().setAttachEnabled(false); + findInputBar().setSlashEnabled(false); } } diff --git a/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/inputbar/InputBarCallback.java b/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/inputbar/InputBarCallback.java index 0a85d4d7f1..891333534e 100644 --- a/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/inputbar/InputBarCallback.java +++ b/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/inputbar/InputBarCallback.java @@ -19,4 +19,6 @@ public interface InputBarCallback { void onStickerSent(Sticker sticker); void onAttachPressed(); + + void onSlashPressed(); } diff --git a/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/inputbar/InputBarFragment.java b/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/inputbar/InputBarFragment.java index 849de3bc67..24d005a86f 100644 --- a/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/inputbar/InputBarFragment.java +++ b/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/controllers/conversation/inputbar/InputBarFragment.java @@ -58,6 +58,7 @@ public class InputBarFragment extends BaseFragment { private boolean isAudioEnabled = true; private boolean isAttachEnabled = true; + private boolean isSlashEnabled = true; private boolean isDisableOnEmptyText = true; // @@ -67,6 +68,7 @@ public class InputBarFragment extends BaseFragment { protected BarEditText messageEditText; protected TintImageView sendButton; protected ImageButton attachButton; + protected ImageButton slashButton; protected String lastWord = ""; // @@ -188,6 +190,15 @@ public void afterTextChanged(Editable editable) { }); + // + // Slash Button + // + slashButton = (ImageButton) res.findViewById(R.id.ib_slash); + slashButton.setOnClickListener(v -> { + onSlashButtonClicked(); + }); + + // // Emoji keyboard // @@ -375,6 +386,16 @@ public void setAttachEnabled(boolean attachEnabled) { checkSendButton(); } + public boolean isSlashEnabled() { + return isSlashEnabled; + } + + public void setSlashEnabled(boolean slashEnabled) { + isSlashEnabled = slashEnabled; + hideAudio(true); + checkSendButton(); + } + public boolean isDisableOnEmptyText() { return isDisableOnEmptyText; } @@ -406,6 +427,13 @@ protected void onAttachButtonClicked() { } } + protected void onSlashButtonClicked() { + Fragment parent = getParentFragment(); + if (parent instanceof InputBarCallback) { + ((InputBarCallback) parent).onSlashPressed(); + } + } + protected void onBeforeTextChanged(CharSequence s, int start, int count, int after) { Fragment parent = getParentFragment(); if (parent instanceof InputBarCallback) { @@ -484,6 +512,7 @@ protected void checkSendButton(boolean hasText) { } else { zoomOutView(attachButton); } + zoomOutView(slashButton); zoomInView(sendButton); zoomOutView(audioButton); } else { @@ -494,6 +523,11 @@ protected void checkSendButton(boolean hasText) { } else { zoomOutView(attachButton); } + if (isSlashEnabled) { + zoomInView(slashButton); + } else { + zoomOutView(slashButton); + } if (isAudioEnabled) { zoomInView(audioButton); zoomOutView(sendButton); @@ -519,6 +553,7 @@ protected void showAudio() { isAudioVisible = true; hideView(attachButton); + hideView(slashButton); hideView(messageEditText); hideView(emojiButton); @@ -561,6 +596,7 @@ protected void hideAudio(boolean cancel) { isAudioVisible = false; showView(attachButton); + showView(slashButton); showView(messageEditText); showView(emojiButton); diff --git a/actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable-hdpi/conv_slash.png b/actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable-hdpi/conv_slash.png new file mode 100644 index 0000000000000000000000000000000000000000..05010ad37f3621f294fb58987dc71190c4510dea GIT binary patch literal 380 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!oCO|{#S9GG!XV7ZFl&wk0|TR; zr;B4q#jUs375$h4MOq*J_dRPM$FnYzqm8xUxFdV$)sHLIExavpTW#wSUjYf8>I7~H zBgX`R$?Yo@f_Qh}i_^Mj5Ay#D%&v4ZK=vP`-DnM*l-JzU11 zx%BPE<`(UYoiSnuWIx<3y}O!~x99j{=?5Yekvd}bVkUb;f@d*3nX_H+lgpmwtOfd~ zKizC%Gn;)@wSaNY*|g2)n%I8rTmSv>*6vA~w>o?o-4zopr0D_U8-v9sr literal 0 HcmV?d00001 diff --git a/actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable-mdpi/conv_slash.png b/actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable-mdpi/conv_slash.png new file mode 100644 index 0000000000000000000000000000000000000000..18e63837e725c224dccf1afe961f71e53a37a3c0 GIT binary patch literal 307 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC&H|6fVg?3oVGw3ym^DWNDEQRV z#W5t~-rH*%y^c7Dv_7oA)}X1gw&e#;Ql_}HW5FpA%}*iw4yv&%yTUqq?VC4mb&sC& zl2qDh*EqL4@j(s0!H0N1Lj@%;sFyzev2OR>eX}Efyx(r#&S9|GIzilN!y~3;nY$Ry zoqcog@!zwI>*O2P?^^fWm2J&ysm9vtrT34rp7~rO=CtF>tp4f)n{)&htXdU2kx{XQ zW6zh`|A8?MUN2d8u*uo>KM|WyypOTZ_WOI=g&cc$4}XXP$#LvpjamO5B*o;n_xWSX tg&Z|zzMo@?4g}xcX8)_Zy8{HK$Nvp+&(oU0a0=*Q22WQ%mvv4FO#sOdfCT^m literal 0 HcmV?d00001 diff --git a/actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable-xhdpi/conv_slash.png b/actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable-xhdpi/conv_slash.png new file mode 100644 index 0000000000000000000000000000000000000000..9b0c640a085257889fc651fd983073621ea7085f GIT binary patch literal 521 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGooCO|{#S9GG!XV7ZFl&wk0|Vo3 zPZ!6Kid%1Q8D=Xv%CvnfXN&yEJZI|C3F`|qb&GuWEa_6{n4fCj*;;nmw2I~3tdN)Q zPOVuLtkWwD$s9g9a+52b^j(@ior6{mt`|$0R3? z^3_*g-FA;J*HLx2y)FFibp4fUSG{UKysMjYLeQ?W_w01Uy2Y8kELrzj!f8gj{M*=T zaV`xnOR6+8@BEcuYd%=c^yRf$_2259G5?eg%zXD>v1RY&TW^`)l&3Yq#gT@cx~;{oh+W_q#YA*wkn% zHGKZCwu9mS+`6@G`Acn>^XBl!Ut_$}p8pL(e0n(h^Sk3l2g-KKYD@3)v=Ufw{^&7_ z=|4Z5wQ}G*Y<`caTa()7Bet#3xhBt!>lWz)m$p&UGM5Y?Xk|Unq%pgr@!C( zesB3BC7}H{K*Q-toeyfRUBA9wM^EpcuwcHuv0R_q;__+Jr_VnVB^Ms@s79*y*mBQG zB_+P}jW%2+XD7`~-G2PcyE9pGTqSksTqaVzd?Fn|yLa!FcRj*>^2c_+<)0%OH9|#> zmM0%$-#n+2Y3}(QOm}BKb&z?ie&zl5^-nARecwD&)b(Td^2?Ryxm;G-oX=k_9y2YK zee=9-Cd+-=7q~5I_lAkM8cWLS>*&}7DR}j|Encs*Xj;#E^Vw%(8aLExUU>TQYt_|` zA4Zb=SzB*0ztjj=S+)0GPsjDi9}kDE{u*M%6_R!5^7BO+d@73_CQniC?#RFVvA|-F zwk)gG*6rKB7rN-En4jNYviq*`ON|L{y&L2He6&sb^YrD+9v6dq-@biIS{n3IS@QqA zyzTZ=`b1ZR0J-;GEp`xp_;Ryuj@9hhv-3k&UtRo!$vP@3YS*;XNJT~M3;$PL&Dwq} zr8vA&br|8L-e zB5P~w>&lP*ru@lXe)(sx6_?4?SINJF7I4enPye~wUO2u&spG}>-|wGQ&dUq!zx}q% z*(z*7(BX#{cI&fN?Ylkww>;~t6W6X?lNS6KX;f!qZeG4Zjw@tU)Y>{>L4DQ7)oa7D zfdVEczdil2&f)US8#i`H3C62DuJ`xzs|(@Xk)s$Pvk|= z>B*^)W!jSce*XUNR~~($wfWa!>E2`Nk<mdKI;Vst041c0^Z)<= literal 0 HcmV?d00001 diff --git a/actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable/button_slash.xml b/actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable/button_slash.xml new file mode 100644 index 0000000000..5216486905 --- /dev/null +++ b/actor-sdk/sdk-core-android/android-sdk/src/main/res/drawable/button_slash.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/actor-sdk/sdk-core-android/android-sdk/src/main/res/layout/fragment_inputbar.xml b/actor-sdk/sdk-core-android/android-sdk/src/main/res/layout/fragment_inputbar.xml index 26ecd31934..52d03bf305 100644 --- a/actor-sdk/sdk-core-android/android-sdk/src/main/res/layout/fragment_inputbar.xml +++ b/actor-sdk/sdk-core-android/android-sdk/src/main/res/layout/fragment_inputbar.xml @@ -23,6 +23,28 @@ android:textCursorDrawable="@null" android:textSize="16sp" /> + + + + + + +