Skip to content

Commit d0a1a95

Browse files
committed
set up basic project structure; implement basic Utils
1 parent 17cb2e2 commit d0a1a95

File tree

7 files changed

+190
-4
lines changed

7 files changed

+190
-4
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.lcl.lclmeasurementtool.Functionality;
2+
3+
/**
4+
* Iperf a functionality module that is able to
5+
* test the upload and download speed from the current device.
6+
*/
7+
public class Iperf {
8+
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.lcl.lclmeasurementtool.Functionality;
2+
3+
/**
4+
* Ping is a functionality module that is able to
5+
* run ping test to test the reachability between a host and the current device.
6+
*/
7+
8+
public class Ping {
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.lcl.lclmeasurementtool.Managers;
2+
import android.telephony.TelephonyManager;
3+
4+
/**
5+
* CellularManager monitors changes in device's signal strength and
6+
* report changes(callback) to front-end UI
7+
*/
8+
9+
public class CellularManager {
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.lcl.lclmeasurementtool.Managers;
2+
import android.net.ConnectivityManager;
3+
4+
/**
5+
* NetworkManager manages all network related information, including but not limited to
6+
* connectivity states, active network information(wifi, cellular) and
7+
* listen to changes in network states.
8+
*/
9+
10+
public class NetworkManager {
11+
12+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.lcl.lclmeasurementtool.Utils;
2+
3+
public class ConvertUtils {
4+
5+
// the conversion rate between megabit and megabyte
6+
public static final int CONVERSION_RATE = 8;
7+
8+
/**
9+
* Convert data in MBps to Mbps
10+
*
11+
* @param MBps the data to be converted in MBps
12+
* @return corresponding data in Mbps
13+
*/
14+
public static double toMbps(double MBps) {
15+
return MBps * CONVERSION_RATE;
16+
}
17+
18+
/**
19+
* Convert data in Mbps to MBps
20+
*
21+
* @param Mbps the data to be converted in Mbps
22+
* @return corresponding data in MBps
23+
*/
24+
public static double toMBps(double Mbps) {
25+
return Mbps / CONVERSION_RATE;
26+
}
27+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.lcl.lclmeasurementtool.Utils;
2+
3+
public enum SignalStrength {
4+
NONE(0), // the signal strength is none or unknown
5+
POOR(1), // the signal strength is poor
6+
MODERATE(2), // the signal strength is moderate
7+
GOOD(3), // the signal strength is good
8+
GREAT(4); // the signal strength is great
9+
10+
// the numerical equivalence of the signal strength
11+
private final int levelCode;
12+
13+
// constructor
14+
SignalStrength(int levelCode) {
15+
this.levelCode = levelCode;
16+
}
17+
18+
/**
19+
* Get the numerical level code corresponding to the signal strength
20+
* @return an integer associates with the signal strength
21+
*/
22+
public int getLevelCode() {
23+
return this.levelCode;
24+
}
25+
26+
@Override
27+
public String toString() {
28+
return "SignalStrength{" +
29+
this.name() + " " +
30+
"levelCode=" + levelCode +
31+
'}';
32+
}
33+
}

app/src/main/res/layout/activity_main.xml

Lines changed: 90 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,98 @@
77
tools:context=".MainActivity">
88

99
<TextView
10+
android:id="@+id/cellularStatusLabel"
1011
android:layout_width="wrap_content"
1112
android:layout_height="wrap_content"
12-
android:text="Hello World!"
13-
app:layout_constraintBottom_toBottomOf="parent"
14-
app:layout_constraintLeft_toLeftOf="parent"
15-
app:layout_constraintRight_toRightOf="parent"
13+
android:layout_marginStart="53dp"
14+
android:layout_marginTop="110dp"
15+
android:text="WiFi off?"
16+
app:layout_constraintStart_toStartOf="parent"
17+
app:layout_constraintTop_toTopOf="parent" />
18+
19+
<TextView
20+
android:id="@+id/cellularStatus"
21+
android:layout_width="wrap_content"
22+
android:layout_height="wrap_content"
23+
android:layout_marginStart="20dp"
24+
android:layout_marginTop="110dp"
25+
app:layout_constraintStart_toEndOf="@+id/cellularStatusLabel"
26+
app:layout_constraintTop_toTopOf="parent" />
27+
28+
<TextView
29+
android:id="@+id/signalStrengthLabel"
30+
android:layout_width="wrap_content"
31+
android:layout_height="wrap_content"
32+
android:layout_marginStart="53dp"
33+
android:layout_marginTop="22dp"
34+
android:text="Signal Strength: "
35+
app:layout_constraintStart_toStartOf="parent"
36+
app:layout_constraintTop_toBottomOf="@+id/cellularStatusLabel" />
37+
38+
<TextView
39+
android:id="@+id/signalStrengthStatus"
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:layout_marginStart="21dp"
43+
android:layout_marginTop="152dp"
44+
app:layout_constraintStart_toEndOf="@+id/signalStrengthLabel"
45+
app:layout_constraintTop_toTopOf="parent" />
46+
47+
<TextView
48+
android:id="@+id/pingLabel"
49+
android:layout_width="wrap_content"
50+
android:layout_height="wrap_content"
51+
android:layout_marginStart="52dp"
52+
android:layout_marginTop="29dp"
53+
android:text="Ping: "
54+
app:layout_constraintStart_toStartOf="parent"
55+
app:layout_constraintTop_toBottomOf="@+id/signalStrengthLabel" />
56+
57+
<TextView
58+
android:id="@+id/pingStatus"
59+
android:layout_width="wrap_content"
60+
android:layout_height="wrap_content"
61+
android:layout_marginStart="31dp"
62+
android:layout_marginTop="29dp"
63+
app:layout_constraintStart_toEndOf="@+id/pingLabel"
64+
app:layout_constraintTop_toBottomOf="@+id/signalStrengthLabel" />
65+
66+
<TextView
67+
android:id="@+id/uploadLabel"
68+
android:layout_width="wrap_content"
69+
android:layout_height="wrap_content"
70+
android:layout_marginStart="50dp"
71+
android:layout_marginTop="24dp"
72+
android:text="Upload Speed: "
73+
app:layout_constraintStart_toStartOf="parent"
74+
app:layout_constraintTop_toBottomOf="@+id/pingLabel" />
75+
76+
<TextView
77+
android:id="@+id/uploadSpeed"
78+
android:layout_width="wrap_content"
79+
android:layout_height="wrap_content"
80+
android:layout_marginStart="24dp"
81+
android:layout_marginTop="242dp"
82+
app:layout_constraintStart_toEndOf="@+id/uploadLabel"
83+
app:layout_constraintTop_toTopOf="parent" />
84+
85+
<TextView
86+
android:id="@+id/downloadLabel"
87+
android:layout_width="wrap_content"
88+
android:layout_height="wrap_content"
89+
android:layout_marginStart="49dp"
90+
android:layout_marginTop="29dp"
91+
android:text="Download Speed: "
92+
app:layout_constraintStart_toStartOf="parent"
93+
app:layout_constraintTop_toBottomOf="@+id/uploadLabel" />
94+
95+
<TextView
96+
android:id="@+id/downloadSpeed"
97+
android:layout_width="wrap_content"
98+
android:layout_height="wrap_content"
99+
android:layout_marginStart="18dp"
100+
android:layout_marginTop="292dp"
101+
app:layout_constraintStart_toEndOf="@+id/downloadLabel"
16102
app:layout_constraintTop_toTopOf="parent" />
17103

18104
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)