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
32ce1eb9
Commit
32ce1eb9
authored
Jan 30, 2020
by
akwizgran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show an error message if the address is invalid.
parent
30741380
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
10 deletions
+23
-10
app/build.gradle
app/build.gradle
+2
-2
app/src/main/java/org/briarproject/interferometer/MainActivity.java
...in/java/org/briarproject/interferometer/MainActivity.java
+10
-3
app/src/main/java/org/briarproject/interferometer/MainViewModel.java
...n/java/org/briarproject/interferometer/MainViewModel.java
+7
-2
app/src/main/res/values/colors.xml
app/src/main/res/values/colors.xml
+3
-3
app/src/main/res/values/strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/build.gradle
View file @
32ce1eb9
...
...
@@ -23,6 +23,6 @@ android {
}
dependencies
{
implementation
'androidx.appcompat:appcompat:1.
0.2
'
implementation
'androidx.lifecycle:lifecycle-extensions:2.
1
.0'
implementation
'androidx.appcompat:appcompat:1.
1.0
'
implementation
'androidx.lifecycle:lifecycle-extensions:2.
2
.0'
}
app/src/main/java/org/briarproject/interferometer/MainActivity.java
View file @
32ce1eb9
...
...
@@ -5,16 +5,20 @@ import android.view.View;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
org.briarproject.interferometer.MainViewModel.ConnectionState
;
import
org.briarproject.interferometer.MainViewModel.StartResult
;
import
org.briarproject.interferometer.MainViewModel.TestPhase
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.lifecycle.ViewModelProvider
s
;
import
androidx.lifecycle.ViewModelProvider
;
import
static
android
.
widget
.
Toast
.
LENGTH_SHORT
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
ConnectionState
.
DISCONNECTED
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
ConnectionState
.
DOWNLOADING
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
ConnectionState
.
UPLOADING
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
StartResult
.
INVALID_ADDRESS
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
TestPhase
.
READY
;
public
class
MainActivity
extends
AppCompatActivity
{
...
...
@@ -30,7 +34,7 @@ public class MainActivity extends AppCompatActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
viewModel
=
ViewModelProviders
.
of
(
this
).
get
(
MainViewModel
.
class
);
viewModel
=
new
ViewModelProvider
(
this
).
get
(
MainViewModel
.
class
);
serverAddressEditText
=
findViewById
(
R
.
id
.
server_address_edit_text
);
throughputTextView
=
findViewById
(
R
.
id
.
throughput_text_view
);
...
...
@@ -66,7 +70,10 @@ public class MainActivity extends AppCompatActivity {
public
void
onTestClick
(
View
view
)
{
TestPhase
phase
=
viewModel
.
getTestPhase
().
getValue
();
if
(
phase
==
null
||
phase
==
READY
)
{
viewModel
.
startTest
(
serverAddressEditText
.
getText
().
toString
());
StartResult
result
=
viewModel
.
startTest
(
serverAddressEditText
.
getText
().
toString
());
if
(
result
==
INVALID_ADDRESS
)
{
Toast
.
makeText
(
this
,
R
.
string
.
server_address_error
,
LENGTH_SHORT
).
show
();
}
}
else
{
viewModel
.
stopTest
();
}
...
...
app/src/main/java/org/briarproject/interferometer/MainViewModel.java
View file @
32ce1eb9
...
...
@@ -23,6 +23,8 @@ import androidx.lifecycle.ViewModel;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
ConnectionState
.
DISCONNECTED
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
ConnectionState
.
DOWNLOADING
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
ConnectionState
.
UPLOADING
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
StartResult
.
INVALID_ADDRESS
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
StartResult
.
STARTED
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
TestPhase
.
DOWNLOAD
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
TestPhase
.
READY
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
TestPhase
.
UPLOAD
;
...
...
@@ -33,6 +35,8 @@ public class MainViewModel extends ViewModel {
enum
ConnectionState
{
DISCONNECTED
,
DOWNLOADING
,
UPLOADING
}
enum
StartResult
{
INVALID_ADDRESS
,
STARTED
}
private
static
final
byte
CONNECTION_TYPE_UPLOAD
=
0
;
private
static
final
byte
CONNECTION_TYPE_DOWNLOAD
=
1
;
private
static
final
int
BUFFER_SIZE
=
4096
;
...
...
@@ -62,9 +66,9 @@ public class MainViewModel extends ViewModel {
}
@UiThread
void
startTest
(
String
serverAddress
)
{
StartResult
startTest
(
String
serverAddress
)
{
HostPort
hostPort
=
parseServerAddress
(
serverAddress
);
if
(
hostPort
==
null
)
return
;
if
(
hostPort
==
null
)
return
INVALID_ADDRESS
;
task
=
executorService
.
submit
(()
->
{
try
{
testPhase
.
postValue
(
DOWNLOAD
);
...
...
@@ -86,6 +90,7 @@ public class MainViewModel extends ViewModel {
testPhase
.
postValue
(
READY
);
}
});
return
STARTED
;
}
@UiThread
...
...
app/src/main/res/values/colors.xml
View file @
32ce1eb9
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name=
"colorPrimary"
>
#00
8577
</color>
<color
name=
"colorPrimaryDark"
>
#00
574B
</color>
<color
name=
"colorAccent"
>
#
D81B60
</color>
<color
name=
"colorPrimary"
>
#00
7766
</color>
<color
name=
"colorPrimaryDark"
>
#00
4433
</color>
<color
name=
"colorAccent"
>
#
00AA99
</color>
</resources>
app/src/main/res/values/strings.xml
View file @
32ce1eb9
...
...
@@ -2,6 +2,7 @@
<string
name=
"app_name"
>
Interferometer
</string>
<string
name=
"server_address"
>
Server address
</string>
<string
name=
"server_address_error"
>
Invalid address
</string>
<string
name=
"start_test"
>
Start test
</string>
<string
name=
"stop_test"
>
Stop test
</string>
...
...
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