Skip to content
Snippets Groups Projects
Commit 51b1f721 authored by Viktor Rönnbäck's avatar Viktor Rönnbäck
Browse files

Init repo

parents
Branches
No related tags found
No related merge requests found
Showing
with 1005 additions and 0 deletions
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/Users/vikto/AndroidStudioProjects/BluetoothControl/app/src/main/res/drawable/ic_bulb_light.xml" value="0.14635416666666667" />
<entry key="..\:/Users/vikto/AndroidStudioProjects/BluetoothControl/app/src/main/res/drawable/ic_launcher_background.xml" value="0.14635416666666667" />
<entry key="..\:/Users/vikto/AndroidStudioProjects/BluetoothControl/app/src/main/res/layout/activity_main.xml" value="0.264" />
<entry key="..\:/Users/vikto/AndroidStudioProjects/BluetoothControl/app/src/main/res/layout/activity_select_device.xml" value="0.1793478260869565" />
<entry key="..\:/Users/vikto/AndroidStudioProjects/BluetoothControl/app/src/main/res/layout/device_info_layout.xml" value="0.1793478260869565" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
/build
\ No newline at end of file
plugins {
id 'com.android.application'
}
android {
compileSdk 31
defaultConfig {
applicationId "se.liu.vikro145.bluetoothcontrol"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
package se.liu.vikro145.bluetoothcontrol;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("se.liu.vikro145.bluetoothcontrol", appContext.getPackageName());
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="se.liu.vikro145.bluetoothcontrol">
<!--Permissions for Bluetooth access-->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SelectDeviceActivity"></activity>
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package se.liu.vikro145.bluetoothcontrol;
public class DeviceInfoModel {
private String deviceName, deviceHardwareAddress;
public DeviceInfoModel(){}
public DeviceInfoModel(String deviceName, String deviceHardwareAddress){
this.deviceName = deviceName;
this.deviceHardwareAddress = deviceHardwareAddress;
}
public String getDeviceName(){return deviceName;}
public String getDeviceHardwareAddress(){return deviceHardwareAddress;}
}
\ No newline at end of file
package se.liu.vikro145.bluetoothcontrol;
import android.content.Intent;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
public class DeviceListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private List<Object> deviceList;
public static class ViewHolder extends RecyclerView.ViewHolder {
TextView textName, textAddress;
LinearLayout linearLayout;
public ViewHolder(View v) {
super(v);
textName = v.findViewById(R.id.textViewDeviceName);
textAddress = v.findViewById(R.id.textViewDeviceAddress);
linearLayout = v.findViewById(R.id.linearLayoutDeviceInfo);
}
}
public DeviceListAdapter(Context context, List<Object> deviceList) {
this.context = context;
this.deviceList = deviceList;
}
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.device_info_layout, parent, false);
ViewHolder vh = new ViewHolder(v);
return vh;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
ViewHolder itemHolder = (ViewHolder) holder;
final DeviceInfoModel deviceInfoModel = (DeviceInfoModel) deviceList.get(position);
itemHolder.textName.setText(deviceInfoModel.getDeviceName());
itemHolder.textAddress.setText(deviceInfoModel.getDeviceHardwareAddress());
// When a device is selected
itemHolder.linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context,MainActivity.class);
// Send device details to the MainActivity
intent.putExtra("deviceName", deviceInfoModel.getDeviceName());
intent.putExtra("deviceAddress",deviceInfoModel.getDeviceHardwareAddress());
// Call MainActivity
context.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
int dataCount = deviceList.size();
return dataCount;
}
}
\ No newline at end of file
package se.liu.vikro145.bluetoothcontrol;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
import static android.content.ContentValues.TAG;
public class MainActivity extends AppCompatActivity {
private String deviceName = null;
private String deviceAddress;
public static Handler handler;
public static BluetoothSocket mmSocket;
public static ConnectedThread connectedThread;
public static CreateConnectThread createConnectThread;
private final static int CONNECTING_STATUS = 1; // used in bluetooth handler to identify message status
private final static int MESSAGE_READ = 2; // used in bluetooth handler to identify message update
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// UI Initialization
final Button buttonConnect = findViewById(R.id.buttonConnect);
final Toolbar toolbar = findViewById(R.id.toolbar);
final ProgressBar progressBar = findViewById(R.id.progressBar);
progressBar.setVisibility(View.GONE);
final TextView textViewInfo = findViewById(R.id.textViewInfo);
final Button buttonToggle = findViewById(R.id.buttonToggle);
buttonToggle.setEnabled(false);
final ImageView imageView = findViewById(R.id.imageView);
imageView.setBackgroundColor(getResources().getColor(R.color.colorOff));
// If a bluetooth device has been selected from SelectDeviceActivity
deviceName = getIntent().getStringExtra("deviceName");
if (deviceName != null){
// Get the device address to make BT Connection
deviceAddress = getIntent().getStringExtra("deviceAddress");
// Show progree and connection status
toolbar.setSubtitle("Connecting to " + deviceName + "...");
progressBar.setVisibility(View.VISIBLE);
buttonConnect.setEnabled(false);
/*
This is the most important piece of code. When "deviceName" is found
the code will call a new thread to create a bluetooth connection to the
selected device (see the thread code below)
*/
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
createConnectThread = new CreateConnectThread(bluetoothAdapter,deviceAddress);
createConnectThread.start();
}
/*
Second most important piece of Code. GUI Handler
*/
handler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg){
switch (msg.what){
case CONNECTING_STATUS:
switch(msg.arg1){
case 1:
toolbar.setSubtitle("Connected to " + deviceName);
progressBar.setVisibility(View.GONE);
buttonConnect.setEnabled(true);
buttonToggle.setEnabled(true);
break;
case -1:
toolbar.setSubtitle("Device fails to connect");
progressBar.setVisibility(View.GONE);
buttonConnect.setEnabled(true);
break;
}
break;
case MESSAGE_READ:
String arduinoMsg = msg.obj.toString(); // Read message from Arduino
switch (arduinoMsg.toLowerCase()){
case "led is turned on":
imageView.setBackgroundColor(getResources().getColor(R.color.colorOn));
textViewInfo.setText("Arduino Message : " + arduinoMsg);
break;
case "led is turned off":
imageView.setBackgroundColor(getResources().getColor(R.color.colorOff));
textViewInfo.setText("Arduino Message : " + arduinoMsg);
break;
}
break;
}
}
};
// Select Bluetooth Device
buttonConnect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Move to adapter list
Intent intent = new Intent(MainActivity.this, SelectDeviceActivity.class);
startActivity(intent);
}
});
// Button to ON/OFF LED on Arduino Board
buttonToggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String cmdText = null;
String btnState = buttonToggle.getText().toString().toLowerCase();
switch (btnState){
case "turn on":
buttonToggle.setText("Turn Off");
// Command to turn on LED on Arduino. Must match with the command in Arduino code
cmdText = "<turn on>";
break;
case "turn off":
buttonToggle.setText("Turn On");
// Command to turn off LED on Arduino. Must match with the command in Arduino code
cmdText = "<turn off>";
break;
}
// Send command to Arduino board
connectedThread.write(cmdText);
}
});
}
/* ============================ Thread to Create Bluetooth Connection =================================== */
public static class CreateConnectThread extends Thread {
public CreateConnectThread(BluetoothAdapter bluetoothAdapter, String address) {
/*
Use a temporary object that is later assigned to mmSocket
because mmSocket is final.
*/
BluetoothDevice bluetoothDevice = bluetoothAdapter.getRemoteDevice(address);
BluetoothSocket tmp = null;
UUID uuid = bluetoothDevice.getUuids()[0].getUuid();
try {
/*
Get a BluetoothSocket to connect with the given BluetoothDevice.
Due to Android device varieties,the method below may not work fo different devices.
You should try using other methods i.e. :
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
*/
tmp = bluetoothDevice.createInsecureRfcommSocketToServiceRecord(uuid);
} catch (IOException e) {
Log.e(TAG, "Socket's create() method failed", e);
}
mmSocket = tmp;
}
public void run() {
// Cancel discovery because it otherwise slows down the connection.
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
bluetoothAdapter.cancelDiscovery();
try {
// Connect to the remote device through the socket. This call blocks
// until it succeeds or throws an exception.
mmSocket.connect();
Log.e("Status", "Device connected");
handler.obtainMessage(CONNECTING_STATUS, 1, -1).sendToTarget();
} catch (IOException connectException) {
// Unable to connect; close the socket and return.
try {
mmSocket.close();
Log.e("Status", "Cannot connect to device");
handler.obtainMessage(CONNECTING_STATUS, -1, -1).sendToTarget();
} catch (IOException closeException) {
Log.e(TAG, "Could not close the client socket", closeException);
}
return;
}
// The connection attempt succeeded. Perform work associated with
// the connection in a separate thread.
connectedThread = new ConnectedThread(mmSocket);
connectedThread.run();
}
// Closes the client socket and causes the thread to finish.
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
Log.e(TAG, "Could not close the client socket", e);
}
}
}
/* =============================== Thread for Data Transfer =========================================== */
public static class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInStream;
private final OutputStream mmOutStream;
public ConnectedThread(BluetoothSocket socket) {
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
// Get the input and output streams, using temp objects because
// member streams are final
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) { }
mmInStream = tmpIn;
mmOutStream = tmpOut;
}
public void run() {
byte[] buffer = new byte[1024]; // buffer store for the stream
int bytes = 0; // bytes returned from read()
// Keep listening to the InputStream until an exception occurs
while (true) {
try {
/*
Read from the InputStream from Arduino until termination character is reached.
Then send the whole String message to GUI Handler.
*/
buffer[bytes] = (byte) mmInStream.read();
String readMessage;
if (buffer[bytes] == '\n'){
readMessage = new String(buffer,0,bytes);
Log.e("Arduino Message",readMessage);
handler.obtainMessage(MESSAGE_READ,readMessage).sendToTarget();
bytes = 0;
} else {
bytes++;
}
} catch (IOException e) {
e.printStackTrace();
break;
}
}
}
/* Call this from the main activity to send data to the remote device */
public void write(String input) {
byte[] bytes = input.getBytes(); //converts entered String into bytes
try {
mmOutStream.write(bytes);
} catch (IOException e) {
Log.e("Send Error","Unable to send message",e);
}
}
/* Call this from the main activity to shutdown the connection */
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) { }
}
}
/* ============================ Terminate Connection at BackPress ====================== */
@Override
public void onBackPressed() {
// Terminate Bluetooth Connection and close app
if (createConnectThread != null){
createConnectThread.cancel();
}
Intent a = new Intent(Intent.ACTION_MAIN);
a.addCategory(Intent.CATEGORY_HOME);
a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(a);
}
}
\ No newline at end of file
package se.liu.vikro145.bluetoothcontrol;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
import android.view.View;
import com.google.android.material.snackbar.Snackbar;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class SelectDeviceActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_device);
// Bluetooth Setup
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
// Get List of Paired Bluetooth Device
Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
List<Object> deviceList = new ArrayList<>();
if (!pairedDevices.isEmpty()) {
// There are paired devices. Get the name and address of each paired device.
for (BluetoothDevice device : pairedDevices) {
String deviceName = device.getName();
String deviceHardwareAddress = device.getAddress(); // MAC address
DeviceInfoModel deviceInfoModel = new DeviceInfoModel(deviceName,deviceHardwareAddress);
deviceList.add(deviceInfoModel);
}
// Display paired device using recyclerView
RecyclerView recyclerView = findViewById(R.id.recyclerViewDevice);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
DeviceListAdapter deviceListAdapter = new DeviceListAdapter(this,deviceList);
recyclerView.setAdapter(deviceListAdapter);
recyclerView.setItemAnimator(new DefaultItemAnimator());
} else {
View view = findViewById(R.id.recyclerViewDevice);
Snackbar snackbar = Snackbar.make(view, "Activate Bluetooth or pair a Bluetooth device", Snackbar.LENGTH_INDEFINITE);
snackbar.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) { }
});
snackbar.show();
}
}
}
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#333333"
android:alpha="0.6">
<path
android:fillColor="#FF000000"
android:pathData="M9,21c0,0.55 0.45,1 1,1h4c0.55,0 1,-0.45 1,-1v-1L9,20v1zM12,2C8.14,2 5,5.14 5,9c0,2.38 1.19,4.47 3,5.74L8,17c0,0.55 0.45,1 1,1h6c0.55,0 1,-0.45 1,-1v-2.26c1.81,-1.27 3,-3.36 3,-5.74 0,-3.86 -3.14,-7 -7,-7zM14.85,13.1l-0.85,0.6L14,16h-4v-2.3l-0.85,-0.6C7.8,12.16 7,10.63 7,9c0,-2.76 2.24,-5 5,-5s5,2.24 5,5c0,1.63 -0.8,3.16 -2.15,4.1z"/>
</vector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constrainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
tools:context=".MainActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:subtitleTextColor="@android:color/background_light"
app:title="Bluetooth Connection"
app:titleTextColor="@android:color/background_light" />
<ImageView
android:id="@+id/imageView"
android:layout_width="200dp"
android:layout_height="300dp"
android:layout_marginTop="24dp"
android:background="@color/colorOff"
android:contentDescription="Visual LED"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"
app:srcCompat="@drawable/ic_bulb_light"
tools:ignore="VectorDrawableCompat" />
<Button
android:id="@+id/buttonConnect"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Connect"
android:textColor="@android:color/background_light"
app:layout_constraintBottom_toBottomOf="@+id/toolbar"
app:layout_constraintEnd_toEndOf="@+id/toolbar"
app:layout_constraintTop_toTopOf="@+id/toolbar" />
<Button
android:id="@+id/buttonToggle"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:text="Turn On"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textViewInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:textAlignment="center"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttonToggle" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SelectDeviceActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewDevice"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/linearLayoutDeviceInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/textViewDeviceName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewDeviceAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:background="?android:attr/listDivider"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayoutDeviceInfo" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment