From 2bc9fdf5d3ef5d46b5cc1eebed50bb759d7297d4 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 27 Jan 2019 16:35:55 +0100 Subject: [PATCH] show sub menu fabs for create group chats. fixes #2950 --- build.gradle | 1 + .../ui/StartConversationActivity.java | 69 ++++++++++++------ .../res/drawable-hdpi/ic_close_white_24dp.png | Bin 0 -> 221 bytes .../res/drawable-hdpi/ic_input_white_24dp.png | Bin 0 -> 226 bytes .../res/drawable-mdpi/ic_close_white_24dp.png | Bin 0 -> 175 bytes .../res/drawable-mdpi/ic_input_white_24dp.png | Bin 0 -> 148 bytes .../drawable-xhdpi/ic_close_white_24dp.png | Bin 0 -> 257 bytes .../drawable-xhdpi/ic_input_white_24dp.png | Bin 0 -> 219 bytes .../drawable-xxhdpi/ic_close_white_24dp.png | Bin 0 -> 347 bytes .../drawable-xxhdpi/ic_input_white_24dp.png | Bin 0 -> 303 bytes .../drawable-xxxhdpi/ic_close_white_24dp.png | Bin 0 -> 436 bytes .../drawable-xxxhdpi/ic_input_white_24dp.png | Bin 0 -> 382 bytes .../layout/activity_start_conversation.xml | 25 +++++-- src/main/res/menu/start_conversation.xml | 4 - .../res/menu/start_conversation_group_fab.xml | 11 +++ src/main/res/values/attrs.xml | 1 + src/main/res/values/colors.xml | 2 + src/main/res/values/strings.xml | 2 + src/main/res/values/themes.xml | 2 + 19 files changed, 87 insertions(+), 30 deletions(-) create mode 100644 src/main/res/drawable-hdpi/ic_close_white_24dp.png create mode 100644 src/main/res/drawable-hdpi/ic_input_white_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_close_white_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_input_white_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_close_white_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_input_white_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_close_white_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_input_white_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_close_white_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_input_white_24dp.png create mode 100644 src/main/res/menu/start_conversation_group_fab.xml diff --git a/build.gradle b/build.gradle index ba4a36ebf..19efaad00 100644 --- a/build.gradle +++ b/build.gradle @@ -63,6 +63,7 @@ dependencies { implementation 'org.hsluv:hsluv:0.2' implementation 'org.conscrypt:conscrypt-android:1.3.0' implementation 'me.drakeet.support:toastcompat:1.1.0' + implementation "com.leinardi.android:speed-dial:2.0.1" quicksyImplementation 'io.michaelrocks:libphonenumber-android:8.10.1' } diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 66af744a8..df78a6618 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -21,6 +21,7 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v4.app.ListFragment; +import android.support.v4.content.ContextCompat; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v4.widget.SwipeRefreshLayout; @@ -55,6 +56,9 @@ import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; +import com.leinardi.android.speeddial.SpeedDialActionItem; +import com.leinardi.android.speeddial.SpeedDialView; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -79,6 +83,7 @@ import eu.siacs.conversations.ui.util.JidDialog; import eu.siacs.conversations.ui.util.MenuDoubleTabUtil; import eu.siacs.conversations.ui.util.PendingItem; import eu.siacs.conversations.ui.util.SoftKeyboardUtils; +import eu.siacs.conversations.ui.util.StyledAttributes; import eu.siacs.conversations.ui.widget.SwipeRefreshListFragment; import eu.siacs.conversations.utils.AccountUtils; import eu.siacs.conversations.utils.XmppUri; @@ -122,7 +127,9 @@ public class StartConversationActivity extends XmppActivity implements XmppConne imm.showSoftInput(mSearchEditText, InputMethodManager.SHOW_IMPLICIT); } }); - + if (binding.speedDial.isOpen()) { + binding.speedDial.close(); + } return true; } @@ -272,25 +279,33 @@ public class StartConversationActivity extends XmppActivity implements XmppConne Toolbar toolbar = (Toolbar) binding.toolbar; setSupportActionBar(toolbar); configureActionBar(getSupportActionBar()); - this.binding.fab.setOnClickListener((v) -> { - if (binding.startConversationViewPager.getCurrentItem() == 0) { - String searchString = mSearchEditText != null ? mSearchEditText.getText().toString() : null; - if (searchString != null && !searchString.trim().isEmpty()) { - try { - Jid jid = Jid.of(searchString); - if (jid.getLocal() != null && jid.isBareJid() && jid.getDomain().contains(".")) { - showCreateContactDialog(jid.toString(), null); - return; + this.binding.speedDial.setOnChangeListener(new SpeedDialView.OnChangeListener() { + @Override + public boolean onMainActionSelected() { + if (binding.startConversationViewPager.getCurrentItem() == 0) { + String searchString = mSearchEditText != null ? mSearchEditText.getText().toString() : null; + if (searchString != null && !searchString.trim().isEmpty()) { + try { + Jid jid = Jid.of(searchString); + if (jid.getLocal() != null && jid.isBareJid() && jid.getDomain().contains(".")) { + showCreateContactDialog(jid.toString(), null); + return false; + } + } catch (IllegalArgumentException ignored) { + //ignore and fall through } - } catch (IllegalArgumentException ignored) { - //ignore and fall through } + showCreateContactDialog(null, null); } - showCreateContactDialog(null, null); - } else { - showCreateConferenceDialog(); + return false; + } + + @Override + public void onToggleChanged(boolean isOpen) { + } }); + binding.tabLayout.setupWithViewPager(binding.startConversationViewPager); binding.startConversationViewPager.addOnPageChangeListener(mOnPageChangeListener); mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager()); @@ -326,6 +341,17 @@ public class StartConversationActivity extends XmppActivity implements XmppConne mInitialSearchValue.push(""); } mRequestedContactsPermission.set(savedInstanceState != null && savedInstanceState.getBoolean("requested_contacts_permission",false)); + binding.speedDial.setOnActionSelectedListener(actionItem -> { + switch (actionItem.getId()) { + case R.id.enter: + showJoinConferenceDialog(null); + break; + case R.id.create: + showCreateConferenceDialog(); + break; + } + return false; + }); } @Override @@ -593,9 +619,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne getMenuInflater().inflate(R.menu.start_conversation, menu); AccountUtils.showHideMenuItems(menu); MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline); - MenuItem joinGroupChat = menu.findItem(R.id.action_join_conference); MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code); - joinGroupChat.setVisible(binding.startConversationViewPager.getCurrentItem() == 1); qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable()); if (QuickConversationsService.isQuicksy()) { menuHideOffline.setVisible(false); @@ -628,9 +652,6 @@ public class StartConversationActivity extends XmppActivity implements XmppConne case android.R.id.home: navigateBack(); return true; - case R.id.action_join_conference: - showJoinConferenceDialog(null); - return true; case R.id.action_scan_qr_code: UriHandlerActivity.scan(this); return true; @@ -927,10 +948,12 @@ public class StartConversationActivity extends XmppActivity implements XmppConne @DrawableRes final int fabDrawable; if (binding.startConversationViewPager.getCurrentItem() == 0) { fabDrawable = R.drawable.ic_person_add_white_24dp; + binding.speedDial.clearActionItems(); } else { fabDrawable = R.drawable.ic_group_add_white_24dp; + binding.speedDial.inflate(R.menu.start_conversation_group_fab); } - binding.fab.setImageResource(fabDrawable); + binding.speedDial.setMainFabClosedDrawable(ContextCompat.getDrawable(this,fabDrawable)); invalidateOptionsMenu(); } @@ -952,6 +975,10 @@ public class StartConversationActivity extends XmppActivity implements XmppConne @Override public void onBackPressed() { + if (binding.speedDial.isOpen()) { + binding.speedDial.close(); + return; + } navigateBack(); } diff --git a/src/main/res/drawable-hdpi/ic_close_white_24dp.png b/src/main/res/drawable-hdpi/ic_close_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..ceb1a1eebf2b2cc9a008f42010e144f4dab968de GIT binary patch literal 221 zcmV<303!d1P)og+*{ z>6z1@lfD*AYSPav7)mQagIyMzXunR9_N&ai|MPQnU|d;dFhqFx(nNKc!Wm)@z@h4PD!lpKmw zezZ5KCa&j0`b literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-mdpi/ic_close_white_24dp.png b/src/main/res/drawable-mdpi/ic_close_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..af7f8288da6854204dcc4e6678b9053cd72032c4 GIT binary patch literal 175 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_+iGEW!B5R21KC-3Avpdi4K$<+1X zay^SH!@6{thMdKZi+L1hS^BMZUAdKCT}(HRw{NeWg~AlBHtr3jj>2B5kK^|J))MUC zlz7ydwCsb8xn}W?^r?}5wtsjdmvX{3=JbT!J9sKPrYmk={m|7^>A|Z*7j^D$`>}ry Zqi^Z9GQN4ct^!@a;OXk;vd$@?2>?I&LQeny literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-mdpi/ic_input_white_24dp.png b/src/main/res/drawable-mdpi/ic_input_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..7abc692947a75e72df0ebb0bdb9616f04748a687 GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_+iXipc%kP61LmmIko40v2F$^@L4 zS`^WG!vlFZg zOA5m<3jYBNi%A&<@ZO?$P9};P4Y5CjG5$M&YXI45J{s}~# zf|&?x1_gn4B7+hS@X!l}&!voFhmZP^sujifL@~PKMMM~{6xH}^g$q7WOzwCQ5vHTU z6`v~H@rlA8e;CUh_(b84zg=+ih`wG<)HiJjzSlQx5#CnjMR;A)R^jtaTa9;7rSy)7O%~`cm?ZjXImW?6TYRT<;U^@VKiSj`soFk00000NkvXX Hu0mjfhD&W| literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xhdpi/ic_input_white_24dp.png b/src/main/res/drawable-xhdpi/ic_input_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..d3c941d060de2c3a740e1eac27602307dbc1a772 GIT binary patch literal 219 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0DMV>B>Ar*{ouN!h5au8^JxU+jl z#hIOb8i5}oyhL0*6#oc0-8iI`7`M^lzx9Fe7M{-3z*LdGFEvfy7A#J9+*8;(??sgt ztCh%Htq&<#9Jj8lW-1ojvXe#V$K2J7A4Cr{G47CJ2xoqf#ZV);K@G_0WnNc*!s)>5 zx{EP2Z*Ey!*PiCUl>hbkdsf%yTyJ({*E{s+vgh$Q?%tH%9O|%xvMkH8EXyh{JTRaptiwcq@D(P;=ehLbl?EMKm*m7(@7_siS}}k zNFtnck{HL4mc!ypcyUoqJV~4rM^fS3C#iAnkyJU3biCmDy`VZLOv=LXld^HVq?qLs@!k^K z=Bk4oD;{vZ%6WBYf8v4a9`5FIPCsH!T$uLY)WX$n_rB|WXr8cSww{;f(z;&W=)8)D ziywcxQ|PwzjP@DpClgn&_0=_L`Ma0}*uI$Z;+*Y^X)oT{zLc0lF{>5A`{y{c5(rYVe;MbP4;@#_XV;SZ7VLQUW~1{z<7SA+y}1XJT6;5`_K8Tr5BlFmjOB0vh5&=7tDnm{r-UW|CoqF* literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxxhdpi/ic_close_white_24dp.png b/src/main/res/drawable-xxxhdpi/ic_close_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..39641921925f090e33df2767a4ee5e6d5911194f GIT binary patch literal 436 zcmV;l0ZaagP)32ETvhYyB39D^lU%DgQgv&#U%8l^-CA%qY@2qA=!B5=cm zUgehujQG*l{{`@rPr!f|fEk^>KI9WteE@ilV6HEl&_rJ@p_zU*;T}RirIc{5NocNLm*7JGdV(AM zYYDFOvk5~8{Z*t_>U=!XvoehUSEh=adIga45oe)B9kGgT}7UT3Cirmr(oHPv^YQ1-p=Hlh5u;xggf zX{&yw+El-OrrKQJRl@b7x{HLmNkj95`a#LLnW{Veb2C+!`ppt#r)=g4@?c8RY{yJj~W@W|h^mU4q`i)2y~Rw@J`jIh$1%|In!~{Tb{nMqaxlgb+dq eA%qY@zJ@mriVM?qfwL0;0000G>&KNb zdplNiG^zi&t|YZc@W^bB1I!(*O#(K~vm6|l^X$AO|8I<$>3;9~sww*u3epo!`=7IX zKBu@(*=^6J2b(wQRy^!-_S*X^`8cnw?sem&=lTxEMOx)vm@(%CX71rEI3zW-s?Ru~ zDd;iJjD=UC+19LxHruwVpXWzxX3iDKga$@72@qkz%TdbEV#VMj%V21euwo+TEC#s1 zLcWFoc83+r3T@1P!r`24Vh`*U|92#N|DX6X@DP9T#-;31@|v|P_~Uaj<8*%&UBCX? zl>=_R#D+zA_inrjll;&Zw3%mz^GZ*)ISVh(y3C_-C%g8)On7MYxT)tcs zAMgT}?vdUMYSKY#Q5`i3LvAZHpdmw@ORW^a*htx~D}E5LAN@O1TaS?83{ F1OS~Am0SP- literal 0 HcmV?d00001 diff --git a/src/main/res/layout/activity_start_conversation.xml b/src/main/res/layout/activity_start_conversation.xml index d28bd0d63..e6651d174 100644 --- a/src/main/res/layout/activity_start_conversation.xml +++ b/src/main/res/layout/activity_start_conversation.xml @@ -25,16 +25,31 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/tab_layout" - android:background="?attr/color_background_primary"/> - + + + + + + + + + app:sdMainFabClosedSrc="@drawable/ic_person_add_white_24dp" + app:sdMainFabClosedBackgroundColor="?colorPrimary" + app:sdMainFabOpenedSrc="@drawable/ic_close_white_24dp" + app:sdMainFabOpenedBackgroundColor="?colorPrimaryDark" + app:sdOverlayLayout="@id/overlay"/> diff --git a/src/main/res/menu/start_conversation.xml b/src/main/res/menu/start_conversation.xml index c7709c665..ffbcc0c44 100644 --- a/src/main/res/menu/start_conversation.xml +++ b/src/main/res/menu/start_conversation.xml @@ -8,10 +8,6 @@ android:title="@string/search" app:actionLayout="@layout/actionview_search" app:showAsAction="collapseActionView|always"/> - + + + + \ No newline at end of file diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index 47ae372eb..2c2acba97 100644 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -15,6 +15,7 @@ + diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml index 69474a4b4..074b5ae30 100644 --- a/src/main/res/values/colors.xml +++ b/src/main/res/values/colors.xml @@ -12,8 +12,10 @@ #fffafafa #ffeeeeee #ffe0e0e0 + #66e0e0e0 #ff9e9e9e #ff616161 + #66616161 #ff424242 #ff282828 #fff44336 diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index e6265d942..bf0c7d662 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -822,4 +822,6 @@ Unable to restore backup. Unable to decrypt backup. Is the password correct? Backup & Restore + Enter Jabber ID + Create group chat diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 971fb8ef9..f7522f284 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -10,6 +10,7 @@ @color/grey50 @color/grey200 @color/grey300 + @color/grey300_40 @color/red_a700 @color/green600 @color/red800 @@ -122,6 +123,7 @@ @color/grey800 @color/grey900 @color/grey700 + @color/grey700_40 @drawable/search_background_dark @drawable/no_results_background_dark @drawable/list_item_background_dark