Skip to content

Commit

Permalink
Updated project structure. Added feature for hiding Snackbar messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperPaul123 committed Jan 19, 2016
1 parent 74aac27 commit f207647
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions .idea/libraries/appcompat_v7_23_0_1.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/libraries/core_0_8_1_0.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/libraries/recyclerview_v7_23_0_1.xml

This file was deleted.

11 changes: 0 additions & 11 deletions .idea/libraries/support_annotations_23_0_1.xml

This file was deleted.

16 changes: 0 additions & 16 deletions .idea/libraries/support_v4_23_0_1.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BluetoothUtilityDemo.iml → SimpleBluetoothLibrary.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
Expand Down
6 changes: 5 additions & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,22 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/ivy.xml" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="module" module-name="btutillib" exported="" />
</component>
</module>
13 changes: 9 additions & 4 deletions btutillib/btutillib.iml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
Expand All @@ -77,15 +78,19 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/ivy.xml" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
<orderEntry type="library" exported="" name="core-0.8.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="design-23.1.1" level="project" />
</component>
</module>
1 change: 1 addition & 0 deletions btutillib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -125,6 +125,8 @@ public static enum InputStreamType {NORMAL, BUFFERED};

private InputStreamType streamType = InputStreamType.NORMAL;

private boolean shouldShowSnackbars = true;

/**
* Bluetooth Request constant.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f207647

Please sign in to comment.