-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
229 changed files
with
4,141 additions
and
4,234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...src/classic/java/pl/marianjureczko/poszukiwacz/activity/bluetooth/AbstractDeviceHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//package pl.marianjureczko.poszukiwacz.activity.bluetooth | ||
// | ||
//import android.bluetooth.BluetoothDevice | ||
//import android.view.View | ||
//import android.widget.Button | ||
//import androidx.recyclerview.widget.RecyclerView | ||
//import pl.marianjureczko.poszukiwacz.R | ||
// | ||
//abstract class AbstractDeviceHolder(view: View) : RecyclerView.ViewHolder(view) { | ||
// | ||
// val deviceName: Button = itemView.findViewById((R.id.device_name)) | ||
// | ||
// abstract fun setupView(device: BluetoothDevice) | ||
//} |
58 changes: 58 additions & 0 deletions
58
app/src/classic/java/pl/marianjureczko/poszukiwacz/activity/bluetooth/AcceptThread.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//package pl.marianjureczko.poszukiwacz.activity.bluetooth | ||
// | ||
//import android.annotation.SuppressLint | ||
//import android.bluetooth.BluetoothServerSocket | ||
//import android.bluetooth.BluetoothSocket | ||
//import android.content.Context | ||
//import android.util.Log | ||
//import pl.marianjureczko.poszukiwacz.R | ||
//import pl.marianjureczko.poszukiwacz.activity.main.Bluetooth | ||
//import java.io.IOException | ||
// | ||
//@SuppressLint("MissingPermission") | ||
//class AcceptThread( | ||
// memoConsole: MemoConsole, | ||
// private val bluetooth: Bluetooth, | ||
// private val bluetoothConnectionManager: BluetoothConnectionManager, | ||
// private val context: Context | ||
//) : CancellableThread(memoConsole) { | ||
// | ||
// private val TAG = javaClass.simpleName | ||
// private val serverSocket: BluetoothServerSocket? by lazy(LazyThreadSafetyMode.PUBLICATION) { | ||
// bluetooth.adapter?.listenUsingRfcommWithServiceRecord(Bluetooth.NAME, MY_BLUETOOTH_UUID) | ||
// } | ||
// | ||
// override fun run() { | ||
// if (serverSocket == null) { | ||
// printInConsole(context.getString(R.string.no_bluetooth_to_receive_route)) | ||
// return | ||
// } | ||
// // Keep listening until exception occurs or a socket is returned. | ||
// var shouldLoop = true | ||
// while (shouldLoop) { | ||
// val socket: BluetoothSocket? = try { | ||
// printInConsole(context.getString(R.string.bluetooth_waiting_to_accept)) | ||
// serverSocket?.accept() | ||
// } catch (e: IOException) { | ||
// printInConsole(context.getString(R.string.accepting_bluetooth_connection_error) + e.message) | ||
// shouldLoop = false | ||
// null | ||
// } | ||
// socket?.also { | ||
// printInConsole(context.getString(R.string.bluetooth_connection_accepted)) | ||
// bluetoothConnectionManager.readRuteFromConnectedSocket(it) | ||
// serverSocket?.close() | ||
// shouldLoop = false | ||
// } | ||
// } | ||
// } | ||
// | ||
// override fun cancel() { | ||
// super.cancel() | ||
// try { | ||
// serverSocket?.close() | ||
// } catch (e: IOException) { | ||
// Log.e(TAG, "Could not close the connect socket", e) | ||
// } | ||
// } | ||
//} |
74 changes: 74 additions & 0 deletions
74
app/src/classic/java/pl/marianjureczko/poszukiwacz/activity/bluetooth/Bluetooth.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//package pl.marianjureczko.poszukiwacz.activity.main | ||
// | ||
//import android.annotation.SuppressLint | ||
//import android.bluetooth.BluetoothAdapter | ||
//import android.bluetooth.BluetoothClass | ||
//import android.bluetooth.BluetoothDevice | ||
//import pl.marianjureczko.poszukiwacz.R | ||
// | ||
//class BluetoothException(val msgId: Int) : Exception() | ||
// | ||
//class Bluetooth( | ||
//// private val permissionsManager: PermissionsManager | ||
//) { | ||
// companion object { | ||
// val NAME = "MALY_POSZUKIWACZ_SKARBOW" | ||
// } | ||
// | ||
// val adapter: BluetoothAdapter? by lazy { | ||
// BluetoothAdapter.getDefaultAdapter() | ||
// } | ||
// | ||
// @SuppressLint("MissingPermission") | ||
// @Throws(BluetoothException::class) | ||
// fun findDevices(): List<BluetoothDevice> { | ||
// if (adapter == null) { | ||
// throw BluetoothException(R.string.no_bluetooth) | ||
// } | ||
// if (!adapter!!.isEnabled) { | ||
// throw BluetoothException(R.string.bluetooth_disabled) | ||
// } | ||
// return adapter?.bondedDevices | ||
// ?.filter { | ||
// it.bluetoothClass.majorDeviceClass == BluetoothClass.Device.Major.PHONE | ||
// } | ||
// ?: listOf() | ||
// } | ||
// | ||
// fun isConnected() { | ||
// // https://stackoverflow.com/questions/4715865/how-can-i-programmatically-tell-if-a-bluetooth-device-is-connected | ||
// // public void onCreate() { | ||
// // ... | ||
// // IntentFilter filter = new IntentFilter(); | ||
// // filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); | ||
// // filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED); | ||
// // filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); | ||
// // this.registerReceiver(mReceiver, filter); | ||
// //} | ||
// // | ||
// ////The BroadcastReceiver that listens for bluetooth broadcasts | ||
// //private final BroadcastReceiver mReceiver = new BroadcastReceiver() { | ||
// // @Override | ||
// // public void onReceive(Context context, Intent intent) { | ||
// // String action = intent.getAction(); | ||
// // BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); | ||
// // | ||
// // if (BluetoothDevice.ACTION_FOUND.equals(action)) { | ||
// // ... //Device found | ||
// // } | ||
// // else if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) { | ||
// // ... //Device is now connected | ||
// // } | ||
// // else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) { | ||
// // ... //Done searching | ||
// // } | ||
// // else if (BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED.equals(action)) { | ||
// // ... //Device is about to disconnect | ||
// // } | ||
// // else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) { | ||
// // ... //Device has disconnected | ||
// // } | ||
// // } | ||
// //}; | ||
// } | ||
//} |
Oops, something went wrong.