iii
This commit is contained in:
parent
672fe9e0d4
commit
db049fe41c
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,5 +5,6 @@
|
||||||
/.idea/libraries
|
/.idea/libraries
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
|
/Application/build
|
||||||
/captures
|
/captures
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/Application/Application.iml" filepath="$PROJECT_DIR$/Application/Application.iml" />
|
<module fileurl="file://$PROJECT_DIR$/Application/Application.iml" filepath="$PROJECT_DIR$/Application/Application.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/BluetoothChat.iml" filepath="$PROJECT_DIR$/BluetoothChat.iml" />
|
<module fileurl="file://$PROJECT_DIR$/iconsole-android.iml" filepath="$PROJECT_DIR$/iconsole-android.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -66,13 +66,6 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/template/java" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/template/java" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests/res" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/tests/res" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests/resources" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/tests/resources" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests/assets" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/tests/assets" type="java-test-resource" />
|
||||||
|
@ -80,7 +73,13 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests/src" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/tests/src" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests/rs" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/tests/rs" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests/shaders" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/tests/shaders" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/.DS_Store" />
|
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class BluetoothChatFragment extends Fragment {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
// If BT is not on, request that it be enabled.
|
// If BT is not on, request that it be enabled.
|
||||||
// setupChat() will then be called during onActivityResult
|
// setupChat() will then be called during onActivityResult
|
||||||
if (!mBluetoothAdapter.isEnabled()) {
|
if (null == mBluetoothAdapter || !mBluetoothAdapter.isEnabled()) {
|
||||||
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
||||||
startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
|
startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
|
||||||
// Otherwise, setup the chat session
|
// Otherwise, setup the chat session
|
||||||
|
@ -161,7 +161,7 @@ public class BluetoothChatFragment extends Fragment {
|
||||||
Log.d(TAG, "setupChat()");
|
Log.d(TAG, "setupChat()");
|
||||||
|
|
||||||
// Initialize the array adapter for the conversation thread
|
// Initialize the array adapter for the conversation thread
|
||||||
mConversationArrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.message);
|
mConversationArrayAdapter = new ArrayAdapter<>(getActivity(), R.layout.message);
|
||||||
|
|
||||||
mConversationView.setAdapter(mConversationArrayAdapter);
|
mConversationView.setAdapter(mConversationArrayAdapter);
|
||||||
|
|
||||||
|
|
|
@ -153,8 +153,8 @@ public class BluetoothChatService {
|
||||||
* @param device The BluetoothDevice that has been connected
|
* @param device The BluetoothDevice that has been connected
|
||||||
*/
|
*/
|
||||||
public synchronized void connected(BluetoothSocket socket, BluetoothDevice
|
public synchronized void connected(BluetoothSocket socket, BluetoothDevice
|
||||||
device, final String socketType) {
|
device) {
|
||||||
Log.d(TAG, "connected, Socket Type:" + socketType);
|
Log.d(TAG, "connected");
|
||||||
|
|
||||||
// Cancel the thread that completed the connection
|
// Cancel the thread that completed the connection
|
||||||
if (mConnectThread != null) {
|
if (mConnectThread != null) {
|
||||||
|
@ -169,7 +169,7 @@ public class BluetoothChatService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the thread to manage the connection and perform transmissions
|
// Start the thread to manage the connection and perform transmissions
|
||||||
mConnectedThread = new ConnectedThread(socket, socketType);
|
mConnectedThread = new ConnectedThread(socket);
|
||||||
mConnectedThread.start();
|
mConnectedThread.start();
|
||||||
|
|
||||||
// Send the name of the connected device back to the UI Activity
|
// Send the name of the connected device back to the UI Activity
|
||||||
|
@ -258,7 +258,6 @@ public class BluetoothChatService {
|
||||||
private class ConnectThread extends Thread {
|
private class ConnectThread extends Thread {
|
||||||
private final BluetoothSocket mmSocket;
|
private final BluetoothSocket mmSocket;
|
||||||
private final BluetoothDevice mmDevice;
|
private final BluetoothDevice mmDevice;
|
||||||
private String mSocketType;
|
|
||||||
|
|
||||||
public ConnectThread(BluetoothDevice device) {
|
public ConnectThread(BluetoothDevice device) {
|
||||||
mmDevice = device;
|
mmDevice = device;
|
||||||
|
@ -276,8 +275,8 @@ public class BluetoothChatService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.i(TAG, "BEGIN mConnectThread SocketType:" + mSocketType);
|
Log.i(TAG, "BEGIN mConnectThread");
|
||||||
setName("ConnectThread" + mSocketType);
|
setName("ConnectThread");
|
||||||
|
|
||||||
// Always cancel discovery because it will slow down a connection
|
// Always cancel discovery because it will slow down a connection
|
||||||
mAdapter.cancelDiscovery();
|
mAdapter.cancelDiscovery();
|
||||||
|
@ -292,8 +291,7 @@ public class BluetoothChatService {
|
||||||
try {
|
try {
|
||||||
mmSocket.close();
|
mmSocket.close();
|
||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
Log.e(TAG, "unable to close() " + mSocketType +
|
Log.e(TAG, "unable to close() socket during connection failure", e2);
|
||||||
" socket during connection failure", e2);
|
|
||||||
}
|
}
|
||||||
connectionFailed();
|
connectionFailed();
|
||||||
return;
|
return;
|
||||||
|
@ -305,14 +303,14 @@ public class BluetoothChatService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the connected thread
|
// Start the connected thread
|
||||||
connected(mmSocket, mmDevice, mSocketType);
|
connected(mmSocket, mmDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
try {
|
try {
|
||||||
mmSocket.close();
|
mmSocket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "close() of connect " + mSocketType + " socket failed", e);
|
Log.e(TAG, "close() of socket failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,8 +324,8 @@ public class BluetoothChatService {
|
||||||
private final InputStream mmInStream;
|
private final InputStream mmInStream;
|
||||||
private final OutputStream mmOutStream;
|
private final OutputStream mmOutStream;
|
||||||
|
|
||||||
public ConnectedThread(BluetoothSocket socket, String socketType) {
|
public ConnectedThread(BluetoothSocket socket) {
|
||||||
Log.d(TAG, "create ConnectedThread: " + socketType);
|
Log.d(TAG, "create ConnectedThread");
|
||||||
mmSocket = socket;
|
mmSocket = socket;
|
||||||
InputStream tmpIn = null;
|
InputStream tmpIn = null;
|
||||||
OutputStream tmpOut = null;
|
OutputStream tmpOut = null;
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module external.linked.project.id="BluetoothChat" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet type="java-gradle" name="Java-Gradle">
|
|
||||||
<configuration>
|
|
||||||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
|
|
||||||
<option name="BUILDABLE" value="false" />
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
Loading…
Reference in a new issue