Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
interferometer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
akwizgran
interferometer
Commits
56c7ef02
Commit
56c7ef02
authored
Jan 30, 2020
by
akwizgran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show test phase in UI.
parent
b7f7084c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
14 deletions
+34
-14
app/src/main/java/org/briarproject/interferometer/MainActivity.java
...in/java/org/briarproject/interferometer/MainActivity.java
+24
-11
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_main.xml
+7
-3
app/src/main/res/values/strings.xml
app/src/main/res/values/strings.xml
+3
-0
No files found.
app/src/main/java/org/briarproject/interferometer/MainActivity.java
View file @
56c7ef02
...
...
@@ -20,13 +20,16 @@ import static org.briarproject.interferometer.MainViewModel.ConnectionState.DOWN
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
ConnectionState
.
UPLOADING
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
StartResult
.
INVALID_ADDRESS
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
StartResult
.
NO_BLUETOOTH
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
TestPhase
.
BASELINE
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
TestPhase
.
BLUETOOTH
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
TestPhase
.
READY
;
public
class
MainActivity
extends
AppCompatActivity
{
private
MainViewModel
viewModel
;
private
EditText
serverAddressEditText
;
private
TextView
throughputTextView
;
private
Button
testButton
;
private
TextView
testPhaseTextView
,
throughputTextView
;
private
ConnectionState
state
=
DISCONNECTED
;
private
long
throughput
=
0
;
...
...
@@ -35,30 +38,27 @@ public class MainActivity extends AppCompatActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
viewModel
=
new
ViewModelProvider
(
this
).
get
(
MainViewModel
.
class
);
serverAddressEditText
=
findViewById
(
R
.
id
.
server_address_edit_text
);
testPhaseTextView
=
findViewById
(
R
.
id
.
test_phase_text_view
);
throughputTextView
=
findViewById
(
R
.
id
.
throughput_text_view
);
testButton
=
findViewById
(
R
.
id
.
test_button
);
showThroughput
(
state
,
throughput
);
Button
testButton
=
findViewById
(
R
.
id
.
test_button
);
viewModel
.
getTestPhase
().
observe
(
this
,
phase
->
{
if
(
phase
==
READY
)
testButton
.
setText
(
R
.
string
.
start_test
);
else
testButton
.
setText
(
R
.
string
.
stop_test
);
});
viewModel
.
getTestPhase
().
observe
(
this
,
this
::
showTestPhase
);
viewModel
.
getConnectionState
().
observe
(
this
,
state
->
{
this
.
state
=
state
;
showThroughput
(
state
,
throughput
);
showThroughput
();
});
viewModel
.
getThroughput
().
observe
(
this
,
throughput
->
{
this
.
throughput
=
throughput
;
showThroughput
(
state
,
throughput
);
showThroughput
();
});
}
private
void
showThroughput
(
ConnectionState
state
,
long
throughput
)
{
private
void
showThroughput
()
{
if
(
state
==
DISCONNECTED
)
{
throughputTextView
.
setText
(
null
);
}
else
if
(
state
==
DOWNLOADING
)
{
...
...
@@ -68,6 +68,19 @@ public class MainActivity extends AppCompatActivity {
}
}
private
void
showTestPhase
(
TestPhase
phase
)
{
if
(
phase
==
READY
)
{
testButton
.
setText
(
R
.
string
.
start_test
);
testPhaseTextView
.
setText
(
null
);
}
else
if
(
phase
==
BASELINE
)
{
testButton
.
setText
(
R
.
string
.
stop_test
);
testPhaseTextView
.
setText
(
R
.
string
.
testing_baseline
);
}
else
if
(
phase
==
BLUETOOTH
)
{
testButton
.
setText
(
R
.
string
.
stop_test
);
testPhaseTextView
.
setText
(
R
.
string
.
testing_bluetooth
);
}
}
public
void
onTestClick
(
View
view
)
{
TestPhase
phase
=
viewModel
.
getTestPhase
().
getValue
();
if
(
phase
==
null
||
phase
==
READY
)
{
...
...
app/src/main/res/layout/activity_main.xml
View file @
56c7ef02
...
...
@@ -3,7 +3,7 @@
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:
layout_margin=
"16
dp"
android:
padding=
"32
dp"
android:gravity=
"center"
android:orientation=
"vertical"
tools:context=
".MainActivity"
>
...
...
@@ -12,7 +12,6 @@
android:id=
"@+id/server_address_edit_text"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"16dp"
android:hint=
"@string/server_address"
android:inputType=
"textUri"
android:text=
"@string/default_server_address"
...
...
@@ -27,11 +26,16 @@
android:text=
"@string/start_test"
tools:ignore=
"ButtonStyle"
/>
<TextView
android:id=
"@+id/test_phase_text_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
""
/>
<TextView
android:id=
"@+id/throughput_text_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"16dp"
android:text=
""
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
56c7ef02
...
...
@@ -9,6 +9,9 @@
<string
name=
"start_test"
>
Start test
</string>
<string
name=
"stop_test"
>
Stop test
</string>
<string
name=
"testing_baseline"
>
Testing with Bluetooth disabled
</string>
<string
name=
"testing_bluetooth"
>
Testing with Bluetooth enabled
</string>
<string
name=
"download_format"
>
Download: %,d bytes/sec
</string>
<string
name=
"upload_format"
>
Upload: %,d bytes/sec
</string>
</resources>
Write
Preview
Markdown
is supported
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