diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 0000000..15e9150
--- /dev/null
+++ b/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 59b02ee..9d7715e 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -11,6 +11,7 @@
+
diff --git a/app/build.gradle b/app/build.gradle
index 6907c50..5163dee 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -47,4 +47,5 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
+ implementation project(':networkmonitor')
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/network_monitoring/MainActivity.kt b/app/src/main/java/com/example/network_monitoring/MainActivity.kt
index 6204045..098bd4a 100644
--- a/app/src/main/java/com/example/network_monitoring/MainActivity.kt
+++ b/app/src/main/java/com/example/network_monitoring/MainActivity.kt
@@ -1,24 +1,21 @@
package com.example.network_monitoring
-import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
-import androidx.annotation.RequiresApi
+import com.example.networkmonitor.NetworkStatusView
class MainActivity : AppCompatActivity() {
private lateinit var networkStatusView: NetworkStatusView
- @RequiresApi(Build.VERSION_CODES.Q)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
networkStatusView = findViewById(R.id.network_status_view)
- networkStatusView.setFontFamily(R.font.airstrip)
networkStatusView.startMonitoring(this)
}
override fun onDestroy() {
super.onDestroy()
- networkStatusView.onDestroy()
+ networkStatusView.unregisterNetworkMonitor()
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index a5e6d74..3f55786 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -7,7 +7,7 @@
android:orientation="vertical"
tools:context=".MainActivity">
-
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/network_monitoring/NetworkMonitor.kt b/networkmonitor/src/main/java/com/example/networkmonitor/NetworkMonitor.kt
similarity index 98%
rename from app/src/main/java/com/example/network_monitoring/NetworkMonitor.kt
rename to networkmonitor/src/main/java/com/example/networkmonitor/NetworkMonitor.kt
index ea1778e..fe99271 100644
--- a/app/src/main/java/com/example/network_monitoring/NetworkMonitor.kt
+++ b/networkmonitor/src/main/java/com/example/networkmonitor/NetworkMonitor.kt
@@ -1,4 +1,4 @@
-package com.example.network_monitoring
+package com.example.networkmonitor
import android.content.Context
import android.net.ConnectivityManager
diff --git a/app/src/main/java/com/example/network_monitoring/NetworkStatusView.kt b/networkmonitor/src/main/java/com/example/networkmonitor/NetworkStatusView.kt
similarity index 97%
rename from app/src/main/java/com/example/network_monitoring/NetworkStatusView.kt
rename to networkmonitor/src/main/java/com/example/networkmonitor/NetworkStatusView.kt
index 146e537..d228ebe 100644
--- a/app/src/main/java/com/example/network_monitoring/NetworkStatusView.kt
+++ b/networkmonitor/src/main/java/com/example/networkmonitor/NetworkStatusView.kt
@@ -1,4 +1,4 @@
-package com.example.network_monitoring
+package com.example.networkmonitor
import android.content.Context
import android.graphics.Color
@@ -13,7 +13,7 @@ import android.widget.LinearLayout
import androidx.core.content.res.ResourcesCompat
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.Observer
-import com.example.network_monitoring.databinding.ViewNetworkStatusBinding
+import com.example.networkmonitor.databinding.ViewNetworkStatusBinding
import kotlinx.coroutines.*
class NetworkStatusView @JvmOverloads constructor(
@@ -145,7 +145,7 @@ class NetworkStatusView @JvmOverloads constructor(
}
}
- fun onDestroy() {
+ fun unregisterNetworkMonitor() {
networkMonitor.unregisterCallback()
}
}
diff --git a/app/src/main/res/drawable/network_off.xml b/networkmonitor/src/main/res/drawable/network_off.xml
similarity index 100%
rename from app/src/main/res/drawable/network_off.xml
rename to networkmonitor/src/main/res/drawable/network_off.xml
diff --git a/app/src/main/res/drawable/network_on.xml b/networkmonitor/src/main/res/drawable/network_on.xml
similarity index 100%
rename from app/src/main/res/drawable/network_on.xml
rename to networkmonitor/src/main/res/drawable/network_on.xml
diff --git a/app/src/main/res/font/airstrip.ttf b/networkmonitor/src/main/res/font/airstrip.ttf
similarity index 100%
rename from app/src/main/res/font/airstrip.ttf
rename to networkmonitor/src/main/res/font/airstrip.ttf
diff --git a/app/src/main/res/layout/view_network_status.xml b/networkmonitor/src/main/res/layout/view_network_status.xml
similarity index 100%
rename from app/src/main/res/layout/view_network_status.xml
rename to networkmonitor/src/main/res/layout/view_network_status.xml
diff --git a/networkmonitor/src/test/java/com/example/networkmonitor/ExampleUnitTest.kt b/networkmonitor/src/test/java/com/example/networkmonitor/ExampleUnitTest.kt
new file mode 100644
index 0000000..bdb3e11
--- /dev/null
+++ b/networkmonitor/src/test/java/com/example/networkmonitor/ExampleUnitTest.kt
@@ -0,0 +1,17 @@
+package com.example.networkmonitor
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 94425a4..00a08ca 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -14,3 +14,4 @@ dependencyResolutionManagement {
}
rootProject.name = "Network_Monitoring"
include ':app'
+include ':networkmonitor'