Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Companion App Android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andy B-S
Companion App Android
Commits
3fd6494c
Commit
3fd6494c
authored
Aug 17, 2019
by
Andreas Schildbach
Browse files
Options
Downloads
Patches
Plain Diff
MainFragment: Show pairing status in status line.
parent
500e95d0
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/de/ccc/events/badge/card10/main/MainFragment.kt
+13
-8
13 additions, 8 deletions
...main/java/de/ccc/events/badge/card10/main/MainFragment.kt
app/src/main/res/values/strings.xml
+1
-0
1 addition, 0 deletions
app/src/main/res/values/strings.xml
with
14 additions
and
8 deletions
app/src/main/java/de/ccc/events/badge/card10/main/MainFragment.kt
+
13
−
8
View file @
3fd6494c
...
...
@@ -22,24 +22,36 @@
package
de.ccc.events.badge.card10.main
import
android.bluetooth.BluetoothAdapter
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.Button
import
android.widget.TextView
import
androidx.constraintlayout.widget.ConstraintLayout
import
androidx.fragment.app.Fragment
import
de.ccc.events.badge.card10.CARD10_BLUETOOTH_MAC_PREFIX
import
de.ccc.events.badge.card10.R
import
de.ccc.events.badge.card10.common.ConnectionService
import
de.ccc.events.badge.card10.scanner.ScannerFragment
import
kotlinx.android.synthetic.main.main_fragment.*
class
MainFragment
:
Fragment
()
{
private
val
bluetoothAdapter
=
BluetoothAdapter
.
getDefaultAdapter
()
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?)
=
inflater
.
inflate
(
R
.
layout
.
main_fragment
,
container
,
false
)
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
val
bondedCard10s
=
bluetoothAdapter
.
bondedDevices
.
filter
{
it
.
address
.
startsWith
(
CARD10_BLUETOOTH_MAC_PREFIX
,
true
)
}
if
(
bondedCard10s
.
isNotEmpty
())
{
val
device
=
bondedCard10s
.
get
(
0
)
label_status
.
text
=
getString
(
R
.
string
.
main_label_paired
,
device
.
name
,
device
.
address
)
}
else
{
label_status
.
text
=
getString
(
R
.
string
.
main_label_not_connected
)
}
if
(
ConnectionService
.
isConnected
())
{
showConnectedView
(
view
)
}
else
{
...
...
@@ -51,10 +63,6 @@ class MainFragment : Fragment() {
view
.
findViewById
<
ConstraintLayout
>(
R
.
id
.
container_connected
).
visibility
=
View
.
VISIBLE
view
.
findViewById
<
ConstraintLayout
>(
R
.
id
.
container_disconnected
).
visibility
=
View
.
GONE
val
tvStatus
=
view
.
findViewById
<
TextView
>(
R
.
id
.
label_status
)
tvStatus
.
text
=
getString
(
R
.
string
.
main_label_status
,
ConnectionService
.
deviceName
,
ConnectionService
.
deviceAddress
)
val
buttonSend
=
view
.
findViewById
<
Button
>(
R
.
id
.
button_send
)
buttonSend
.
setOnClickListener
{
// TODO: Open file transfer fragment
...
...
@@ -65,9 +73,6 @@ class MainFragment : Fragment() {
view
.
findViewById
<
ConstraintLayout
>(
R
.
id
.
container_connected
).
visibility
=
View
.
GONE
view
.
findViewById
<
ConstraintLayout
>(
R
.
id
.
container_disconnected
).
visibility
=
View
.
VISIBLE
val
tvStatus
=
view
.
findViewById
<
TextView
>(
R
.
id
.
label_status
)
tvStatus
.
text
=
getString
(
R
.
string
.
main_label_not_connected
)
button_pair
.
setOnClickListener
{
fragmentManager
!!
.
beginTransaction
()
.
replace
(
R
.
id
.
fragment_container
,
ScannerFragment
())
...
...
This diff is collapsed.
Click to expand it.
app/src/main/res/values/strings.xml
+
1
−
0
View file @
3fd6494c
<resources>
<string
name=
"app_name"
>
card10 Companion
</string>
<string
name=
"main_label_paired"
>
You are paired to %1$s (%2$s)
</string>
<string
name=
"main_label_not_connected"
>
You are currently not connected to your card10.
</string>
<string
name=
"main_label_status"
>
You are connected to %1$s (%2$s)
</string>
<string
name=
"main_button_connect"
>
Connect
</string>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment