Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stefan Zabka
Companion App Android
Commits
ec3ba800
Commit
ec3ba800
authored
Aug 19, 2019
by
Anon
Browse files
Add input field for destination path.
parent
9329a4ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/de/ccc/events/badge/card10/filetransfer/FileTransfer.kt
View file @
ec3ba800
...
...
@@ -34,7 +34,8 @@ private const val TAG = "FileTransfer"
class
FileTransfer
(
private
val
service
:
LowEffortService
,
private
val
reader
:
ChunkedReader
,
private
var
listener
:
FileTransferListener
private
var
listener
:
FileTransferListener
,
private
val
destinationPath
:
String
)
:
OnPacketReceivedListener
{
private
var
currentState
=
TransferState
.
IDLE
...
...
@@ -100,7 +101,7 @@ class FileTransfer(
service
.
sendPacket
(
Packet
(
PacketType
.
START
,
"/foo.py"
.
toByteArray
(
Charset
.
forName
(
"ASCII"
))
destinationPath
.
toByteArray
(
Charset
.
forName
(
"ASCII"
))
)
)
currentState
=
TransferState
.
START_SENT
...
...
app/src/main/java/de/ccc/events/badge/card10/filetransfer/FileTransferFragment.kt
View file @
ec3ba800
...
...
@@ -30,6 +30,7 @@ import android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.Button
import
android.widget.EditText
import
android.widget.ProgressBar
import
android.widget.TextView
import
androidx.annotation.UiThread
...
...
@@ -53,6 +54,7 @@ class FileTransferFragment : Fragment(), GattListener, FileTransferListener{
private
lateinit
var
tvSelected
:
TextView
private
lateinit
var
tvStatus
:
TextView
private
lateinit
var
progressBar
:
ProgressBar
private
lateinit
var
inputDestination
:
EditText
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
return
inflater
.
inflate
(
R
.
layout
.
file_transfer_fragment
,
container
,
false
)
...
...
@@ -62,6 +64,7 @@ class FileTransferFragment : Fragment(), GattListener, FileTransferListener{
tvSelected
=
view
.
findViewById
(
R
.
id
.
label_selected
)
tvStatus
=
view
.
findViewById
(
R
.
id
.
label_status
)
progressBar
=
view
.
findViewById
(
R
.
id
.
progress
)
inputDestination
=
view
.
findViewById
(
R
.
id
.
input_destination
)
buttonPickFile
=
view
.
findViewById
(
R
.
id
.
button_pick_file
)
buttonPickFile
.
setOnClickListener
{
...
...
@@ -95,7 +98,7 @@ class FileTransferFragment : Fragment(), GattListener, FileTransferListener{
val
reader
=
ChunkedReader
(
ctx
,
uri
,
ConnectionService
.
mtu
)
val
service
=
ConnectionService
.
leService
?:
throw
IllegalStateException
()
transfer
=
FileTransfer
(
service
,
reader
,
this
)
transfer
=
FileTransfer
(
service
,
reader
,
this
,
inputDestination
.
text
.
toString
()
)
}
catch
(
e
:
Exception
)
{
Log
.
e
(
TAG
,
"Failed to initialize transfer"
)
return
...
...
app/src/main/res/layout/file_transfer_fragment.xml
View file @
ec3ba800
...
...
@@ -25,6 +25,23 @@
app:layout_constraintTop_toBottomOf=
"@id/button_pick_file"
android:text=
"@string/file_transfer_label_no_file_selected"
/>
<EditText
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/input_destination"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/label_selected"
android:importantForAutofill=
"no"
android:hint=
"@string/file_transfer_hint_destination"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/label_destination_help"
android:text=
"@string/file_transfer_label_destination_help"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/input_destination"
/>
<Button
android:id=
"@+id/button_start_stop_transfer"
android:layout_width=
"wrap_content"
...
...
@@ -32,8 +49,8 @@
android:layout_marginTop=
"@dimen/send_label_margin"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/label_
selected
"
android:text=
"@string/file_transfer_button_start_transfer"
/>
app:layout_constraintTop_toBottomOf=
"@id/label_
destination_help
"
android:text=
"@string/file_transfer_button_start_transfer"
/>
<TextView
android:id=
"@+id/label_status"
...
...
app/src/main/res/values/strings.xml
View file @
ec3ba800
...
...
@@ -16,6 +16,8 @@
<string
name=
"file_transfer_button_stop_transfer"
>
Cancel
</string>
<string
name=
"file_transfer_label_no_file_selected"
>
No file selected
</string>
<string
name=
"file_transfer_label_selected_file"
>
Selected file:
</string>
<string
name=
"file_transfer_hint_destination"
>
Destination path
</string>
<string
name=
"file_transfer_label_destination_help"
>
(e.g. /test.py)
</string>
<string
name=
"loading_dialog_loading"
>
Loading
</string>
<string
name=
"dialog_action_ok"
>
OK
</string>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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