From dac10b5e5a3968aad4c4d05728b04d51c90d9c91 Mon Sep 17 00:00:00 2001 From: akwizgran Date: Thu, 27 Sep 2018 17:20:20 +0100 Subject: [PATCH] Use kobakei's speed dial library. --- briar-android/build.gradle | 66 ++++++++++++++++++- .../android/contact/ContactListFragment.java | 32 +++++---- .../main/res/layout/fragment_contact_list.xml | 20 +++--- .../main/res/menu/contact_list_actions.xml | 15 +---- briar-android/witness.gradle | 3 +- 5 files changed, 96 insertions(+), 40 deletions(-) diff --git a/briar-android/build.gradle b/briar-android/build.gradle index b613f83f6..bd35c850f 100644 --- a/briar-android/build.gradle +++ b/briar-android/build.gradle @@ -2,6 +2,70 @@ apply plugin: 'com.android.application' apply plugin: 'witness' apply from: 'witness.gradle' +// prototype +repositories { + maven { url 'https://jitpack.io' } +} + +dependencies { + implementation project(path: ':briar-core', configuration: 'default') + implementation project(path: ':bramble-core', configuration: 'default') + implementation project(':bramble-android') + + def supportVersion = '28.0.0' + implementation "com.android.support:support-v4:$supportVersion" + implementation("com.android.support:appcompat-v7:$supportVersion") { + exclude module: 'support-v4' + } + implementation("com.android.support:preference-v14:$supportVersion") { + exclude module: 'support-v4' + } + implementation("com.android.support:design:$supportVersion") { + exclude module: 'support-v4' + exclude module: 'recyclerview-v7' + } + implementation "com.android.support:cardview-v7:$supportVersion" + implementation "com.android.support:support-annotations:$supportVersion" + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + + implementation('ch.acra:acra:4.9.1') { + exclude module: 'support-v4' + exclude module: 'support-annotations' + } + implementation 'info.guardianproject.panic:panic:0.5' + implementation 'info.guardianproject.trustedintents:trustedintents:0.2' + implementation 'de.hdodenhof:circleimageview:2.2.0' + implementation 'com.google.zxing:core:3.3.0' + implementation 'uk.co.samuelwall:material-tap-target-prompt:2.8.0' + implementation 'com.vanniktech:emoji-google:0.5.1' + + annotationProcessor 'com.google.dagger:dagger-compiler:2.0.2' + + compileOnly 'javax.annotation:jsr250-api:1.0' + + testImplementation project(path: ':bramble-api', configuration: 'testOutput') + testImplementation project(path: ':bramble-core', configuration: 'testOutput') + testImplementation 'org.robolectric:robolectric:3.8' + testImplementation 'org.robolectric:shadows-support-v4:3.3.2' + testImplementation 'org.mockito:mockito-core:2.13.0' + testImplementation 'junit:junit:4.12' + testImplementation "org.jmock:jmock:2.8.2" + testImplementation "org.jmock:jmock-junit4:2.8.2" + testImplementation "org.jmock:jmock-legacy:2.8.2" + testImplementation "org.hamcrest:hamcrest-library:1.3" + testImplementation "org.hamcrest:hamcrest-core:1.3" + + def espressoVersion = '3.0.2' + androidTestImplementation "com.android.support.test.espresso:espresso-core:$espressoVersion" + androidTestImplementation "com.android.support.test.espresso:espresso-contrib:$espressoVersion" + androidTestImplementation "com.android.support.test.espresso:espresso-intents:$espressoVersion" + androidTestImplementation "tools.fastlane:screengrab:1.1.0" + androidTestImplementation "com.android.support.test.uiautomator:uiautomator-v18:2.1.3" + androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.0.2" + androidTestCompileOnly 'javax.annotation:jsr250-api:1.0' + androidTestImplementation 'junit:junit:4.12' +} + def getStdout = { command, defaultValue -> def stdout = new ByteArrayOutputStream() try { @@ -118,7 +182,7 @@ dependencies { implementation 'com.vanniktech:emoji-google:0.5.1' // prototype - implementation "com.leinardi.android:speed-dial:2.0.0" + implementation "com.github.kobakei:MaterialFabSpeedDial:1.2.0" annotationProcessor 'com.google.dagger:dagger-compiler:2.0.2' diff --git a/briar-android/src/main/java/org/briarproject/briar/android/contact/ContactListFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/contact/ContactListFragment.java index e708b4230..fe6e800dc 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/contact/ContactListFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/contact/ContactListFragment.java @@ -2,6 +2,7 @@ package org.briarproject.briar.android.contact; import android.content.Intent; import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityOptionsCompat; @@ -14,9 +15,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; - -import com.leinardi.android.speeddial.SpeedDialActionItem; -import com.leinardi.android.speeddial.SpeedDialView; +import android.widget.TextView; import org.briarproject.bramble.api.contact.Contact; import org.briarproject.bramble.api.contact.ContactId; @@ -56,6 +55,9 @@ import java.util.logging.Logger; import javax.annotation.Nullable; import javax.inject.Inject; +import io.github.kobakei.materialfabspeeddial.FabSpeedDial; +import io.github.kobakei.materialfabspeeddial.FabSpeedDial.OnMenuItemClickListener; + import static android.os.Build.VERSION.SDK_INT; import static android.support.design.widget.Snackbar.LENGTH_INDEFINITE; import static android.support.v4.app.ActivityOptionsCompat.makeSceneTransitionAnimation; @@ -69,7 +71,7 @@ import static org.briarproject.briar.android.contact.ConversationActivity.CONTAC @MethodsNotNullByDefault @ParametersNotNullByDefault public class ContactListFragment extends BaseFragment implements EventListener, - SpeedDialView.OnActionSelectedListener { + OnMenuItemClickListener { public static final String TAG = ContactListFragment.class.getName(); private static final Logger LOG = Logger.getLogger(TAG); @@ -120,11 +122,12 @@ public class ContactListFragment extends BaseFragment implements EventListener, getActivity().setTitle(R.string.contact_list_button); - View contentView = inflater.inflate(R.layout.fragment_contact_list, container, false); + View contentView = + inflater.inflate(R.layout.fragment_contact_list, container, + false); - SpeedDialView speedDialView = contentView.findViewById(R.id.speedDial); - speedDialView.inflate(R.menu.contact_list_actions); - speedDialView.setOnActionSelectedListener(this); + FabSpeedDial speedDialView = contentView.findViewById(R.id.speedDial); + speedDialView.addOnMenuItemClickListener(this); OnContactClickListener onContactClickListener = (view, item) -> { @@ -195,23 +198,24 @@ public class ContactListFragment extends BaseFragment implements EventListener, } @Override - public boolean onActionSelected(SpeedDialActionItem item) { - switch (item.getId()) { + public void onMenuItemClick(FloatingActionButton fab, TextView v, + int itemId) { + switch (itemId) { case R.id.action_add_contact: Intent intent = new Intent(getContext(), ContactExchangeActivity.class); startActivity(intent); - return false; + return; case R.id.action_open_link: startActivity(new Intent(getContext(), ContactInviteInputActivity.class)); - return false; + return; case R.id.action_send_link: startActivity(new Intent(getContext(), ContactInviteOutputActivity.class)); - return false; + return; default: - return false; + return; } } diff --git a/briar-android/src/main/res/layout/fragment_contact_list.xml b/briar-android/src/main/res/layout/fragment_contact_list.xml index 68fa4955e..104f4b6c1 100644 --- a/briar-android/src/main/res/layout/fragment_contact_list.xml +++ b/briar-android/src/main/res/layout/fragment_contact_list.xml @@ -11,18 +11,14 @@ android:layout_height="match_parent" app:scrollToEnd="false"/> - - - + android:layout_width="match_parent" + android:layout_height="match_parent" + app:fab_fabDrawable="@drawable/ic_action_add" + app:fab_fabRippleColor="@android:color/transparent" + app:fab_menu="@menu/contact_list_actions" + app:fab_miniFabTextBackground="@color/briar_blue" + app:fab_miniFabTextColor="@android:color/white"/> diff --git a/briar-android/src/main/res/menu/contact_list_actions.xml b/briar-android/src/main/res/menu/contact_list_actions.xml index e9a82a439..5189c7fdf 100644 --- a/briar-android/src/main/res/menu/contact_list_actions.xml +++ b/briar-android/src/main/res/menu/contact_list_actions.xml @@ -6,30 +6,21 @@ - diff --git a/briar-android/witness.gradle b/briar-android/witness.gradle index e54187a0e..19a1a45b2 100644 --- a/briar-android/witness.gradle +++ b/briar-android/witness.gradle @@ -81,6 +81,7 @@ dependencyVerification { 'com.android.tools:repository:26.2.1:repository-26.2.1.jar:fa74dae09103faef703df38550ad8fa244c5b6d1bf90d6198be932292b3d9cc1', 'com.android.tools:sdk-common:26.2.1:sdk-common-26.2.1.jar:759d4b292ca69a35cf961fca377b54158fc6c88108978006999442e80a011cf4', 'com.android.tools:sdklib:26.2.1:sdklib-26.2.1.jar:248df7ad5eac4aeb6f96c394c76760de4b7b89ac056e54d0c21a739368b91b45', + 'com.github.kobakei:MaterialFabSpeedDial:1.2.0:MaterialFabSpeedDial-1.2.0.aar:fda1784d6f213e22079d5c1e9ea53e3e6eb4f908297ccfe6dea588c57aafc800', 'com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:2.0:accessibility-test-framework-2.0.jar:cdf16ef8f5b8023d003ce3cc1b0d51bda737762e2dab2fedf43d1c4292353f7f', 'com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:2.1:accessibility-test-framework-2.1.jar:7b0aa6ed7553597ce0610684a9f7eca8021eee218f2e2f427c04a7fbf5f920bd', 'com.google.code.findbugs:jsr305:1.3.9:jsr305-1.3.9.jar:905721a0eea90a81534abb7ee6ef4ea2e5e645fa1def0a5cd88402df1b46c9ed', @@ -101,7 +102,6 @@ dependencyVerification { 'com.googlecode.json-simple:json-simple:1.1:json-simple-1.1.jar:2d9484f4c649f708f47f9a479465fc729770ee65617dca3011836602264f6439', 'com.ibm.icu:icu4j:53.1:icu4j-53.1.jar:e37a4467bac5cdeb02c5c4b8e5063d2f4e67b69e3c7df6d6b610f13185572bab', 'com.jraska:falcon:1.0.4:falcon-1.0.4.aar:6114a48d8b3814f75fc69b5e84dc087c1254883874eae8a36bd778979800630a', - 'com.leinardi.android:speed-dial:2.0.0:speed-dial-2.0.0.aar:c219aac9e4e803c85a5ebf47f160b31736bc7b17ca56c024ce6803f11fc18741', 'com.squareup:javawriter:2.1.1:javawriter-2.1.1.jar:f699823d0081f69cbb676c1845ea222e0ada79bc88a53e5d22d8bd02d328f57e', 'com.squareup:javawriter:2.5.0:javawriter-2.5.0.jar:fcfb09fb0ea0aa97d3cfe7ea792398081348e468f126b3603cb3803f240197f0', 'com.sun.activation:javax.activation:1.2.0:javax.activation-1.2.0.jar:993302b16cd7056f21e779cc577d175a810bb4900ef73cd8fbf2b50f928ba9ce', @@ -192,6 +192,7 @@ dependencyVerification { 'org.robolectric:shadows-framework:3.8:shadows-framework-3.8.jar:83548db7249edf1af87e1a1f4d8f4eec3e85d6220161da601e6f6398476911b2', 'org.robolectric:shadows-support-v4:3.3.2:shadows-support-v4-3.3.2.jar:6f689264738266e70fe08db7c04b7b5a75155994f4e3f7f311960d90486bf005', 'org.robolectric:utils:3.8:utils-3.8.jar:e945d04d40e37554e02d4be1bc3abf9bede45375c843aa36d10ccb6b63edbf34', + 'tools.fastlane:screengrab:1.1.0:screengrab-1.1.0.aar:03ce3868ee8a0082d14e7a1de0999f91531c0cc794392688beb08ee9bc4495fd', 'tools.fastlane:screengrab:1.2.0:screengrab-1.2.0.aar:af4ee23bb06f94404d3ab18e2ea69db8265539fc8da29f9ee45b7e472684ba83', 'uk.co.samuelwall:material-tap-target-prompt:2.12.4:material-tap-target-prompt-2.12.4.aar:6c0990ab3aa22de9f7d09dcb0a944e671128c31634ac8429012faa5c508202fb', 'xmlpull:xmlpull:1.1.3.1:xmlpull-1.1.3.1.jar:34e08ee62116071cbb69c0ed70d15a7a5b208d62798c59f2120bb8929324cb63',