Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Andy B-S
Companion App Android
Commits
ad48e9a9
Commit
ad48e9a9
authored
Aug 22, 2019
by
Anon
Browse files
Implement manual set time button.
parent
d627d0c1
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/de/ccc/events/badge/card10/main/MainFragment.kt
View file @
ad48e9a9
...
...
@@ -29,6 +29,7 @@ import android.view.View
import
android.view.ViewGroup
import
android.widget.Button
import
androidx.constraintlayout.widget.ConstraintLayout
import
androidx.fragment.app.DialogFragment
import
androidx.fragment.app.Fragment
import
de.ccc.events.badge.card10.CARD10_BLUETOOTH_MAC_PREFIX
import
de.ccc.events.badge.card10.R
...
...
@@ -38,6 +39,7 @@ import de.ccc.events.badge.card10.hatchery.AppListFragment
import
de.ccc.events.badge.card10.mood.MoodFragment
import
de.ccc.events.badge.card10.scanner.ScannerFragment
import
de.ccc.events.badge.card10.sparkle.BeautifulFragment
import
de.ccc.events.badge.card10.time.TimeUpdateDialog
import
kotlinx.android.synthetic.main.main_fragment.*
class
MainFragment
:
Fragment
()
{
...
...
@@ -53,6 +55,13 @@ class MainFragment : Fragment() {
button_hatchery
.
setOnClickListener
{
startFragment
(
AppListFragment
())
}
button_send
.
setOnClickListener
{
startFragment
(
FileTransferFragment
())
}
button_set_time
.
setOnClickListener
{
val
dialogFragment
=
TimeUpdateDialog
()
dialogFragment
.
show
(
fragmentManager
,
"time"
)
dialogFragment
.
setTime
()
dialogFragment
.
dismiss
()
}
val
bondedCard10s
=
bluetoothAdapter
.
bondedDevices
.
filter
{
it
.
address
.
startsWith
(
CARD10_BLUETOOTH_MAC_PREFIX
,
true
)
}
...
...
app/src/main/java/de/ccc/events/badge/card10/time/TimeUpdateDialog.kt
0 → 100644
View file @
ad48e9a9
/*
* Copyright by the original author or authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package
de.ccc.events.badge.card10.time
import
android.os.Bundle
import
android.util.Log
import
android.view.LayoutInflater
import
android.view.ViewGroup
import
androidx.fragment.app.DialogFragment
import
de.ccc.events.badge.card10.R
import
de.ccc.events.badge.card10.common.ConnectionService
private
const
val
TAG
=
"TimeUpdateDialog"
class
TimeUpdateDialog
:
DialogFragment
()
{
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?)
=
inflater
.
inflate
(
R
.
layout
.
time_update_dialog
,
container
,
false
)
fun
setTime
()
{
ConnectionService
.
card10Service
?.
setTime
()
?:
Log
.
e
(
TAG
,
"card10 service not initialized"
)
}
}
\ No newline at end of file
app/src/main/res/layout/main_fragment.xml
View file @
ad48e9a9
...
...
@@ -85,6 +85,16 @@
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
/>
<Button
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/main_button_margin"
style=
"@style/MainButton"
android:id=
"@+id/button_set_time"
android:text=
"@string/main_button_set_time"
app:layout_constraintTop_toBottomOf=
"@+id/button_beautiful"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
...
...
app/src/main/res/layout/time_update_dialog.xml
0 → 100644
View file @
ad48e9a9
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:padding=
"@dimen/dialog_padding"
>
<ProgressBar
android:layout_width=
"@dimen/progress_dialog_progress_size"
android:layout_height=
"@dimen/progress_dialog_progress_size"
android:layout_gravity=
"center"
android:indeterminate=
"true"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginTop=
"@dimen/progress_dialog_text_margin"
android:text=
"@string/time_update_dialog_setting"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
ad48e9a9
...
...
@@ -10,6 +10,7 @@
<string
name=
"main_button_send_file"
>
Send File
</string>
<string
name=
"main_button_mood"
>
Change Mood
</string>
<string
name=
"main_button_beautiful"
>
Beautiful
</string>
<string
name=
"main_button_set_time"
>
Set Time
</string>
<string
name=
"file_transfer_button_pick_file"
>
Select file
</string>
<string
name=
"file_transfer_button_start_transfer"
>
Start
</string>
...
...
@@ -32,6 +33,8 @@
<string
name=
"dialog_action_ok"
>
OK
</string>
<string
name=
"dialog_action_cancel"
>
Cancel
</string>
<string
name=
"time_update_dialog_setting"
>
Setting time
</string>
<string
name=
"hatchery_error_generic"
>
Something went wrong
</string>
<string
name=
"app_detail_downloads"
>
Downloads: %1$d
</string>
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment