Merge branch 'main' of https://dev.lunaticbum.kr/lun_admin/lun_launcher
# Conflicts: # app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt
This commit is contained in:
commit
470e304918
@ -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")
|
||||
}
|
||||
|
||||
@ -32,10 +32,6 @@ import android.content.pm.PackageManager
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.media.MediaMetadata
|
||||
import android.media.session.MediaController
|
||||
import android.media.session.MediaSessionManager
|
||||
import android.media.session.PlaybackState
|
||||
import android.net.Uri
|
||||
import android.net.http.SslError
|
||||
import android.os.Build
|
||||
@ -65,13 +61,14 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
@ -153,31 +150,32 @@ 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 qDayPeriod = 60L * 8L
|
||||
val midTimePeriod = 30L
|
||||
val shortTimePeriod = 200L
|
||||
val longTimePeriod = 600L
|
||||
val midTimePeriod = 300L
|
||||
var isOpendFold = false
|
||||
|
||||
@JvmStatic var lActivity: LauncherActivity? = null
|
||||
@JvmStatic var appWidgetManager: AppWidgetManager? = null
|
||||
@JvmStatic var appWidgetHost: WidgetHost? = null
|
||||
fun refreshDeviceData() {
|
||||
fun refreshSms() {
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(SMS_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
SMS_WORK_TAG,
|
||||
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<RecentSmsGetter>(qDayPeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<RecentSmsGetter>(longTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(SMS_WORK_TAG)
|
||||
.build())
|
||||
}, 1, TimeUnit.SECONDS)
|
||||
}
|
||||
fun refreshCalls() {
|
||||
var delay = 1L
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(ContactInfoGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
ContactInfoGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<ContactInfoGetter>(qDayPeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<ContactInfoGetter>(12, TimeUnit.HOURS)
|
||||
.addTag(ContactInfoGetter.TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -186,7 +184,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(AppInfoGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
AppInfoGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<AppInfoGetter>(qDayPeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<AppInfoGetter>(12, TimeUnit.HOURS)
|
||||
.addTag(AppInfoGetter.TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -334,6 +332,12 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
intent?.extras?.keySet()?.forEach {
|
||||
BLog.LOGE("onNewIntent intent >> ${it}")
|
||||
}
|
||||
|
||||
|
||||
// binding.viewPager.invalidate()
|
||||
// binding.viewPager.post {
|
||||
// binding.viewPager?.adapter?.notifyDataSetChanged()
|
||||
// }
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@ -437,7 +441,8 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
if (!needAsk) {
|
||||
refreshDeviceData()
|
||||
refreshSms()
|
||||
refreshCalls()
|
||||
refreshFeeds()
|
||||
}
|
||||
}
|
||||
@ -480,33 +485,6 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private var currentMediaController: MediaController? = null
|
||||
|
||||
private val mSessionsChangedListener = MediaSessionManager.OnActiveSessionsChangedListener { list: List<MediaController>? ->
|
||||
var latestPlaybackState: PlaybackState? = null
|
||||
var latestMediaController: MediaController? = null
|
||||
|
||||
list?.forEach { mediaController ->
|
||||
val playbackState = mediaController.playbackState
|
||||
if (playbackState != null) {
|
||||
if (latestPlaybackState == null || playbackState.lastPositionUpdateTime > latestPlaybackState!!.lastPositionUpdateTime) {
|
||||
if (playbackState.state == PlaybackState.STATE_PLAYING) {
|
||||
BLog.LOGE("mSessionsChangedListener playbackState.state >>> ${playbackState.state}")
|
||||
latestPlaybackState = playbackState
|
||||
latestMediaController = mediaController
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentMediaController = latestMediaController
|
||||
BLog.LOGE("mSessionsChangedListener mediaController.metadata >>> ${mediaController.metadata?.describeContents()}")
|
||||
BLog.LOGE("mSessionsChangedListener currentMediaController >>> ${currentMediaController?.packageName}")
|
||||
// Now you have the MediaController that is currently playing.
|
||||
// You can get the playback state using currentMediaController?.playbackState.
|
||||
}
|
||||
|
||||
/* set up viewpager2 */
|
||||
private fun setupView() {
|
||||
viewPager = binding.viewPager.apply {
|
||||
@ -596,14 +574,14 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
BLog.LOGE("EndCallReceiver >>> ${intent}")
|
||||
val phoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE) ?: return
|
||||
if (phoneState == TelephonyManager.EXTRA_STATE_IDLE) {
|
||||
refreshDeviceData()
|
||||
refreshCalls()
|
||||
}
|
||||
}
|
||||
}
|
||||
class SMSReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
BLog.LOGE("SMSReceiver >>> ${intent}")
|
||||
refreshDeviceData()
|
||||
refreshSms()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1057,7 +1035,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
var postNext : Runnable = Runnable{
|
||||
callBack?.collectComplete()
|
||||
callBack?.collectComplete()
|
||||
}
|
||||
|
||||
val callBackHandler = Handler(Looper.getMainLooper())
|
||||
|
||||
@ -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
|
||||
// }
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user