This commit is contained in:
lunaticbum 2024-09-12 18:22:11 +09:00
parent ddc1755c6f
commit 1470721399
9 changed files with 159 additions and 81 deletions

View File

@ -33,6 +33,9 @@
<!-- Include only if your app benefits from precise location access. --> <!-- Include only if your app benefits from precise location access. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INJECT_EVENTS"
tools:ignore="ProtectedPermissions" />
<uses-permission <uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES" android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" /> tools:ignore="QueryAllPackagesPermission" />

View File

@ -159,7 +159,7 @@ internal class LauncherActivity : AppCompatActivity() {
@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 refreshSms() { fun refreshDeviceData() {
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(SMS_WORK_TAG) mWorkManager?.cancelAllWorkByTag(SMS_WORK_TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -169,8 +169,6 @@ internal class LauncherActivity : AppCompatActivity() {
.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)
@ -442,8 +440,7 @@ internal class LauncherActivity : AppCompatActivity() {
} }
if (!needAsk) { if (!needAsk) {
refreshSms() refreshDeviceData()
refreshCalls()
refreshFeeds() refreshFeeds()
} }
} }
@ -575,14 +572,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) {
refreshCalls() refreshDeviceData()
} }
} }
} }
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}")
refreshSms() refreshDeviceData()
} }
} }

View File

@ -58,8 +58,8 @@ import rasel.lunar.launcher.CommadCallabck
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetManager import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetManager
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.LauncherActivity.Companion.refreshFeeds
import rasel.lunar.launcher.LauncherActivity.Companion.refreshDeviceData import rasel.lunar.launcher.LauncherActivity.Companion.refreshDeviceData
import rasel.lunar.launcher.LauncherActivity.Companion.refreshFeeds
import rasel.lunar.launcher.R import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.FeedsBinding import rasel.lunar.launcher.databinding.FeedsBinding
import rasel.lunar.launcher.feeds.rss.RssAdapter import rasel.lunar.launcher.feeds.rss.RssAdapter

View File

@ -20,18 +20,20 @@ package rasel.lunar.launcher.home
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.ComponentName import android.content.ComponentName
import android.content.ContentUris import android.content.Context.AUDIO_SERVICE
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.content.SharedPreferences import android.content.SharedPreferences
import android.graphics.Bitmap import android.graphics.Bitmap
import android.media.AudioManager
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.os.SystemClock
import android.provider.AlarmClock import android.provider.AlarmClock
import android.provider.MediaStore import android.view.KeyEvent
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -41,7 +43,6 @@ import android.widget.TableRow
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.biometric.BiometricPrompt import androidx.biometric.BiometricPrompt
import androidx.core.net.toUri
import androidx.core.view.children import androidx.core.view.children
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
@ -88,6 +89,7 @@ import rasel.lunar.launcher.todos.NotificationItemAdapter
import rasel.lunar.launcher.todos.RssItemAdapter import rasel.lunar.launcher.todos.RssItemAdapter
import rasel.lunar.launcher.todos.SmsLogsAdapter import rasel.lunar.launcher.todos.SmsLogsAdapter
import rasel.lunar.launcher.utils.BLog import rasel.lunar.launcher.utils.BLog
import rasel.lunar.launcher.utils.BitmapConverter
import rasel.lunar.launcher.utils.JamoUtils import rasel.lunar.launcher.utils.JamoUtils
import rasel.lunar.launcher.utils.SimpleFingerGestures import rasel.lunar.launcher.utils.SimpleFingerGestures
import rasel.lunar.launcher.utils.beforeDay import rasel.lunar.launcher.utils.beforeDay
@ -112,7 +114,7 @@ internal class LauncherHome : Fragment() {
companion object { companion object {
var home : LauncherHome? = null var home : LauncherHome? = null
var lastedFinishedPageUrl : String = "" var lastedFinishedPageUrl : String = ""
// var recentCalls = arrayListOf<RecentCall>() // var recentCalls = arrayListOf<RecentCall>()
var callList = arrayListOf<RecentCall>() var callList = arrayListOf<RecentCall>()
var smsList = arrayListOf<RecentSms>() var smsList = arrayListOf<RecentSms>()
var listTags = arrayListOf<RssDataInterface>() var listTags = arrayListOf<RssDataInterface>()
@ -215,16 +217,14 @@ internal class LauncherHome : Fragment() {
if (changes.list.size > 0) { if (changes.list.size > 0) {
changes.list?.first()?.let { changes.list?.first()?.let {
binding.currentMusic.visibility = View.VISIBLE binding.currentMusic.visibility = View.VISIBLE
binding.nextPlay.visibility = View.GONE
binding.artist.text = it.artists binding.artist.text = it.artists
binding.title.text = it.title binding.title.text = it.title
val albumArtUri = it.albumArt?.toUri()
var bitmap: Bitmap? = null var bitmap: Bitmap? = null
try { try {
bitmap = MediaStore.Images.Media.getBitmap( bitmap = BitmapConverter.StringToBitmap(it.albumArt)
requireContext().contentResolver,
albumArtUri
)
binding.albumArt.setImageBitmap(bitmap) binding.albumArt.setImageBitmap(bitmap)
} catch (exception: java.lang.Exception) { } catch (exception: java.lang.Exception) {
// log error // log error
@ -232,12 +232,42 @@ internal class LauncherHome : Fragment() {
} }
} else { } else {
binding.currentMusic.visibility = View.GONE binding.currentMusic.visibility = View.GONE
binding.nextPlay.visibility = View.VISIBLE
}}, 150L) }}, 150L)
} }
} }
} }
BLog.LOGE("onCreateView()") BLog.LOGE("onCreateView()")
binding.nextBtn.setOnClickListener {
val mAudioManager =
requireContext().getSystemService(AUDIO_SERVICE) as AudioManager
val eventtime: Long = SystemClock.uptimeMillis()
val downEvent =
KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT, 0)
mAudioManager.dispatchMediaKeyEvent(downEvent)
val upEvent =
KeyEvent(eventtime, eventtime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT, 0)
mAudioManager.dispatchMediaKeyEvent(upEvent)
}
binding.nextPlay.setOnClickListener {
val mAudioManager =
requireContext().getSystemService(AUDIO_SERVICE) as AudioManager
val eventtime: Long = SystemClock.uptimeMillis()
val downEvent =
KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY, 0)
mAudioManager.dispatchMediaKeyEvent(downEvent)
val upEvent =
KeyEvent(eventtime, eventtime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY, 0)
mAudioManager.dispatchMediaKeyEvent(upEvent)
}
queryInfos() queryInfos()
queryNotice() queryNotice()

