Switch to Floating Action Button Speed Dial

FABsMenu is now deprecated (and crashes on KitKat)

Fixes #186
This commit is contained in:
Jakob Nixdorf 2018-06-04 12:29:27 +02:00
parent 00a6085b29
commit d493f95f5a
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
7 changed files with 92 additions and 106 deletions

View file

@ -149,7 +149,7 @@ So make sure you have a **current backup** before switching!
* [AboutLibraries](https://github.com/mikepenz/AboutLibraries)
* [Apache Commons Codec](https://commons.apache.org/proper/commons-codec/)
* [Expandable Layout](https://github.com/AAkira/ExpandableLayout)
* [FABsMenu](https://github.com/jahirfiquitiva/FABsMenu)
* [Floating Action Button Speed Dial](https://github.com/leinardi/FloatingActionButtonSpeedDial)
* [material-intro](https://github.com/heinrichreimer/material-intro)
* [MaterialProgressBar](https://github.com/DreaminginCodeZH/MaterialProgressBar)
* [OpenPGP API library](https://github.com/open-keychain/openpgp-api)
@ -165,6 +165,7 @@ So make sure you have a **current backup** before switching!
#### Previously used open-source components:
* [FABsMenu](https://github.com/jahirfiquitiva/FABsMenu)
* [LicensesDialog](https://github.com/PSDev/LicensesDialog)
#### Previously used code examples:

View file

@ -46,6 +46,6 @@ dependencies {
implementation "com.vanniktech:vntnumberpickerpreference:1.0.0"
implementation "me.zhanghai.android.materialprogressbar:library:1.4.2"
implementation "org.sufficientlysecure:openpgp-api:12.0"
implementation "me.jahirfiquitiva:FABsMenu:1.1.2"
implementation "com.leinardi.android:speed-dial:1.0.0"
implementation "com.mikepenz:aboutlibraries:6.0.6"
}

View file

@ -53,6 +53,8 @@ import android.widget.Toast;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.leinardi.android.speeddial.SpeedDialActionItem;
import com.leinardi.android.speeddial.SpeedDialView;
import org.shadowice.flocke.andotp.Database.Entry;
import org.shadowice.flocke.andotp.R;
@ -71,9 +73,6 @@ import java.util.HashMap;
import javax.crypto.SecretKey;
import jahirfiquitiva.libs.fabsmenu.FABsMenu;
import jahirfiquitiva.libs.fabsmenu.TitleFAB;
import static org.shadowice.flocke.andotp.Utilities.Constants.AuthMethod;
import static org.shadowice.flocke.andotp.Utilities.Constants.EncryptionType;
import static org.shadowice.flocke.andotp.Utilities.Constants.SortMode;
@ -86,7 +85,7 @@ public class MainActivity extends BaseActivity
private static final String INTENT_ENTER_DETAILS = "org.shadowice.flocke.andotp.intent.ENTER_DETAILS";
private EntriesCardAdapter adapter;
private FABsMenu fabsMenu;
private SpeedDialView speedDial;
private MenuItem sortMenu;
private SimpleItemTouchHelperCallback touchHelperCallback;
@ -198,23 +197,22 @@ public class MainActivity extends BaseActivity
showFirstTimeWarning();
}
fabsMenu = findViewById(R.id.fabs_menu);
speedDial = findViewById(R.id.speedDial);
speedDial.inflate(R.menu.menu_fab);
TitleFAB qrFAB = findViewById(R.id.fab_qr_scan);
qrFAB.setOnClickListener(new View.OnClickListener() {
speedDial.setOnActionSelectedListener(new SpeedDialView.OnActionSelectedListener() {
@Override
public void onClick(View view) {
fabsMenu.collapse();
scanQRCode();
}
});
TitleFAB manualFAB = findViewById(R.id.fab_manual_entry);
manualFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
fabsMenu.collapse();
ManualEntryDialog.show(MainActivity.this, settings, adapter);
public boolean onActionSelected(SpeedDialActionItem speedDialActionItem) {
switch (speedDialActionItem.getId()) {
case R.id.fabScanQR:
scanQRCode();
return false;
case R.id.fabEnterDetails:
ManualEntryDialog.show(MainActivity.this, settings, adapter);
return false;
default:
return false;
}
}
});
@ -467,7 +465,7 @@ public class MainActivity extends BaseActivity
searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem menuItem) {
fabsMenu.setVisibility(View.GONE);
speedDial.setVisibility(View.GONE);
touchHelperCallback.setDragEnabled(false);
if (sortMenu != null)
sortMenu.setVisible(false);
@ -476,7 +474,7 @@ public class MainActivity extends BaseActivity
@Override
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
fabsMenu.setVisibility(View.VISIBLE);
speedDial.setVisibility(View.VISIBLE);
if (adapter == null || adapter.getSortMode() == SortMode.UNSORTED)
touchHelperCallback.setDragEnabled(true);

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -44,6 +45,45 @@
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<RelativeLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/cardList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:paddingStart="@dimen/activity_margin_small"
android:paddingEnd="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_xsmall"
android:paddingBottom="@dimen/fab_recyclerview_padding"
android:clipToPadding="false" />
<include layout="@layout/component_tags" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
<com.leinardi.android.speeddial.SpeedDialOverlayLayout
android:id="@+id/speedDialOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.leinardi.android.speeddial.SpeedDialView
android:id="@+id/speedDial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
app:sdMainFabClosedSrc="@drawable/ic_add_white"
app:sdOverlayLayout="@id/speedDialOverlay" />
</android.support.design.widget.CoordinatorLayout>

View file

@ -1,81 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="org.shadowice.flocke.andotp.Activities.MainActivity"
tools:showIn="@layout/activity_main">
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/cardList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:paddingStart="@dimen/activity_margin_small"
android:paddingEnd="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_xsmall"
android:paddingBottom="@dimen/fab_recyclerview_padding"
android:clipToPadding="false" />
<jahirfiquitiva.libs.fabsmenu.FABsMenuLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:fabs_menu_overlayColor="#4d000000"
app:fabs_menu_clickableOverlay="true"
tools:layout_behavior="@string/fabs_menu_layout_behavior">
<jahirfiquitiva.libs.fabsmenu.FABsMenu
android:id="@+id/fabs_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:clipChildren="false"
app:fab_moreButtonPlusIcon="@drawable/ic_add_white"
app:fab_moreButtonBackgroundColor="@color/colorAccent"
app:fab_moreButtonRippleColor="@color/colorAccent"
app:fab_moreButtonSize="normal"
app:fab_labelsPosition="left"
app:fab_expandDirection="up">
<jahirfiquitiva.libs.fabsmenu.TitleFAB
android:id="@+id/fab_qr_scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_camera_white"
app:fabSize="mini"
app:backgroundTint="@color/colorAccent"
app:rippleColor="@color/colorAccent"
app:fab_title="@string/button_scan_qr"
app:fab_title_textColor="?android:attr/colorForeground"
app:fab_title_backgroundColor="?android:attr/colorBackground"/>
<jahirfiquitiva.libs.fabsmenu.TitleFAB
android:id="@+id/fab_manual_entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_edit_white"
app:fabSize="mini"
app:backgroundTint="@color/colorAccent"
app:rippleColor="@color/colorAccent"
app:fab_title="@string/button_enter_details"
app:fab_enableTitleClick="true"
app:fab_title_textColor="?android:attr/colorForeground"
app:fab_title_backgroundColor="?android:attr/colorBackground" />
</jahirfiquitiva.libs.fabsmenu.FABsMenu>
</jahirfiquitiva.libs.fabsmenu.FABsMenuLayout>
<include layout="@layout/component_tags" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/fabEnterDetails"
android:title="@string/button_enter_details"
android:icon="@drawable/ic_edit_white" />
<item
android:id="@+id/fabScanQR"
android:title="@string/button_scan_qr"
android:icon="@drawable/ic_camera_white" />
</menu>

View file

@ -35,6 +35,22 @@
<string name="library_ExpandableLayout_licenseId">apache_2_0</string>
<!-- Floating Action Button Speed Dial -->
<string name="define_FloatingActionButtonSpeedDial"></string>
<string name="library_FloatingActionButtonSpeedDial_author">Roberto Leinardi</string>
<string name="library_FloatingActionButtonSpeedDial_libraryName">Floating Action Button Speed Dial</string>
<string name="library_FloatingActionButtonSpeedDial_libraryDescription">Android library providing an implementation of the Material Design Floating Action Button Speed Dial.</string>
<string name="library_FloatingActionButtonSpeedDial_libraryWebsite">https://github.com/leinardi/FloatingActionButtonSpeedDial</string>
<string name="library_FloatingActionButtonSpeedDial_libraryVersion">1.0.0</string>
<string name="library_FloatingActionButtonSpeedDial_isOpenSource">true</string>
<string name="library_FloatingActionButtonSpeedDial_repositoryLink">https://github.com/leinardi/FloatingActionButtonSpeedDial</string>
<string name="library_FloatingActionButtonSpeedDial_classPath">com.leinardi.android.speeddial.SpeedDialView</string>
<string name="library_FloatingActionButtonSpeedDial_licenseId">apache_2_0</string>
<!-- material-intro -->
<string name="define_materialintro"></string>
<string name="library_materialintro_author">Jan Heinrich Reimer</string>