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.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'
}

View file

@ -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();
}

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_height="match_parent"
android:layout_below="@id/tab_layout"
android:background="?attr/color_background_primary"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:background="?attr/color_background_primary">
</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_height="wrap_content"
android:layout_alignParentEnd="true"
app:backgroundTint="?colorPrimary"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="?attr/icon_add_person"
android:layout_margin="16dp" />
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"/>
</RelativeLayout>
</layout>

View file

@ -8,10 +8,6 @@
android:title="@string/search"
app:actionLayout="@layout/actionview_search"
app:showAsAction="collapseActionView|always"/>
<item
android:id="@+id/action_join_conference"
android:title="@string/join_conference"
app:showAsAction="never"/>
<item
android:id="@+id/action_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_secondary" 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="color_warning" format="reference|color"/>
<attr name="EmojiColor" format="reference|color"/>

View file

@ -12,8 +12,10 @@
<color name="grey50">#fffafafa</color>
<color name="grey200">#ffeeeeee</color>
<color name="grey300">#ffe0e0e0</color>
<color name="grey300_40">#66e0e0e0</color>
<color name="grey500">#ff9e9e9e</color>
<color name="grey700">#ff616161</color>
<color name="grey700_40">#66616161</color>
<color name="grey800">#ff424242</color>
<color name="grey900">#ff282828</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_decrypt_backup">Unable to decrypt backup. Is the password correct?</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>

View file

@ -10,6 +10,7 @@
<item name="color_background_primary">@color/grey50</item>
<item name="color_background_secondary">@color/grey200</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="TextColorOnline">@color/green600</item>
<item name="TextColorError">@color/red800</item>
@ -122,6 +123,7 @@
<item name="color_background_primary">@color/grey800</item>
<item name="color_background_secondary">@color/grey900</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_no_results">@drawable/no_results_background_dark</item>
<item name="list_item_background">@drawable/list_item_background_dark</item>