-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: feature to turn bluetooth on #585
Conversation
@adityastic please review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, This would be very handy. Can you shift the bluetooth adapter from the textfragment and make it a singleton and use it to perform bluetooth operations
@@ -77,6 +77,7 @@ class TextArtFragment : BaseFragment() { | |||
private val modeAdapter = ModeAdapter() | |||
|
|||
private val viewModel by sharedViewModel<TextArtViewModel>() | |||
private val bluetoothManager: org.fossasia.badgemagic.util.BluetoothManager by inject() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why using FQN
|
||
class BluetoothManager(val context: Context) { | ||
private val btManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager | ||
val btAdapter = btManager.adapter!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep this private
if (btAdapter.disable()) { | ||
btAdapter.enable() | ||
if (bluetoothManager.btAdapter.disable()) { | ||
bluetoothManager.btAdapter.enable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a function inside the singleton to enable bluetooth and shift everything there
} | ||
|
||
private fun turnOnBluetooth() { | ||
if (bluetoothManager.btAdapter.disable()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamareebjamal Looks good to me 👍👍
Fixes #584
Screenshots for the change: