diff --git a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java
index b4442c4..6ca72eb 100644
--- a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java
+++ b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java
@@ -43,6 +43,7 @@ import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
import androidx.room.Room;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.zxing.client.android.BuildConfig;
import com.google.zxing.client.android.Intents;
@@ -182,6 +183,8 @@ public class DrugListActivity extends AppCompatActivity {
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle());
}
+ FloatingActionButton mFloatingActionButton = findViewById(R.id.fab);
+ mFloatingActionButton.setOnClickListener(v-> onButtonClick());
if (DEMO) {
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
@@ -315,7 +318,7 @@ public class DrugListActivity extends AppCompatActivity {
}
// Launch scan
- public void onButtonClick(View v) {
+ public void onButtonClick() {
Log.d(TAG, "add medication");
ScanOptions options = new ScanOptions();
options.setDesiredBarcodeFormats(ScanOptions.DATA_MATRIX, ScanOptions.CODE_128);
@@ -330,6 +333,7 @@ public class DrugListActivity extends AppCompatActivity {
Log.d(TAG, "scanOptions == " + options);
mBarcodeScannerLauncher.launch(options);
+ return;
}
/**
diff --git a/app/src/main/res/drawable/ic_add.xml b/app/src/main/res/drawable/ic_add.xml
new file mode 100644
index 0000000..2fcde96
--- /dev/null
+++ b/app/src/main/res/drawable/ic_add.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/layout/drug_list_activity.xml b/app/src/main/res/layout/drug_list_activity.xml
index 146258b..a332dbf 100644
--- a/app/src/main/res/layout/drug_list_activity.xml
+++ b/app/src/main/res/layout/drug_list_activity.xml
@@ -13,11 +13,14 @@
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
-
+ android:layout_height="?attr/actionBarSize"
+ android:background="@color/colorPrimary"
+ app:layout_collapseMode="pin"
+ app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
+ app:titleTextColor="@color/white"/>
@@ -25,7 +28,7 @@
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:layout_behavior="@string/appbar_scrolling_view_behavior">
+ android:layout_marginTop="?attr/actionBarSize">
+ android:src="@drawable/ic_add"
+ app:backgroundTint="@color/colorPrimary" />
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 0a8c40b..3434f3c 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -6,6 +6,8 @@
- @color/colorPrimary
- @color/colorPrimaryDark
- @color/colorAccent
+ - @color/white
+ - @android:color/white