show sub menu fabs for create group chats. fixes #2950

This commit is contained in:
Daniel Gultsch 2019-01-27 16:35:55 +01:00
parent 20e731c956
commit 2bc9fdf5d3
19 changed files with 87 additions and 30 deletions

View File

@ -63,6 +63,7 @@ dependencies {
implementation 'org.hsluv:hsluv:0.2' implementation 'org.hsluv:hsluv:0.2'
implementation 'org.conscrypt:conscrypt-android:1.3.0' implementation 'org.conscrypt:conscrypt-android:1.3.0'
implementation 'me.drakeet.support:toastcompat:1.1.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' quicksyImplementation 'io.michaelrocks:libphonenumber-android:8.10.1'
} }

View File

@ -21,6 +21,7 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.ListFragment; import android.support.v4.app.ListFragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerAdapter; import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
@ -55,6 +56,9 @@ import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.leinardi.android.speeddial.SpeedDialActionItem;
import com.leinardi.android.speeddial.SpeedDialView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; 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.MenuDoubleTabUtil;
import eu.siacs.conversations.ui.util.PendingItem; import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.ui.util.SoftKeyboardUtils; 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.ui.widget.SwipeRefreshListFragment;
import eu.siacs.conversations.utils.AccountUtils; import eu.siacs.conversations.utils.AccountUtils;
import eu.siacs.conversations.utils.XmppUri; import eu.siacs.conversations.utils.XmppUri;
@ -122,7 +127,9 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
imm.showSoftInput(mSearchEditText, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(mSearchEditText, InputMethodManager.SHOW_IMPLICIT);
} }
}); });
if (binding.speedDial.isOpen()) {
binding.speedDial.close();
}
return true; return true;
} }
@ -272,7 +279,9 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
Toolbar toolbar = (Toolbar) binding.toolbar; Toolbar toolbar = (Toolbar) binding.toolbar;
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
configureActionBar(getSupportActionBar()); configureActionBar(getSupportActionBar());
this.binding.fab.setOnClickListener((v) -> { this.binding.speedDial.setOnChangeListener(new SpeedDialView.OnChangeListener() {
@Override
public boolean onMainActionSelected() {
if (binding.startConversationViewPager.getCurrentItem() == 0) { if (binding.startConversationViewPager.getCurrentItem() == 0) {
String searchString = mSearchEditText != null ? mSearchEditText.getText().toString() : null; String searchString = mSearchEditText != null ? mSearchEditText.getText().toString() : null;
if (searchString != null && !searchString.trim().isEmpty()) { if (searchString != null && !searchString.trim().isEmpty()) {
@ -280,17 +289,23 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
Jid jid = Jid.of(searchString); Jid jid = Jid.of(searchString);
if (jid.getLocal() != null && jid.isBareJid() && jid.getDomain().contains(".")) { if (jid.getLocal() != null && jid.isBareJid() && jid.getDomain().contains(".")) {
showCreateContactDialog(jid.toString(), null); showCreateContactDialog(jid.toString(), null);
return; return false;
} }
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
//ignore and fall through //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.tabLayout.setupWithViewPager(binding.startConversationViewPager);
binding.startConversationViewPager.addOnPageChangeListener(mOnPageChangeListener); binding.startConversationViewPager.addOnPageChangeListener(mOnPageChangeListener);
mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager()); mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager());
@ -326,6 +341,17 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
mInitialSearchValue.push(""); mInitialSearchValue.push("");
} }
mRequestedContactsPermission.set(savedInstanceState != null && savedInstanceState.getBoolean("requested_contacts_permission",false)); 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 @Override
@ -593,9 +619,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
getMenuInflater().inflate(R.menu.start_conversation, menu); getMenuInflater().inflate(R.menu.start_conversation, menu);
AccountUtils.showHideMenuItems(menu); AccountUtils.showHideMenuItems(menu);
MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline); 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); MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
joinGroupChat.setVisible(binding.startConversationViewPager.getCurrentItem() == 1);
qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable()); qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable());
if (QuickConversationsService.isQuicksy()) { if (QuickConversationsService.isQuicksy()) {
menuHideOffline.setVisible(false); menuHideOffline.setVisible(false);
@ -628,9 +652,6 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
case android.R.id.home: case android.R.id.home:
navigateBack(); navigateBack();
return true; return true;
case R.id.action_join_conference:
showJoinConferenceDialog(null);
return true;
case R.id.action_scan_qr_code: case R.id.action_scan_qr_code:
UriHandlerActivity.scan(this); UriHandlerActivity.scan(this);
return true; return true;
@ -927,10 +948,12 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
@DrawableRes final int fabDrawable; @DrawableRes final int fabDrawable;
if (binding.startConversationViewPager.getCurrentItem() == 0) { if (binding.startConversationViewPager.getCurrentItem() == 0) {
fabDrawable = R.drawable.ic_person_add_white_24dp; fabDrawable = R.drawable.ic_person_add_white_24dp;
binding.speedDial.clearActionItems();
} else { } else {
fabDrawable = R.drawable.ic_group_add_white_24dp; 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(); invalidateOptionsMenu();
} }
@ -952,6 +975,10 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (binding.speedDial.isOpen()) {
binding.speedDial.close();
return;
}
navigateBack(); navigateBack();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

View File

@ -25,16 +25,31 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_below="@id/tab_layout" android:layout_below="@id/tab_layout"
android:background="?attr/color_background_primary"/> android:background="?attr/color_background_primary">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
</android.support.v4.view.ViewPager>
<com.leinardi.android.speeddial.SpeedDialOverlayLayout
android:id="@+id/overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/tab_layout"
android:background="?color_background_overlay"/>
<com.leinardi.android.speeddial.SpeedDialView
android:id="@+id/speed_dial"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
app:backgroundTint="?colorPrimary" app:backgroundTint="?colorPrimary"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:src="?attr/icon_add_person" app:sdMainFabClosedSrc="@drawable/ic_person_add_white_24dp"
android:layout_margin="16dp" /> app:sdMainFabClosedBackgroundColor="?colorPrimary"
app:sdMainFabOpenedSrc="@drawable/ic_close_white_24dp"
app:sdMainFabOpenedBackgroundColor="?colorPrimaryDark"
app:sdOverlayLayout="@id/overlay"/>
</RelativeLayout> </RelativeLayout>
</layout> </layout>

View File

@ -8,10 +8,6 @@
android:title="@string/search" android:title="@string/search"
app:actionLayout="@layout/actionview_search" app:actionLayout="@layout/actionview_search"
app:showAsAction="collapseActionView|always"/> app:showAsAction="collapseActionView|always"/>
<item
android:id="@+id/action_join_conference"
android:title="@string/join_conference"
app:showAsAction="never"/>
<item <item
android:id="@+id/action_scan_qr_code" android:id="@+id/action_scan_qr_code"
android:title="@string/scan_qr_code" android:title="@string/scan_qr_code"

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/enter"
android:title="@string/enter_jabber_id"
android:icon="@drawable/ic_input_white_24dp"/>
<item
android:id="@+id/create"
android:title="@string/create_group_chat"
android:icon="@drawable/ic_edit_white_24dp"/>
</menu>

View File

@ -15,6 +15,7 @@
<attr name="color_background_tertiary" format="reference|color"/> <attr name="color_background_tertiary" format="reference|color"/>
<attr name="color_background_secondary" format="reference|color"/> <attr name="color_background_secondary" format="reference|color"/>
<attr name="color_background_primary" format="reference|color"/> <attr name="color_background_primary" format="reference|color"/>
<attr name="color_background_overlay" format="reference|color"/>
<attr name="edit_text_color" format="reference|color"/> <attr name="edit_text_color" format="reference|color"/>
<attr name="color_warning" format="reference|color"/> <attr name="color_warning" format="reference|color"/>
<attr name="EmojiColor" format="reference|color"/> <attr name="EmojiColor" format="reference|color"/>

View File

@ -12,8 +12,10 @@
<color name="grey50">#fffafafa</color> <color name="grey50">#fffafafa</color>
<color name="grey200">#ffeeeeee</color> <color name="grey200">#ffeeeeee</color>
<color name="grey300">#ffe0e0e0</color> <color name="grey300">#ffe0e0e0</color>
<color name="grey300_40">#66e0e0e0</color>
<color name="grey500">#ff9e9e9e</color> <color name="grey500">#ff9e9e9e</color>
<color name="grey700">#ff616161</color> <color name="grey700">#ff616161</color>
<color name="grey700_40">#66616161</color>
<color name="grey800">#ff424242</color> <color name="grey800">#ff424242</color>
<color name="grey900">#ff282828</color> <color name="grey900">#ff282828</color>
<color name="red500">#fff44336</color> <color name="red500">#fff44336</color>

View File

@ -822,4 +822,6 @@
<string name="unable_to_restore_backup">Unable to restore backup.</string> <string name="unable_to_restore_backup">Unable to restore backup.</string>
<string name="unable_to_decrypt_backup">Unable to decrypt backup. Is the password correct?</string> <string name="unable_to_decrypt_backup">Unable to decrypt backup. Is the password correct?</string>
<string name="backup_channel_name">Backup &amp; Restore</string> <string name="backup_channel_name">Backup &amp; Restore</string>
<string name="enter_jabber_id">Enter Jabber ID</string>
<string name="create_group_chat">Create group chat</string>
</resources> </resources>

View File

@ -10,6 +10,7 @@
<item name="color_background_primary">@color/grey50</item> <item name="color_background_primary">@color/grey50</item>
<item name="color_background_secondary">@color/grey200</item> <item name="color_background_secondary">@color/grey200</item>
<item name="color_background_tertiary">@color/grey300</item> <item name="color_background_tertiary">@color/grey300</item>
<item name="color_background_overlay">@color/grey300_40</item>
<item name="color_warning">@color/red_a700</item> <item name="color_warning">@color/red_a700</item>
<item name="TextColorOnline">@color/green600</item> <item name="TextColorOnline">@color/green600</item>
<item name="TextColorError">@color/red800</item> <item name="TextColorError">@color/red800</item>
@ -122,6 +123,7 @@
<item name="color_background_primary">@color/grey800</item> <item name="color_background_primary">@color/grey800</item>
<item name="color_background_secondary">@color/grey900</item> <item name="color_background_secondary">@color/grey900</item>
<item name="color_background_tertiary">@color/grey700</item> <item name="color_background_tertiary">@color/grey700</item>
<item name="color_background_overlay">@color/grey700_40</item>
<item name="activity_background_search">@drawable/search_background_dark</item> <item name="activity_background_search">@drawable/search_background_dark</item>
<item name="activity_background_no_results">@drawable/no_results_background_dark</item> <item name="activity_background_no_results">@drawable/no_results_background_dark</item>
<item name="list_item_background">@drawable/list_item_background_dark</item> <item name="list_item_background">@drawable/list_item_background_dark</item>