From f7bbc9f50f2a20c5a991ca43cc8dc9e2ddf70f6e Mon Sep 17 00:00:00 2001 From: mk17ru Date: Sun, 16 Apr 2023 15:20:58 +0300 Subject: [PATCH] Gradle Plugin --- app/build.gradle | 1 + .../java/ru/ok/android/itmohack2023/MainActivity.kt | 13 +++++++++++++ local.properties | 8 +++----- settings.gradle | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9311fb1..204fff3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -68,4 +68,5 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation("com.github.BetsonWick:NetworkMonitor:1.1.1") } \ No newline at end of file diff --git a/app/src/main/java/ru/ok/android/itmohack2023/MainActivity.kt b/app/src/main/java/ru/ok/android/itmohack2023/MainActivity.kt index 2a4528e..03a45b9 100644 --- a/app/src/main/java/ru/ok/android/itmohack2023/MainActivity.kt +++ b/app/src/main/java/ru/ok/android/itmohack2023/MainActivity.kt @@ -1,14 +1,27 @@ package ru.ok.android.itmohack2023 +import android.app.ActivityManager +import android.app.usage.NetworkStatsManager +import android.content.Context import android.content.Intent +import android.os.Build import android.os.Bundle import android.view.View +import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity +import ru.itmo.networkmonitor.NetworkMonitorTask class MainActivity : AppCompatActivity() { + @RequiresApi(Build.VERSION_CODES.M) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + NetworkMonitorTask( + getSystemService(NETWORK_STATS_SERVICE) as NetworkStatsManager, getSystemService( + Context.ACTIVITY_SERVICE + ) as ActivityManager, + listOf("ru.ok") + ).start() findViewById(R.id.url_connection).setOnClickListener { startActivity(Intent(this, UrlConnectionActivity::class.java)) } diff --git a/local.properties b/local.properties index a5a1835..db49f31 100644 --- a/local.properties +++ b/local.properties @@ -1,10 +1,8 @@ -## This file is automatically generated by Android Studio. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file should *NOT* be checked into Version Control Systems, +## This file must *NOT* be checked into Version Control Systems, # as it contains information specific to your local configuration. # # Location of the SDK. This is only used by Gradle. # For customization when using a Version Control System, please read the # header note. -sdk.dir=/Users/kirill.popov/Library/Android/sdk \ No newline at end of file +#Sun Apr 16 15:10:41 MSK 2023 +sdk.dir=/Users/mk17ru/Library/Android/sdk diff --git a/settings.gradle b/settings.gradle index 005db70..2d2d4c0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,6 +10,7 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + maven { url 'https://jitpack.io' } } } rootProject.name = "ItmoHack2023"