From af9da4c8ce22e6fb13bcc58335cf6c4873c6c5d8 Mon Sep 17 00:00:00 2001 From: JUNGGWAN KIM Date: Thu, 12 Sep 2024 17:16:23 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9C=84=EC=B9=98=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 1 + .../rasel/lunar/launcher/LauncherActivity.kt | 6 ++-- .../launcher/workers/OpenWeatherGetter.kt | 35 ++++++++++++++++++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 21249d01..92cbb3c2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -90,6 +90,7 @@ dependencies { implementation ("org.jsoup:jsoup:1.18.1") implementation ("org.apache.commons:commons-text:1.12.0") implementation("com.squareup.okhttp:okhttp:2.7.5") + implementation("com.google.android.gms:play-services-location:21.0.1") // implementation ("androidx.window:window:1.0.0") // implementation("io.github.vaneproject:hanguleditor:1.0.0") } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt b/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt index 46d3b18b..cdb77793 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt @@ -150,9 +150,9 @@ internal class LauncherActivity : AppCompatActivity() { val COMIC_WORK_TAG = "ComicGetter" val COMIC2_WORK_TAG = "ComicGetter2" val REDDIT_WORK_TAG = "RedditGetter" - val shortTimePeriod = 20L - val longTimePeriod = 60L - val midTimePeriod = 30L + val shortTimePeriod = 200L + val longTimePeriod = 600L + val midTimePeriod = 300L var isOpendFold = false @JvmStatic var lActivity: LauncherActivity? = null diff --git a/app/src/main/kotlin/rasel/lunar/launcher/workers/OpenWeatherGetter.kt b/app/src/main/kotlin/rasel/lunar/launcher/workers/OpenWeatherGetter.kt index 95a77c55..dc68d169 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/workers/OpenWeatherGetter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/workers/OpenWeatherGetter.kt @@ -1,20 +1,29 @@ package rasel.lunar.launcher.workers +import android.Manifest +import android.annotation.SuppressLint import android.content.Context +import android.content.pm.PackageManager +import android.location.Location +import androidx.core.app.ActivityCompat import androidx.work.WorkerParameters +import com.google.android.gms.location.LocationServices +import com.google.android.gms.location.Priority +import com.google.android.gms.tasks.CancellationTokenSource import rasel.lunar.launcher.utils.BLog class OpenWeatherGetter : BaseGetter { companion object { val TAG = "OpenWeatherGetter" } - constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) + constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {} override fun realWork(): Result { BLog.LOGE("${TAG} realWork() ") //위치 정보 {위 경도 가져오자} + getLocation() //87cd0810b7e4b4debd31a6ef98b98154 //{https://home.openweathermap.org/api 에서 정보를 조회 하자} @@ -24,4 +33,28 @@ class OpenWeatherGetter : BaseGetter { return Result.success() } + + @SuppressLint("MissingPermission") + fun getLocation() { + val fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this.applicationContext) +// if (ActivityCompat.checkSelfPermission( +// this.applicationContext, +// Manifest.permission.ACCESS_FINE_LOCATION +// ) == PackageManager.PERMISSION_GRANTED && +// ActivityCompat.checkSelfPermission( +// this.applicationContext, +// Manifest.permission.ACCESS_COARSE_LOCATION +// ) == PackageManager.PERMISSION_GRANTED +// ) { + fusedLocationProviderClient.getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY,CancellationTokenSource().token) + .addOnSuccessListener{ success: Location? -> + success?.let { + BLog.LOGE("Location >>> $it") + } + }.addOnFailureListener{ + BLog.LOGE("Location error >>> $it") + } + return +// } + } } \ No newline at end of file