diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 51042a9..7ea9173 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -10,6 +10,8 @@ diff --git a/.idea/libraries/appcompat_v7_23_0_1.xml b/.idea/libraries/appcompat_v7_23_0_1.xml deleted file mode 100644 index b5b0b73..0000000 --- a/.idea/libraries/appcompat_v7_23_0_1.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/core_0_8_1_0.xml b/.idea/libraries/core_0_8_1_0.xml deleted file mode 100644 index 01f2210..0000000 --- a/.idea/libraries/core_0_8_1_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/recyclerview_v7_23_0_1.xml b/.idea/libraries/recyclerview_v7_23_0_1.xml deleted file mode 100644 index 263204f..0000000 --- a/.idea/libraries/recyclerview_v7_23_0_1.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/support_annotations_23_0_1.xml b/.idea/libraries/support_annotations_23_0_1.xml deleted file mode 100644 index b10f12f..0000000 --- a/.idea/libraries/support_annotations_23_0_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/support_v4_23_0_1.xml b/.idea/libraries/support_v4_23_0_1.xml deleted file mode 100644 index 87b2a22..0000000 --- a/.idea/libraries/support_v4_23_0_1.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 95184eb..dbe2b96 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + diff --git a/BluetoothUtilityDemo.iml b/SimpleBluetoothLibrary.iml similarity index 67% rename from BluetoothUtilityDemo.iml rename to SimpleBluetoothLibrary.iml index 69f265b..fe3ef38 100644 --- a/BluetoothUtilityDemo.iml +++ b/SimpleBluetoothLibrary.iml @@ -1,5 +1,5 @@ - + diff --git a/app/app.iml b/app/app.iml index 3a92e28..228495b 100644 --- a/app/app.iml +++ b/app/app.iml @@ -67,18 +67,22 @@ + + + + - + \ No newline at end of file diff --git a/btutillib/btutillib.iml b/btutillib/btutillib.iml index db33ebe..19cc5c4 100644 --- a/btutillib/btutillib.iml +++ b/btutillib/btutillib.iml @@ -65,6 +65,7 @@ + @@ -77,15 +78,19 @@ + + + - - + + - - + + + \ No newline at end of file diff --git a/btutillib/build.gradle b/btutillib/build.gradle index 14f1cf0..1fab48b 100644 --- a/btutillib/build.gradle +++ b/btutillib/build.gradle @@ -34,6 +34,7 @@ dependencies { compile('com.afollestad.material-dialogs:core:0.8.1.0@aar') { transitive = true } + compile 'com.android.support:design:23.1.1' } task javadoc(type: Javadoc) { diff --git a/btutillib/src/main/java/com/devpaul/bluetoothutillib/SimpleBluetooth.java b/btutillib/src/main/java/com/devpaul/bluetoothutillib/SimpleBluetooth.java index 6b14cfe..5a12368 100644 --- a/btutillib/src/main/java/com/devpaul/bluetoothutillib/SimpleBluetooth.java +++ b/btutillib/src/main/java/com/devpaul/bluetoothutillib/SimpleBluetooth.java @@ -7,7 +7,7 @@ import android.content.Context; import android.content.Intent; import android.os.Message; -import android.widget.Toast; +import android.support.design.widget.Snackbar; import com.devpaul.bluetoothutillib.broadcasts.BluetoothBroadcastReceiver; import com.devpaul.bluetoothutillib.broadcasts.BluetoothPairingReceiver; @@ -157,6 +157,8 @@ public void onDeviceUnpaired(BluetoothDevice device) { */ private boolean connectWithService = false; + private boolean shouldShowSnackbars = false; + /** * Constructor for {@code SimpleBluetooth} * Allows for easy handling for setting up connections and bluetooth servers to connect to. @@ -224,6 +226,14 @@ public void setInputStreamType(InputStreamType type) { this.curType = type; } + /** + * Set whether or not messages should be shown with snackbars. + * @param show true to show them, false otherwise. + */ + public void setShouldShowSnackbars(boolean show) { + shouldShowSnackbars = show; + bluetoothUtility.setShouldShowSnackbars(show); + } /** * Default handler for Simple bluetooth. */ @@ -250,7 +260,10 @@ public void handleMessage(Message message) { if(progressDialog != null) { if(progressDialog.isShowing()) { progressDialog.dismiss(); - Toast.makeText(mContext, "Device connected!", Toast.LENGTH_SHORT).show(); + if(shouldShowSnackbars) { + Snackbar.make(mActivity.findViewById(android.R.id.content), "Device connected.", + Snackbar.LENGTH_SHORT).show(); + } } } break; diff --git a/btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/BluetoothUtility.java b/btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/BluetoothUtility.java index ed1b946..e5cf747 100644 --- a/btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/BluetoothUtility.java +++ b/btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/BluetoothUtility.java @@ -10,8 +10,8 @@ import android.content.Context; import android.content.Intent; import android.os.Build; +import android.support.design.widget.Snackbar; import android.util.Log; -import android.widget.Toast; import com.devpaul.bluetoothutillib.errordialogs.InvalidMacAddressDialog; import com.devpaul.bluetoothutillib.handlers.BluetoothHandler; @@ -125,6 +125,8 @@ public static enum InputStreamType {NORMAL, BUFFERED}; private InputStreamType streamType = InputStreamType.NORMAL; + private boolean shouldShowSnackbars = true; + /** * Bluetooth Request constant. */ @@ -561,6 +563,14 @@ public void createBluetoothServerSocket() { } + /** + * Set if snackbar messages should be shown. + * @param shouldShow true if should be shown, false otherwise. + */ + public void setShouldShowSnackbars(boolean shouldShow) { + this.shouldShowSnackbars = shouldShow; + } + /** * Thread used to accept incoming connections and initiate a server socket. */ @@ -658,7 +668,10 @@ public void run() { mActivity.runOnUiThread(new Runnable() { @Override public void run() { - Toast.makeText(mContext, "Device not available.", Toast.LENGTH_SHORT).show(); + if(shouldShowSnackbars) { + Snackbar.make(mActivity.findViewById(android.R.id.content), "Device not available.", + Snackbar.LENGTH_SHORT).show(); + } } }); try { @@ -849,7 +862,10 @@ public void run() { mActivity.runOnUiThread(new Runnable() { @Override public void run() { - Toast.makeText(mContext, "Device not available.", Toast.LENGTH_SHORT).show(); + if(shouldShowSnackbars) { + Snackbar.make(mActivity.findViewById(android.R.id.content), "Device not available.", + Snackbar.LENGTH_SHORT).show(); + } } }); try {