Skip to content

Commit f207647

Browse files
Updated project structure. Added feature for hiding Snackbar messages.
1 parent 74aac27 commit f207647

13 files changed

+53
-79
lines changed

.idea/gradle.xml

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/appcompat_v7_23_0_1.xml

-15
This file was deleted.

.idea/libraries/core_0_8_1_0.xml

-13
This file was deleted.

.idea/libraries/recyclerview_v7_23_0_1.xml

-12
This file was deleted.

.idea/libraries/support_annotations_23_0_1.xml

-11
This file was deleted.

.idea/libraries/support_v4_23_0_1.xml

-16
This file was deleted.

.idea/modules.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BluetoothUtilityDemo.iml renamed to SimpleBluetoothLibrary.iml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id="BluetoothUtilityDemo" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.github.developerpaul123.simplebluetoothlibrary" external.system.module.version="1.4.1" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id="SimpleBluetoothLibrary" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.github.developerpaul123.simplebluetoothlibrary" external.system.module.version="1.4.1" type="JAVA_MODULE" version="4">
33
<component name="FacetManager">
44
<facet type="java-gradle" name="Java-Gradle">
55
<configuration>

app/app.iml

+5-1
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,22 @@
6767
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
6868
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
6969
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
70+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
7071
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
7172
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
73+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
7274
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
7375
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
7476
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
7577
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
78+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
79+
<excludeFolder url="file://$MODULE_DIR$/build/ivy.xml" />
7680
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
7781
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
7882
</content>
7983
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
8084
<orderEntry type="sourceFolder" forTests="false" />
81-
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
85+
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
8286
<orderEntry type="module" module-name="btutillib" exported="" />
8387
</component>
8488
</module>

btutillib/btutillib.iml

+9-4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
6666
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
6767
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
68+
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
6869
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
6970
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
7071
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
@@ -77,15 +78,19 @@
7778
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
7879
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
7980
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
81+
<excludeFolder url="file://$MODULE_DIR$/build/ivy.xml" />
82+
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
8083
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
84+
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
8185
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
8286
</content>
8387
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
8488
<orderEntry type="sourceFolder" forTests="false" />
85-
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
86-
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
89+
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
90+
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
8791
<orderEntry type="library" exported="" name="core-0.8.1.0" level="project" />
88-
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
89-
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
92+
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
93+
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
94+
<orderEntry type="library" exported="" name="design-23.1.1" level="project" />
9095
</component>
9196
</module>

btutillib/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ dependencies {
3434
compile('com.afollestad.material-dialogs:core:0.8.1.0@aar') {
3535
transitive = true
3636
}
37+
compile 'com.android.support:design:23.1.1'
3738
}
3839

3940
task javadoc(type: Javadoc) {

btutillib/src/main/java/com/devpaul/bluetoothutillib/SimpleBluetooth.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import android.content.Context;
88
import android.content.Intent;
99
import android.os.Message;
10-
import android.widget.Toast;
10+
import android.support.design.widget.Snackbar;
1111

1212
import com.devpaul.bluetoothutillib.broadcasts.BluetoothBroadcastReceiver;
1313
import com.devpaul.bluetoothutillib.broadcasts.BluetoothPairingReceiver;
@@ -157,6 +157,8 @@ public void onDeviceUnpaired(BluetoothDevice device) {
157157
*/
158158
private boolean connectWithService = false;
159159

160+
private boolean shouldShowSnackbars = false;
161+
160162
/**
161163
* Constructor for {@code SimpleBluetooth}
162164
* Allows for easy handling for setting up connections and bluetooth servers to connect to.
@@ -224,6 +226,14 @@ public void setInputStreamType(InputStreamType type) {
224226
this.curType = type;
225227
}
226228

229+
/**
230+
* Set whether or not messages should be shown with snackbars.
231+
* @param show true to show them, false otherwise.
232+
*/
233+
public void setShouldShowSnackbars(boolean show) {
234+
shouldShowSnackbars = show;
235+
bluetoothUtility.setShouldShowSnackbars(show);
236+
}
227237
/**
228238
* Default handler for Simple bluetooth.
229239
*/
@@ -250,7 +260,10 @@ public void handleMessage(Message message) {
250260
if(progressDialog != null) {
251261
if(progressDialog.isShowing()) {
252262
progressDialog.dismiss();
253-
Toast.makeText(mContext, "Device connected!", Toast.LENGTH_SHORT).show();
263+
if(shouldShowSnackbars) {
264+
Snackbar.make(mActivity.findViewById(android.R.id.content), "Device connected.",
265+
Snackbar.LENGTH_SHORT).show();
266+
}
254267
}
255268
}
256269
break;

btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/BluetoothUtility.java

+19-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import android.content.Context;
1111
import android.content.Intent;
1212
import android.os.Build;
13+
import android.support.design.widget.Snackbar;
1314
import android.util.Log;
14-
import android.widget.Toast;
1515

1616
import com.devpaul.bluetoothutillib.errordialogs.InvalidMacAddressDialog;
1717
import com.devpaul.bluetoothutillib.handlers.BluetoothHandler;
@@ -125,6 +125,8 @@ public static enum InputStreamType {NORMAL, BUFFERED};
125125

126126
private InputStreamType streamType = InputStreamType.NORMAL;
127127

128+
private boolean shouldShowSnackbars = true;
129+
128130
/**
129131
* Bluetooth Request constant.
130132
*/
@@ -561,6 +563,14 @@ public void createBluetoothServerSocket() {
561563

562564
}
563565

566+
/**
567+
* Set if snackbar messages should be shown.
568+
* @param shouldShow true if should be shown, false otherwise.
569+
*/
570+
public void setShouldShowSnackbars(boolean shouldShow) {
571+
this.shouldShowSnackbars = shouldShow;
572+
}
573+
564574
/**
565575
* Thread used to accept incoming connections and initiate a server socket.
566576
*/
@@ -658,7 +668,10 @@ public void run() {
658668
mActivity.runOnUiThread(new Runnable() {
659669
@Override
660670
public void run() {
661-
Toast.makeText(mContext, "Device not available.", Toast.LENGTH_SHORT).show();
671+
if(shouldShowSnackbars) {
672+
Snackbar.make(mActivity.findViewById(android.R.id.content), "Device not available.",
673+
Snackbar.LENGTH_SHORT).show();
674+
}
662675
}
663676
});
664677
try {
@@ -849,7 +862,10 @@ public void run() {
849862
mActivity.runOnUiThread(new Runnable() {
850863
@Override
851864
public void run() {
852-
Toast.makeText(mContext, "Device not available.", Toast.LENGTH_SHORT).show();
865+
if(shouldShowSnackbars) {
866+
Snackbar.make(mActivity.findViewById(android.R.id.content), "Device not available.",
867+
Snackbar.LENGTH_SHORT).show();
868+
}
853869
}
854870
});
855871
try {

0 commit comments

Comments
 (0)