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.jsoup:jsoup:1.18.1")
|
||||||
implementation ("org.apache.commons:commons-text:1.12.0")
|
implementation ("org.apache.commons:commons-text:1.12.0")
|
||||||
implementation("com.squareup.okhttp:okhttp:2.7.5")
|
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 ("androidx.window:window:1.0.0")
|
||||||
// implementation("io.github.vaneproject:hanguleditor: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.content.res.Configuration
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Color
|
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.Uri
|
||||||
import android.net.http.SslError
|
import android.net.http.SslError
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@ -65,13 +61,14 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.core.content.getSystemService
|
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import androidx.work.ExistingPeriodicWorkPolicy
|
import androidx.work.ExistingPeriodicWorkPolicy
|
||||||
@ -153,31 +150,32 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
val COMIC_WORK_TAG = "ComicGetter"
|
val COMIC_WORK_TAG = "ComicGetter"
|
||||||
val COMIC2_WORK_TAG = "ComicGetter2"
|
val COMIC2_WORK_TAG = "ComicGetter2"
|
||||||
val REDDIT_WORK_TAG = "RedditGetter"
|
val REDDIT_WORK_TAG = "RedditGetter"
|
||||||
val shortTimePeriod = 20L
|
val shortTimePeriod = 200L
|
||||||
val longTimePeriod = 60L
|
val longTimePeriod = 600L
|
||||||
val qDayPeriod = 60L * 8L
|
val midTimePeriod = 300L
|
||||||
val midTimePeriod = 30L
|
|
||||||
var isOpendFold = false
|
var isOpendFold = false
|
||||||
|
|
||||||
@JvmStatic var lActivity: LauncherActivity? = null
|
@JvmStatic var lActivity: LauncherActivity? = null
|
||||||
@JvmStatic var appWidgetManager: AppWidgetManager? = null
|
@JvmStatic var appWidgetManager: AppWidgetManager? = null
|
||||||
@JvmStatic var appWidgetHost: WidgetHost? = null
|
@JvmStatic var appWidgetHost: WidgetHost? = null
|
||||||
fun refreshDeviceData() {
|
fun refreshSms() {
|
||||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||||
mWorkManager?.cancelAllWorkByTag(SMS_WORK_TAG)
|
mWorkManager?.cancelAllWorkByTag(SMS_WORK_TAG)
|
||||||
mWorkManager?.enqueueUniquePeriodicWork(
|
mWorkManager?.enqueueUniquePeriodicWork(
|
||||||
SMS_WORK_TAG,
|
SMS_WORK_TAG,
|
||||||
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||||
PeriodicWorkRequestBuilder<RecentSmsGetter>(qDayPeriod, TimeUnit.MINUTES)
|
PeriodicWorkRequestBuilder<RecentSmsGetter>(longTimePeriod, TimeUnit.MINUTES)
|
||||||
.addTag(SMS_WORK_TAG)
|
.addTag(SMS_WORK_TAG)
|
||||||
.build())
|
.build())
|
||||||
}, 1, TimeUnit.SECONDS)
|
}, 1, TimeUnit.SECONDS)
|
||||||
|
}
|
||||||
|
fun refreshCalls() {
|
||||||
var delay = 1L
|
var delay = 1L
|
||||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||||
mWorkManager?.cancelAllWorkByTag(ContactInfoGetter.TAG)
|
mWorkManager?.cancelAllWorkByTag(ContactInfoGetter.TAG)
|
||||||
mWorkManager?.enqueueUniquePeriodicWork(
|
mWorkManager?.enqueueUniquePeriodicWork(
|
||||||
ContactInfoGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
ContactInfoGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||||
PeriodicWorkRequestBuilder<ContactInfoGetter>(qDayPeriod, TimeUnit.MINUTES)
|
PeriodicWorkRequestBuilder<ContactInfoGetter>(12, TimeUnit.HOURS)
|
||||||
.addTag(ContactInfoGetter.TAG)
|
.addTag(ContactInfoGetter.TAG)
|
||||||
.build())
|
.build())
|
||||||
}, delay, TimeUnit.SECONDS)
|
}, delay, TimeUnit.SECONDS)
|
||||||
@ -186,7 +184,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
mWorkManager?.cancelAllWorkByTag(AppInfoGetter.TAG)
|
mWorkManager?.cancelAllWorkByTag(AppInfoGetter.TAG)
|
||||||
mWorkManager?.enqueueUniquePeriodicWork(
|
mWorkManager?.enqueueUniquePeriodicWork(
|
||||||
AppInfoGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
AppInfoGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||||
PeriodicWorkRequestBuilder<AppInfoGetter>(qDayPeriod, TimeUnit.MINUTES)
|
PeriodicWorkRequestBuilder<AppInfoGetter>(12, TimeUnit.HOURS)
|
||||||
.addTag(AppInfoGetter.TAG)
|
.addTag(AppInfoGetter.TAG)
|
||||||
.build())
|
.build())
|
||||||
}, delay, TimeUnit.SECONDS)
|
}, delay, TimeUnit.SECONDS)
|
||||||
@ -334,6 +332,12 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
intent?.extras?.keySet()?.forEach {
|
intent?.extras?.keySet()?.forEach {
|
||||||
BLog.LOGE("onNewIntent intent >> ${it}")
|
BLog.LOGE("onNewIntent intent >> ${it}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// binding.viewPager.invalidate()
|
||||||
|
// binding.viewPager.post {
|
||||||
|
// binding.viewPager?.adapter?.notifyDataSetChanged()
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
@ -437,7 +441,8 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!needAsk) {
|
if (!needAsk) {
|
||||||
refreshDeviceData()
|
refreshSms()
|
||||||
|
refreshCalls()
|
||||||
refreshFeeds()
|
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 */
|
/* set up viewpager2 */
|
||||||
private fun setupView() {
|
private fun setupView() {
|
||||||
viewPager = binding.viewPager.apply {
|
viewPager = binding.viewPager.apply {
|
||||||
@ -596,14 +574,14 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
BLog.LOGE("EndCallReceiver >>> ${intent}")
|
BLog.LOGE("EndCallReceiver >>> ${intent}")
|
||||||
val phoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE) ?: return
|
val phoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE) ?: return
|
||||||
if (phoneState == TelephonyManager.EXTRA_STATE_IDLE) {
|
if (phoneState == TelephonyManager.EXTRA_STATE_IDLE) {
|
||||||
refreshDeviceData()
|
refreshCalls()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class SMSReceiver : BroadcastReceiver() {
|
class SMSReceiver : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
BLog.LOGE("SMSReceiver >>> ${intent}")
|
BLog.LOGE("SMSReceiver >>> ${intent}")
|
||||||
refreshDeviceData()
|
refreshSms()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1057,7 +1035,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
var postNext : Runnable = Runnable{
|
var postNext : Runnable = Runnable{
|
||||||
callBack?.collectComplete()
|
callBack?.collectComplete()
|
||||||
}
|
}
|
||||||
|
|
||||||
val callBackHandler = Handler(Looper.getMainLooper())
|
val callBackHandler = Handler(Looper.getMainLooper())
|
||||||
|
|||||||
@ -1,20 +1,29 @@
|
|||||||
package rasel.lunar.launcher.workers
|
package rasel.lunar.launcher.workers
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.location.Location
|
||||||
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.work.WorkerParameters
|
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
|
import rasel.lunar.launcher.utils.BLog
|
||||||
|
|
||||||
class OpenWeatherGetter : BaseGetter {
|
class OpenWeatherGetter : BaseGetter {
|
||||||
companion object {
|
companion object {
|
||||||
val TAG = "OpenWeatherGetter"
|
val TAG = "OpenWeatherGetter"
|
||||||
}
|
}
|
||||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams)
|
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {}
|
||||||
|
|
||||||
override fun realWork(): Result {
|
override fun realWork(): Result {
|
||||||
BLog.LOGE("${TAG} realWork() ")
|
BLog.LOGE("${TAG} realWork() ")
|
||||||
|
|
||||||
|
|
||||||
//위치 정보 {위 경도 가져오자}
|
//위치 정보 {위 경도 가져오자}
|
||||||
|
getLocation()
|
||||||
|
|
||||||
//87cd0810b7e4b4debd31a6ef98b98154
|
//87cd0810b7e4b4debd31a6ef98b98154
|
||||||
//{https://home.openweathermap.org/api 에서 정보를 조회 하자}
|
//{https://home.openweathermap.org/api 에서 정보를 조회 하자}
|
||||||
@ -24,4 +33,28 @@ class OpenWeatherGetter : BaseGetter {
|
|||||||
|
|
||||||
return Result.success()
|
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