View File

@ -0,0 +1,44 @@
package rasel.lunar.launcher.utils
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Base64
import java.io.ByteArrayOutputStream
object BitmapConverter {
/*
* String형을 BitMap으로 변환시켜주는 함수
* */
fun StringToBitmap(encodedString: String?): Bitmap? {
try {
val encodeByte: ByteArray = Base64.decode(encodedString, Base64.DEFAULT)
val bitmap = BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.size)
return bitmap
} catch (e: Exception) {
e.message
return null
}
}
/*
* Bitmap을 String형으로 변환
* */
fun BitmapToString(bitmap: Bitmap?): String {
if (bitmap == null) return ""
val baos = ByteArrayOutputStream()
bitmap?.compress(Bitmap.CompressFormat.PNG, 70, baos)
val bytes = baos.toByteArray()
val temp: String = Base64.encodeToString(bytes, Base64.DEFAULT)
return temp
}
/*
* Bitmap을 byte배열로 변환
* */
fun BitmapToByteArray(bitmap: Bitmap): ByteArray {
val baos = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, baos)
return baos.toByteArray()
}
}

View File

@ -95,6 +95,9 @@ class NLService : NotificationListenerService() {
"Sessions", "Sessions",
"$session -- " + (session?.metadata?.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART)) "$session -- " + (session?.metadata?.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART))
) )
current.albumArt = BitmapConverter.BitmapToString(session.metadata?.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART))
} else {
current.albumArt = ""
} }
BLog.LOGE( BLog.LOGE(
"Sessions", "Sessions",
@ -103,7 +106,7 @@ class NLService : NotificationListenerService() {
current.title = session?.metadata?.getString(MediaMetadata.METADATA_KEY_TITLE) current.title = session?.metadata?.getString(MediaMetadata.METADATA_KEY_TITLE)
current.artists = session?.metadata?.getString(MediaMetadata.METADATA_KEY_ARTIST) current.artists = session?.metadata?.getString(MediaMetadata.METADATA_KEY_ARTIST)
// current.albumArt = session?.metadata?.getBitmap(MediaMetadata.METADATA_KEY_ALBUM)
} else { } else {
delete(query<CurrentPlayItem>().find()) delete(query<CurrentPlayItem>().find())
} }

View File

@ -34,6 +34,16 @@
app:layout_constraintTop_toBottomOf="@+id/batteryProgress" app:layout_constraintTop_toBottomOf="@+id/batteryProgress"
android:textSize="16sp" android:textSize="16sp"
tools:ignore="MissingConstraints" /> tools:ignore="MissingConstraints" />
<ImageView
android:id="@+id/next_play"
android:src="@android:drawable/ic_media_play"
app:layout_constraintRight_toRightOf="@id/time"
app:layout_constraintTop_toTopOf="@id/time"
app:layout_constraintBottom_toBottomOf="@id/time"
android:layout_width="40dp"
android:layout_height="40dp"/>
<rasel.lunar.launcher.view.CircleImageView <rasel.lunar.launcher.view.CircleImageView
app:layout_constraintLeft_toLeftOf="@id/time" app:layout_constraintLeft_toLeftOf="@id/time"
app:layout_constraintTop_toTopOf="@id/time" app:layout_constraintTop_toTopOf="@id/time"
@ -55,34 +65,6 @@
android:layout_height="0dp" android:layout_height="0dp"
android:src="@drawable/kakaot" android:src="@drawable/kakaot"
android:id="@+id/alchol_katalkT"/> android:id="@+id/alchol_katalkT"/>
<!-- <TextClock-->
<!-- android:id="@+id/time"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:gravity="center"-->
<!-- android:maxLines="1"-->
<!-- android:textIsSelectable="false"-->
<!-- android:textSize="@dimen/clockText"-->
<!-- android:textStyle="bold"-->
<!-- android:textLocale="en_US"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/batteryProgress"-->
<!-- tools:ignore="UnusedAttribute" />-->
<!-- <TextClock-->
<!-- android:id="@+id/date"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:gravity="center"-->
<!-- android:maxLines="1"-->
<!-- android:textSize="20sp"-->
<!-- android:format12Hour="yyyy년 M월 d일 E요일"-->
<!-- android:textIsSelectable="false"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/time"-->
<!-- tools:ignore="UnusedAttribute" />-->
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/weather" android:id="@+id/weather"
@ -94,37 +76,56 @@
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/time" app:layout_constraintTop_toBottomOf="@+id/time"
app:layout_constraintVertical_bias="0.100" /> />
<RelativeLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/current_music" android:id="@+id/current_music"
app:layout_constraintTop_toBottomOf="@id/weather" app:layout_constraintTop_toBottomOf="@id/weather"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
android:background="@drawable/base_bg"
android:layout_margin="10dp"
android:padding="5dp"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<ImageView <com.google.android.material.imageview.ShapeableImageView
android:layout_alignParentLeft="true" app:shapeAppearanceOverlay="@style/roundedImageView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/album_art" android:id="@+id/album_art"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:layout_width="90dp"
android:layout_height="90dp"/>
<TextView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@id/album_art"
app:layout_constraintRight_toRightOf="parent"
android:gravity="right"
android:layout_width="0dp"
android:id="@+id/artist"
android:layout_height="wrap_content"/>
<TextView
app:layout_constraintTop_toBottomOf="@id/artist"
android:id="@+id/title"
android:gravity="center"
android:textSize="16dp"
app:layout_constraintBottom_toBottomOf="@id/album_art"
app:layout_constraintLeft_toRightOf="@id/album_art"
app:layout_constraintRight_toRightOf="parent"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/next_btn"
android:src="@android:drawable/ic_media_next"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp"/> android:layout_height="40dp"/>
<TextView
android:layout_alignLeft="@id/album_art" </androidx.constraintlayout.widget.ConstraintLayout>
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:id="@+id/artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_alignLeft="@id/album_art"
android:layout_alignParentRight="true"
android:layout_below="@id/artist"
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
<LinearLayout <LinearLayout

View File

@ -7,8 +7,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.imageview.ShapeableImageView <com.google.android.material.imageview.ShapeableImageView
app:layout_constraintTop_toTopOf="@id/title"
app:shapeAppearanceOverlay="@style/roundedImageView" app:shapeAppearanceOverlay="@style/roundedImageView"
app:layout_constraintTop_toTopOf="@id/title"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="@id/date" app:layout_constraintBottom_toBottomOf="@id/date"
android:id="@+id/circle_preview" android:id="@+id/circle_preview"

View File

@ -18,6 +18,6 @@
<style name="roundedImageView" parent=""> <style name="roundedImageView" parent="">
<item name="cornerFamily">rounded</item> <item name="cornerFamily">rounded</item>
<item name="cornerSize">8dp</item> <item name="cornerSize">10dp</item>
</style> </style>
</resources> </resources>