Skip to content

Commit e60b1c3

Browse files
committed
integrate libndt7 + add sync worker to sync data with the server if not reported
1 parent be8f551 commit e60b1c3

31 files changed

+656
-395
lines changed

app/build.gradle

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,17 @@ dependencies {
7777
implementation project(":libndt7")
7878
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
7979
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
80-
implementation 'androidx.core:core-ktx:1.3.2'
80+
implementation 'androidx.core:core-ktx:1.9.0'
8181
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
8282
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0"
8383

8484
def appCenterSdkVersion = '4.1.0'
85-
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
85+
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
8686
// implementation "androidx.work:work-runtime:2.5.0"
87-
implementation 'androidx.work:work-runtime-ktx:2.7.1'
87+
implementation 'androidx.work:work-runtime-ktx:2.8.1'
88+
implementation("androidx.hilt:hilt-work:1.0.0")
89+
kapt("androidx.hilt:hilt-compiler:1.0.0")
90+
8891
implementation fileTree(dir: 'libs', include: ['*.jar'])
8992
implementation 'androidx.appcompat:appcompat:1.3.0'
9093
implementation 'com.google.android.material:material:1.3.0'
@@ -109,6 +112,9 @@ dependencies {
109112

110113
implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.0-alpha03"
111114

115+
// start up runtime
116+
implementation "androidx.startup:startup-runtime:1.1.1"
117+
112118

113119
// datastore with protobuf preferences
114120
implementation "androidx.datastore:datastore-preferences:1.0.0"
@@ -148,8 +154,8 @@ dependencies {
148154
implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
149155

150156
testImplementation 'junit:junit:4.+'
151-
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
152-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
157+
// androidTestImplementation 'androidx.test.ext:junit:1.1.5'
158+
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
153159
implementation "androidx.room:room-runtime:2.3.0"
154160
annotationProcessor "androidx.room:room-compiler:2.3.0"
155161
androidTestImplementation "androidx.room:room-testing:2.3.0"
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
package com.lcl.lclmeasurementtool;
2-
3-
import android.content.Context;
4-
5-
import androidx.test.platform.app.InstrumentationRegistry;
6-
import androidx.test.ext.junit.runners.AndroidJUnit4;
7-
8-
import org.junit.Test;
9-
import org.junit.runner.RunWith;
10-
11-
import static org.junit.Assert.*;
12-
13-
/**
14-
* Instrumented test, which will execute on an Android device.
15-
*
16-
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17-
*/
18-
@RunWith(AndroidJUnit4.class)
19-
public class ExampleInstrumentedTest {
20-
@Test
21-
public void useAppContext() {
22-
// Context of the app under test.
23-
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24-
assertEquals("com.lcl.lclmeasurementtool", appContext.getPackageName());
25-
}
26-
}
1+
//package com.lcl.lclmeasurementtool;
2+
//
3+
//import android.content.Context;
4+
//
5+
//import androidx.test.platform.app.InstrumentationRegistry;
6+
//import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
//
8+
//import org.junit.Test;
9+
//import org.junit.runner.RunWith;
10+
//
11+
//import static org.junit.Assert.*;
12+
//
13+
///**
14+
// * Instrumented test, which will execute on an Android device.
15+
// *
16+
// * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
// */
18+
//@RunWith(AndroidJUnit4.class)
19+
//public class ExampleInstrumentedTest {
20+
// @Test
21+
// public void useAppContext() {
22+
// // Context of the app under test.
23+
// Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
// assertEquals("com.lcl.lclmeasurementtool", appContext.getPackageName());
25+
// }
26+
//}
Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1-
package com.lcl.lclmeasurementtool;
2-
3-
import android.content.Context;
4-
5-
import androidx.room.Room;
6-
import androidx.test.core.app.ApplicationProvider;
7-
import androidx.test.ext.junit.runners.AndroidJUnit4;
8-
9-
import com.lcl.lclmeasurementtool.database.db.MeasurementResultDatabase;
10-
import com.lcl.lclmeasurementtool.database.Entity.SignalStrengthDAO;
11-
12-
import org.junit.After;
13-
import org.junit.Before;
14-
import org.junit.Test;
15-
import org.junit.runner.RunWith;
16-
17-
import java.io.IOException;
18-
19-
@RunWith(AndroidJUnit4.class)
20-
public class SignalStrengthReadAndWriteTest {
21-
22-
private MeasurementResultDatabase db;
23-
private SignalStrengthDAO ssDAO;
24-
25-
@Before
26-
public void create() {
27-
Context context = ApplicationProvider.getApplicationContext();
28-
db = Room.inMemoryDatabaseBuilder(context, MeasurementResultDatabase.class).build();
29-
ssDAO = db.signalStrengthDAO();
30-
}
31-
32-
@After
33-
public void cleanUp() throws IOException {
34-
db.close();
35-
}
36-
37-
@Test
38-
public void testSimpleWrite() {
39-
// ssDAO.insert(new SignalStrength("124",-98, 3));
40-
// Assert.assertEquals(1, ssDAO.retrieveAllSignalStrengths().size());
41-
}
42-
43-
@Test
44-
public void testDuplicates() {
45-
46-
}
47-
48-
@Test
49-
public void testRead() {
50-
51-
}
52-
}
1+
//package com.lcl.lclmeasurementtool;
2+
//
3+
//import android.content.Context;
4+
//
5+
//import androidx.room.Room;
6+
//import androidx.test.core.app.ApplicationProvider;
7+
//import androidx.test.ext.junit.runners.AndroidJUnit4;
8+
//
9+
//import com.lcl.lclmeasurementtool.database.db.MeasurementResultDatabase;
10+
//import com.lcl.lclmeasurementtool.database.Entity.SignalStrengthDAO;
11+
//
12+
//import org.junit.After;
13+
//import org.junit.Before;
14+
//import org.junit.Test;
15+
//import org.junit.runner.RunWith;
16+
//
17+
//import java.io.IOException;
18+
//
19+
//@RunWith(AndroidJUnit4.class)
20+
//public class SignalStrengthReadAndWriteTest {
21+
//
22+
// private MeasurementResultDatabase db;
23+
// private SignalStrengthDAO ssDAO;
24+
//
25+
// @Before
26+
// public void create() {
27+
// Context context = ApplicationProvider.getApplicationContext();
28+
// db = Room.inMemoryDatabaseBuilder(context, MeasurementResultDatabase.class).build();
29+
// ssDAO = db.signalStrengthDAO();
30+
// }
31+
//
32+
// @After
33+
// public void cleanUp() throws IOException {
34+
// db.close();
35+
// }
36+
//
37+
// @Test
38+
// public void testSimpleWrite() {
39+
//// ssDAO.insert(new SignalStrength("124",-98, 3));
40+
//// Assert.assertEquals(1, ssDAO.retrieveAllSignalStrengths().size());
41+
// }
42+
//
43+
// @Test
44+
// public void testDuplicates() {
45+
//
46+
// }
47+
//
48+
// @Test
49+
// public void testRead() {
50+
//
51+
// }
52+
//}

app/src/main/AndroidManifest.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="com.lcl.lclmeasurementtool">
45

56
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
@@ -49,6 +50,25 @@
4950
android:resource="@xml/filepaths" />
5051
</provider>
5152

53+
<!-- If you want to disable android.startup completely. -->
54+
<!-- <provider-->
55+
<!-- android:name="androidx.startup.InitializationProvider"-->
56+
<!-- android:authorities="${applicationId}.androidx-startup"-->
57+
<!-- android:exported="false"-->
58+
<!-- tools:node="remove">-->
59+
<!-- </provider>-->
60+
61+
<provider
62+
android:name="androidx.startup.InitializationProvider"
63+
android:authorities="${applicationId}.androidx-startup"
64+
android:exported="false"
65+
tools:node="merge">
66+
<meta-data
67+
android:name="com.lcl.lclmeasurementtool.sync.SyncInitializer"
68+
android:value="androidx.startup"
69+
tools:node="remove" />
70+
</provider>
71+
5272
<meta-data
5373
android:name="com.google.android.gms.version"
5474
android:value="@integer/google_play_services_version" />
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
package com.lcl.lclmeasurementtool
22

33
import android.app.Application
4+
import androidx.hilt.work.HiltWorkerFactory
5+
import androidx.work.Configuration
46
import dagger.hilt.android.HiltAndroidApp
7+
import javax.inject.Inject
58

69
/**
710
* [Application] class for LCL Measurement tool
811
*/
912
@HiltAndroidApp
10-
class LCLApplication : Application()
13+
class LCLApplication : Application(), Configuration.Provider {
14+
@Inject lateinit var workerFactory: HiltWorkerFactory
15+
16+
override fun getWorkManagerConfiguration() = Configuration.Builder()
17+
.setWorkerFactory(workerFactory)
18+
.build()
19+
20+
override fun onCreate() {
21+
super.onCreate()
22+
23+
// TODO: uncomment the sync code below
24+
// Initialize Sync; the system responsible for keeping data in the app up to date.
25+
// Sync.initialize(context = this)
26+
}
27+
}

app/src/main/java/com/lcl/lclmeasurementtool/MainActivity2.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class MainActivity2 : ComponentActivity() {
104104
setContent {
105105
if (uiState == MainActivityUiState.Login) {
106106
viewModel.setDeviceId(UUID.randomUUID().toString())
107-
Login(viewModel = viewModel)
108-
return@setContent
107+
// Login(viewModel = viewModel)
108+
// return@setContent
109109
}
110110
LCLApp(windowSizeClass = calculateWindowSizeClass(activity = this), networkMonitor, simStateMonitor)
111111
}

0 commit comments

Comments
 (0)