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 000000000..ceb1a1eeb Binary files /dev/null and b/src/main/res/drawable-hdpi/ic_close_white_24dp.png differ diff --git a/src/main/res/drawable-hdpi/ic_input_white_24dp.png b/src/main/res/drawable-hdpi/ic_input_white_24dp.png new file mode 100644 index 000000000..133f60b25 Binary files /dev/null and b/src/main/res/drawable-hdpi/ic_input_white_24dp.png differ 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 000000000..af7f8288d Binary files /dev/null and b/src/main/res/drawable-mdpi/ic_close_white_24dp.png differ 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 000000000..7abc69294 Binary files /dev/null and b/src/main/res/drawable-mdpi/ic_input_white_24dp.png differ diff --git a/src/main/res/drawable-xhdpi/ic_close_white_24dp.png b/src/main/res/drawable-xhdpi/ic_close_white_24dp.png new file mode 100644 index 000000000..b7c7ffd0e Binary files /dev/null and b/src/main/res/drawable-xhdpi/ic_close_white_24dp.png differ 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 000000000..d3c941d06 Binary files /dev/null and b/src/main/res/drawable-xhdpi/ic_input_white_24dp.png differ diff --git a/src/main/res/drawable-xxhdpi/ic_close_white_24dp.png b/src/main/res/drawable-xxhdpi/ic_close_white_24dp.png new file mode 100644 index 000000000..6b717e0dd Binary files /dev/null and b/src/main/res/drawable-xxhdpi/ic_close_white_24dp.png differ diff --git a/src/main/res/drawable-xxhdpi/ic_input_white_24dp.png b/src/main/res/drawable-xxhdpi/ic_input_white_24dp.png new file mode 100644 index 000000000..3b22d00fd Binary files /dev/null and b/src/main/res/drawable-xxhdpi/ic_input_white_24dp.png differ 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 000000000..396419219 Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_close_white_24dp.png differ diff --git a/src/main/res/drawable-xxxhdpi/ic_input_white_24dp.png b/src/main/res/drawable-xxxhdpi/ic_input_white_24dp.png new file mode 100644 index 000000000..77a0ca4d1 Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_input_white_24dp.png differ 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