Skip to content
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

show error when fail to connect #1939

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class BluetoothFailedDialogFragment : FullScreenDialogFragment() {
val questions = resources.getStringArray(R.array.faq_issues).toList()
val answers = resources.getStringArray(R.array.faq_answers).toList()
bind.faqList.setAdapter(BluetoothTroubleshootAdapter(requireContext(),questions, answers))
bind.errorDisplay.text = PreferenceManager.getDefaultSharedPreferences(requireContext()).getString("connectError", "")
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ class BluetoothChatService @JvmOverloads constructor(handler: Handler? = null, a
private val mmSocket: BluetoothSocket?
private val mSocketType: String
override fun run() {
val preferences = PreferenceManager.getDefaultSharedPreferences(applicationContext)
name = "ConnectThread$mSocketType"
[email protected] = Constants.STATE_CONNECTING
// Always cancel discovery because it will slow down a connection
Expand All @@ -276,6 +277,7 @@ class BluetoothChatService @JvmOverloads constructor(handler: Handler? = null, a
} catch (e: Exception) {
// Close the socket
logE("ERROR WHILE CONNECTING $e")
preferences.edit().putString("connectError", "$e").apply()
closeSocket()
connectionFailed()
return
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/res/layout/dialog_bluetooth_troubleshooting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,25 @@
android:textColor="@color/daynight_textColor"
app:layout_constraintTop_toBottomOf="@+id/textView4" />

<TextView
android:id="@+id/errorDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:textColor="@color/daynight_textColor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/reasons_title" />

<ExpandableListView
android:id="@+id/faq_list"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_margin="@dimen/margin_large"
android:minHeight="300dp"
app:layout_constraintBottom_toTopOf="@+id/closeButton"
app:layout_constraintTop_toBottomOf="@+id/reasons_title" />
app:layout_constraintTop_toBottomOf="@+id/errorDisplay" />

<CheckBox
android:id="@+id/show_again"
Expand Down