bump speed dial version to something that uses AndroidX

This commit is contained in:
Daniel Gultsch 2021-10-20 09:52:10 +02:00
parent e0c4964cc2
commit 2ca00265db
3 changed files with 32 additions and 13 deletions

View file

@ -69,7 +69,7 @@ dependencies {
implementation 'org.hsluv:hsluv:0.2' implementation 'org.hsluv:hsluv:0.2'
implementation 'org.conscrypt:conscrypt-android:2.5.2' implementation 'org.conscrypt:conscrypt-android:2.5.2'
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" implementation "com.leinardi.android:speed-dial:3.2.0"
implementation "com.squareup.retrofit2:retrofit:2.9.0" implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0" implementation "com.squareup.retrofit2:converter-gson:2.9.0"

View file

@ -37,11 +37,14 @@ import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.MenuRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -51,6 +54,8 @@ import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import com.google.android.material.textfield.TextInputLayout; import com.google.android.material.textfield.TextInputLayout;
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;
@ -266,8 +271,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
setSupportActionBar(binding.toolbar); setSupportActionBar(binding.toolbar);
configureActionBar(getSupportActionBar()); configureActionBar(getSupportActionBar());
binding.speedDial.inflate(R.menu.start_conversation_fab_submenu); inflateFab(binding.speedDial, R.menu.start_conversation_fab_submenu);
binding.tabLayout.setupWithViewPager(binding.startConversationViewPager); binding.tabLayout.setupWithViewPager(binding.startConversationViewPager);
binding.startConversationViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { binding.startConversationViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override @Override
@ -338,6 +342,21 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
}); });
} }
private void inflateFab(final SpeedDialView speedDialView, final @MenuRes int menuRes) {
speedDialView.clearActionItems();
final PopupMenu popupMenu = new PopupMenu(this, new View(this));
popupMenu.inflate(menuRes);
final Menu menu = popupMenu.getMenu();
for (int i = 0; i < menu.size(); i++) {
final MenuItem menuItem = menu.getItem(i);
final SpeedDialActionItem actionItem = new SpeedDialActionItem.Builder(menuItem.getItemId(), menuItem.getIcon())
.setLabel(menuItem.getTitle() != null ? menuItem.getTitle().toString() : null)
.setFabImageTintColor(ContextCompat.getColor(this, R.color.white))
.create();
speedDialView.addActionItem(actionItem);
}
}
public static boolean isValidJid(String input) { public static boolean isValidJid(String input) {
try { try {
Jid jid = Jid.ofEscaped(input); Jid jid = Jid.ofEscaped(input);

View file

@ -2,22 +2,22 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:id="@+id/discover_public_channels" android:id="@+id/discover_public_channels"
android:title="@string/discover_channels" android:icon="@drawable/ic_search_white_24dp"
android:icon="@drawable/ic_search_white_24dp"/> android:title="@string/discover_channels" />
<item <item
android:id="@+id/join_public_channel" android:id="@+id/join_public_channel"
android:title="@string/join_public_channel" android:icon="@drawable/ic_input_white_24dp"
android:icon="@drawable/ic_input_white_24dp"/> android:title="@string/join_public_channel" />
<item <item
android:id="@+id/create_public_channel" android:id="@+id/create_public_channel"
android:title="@string/create_public_channel" android:icon="@drawable/ic_public_white_24dp"
android:icon="@drawable/ic_public_white_24dp"/> android:title="@string/create_public_channel" />
<item <item
android:id="@+id/create_private_group_chat" android:id="@+id/create_private_group_chat"
android:title="@string/create_private_group_chat" android:icon="@drawable/ic_group_white_24dp"
android:icon="@drawable/ic_group_white_24dp"/> android:title="@string/create_private_group_chat" />
<item <item
android:id="@+id/create_contact" android:id="@+id/create_contact"
android:title="@string/add_contact" android:icon="@drawable/ic_person_white_48dp"
android:icon="@drawable/ic_person_white_48dp"/> android:title="@string/add_contact" />
</menu> </menu>