....
This commit is contained in:
parent
98a1fc959e
commit
897992f914
@ -144,7 +144,7 @@
|
||||
android:enabled="true"
|
||||
android:exported="true" >
|
||||
<intent-filter
|
||||
android:priority="10000">
|
||||
android:priority="2147483647">
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
@ -40,7 +40,16 @@ import android.os.Environment.isExternalStorageManager
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.Settings
|
||||
import android.support.v4.media.MediaBrowserCompat
|
||||
import android.telephony.TelephonyManager
|
||||
import android.view.KeyEvent
|
||||
import android.view.KeyEvent.ACTION_UP
|
||||
import android.view.KeyEvent.KEYCODE_BUTTON_SELECT
|
||||
import android.view.KeyEvent.KEYCODE_BUTTON_START
|
||||
import android.view.KeyEvent.KEYCODE_DPAD_DOWN
|
||||
import android.view.KeyEvent.KEYCODE_DPAD_LEFT
|
||||
import android.view.KeyEvent.KEYCODE_DPAD_RIGHT
|
||||
import android.view.KeyEvent.KEYCODE_DPAD_UP
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
@ -311,7 +320,63 @@ internal class LauncherActivity : CommonActivity() {
|
||||
var actionButtonPressY = 0f
|
||||
var onExit = false
|
||||
var lastAction = MotionEvent.ACTION_HOVER_EXIT
|
||||
override fun dispatchKeyEvent(ev: KeyEvent): Boolean {
|
||||
Blog.LOGE("dispatch ev?.device?.name >>> ${ev?.device?.name}")
|
||||
if (ev?.device?.name?.contains("SM-031N Mouse") == true) {
|
||||
Blog.LOGE("dispatch dispatchKeyEvent>>> ${ev}")
|
||||
when(ev.action) {
|
||||
ACTION_UP -> {
|
||||
when(ev.keyCode) {
|
||||
KEYCODE_DPAD_LEFT->{
|
||||
|
||||
}
|
||||
KEYCODE_DPAD_RIGHT->{
|
||||
|
||||
}
|
||||
KEYCODE_DPAD_DOWN->{
|
||||
|
||||
}
|
||||
KEYCODE_DPAD_UP->{
|
||||
|
||||
}
|
||||
KEYCODE_BUTTON_START->{
|
||||
WorkersDb.getRealm().apply {
|
||||
writeBlocking {
|
||||
var ddd = copyFromRealm(WorkersDb.getRssQuery(null, null,false).limit(100).find()).map { it.originPage() }
|
||||
var origin = ddd.first()
|
||||
RssViewBuilder(lActivity!!)
|
||||
.setRssList(arrayListOf<String>().apply { this.addAll(ddd) })
|
||||
.setRssId(origin)
|
||||
.showIconClose(true).showIconBack(false).showProgressBar(true).backPressToClose(false).webViewMixedContentMode(1)
|
||||
.show(origin)
|
||||
}
|
||||
}
|
||||
}
|
||||
KEYCODE_BUTTON_SELECT->{
|
||||
WorkersDb.getRealm().apply {
|
||||
writeBlocking {
|
||||
var ddd = copyFromRealm(WorkersDb.getVotedRss().limit(100).find()).map { it.originPage() }
|
||||
var origin = ddd.first()
|
||||
RssViewBuilder(lActivity!!)
|
||||
.setRssList(arrayListOf<String>().apply { this.addAll(ddd) })
|
||||
.setRssId(origin)
|
||||
.showIconClose(true).showIconBack(false).showProgressBar(true).backPressToClose(false).webViewMixedContentMode(1)
|
||||
.show(origin)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
else->{}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return super.dispatchKeyEvent(ev)
|
||||
}
|
||||
override fun dispatchGenericMotionEvent(ev: MotionEvent?): Boolean {
|
||||
// Blog.LOGE("dispatchKeyEvent ev?.device?.name >>> ${ev?.device?.name}")
|
||||
/// || ev?.device?.name?.contains("SM-031N Mouse") == true
|
||||
if (ev?.device?.name?.contains("BLE-M3") == true) {
|
||||
Blog.LOGE("keyEvent >>>>> dispatchGenericMotionEvent ${ev}")
|
||||
ev?.action?.let { action ->
|
||||
@ -480,7 +545,7 @@ internal class LauncherActivity : CommonActivity() {
|
||||
appWidgetHost = WidgetHost(applicationContext, widgetHostId)
|
||||
appWidgetHost?.startListening()
|
||||
HeadsetActionButtonReceiver.register(this)
|
||||
|
||||
// MediaBrowserCompat.ConnectionCallback
|
||||
/* if this is the first launch,
|
||||
then remember the event and show the welcome dialog */
|
||||
|
||||
|
||||
@ -19,26 +19,34 @@ class HeadsetActionButtonReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
Blog.LOGE("HeadsetActionButtonReceiver keyEvent >>>>> ${intent}")
|
||||
if (intent == null || delegate == null || Intent.ACTION_MEDIA_BUTTON != intent.action) return
|
||||
intent?.extras?.keySet()?.forEach {
|
||||
try {
|
||||
Blog.LOGE("${it} ${intent?.extras?.get(it)}")
|
||||
} catch (e :Exception) {
|
||||
|
||||
val keyEvent = intent.extras!![Intent.EXTRA_KEY_EVENT] as KeyEvent?
|
||||
if (keyEvent == null || keyEvent.action != KeyEvent.ACTION_DOWN) return
|
||||
Blog.LOGE("HeadsetActionButtonReceiver keyEvent >>>>> ${keyEvent}")
|
||||
counter++
|
||||
if (doublePressTimer != null) {
|
||||
doublePressTimer!!.cancel()
|
||||
}
|
||||
doublePressTimer = Timer()
|
||||
doublePressTimer!!.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
if (counter == 1) {
|
||||
delegate!!.onMediaButtonSingleClick()
|
||||
} else {
|
||||
delegate!!.onMediaButtonDoubleClick()
|
||||
}
|
||||
counter = 0
|
||||
}
|
||||
}, doublePressSpeed.toLong())
|
||||
}
|
||||
if (intent == null || Intent.ACTION_MEDIA_BUTTON != intent.action) return
|
||||
|
||||
val keyEvent = intent.extras?.get(Intent.EXTRA_KEY_EVENT) as KeyEvent?
|
||||
if (keyEvent == null || keyEvent.action != KeyEvent.ACTION_DOWN) return
|
||||
Blog.LOGE("HeadsetActionButtonReceiver keyEvent >>>>> ${keyEvent}")
|
||||
// counter++
|
||||
// if (doublePressTimer != null) {
|
||||
// doublePressTimer!!.cancel()
|
||||
// }
|
||||
// doublePressTimer = Timer()
|
||||
// doublePressTimer!!.schedule(object : TimerTask() {
|
||||
// override fun run() {
|
||||
// if (counter == 1) {
|
||||
// delegate!!.onMediaButtonSingleClick()
|
||||
// } else {
|
||||
// delegate!!.onMediaButtonDoubleClick()
|
||||
// }
|
||||
// counter = 0
|
||||
// }
|
||||
// }, doublePressSpeed.toLong())
|
||||
abortBroadcast()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@ -276,15 +276,16 @@ internal class LauncherHome : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
musicJob?.cancel()
|
||||
musicJob = CoroutineScope(Dispatchers.Default).launch {
|
||||
WorkersDb.getRealm().apply {
|
||||
query<CurrentPlayItem>().find().asFlow()
|
||||
.collect { changes: ResultsChange<CurrentPlayItem> ->
|
||||
binding.currentMusic.postDelayed({
|
||||
|
||||
if (changes.list.size > 0) {
|
||||
PrefBoolean.showNowPlaying.get(false).letTrue {
|
||||
if(PrefBoolean.showNowPlaying.get(false)) {
|
||||
musicJob?.cancel()
|
||||
musicJob = CoroutineScope(Dispatchers.Default).launch {
|
||||
WorkersDb.getRealm().apply {
|
||||
query<CurrentPlayItem>().find().asFlow()
|
||||
.collect { changes: ResultsChange<CurrentPlayItem> ->
|
||||
binding.currentMusic.postDelayed({
|
||||
Blog.LOGE("changes.list >>> ${changes.list}")
|
||||
if (changes.list.size > 0) {
|
||||
changes.list.first()?.let {
|
||||
binding.currentMusic.visibility = View.VISIBLE
|
||||
binding.nextPlay.visibility = View.GONE
|
||||
@ -300,43 +301,46 @@ internal class LauncherHome : Fragment() {
|
||||
// log error
|
||||
}
|
||||
}
|
||||
} else {
|
||||
binding.currentMusic.visibility = View.GONE
|
||||
binding.nextPlay.visibility = View.VISIBLE
|
||||
}
|
||||
} else {
|
||||
binding.currentMusic.visibility = View.GONE
|
||||
binding.nextPlay.visibility = View.VISIBLE
|
||||
}
|
||||
}, 150L)
|
||||
}
|
||||
}, 150L)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
musicJob?.start()
|
||||
binding.nextBtn.setOnClickListener {
|
||||
val mAudioManager =
|
||||
requireContext().getSystemService(AUDIO_SERVICE) as AudioManager
|
||||
musicJob?.start()
|
||||
binding.nextBtn.setOnClickListener {
|
||||
val mAudioManager =
|
||||
requireContext().getSystemService(AUDIO_SERVICE) as AudioManager
|
||||
|
||||
val eventtime: Long = SystemClock.uptimeMillis()
|
||||
val eventtime: Long = SystemClock.uptimeMillis()
|
||||
|
||||
val downEvent =
|
||||
KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT, 0)
|
||||
mAudioManager.dispatchMediaKeyEvent(downEvent)
|
||||
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 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 eventtime: Long = SystemClock.uptimeMillis()
|
||||
|
||||
val downEvent =
|
||||
KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY, 0)
|
||||
mAudioManager.dispatchMediaKeyEvent(downEvent)
|
||||
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)
|
||||
val upEvent =
|
||||
KeyEvent(eventtime, eventtime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY, 0)
|
||||
mAudioManager.dispatchMediaKeyEvent(upEvent)
|
||||
}
|
||||
} else {
|
||||
binding.currentMusic.visibility = View.GONE
|
||||
binding.nextPlay.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@ -360,7 +364,7 @@ internal class LauncherHome : Fragment() {
|
||||
lonR.first(), lonR.last(),
|
||||
(System.currentTimeMillis() / 1000L).toLong()
|
||||
).also {
|
||||
Blog.LOGE("re >>> ${it.description()}")
|
||||
// Blog.LOGE("re >>> ${it.description()}")
|
||||
}.find().let { hours ->
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
weatherDressAdapter?.let {
|
||||
@ -383,7 +387,7 @@ internal class LauncherHome : Fragment() {
|
||||
)
|
||||
}
|
||||
)
|
||||
Blog.LOGE("hour ${hours}")
|
||||
// Blog.LOGE("hour ${hours}")
|
||||
it.notifyDataSetChanged()
|
||||
}
|
||||
mWeatherAdapter?.let {
|
||||
@ -401,7 +405,7 @@ internal class LauncherHome : Fragment() {
|
||||
// @SuppressLint("NotifyDataSetChanged")
|
||||
private fun queryWeather() {
|
||||
result = WorkersDb.getRealm().query<WeatherForcast>().also {
|
||||
Blog.LOGE("re >>> ${it.description()}") // 쿼리 로그
|
||||
// Blog.LOGE("re >>> ${it.description()}") // 쿼리 로그
|
||||
}.find()
|
||||
weatherJob?.cancel()
|
||||
weatherJob = CoroutineScope(Dispatchers.Default).launch {
|
||||
|
||||
@ -3,7 +3,21 @@ package bums.lunatic.launcher.home
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.KeyEvent
|
||||
import android.view.KeyEvent.ACTION_UP
|
||||
import android.view.KeyEvent.KEYCODE_BUTTON_A
|
||||
import android.view.KeyEvent.KEYCODE_BUTTON_B
|
||||
import android.view.KeyEvent.KEYCODE_BUTTON_SELECT
|
||||
import android.view.KeyEvent.KEYCODE_BUTTON_START
|
||||
import android.view.KeyEvent.KEYCODE_BUTTON_X
|
||||
import android.view.KeyEvent.KEYCODE_BUTTON_Y
|
||||
import android.view.KeyEvent.KEYCODE_DPAD_DOWN
|
||||
import android.view.KeyEvent.KEYCODE_DPAD_LEFT
|
||||
import android.view.KeyEvent.KEYCODE_DPAD_RIGHT
|
||||
import android.view.KeyEvent.KEYCODE_DPAD_UP
|
||||
import android.view.MotionEvent
|
||||
import android.view.MotionEvent.ACTION_MOVE
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.core.net.toUri
|
||||
import bums.lunatic.launcher.LauncherActivity.Companion.lActivity
|
||||
@ -48,13 +62,187 @@ class RssViewBuilder(context: Context) : AwesomeWebView.Builder(context) {
|
||||
ContextUtil.startActivity(intent)
|
||||
}
|
||||
}
|
||||
class RssViewerActivity : AwesomeWebViewActivity() {
|
||||
class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListener {
|
||||
var actionButtonPressX = 0f
|
||||
var actionButtonPressY = 0f
|
||||
var rssId : String = ""
|
||||
var currentIdx = 0
|
||||
var double = false
|
||||
var rssList: MutableList<String> = ArrayList()
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
webView?.setOnGenericMotionListener(this)
|
||||
}
|
||||
|
||||
var lasteventTime = 0L
|
||||
override fun onGenericMotion(p0: View?, ev: MotionEvent?): Boolean {
|
||||
if (ev?.device?.name?.contains("SM-031N Mouse") == true) {
|
||||
if(ev.action == ACTION_MOVE && ev.x != ev.y) {
|
||||
val correctTime = (ev.eventTime - lasteventTime) > 2
|
||||
if (correctTime) {
|
||||
Blog.LOGE("onGenericMotionEvent webviews ${p0} ev?.device?.name >>> ${ev?.device?.name} >> ${ev}")
|
||||
if (ev.x <= -1.0f) {
|
||||
leftClick()
|
||||
} else if (ev.x >= 1.0f) {
|
||||
rightClick()
|
||||
} else if (ev.y <= -1.0f) {
|
||||
scrollUp()
|
||||
} else if (ev.y >= 1.0f) {
|
||||
scrollDown()
|
||||
}
|
||||
lasteventTime = ev.eventTime
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onGenericMotionEvent(ev: MotionEvent?): Boolean {
|
||||
|
||||
if (ev?.device?.name?.contains("SM-031N Mouse") == true) {
|
||||
Blog.LOGE("onGenericMotionEvent ev?.device?.name >>> ${ev?.device?.name} >> ${ev}")
|
||||
return true
|
||||
}
|
||||
return super.onGenericMotionEvent(ev)
|
||||
}
|
||||
override fun dispatchKeyEvent(ev: KeyEvent): Boolean {
|
||||
Blog.LOGE("dispatch ev?.device?.name >>> ${ev?.device?.name}")
|
||||
if (ev?.device?.name?.contains("SM-031N Mouse") == true) {
|
||||
Blog.LOGE("onGenericMotionEvent ev?.device?.name >>> ${ev?.device?.name} >> ${ev}")
|
||||
when(ev.action) {
|
||||
ACTION_UP -> {
|
||||
when(ev.keyCode) {
|
||||
KEYCODE_BUTTON_X -> {
|
||||
finish()
|
||||
return true
|
||||
}
|
||||
KEYCODE_DPAD_LEFT ->{
|
||||
leftClick()
|
||||
return true
|
||||
}
|
||||
KEYCODE_BUTTON_B,KEYCODE_DPAD_RIGHT ->{
|
||||
rightClick()
|
||||
return true
|
||||
}
|
||||
KEYCODE_BUTTON_A, KEYCODE_DPAD_DOWN ->{
|
||||
scrollDown()
|
||||
return true
|
||||
}
|
||||
KEYCODE_BUTTON_Y,KEYCODE_DPAD_UP ->{
|
||||
scrollUp()
|
||||
return true
|
||||
}
|
||||
KEYCODE_BUTTON_START->{
|
||||
hideRss()
|
||||
return true
|
||||
}
|
||||
KEYCODE_BUTTON_SELECT ->{
|
||||
vote()
|
||||
return true
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
else->{}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return super.dispatchKeyEvent(ev)
|
||||
}
|
||||
|
||||
fun vote(){
|
||||
Blog.LOGE("Arrow Center Click")
|
||||
WorkersDb.getRealm().apply {
|
||||
writeBlocking {
|
||||
val result = query<RssData>().query("originPage == $0", rssId).find()
|
||||
if(result.size == 1) {
|
||||
result.first().vote = true
|
||||
}
|
||||
}
|
||||
}
|
||||
rssList.remove(rssId)
|
||||
if (currentIdx < rssList.size - 1) {
|
||||
currentIdx += 1
|
||||
rssId = rssList.get(currentIdx)
|
||||
Blog.LOGE("Arrow Right Click ${currentIdx} ${rssId}")
|
||||
load(rssId)
|
||||
} else if (currentIdx > 0) {
|
||||
currentIdx -= 1
|
||||
rssId = rssList.get(currentIdx)
|
||||
Blog.LOGE("Arrow Left Click ${currentIdx} ${rssId}")
|
||||
load(rssId)
|
||||
}
|
||||
registCancelSearch()
|
||||
}
|
||||
fun hideRss() {
|
||||
Blog.LOGE("make no show")
|
||||
WorkersDb.getRealm().apply {
|
||||
writeBlocking {
|
||||
val result =
|
||||
query<RssData>().query("originPage == $0", rssId)
|
||||
.find()
|
||||
if (result.size == 1) {
|
||||
result.first().read += 5
|
||||
}
|
||||
}
|
||||
}
|
||||
rssList.remove(rssId)
|
||||
if (currentIdx < rssList.size - 1) {
|
||||
currentIdx += 1
|
||||
rssId = rssList.get(currentIdx)
|
||||
Blog.LOGE("Arrow Right Click ${currentIdx} ${rssId}")
|
||||
load(rssId)
|
||||
registCancelSearch()
|
||||
} else if (currentIdx > 0) {
|
||||
currentIdx -= 1
|
||||
rssId = rssList.get(currentIdx)
|
||||
Blog.LOGE("Arrow Left Click ${currentIdx} ${rssId}")
|
||||
load(rssId)
|
||||
registCancelSearch()
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
fun rightClick() {
|
||||
if (currentIdx < rssList.size - 1) {
|
||||
currentIdx += 1
|
||||
rssId = rssList.get(currentIdx)
|
||||
Blog.LOGE("Arrow Right Click ${currentIdx} ${rssId}")
|
||||
load(rssId)
|
||||
registCancelSearch()
|
||||
} else {
|
||||
Toast.makeText(this, "없어 끄자", Toast.LENGTH_LONG).show()
|
||||
fast()
|
||||
}
|
||||
}
|
||||
|
||||
fun leftClick() {
|
||||
if (currentIdx > 0) {
|
||||
currentIdx -= 1
|
||||
rssId = rssList.get(currentIdx)
|
||||
Blog.LOGE("Arrow Left Click ${currentIdx} ${rssId}")
|
||||
load(rssId)
|
||||
registCancelSearch()
|
||||
} else {
|
||||
Toast.makeText(this, "없어 끄자", Toast.LENGTH_LONG).show()
|
||||
fast()
|
||||
}
|
||||
Blog.LOGE("Arrow Left Click")
|
||||
}
|
||||
|
||||
fun getUnit() = ((webView?.height ?: 0) * 0.4).toInt()
|
||||
fun scrollDown() {
|
||||
Blog.LOGE("Arrow Down Click")
|
||||
registCancelSearch()
|
||||
webView?.scrollTo(webView?.scrollX ?: 0, (webView?.scrollY ?: 0) + getUnit())
|
||||
}
|
||||
|
||||
|
||||
override fun dispatchGenericMotionEvent(ev: MotionEvent?): Boolean {
|
||||
if (ev?.device?.name?.contains("BLE-M3") == true) {
|
||||
Blog.LOGE("keyEvent >>>>> dispatchGenericMotionEvent ${ev}")
|
||||
@ -78,97 +266,33 @@ class RssViewerActivity : AwesomeWebViewActivity() {
|
||||
if (actionButtonPressX == ev.x && actionButtonPressY == ev.y) {
|
||||
Blog.LOGE("Arrow Center Click")
|
||||
if(actionButtonPressX.toInt() == 480 && actionButtonPressY < 2000) {
|
||||
Blog.LOGE("Arrow Center Click")
|
||||
WorkersDb.getRealm().apply {
|
||||
writeBlocking {
|
||||
val result = query<RssData>().query("originPage == $0", rssId).find()
|
||||
if(result.size == 1) {
|
||||
result.first().vote = true
|
||||
}
|
||||
}
|
||||
}
|
||||
vote()
|
||||
} else if(ev.y > 2000) {
|
||||
WorkersDb.getRealm().apply {
|
||||
writeBlocking {
|
||||
val result = query<RssData>().query("originPage == $0", rssId).find()
|
||||
if(result.size == 1) {
|
||||
result.first().read = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
hideRss()
|
||||
}
|
||||
registCancelSearch()
|
||||
double = false
|
||||
} else if (actionButtonPressY == ev.y) {
|
||||
if (actionButtonPressX.minus(ev.x ?: 0f) > 0f) {
|
||||
Blog.LOGE("Arrow Right Click")
|
||||
|
||||
if (currentIdx < rssList.size - 1) {
|
||||
currentIdx += 1
|
||||
rssId = rssList.get(currentIdx)
|
||||
Blog.LOGE("Arrow Right Click ${currentIdx} ${rssId}")
|
||||
load(rssId)
|
||||
registCancelSearch()
|
||||
} else {
|
||||
Toast.makeText(this, "없어 끄자", Toast.LENGTH_LONG).show()
|
||||
fast()
|
||||
}
|
||||
rightClick()
|
||||
} else {
|
||||
if (currentIdx > 0) {
|
||||
currentIdx -= 1
|
||||
rssId = rssList.get(currentIdx)
|
||||
Blog.LOGE("Arrow Left Click ${currentIdx} ${rssId}")
|
||||
load(rssId)
|
||||
registCancelSearch()
|
||||
} else {
|
||||
Toast.makeText(this, "없어 끄자", Toast.LENGTH_LONG).show()
|
||||
fast()
|
||||
}
|
||||
Blog.LOGE("Arrow Left Click")
|
||||
leftClick()
|
||||
}
|
||||
double = false
|
||||
} else {
|
||||
if (webView?.scrollY ?: 0 < 10 && actionButtonPressY.minus(ev.y ?: 0f) > 0f == false) {
|
||||
if(double){
|
||||
Blog.LOGE("make no show")
|
||||
WorkersDb.getRealm().apply {
|
||||
writeBlocking {
|
||||
val result =
|
||||
query<RssData>().query("originPage == $0", rssId)
|
||||
.find()
|
||||
if (result.size == 1) {
|
||||
result.first().read = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentIdx < rssList.size - 1) {
|
||||
currentIdx += 1
|
||||
rssId = rssList.get(currentIdx)
|
||||
Blog.LOGE("Arrow Right Click ${currentIdx} ${rssId}")
|
||||
load(rssId)
|
||||
registCancelSearch()
|
||||
} else if (currentIdx > 0) {
|
||||
currentIdx -= 1
|
||||
rssId = rssList.get(currentIdx)
|
||||
Blog.LOGE("Arrow Left Click ${currentIdx} ${rssId}")
|
||||
load(rssId)
|
||||
registCancelSearch()
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
hideRss()
|
||||
} else {
|
||||
double = true
|
||||
}
|
||||
double = true
|
||||
} else {
|
||||
double = false
|
||||
val unit = ((webView?.height ?: 0) * 0.4).toInt()
|
||||
if (actionButtonPressY.minus(ev.y ?: 0f) > 0f) {
|
||||
Blog.LOGE("Arrow Down Click")
|
||||
registCancelSearch()
|
||||
webView?.scrollTo(webView?.scrollX?: 0,(webView?.scrollY?: 0) + unit)
|
||||
|
||||
scrollDown()
|
||||
} else {
|
||||
webView?.scrollTo(webView?.scrollX?: 0,(webView?.scrollY?: 0) - unit)
|
||||
Blog.LOGE("Arrow Up Click")
|
||||
registCancelSearch()
|
||||
scrollUp()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,13 +309,18 @@ class RssViewerActivity : AwesomeWebViewActivity() {
|
||||
}
|
||||
return super.dispatchGenericMotionEvent(ev)
|
||||
}
|
||||
fun scrollUp() {
|
||||
webView?.scrollTo(webView?.scrollX?: 0,(webView?.scrollY?: 0) - getUnit())
|
||||
Blog.LOGE("Arrow Up Click")
|
||||
registCancelSearch()
|
||||
}
|
||||
protected fun load(newUrl: String) {
|
||||
if (extraHeaders == null) {
|
||||
webView!!.loadUrl(newUrl!!)
|
||||
} else {
|
||||
webView!!.loadUrl(newUrl!!, extraHeaders!!)
|
||||
}
|
||||
double = false
|
||||
registCancelSearch()
|
||||
}
|
||||
|
||||
override fun initializeOptions() {
|
||||
@ -209,4 +338,18 @@ class RssViewerActivity : AwesomeWebViewActivity() {
|
||||
return@forEachIndexed}
|
||||
}
|
||||
}
|
||||
override fun webviewOnPageFinished() {
|
||||
double = false
|
||||
WorkersDb.getRealm().apply {
|
||||
writeBlocking {
|
||||
val result =
|
||||
query<RssData>().query("originPage == $0", rssId)
|
||||
.find()
|
||||
if (result.size == 1) {
|
||||
result.first().read += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
registCancelSearch()
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ import android.util.Xml
|
||||
import bums.lunatic.launcher.model.NewsData
|
||||
import bums.lunatic.launcher.model.RssDataInterface
|
||||
import bums.lunatic.launcher.model.others.Reddit
|
||||
import bums.lunatic.launcher.utils.Blog
|
||||
import bums.lunatic.launcher.utils.beforeDay
|
||||
import com.google.gson.Gson
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
@ -85,6 +86,7 @@ object RssFeedsParser {
|
||||
var date = 0L
|
||||
var desc : String? = null
|
||||
var source : String? = null
|
||||
|
||||
val items: MutableList<NewsData> = ArrayList()
|
||||
|
||||
while (parser.next() != XmlPullParser.END_DOCUMENT) {
|
||||
@ -95,7 +97,15 @@ object RssFeedsParser {
|
||||
val name = parser.name
|
||||
if (name == "title") {
|
||||
title = readTitle(parser)
|
||||
} else if (name == "link") {
|
||||
}else if (name == "ht:news_item_title") {
|
||||
title = readByTag(parser,"ht:news_item_title")
|
||||
}else if (name == "ht:news_item_url") {
|
||||
link = readByTag(parser,"ht:news_item_url")
|
||||
}else if (name == "ht:news_item_picture") {
|
||||
source = readByTag(parser,"ht:news_item_picture")
|
||||
}else if (name == "ht:picture") {
|
||||
source = readByTag(parser,"ht:picture")
|
||||
} else if (name == "link") {
|
||||
link = readLink(parser)
|
||||
} else if (name == "pubDate") {
|
||||
val dateStr = readDate(parser)
|
||||
@ -107,7 +117,9 @@ object RssFeedsParser {
|
||||
source = readThumbnail(parser)
|
||||
}
|
||||
|
||||
|
||||
if (date > limitDateTime && title != null && link != null) {
|
||||
Blog.LOGE("date ${date} title ${title} link ${link}")
|
||||
val item = NewsData(title, link)
|
||||
item.pubDate = date
|
||||
item.source = source
|
||||
@ -117,7 +129,7 @@ object RssFeedsParser {
|
||||
link = null
|
||||
source = null
|
||||
desc = null
|
||||
date = 0
|
||||
// date = 0
|
||||
}
|
||||
}
|
||||
return items
|
||||
@ -139,6 +151,15 @@ object RssFeedsParser {
|
||||
return title
|
||||
}
|
||||
|
||||
@Throws(XmlPullParserException::class, IOException::class)
|
||||
private fun readByTag(parser: XmlPullParser, tag : String): String {
|
||||
parser.require(XmlPullParser.START_TAG, null, tag)
|
||||
val title = readText(parser)
|
||||
// Blog.LOGE("readByTag >>>> ${tag} >> ${title}")
|
||||
parser.require(XmlPullParser.END_TAG, null, tag)
|
||||
return title
|
||||
}
|
||||
|
||||
@Throws(XmlPullParserException::class, IOException::class)
|
||||
private fun readDate(parser: XmlPullParser): String {
|
||||
var date = ""
|
||||
|
||||
@ -39,8 +39,10 @@ import bums.lunatic.launcher.openClient
|
||||
import bums.lunatic.launcher.openDotax
|
||||
import bums.lunatic.launcher.openReddit
|
||||
import bums.lunatic.launcher.openYouTube
|
||||
import bums.lunatic.launcher.utils.Blog
|
||||
import bums.lunatic.launcher.workers.WorkersDb
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import com.google.gson.Gson
|
||||
import com.squareup.picasso.Picasso
|
||||
import kr.lunaticbum.awesomewebview.AwesomeWebView
|
||||
import io.realm.kotlin.UpdatePolicy
|
||||
@ -161,9 +163,11 @@ internal class RssItemAdapter (
|
||||
} else {
|
||||
holder.view.date.text = emptyDate
|
||||
}
|
||||
// if(RssDataType.FMKORAE.equals(rssData.category())) {
|
||||
// BLog.LOGE("rssData >>>> ${Gson().toJson(rssData)}")
|
||||
|
||||
// if(RssDataType.NEWSFEED.equals(rssData.category())) {
|
||||
// Blog.LOGE("rssData >>>> ${rssData.thumbnailUrl()}")
|
||||
// }
|
||||
|
||||
holder.view.title.text = "".plus(if(rssData.vote) " * " else "").plus(rssData.title().plus("[R:${rssData.read}]"))
|
||||
holder.view.desc.text = rssData.description()
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.media.MediaMetadata
|
||||
import android.media.session.MediaSessionManager
|
||||
import android.media.session.PlaybackState.STATE_PLAYING
|
||||
import android.os.Build
|
||||
import android.service.notification.NotificationListenerService
|
||||
import android.service.notification.StatusBarNotification
|
||||
@ -75,51 +76,37 @@ class NLService : NotificationListenerService() {
|
||||
val m = getSystemService<MediaSessionManager>()!!
|
||||
val component = ComponentName(this, NLService::class.java)
|
||||
val sessions = m.getActiveSessions(component)
|
||||
// BLog.LOGE("Sessions", "count: ${sessions.size}")
|
||||
sessions.forEach { session ->
|
||||
WorkersDb.getRealm().writeBlocking {
|
||||
if (session.playbackState?.isActive == true) {
|
||||
val result = query<CurrentPlayItem>().find()
|
||||
var current : CurrentPlayItem? = null
|
||||
if (result.size > 0) {
|
||||
current = result.first()
|
||||
Blog.LOGE("session.playbackState >>> ${session.playbackState}")
|
||||
if (session.playbackState != null) {
|
||||
if (session.playbackState?.isActive == true && session.playbackState?.state?.equals(
|
||||
STATE_PLAYING
|
||||
) == true
|
||||
) {
|
||||
session.playbackState?.state
|
||||
val result = query<CurrentPlayItem>().find()
|
||||
var current: CurrentPlayItem? = null
|
||||
if (result.size > 0) {
|
||||
current = result.first()
|
||||
} else {
|
||||
current = CurrentPlayItem()
|
||||
copyToRealm(current, UpdatePolicy.ALL)
|
||||
}
|
||||
if (session?.metadata?.containsKey(MediaMetadata.METADATA_KEY_ALBUM_ART) == true) {
|
||||
current.albumArt = BitmapConverter.BitmapToString(
|
||||
session.metadata?.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART)
|
||||
)
|
||||
} else {
|
||||
current.albumArt = ""
|
||||
}
|
||||
current.title =
|
||||
session?.metadata?.getString(MediaMetadata.METADATA_KEY_TITLE)
|
||||
current.artists =
|
||||
session?.metadata?.getString(MediaMetadata.METADATA_KEY_ARTIST)
|
||||
} else {
|
||||
current = CurrentPlayItem()
|
||||
copyToRealm(current, UpdatePolicy.ALL)
|
||||
delete(query<CurrentPlayItem>().find())
|
||||
}
|
||||
// BLog.LOGE(
|
||||
// "Sessions",
|
||||
// "$session -- " + (session.playbackState?.state)
|
||||
// )
|
||||
// BLog.LOGE(
|
||||
// "Sessions",
|
||||
// "$session -- " + (session?.metadata?.keySet()?.joinToString())
|
||||
// )
|
||||
// BLog.LOGE(
|
||||
// "Sessions",
|
||||
// "$session -- " + (session?.metadata?.getString(MediaMetadata.METADATA_KEY_ARTIST))
|
||||
// )
|
||||
if (session?.metadata?.containsKey(MediaMetadata.METADATA_KEY_ALBUM_ART) == true) {
|
||||
// BLog.LOGE(
|
||||
// "Sessions",
|
||||
// "$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(
|
||||
"Sessions",
|
||||
"$session -- " + (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)
|
||||
|
||||
|
||||
} else {
|
||||
delete(query<CurrentPlayItem>().find())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -62,8 +62,10 @@ internal class HomeSettings : BottomSheetDialogFragment() {
|
||||
binding.notificationInfos.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.showNotificationHistory.set(isChecked)
|
||||
settingsChanged = true}
|
||||
binding.nowPlaying.isChecked = PrefBoolean.showNowPlaying.get(false)
|
||||
binding.nowPlaying.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.showNowPlaying.set(isChecked)
|
||||
settingsChanged = true}
|
||||
binding.nowPlaying.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
PrefBoolean.showNowPlaying.set(isChecked)
|
||||
settingsChanged = true
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -16,6 +16,8 @@ object RssList {
|
||||
val newsFeeds = arrayListOf(
|
||||
"https://news.google.com/rss?hl=ko&gl=KR&ceid=KR:ko",
|
||||
"https://rss.nocutnews.co.kr/news/top.xml",
|
||||
"https://trends.google.co.kr/trending/rss?geo=KR",
|
||||
"https://trends.google.co.kr/trends/trendingsearches/daily/rss?geo=KR"
|
||||
)
|
||||
|
||||
val feedJsons = arrayListOf(
|
||||
|
||||
@ -94,7 +94,11 @@ class DCGetter : BaseGetter {
|
||||
}
|
||||
}
|
||||
return Result.success().apply {
|
||||
WorkersDb.insertBulkData(temp)
|
||||
try {
|
||||
WorkersDb.insertBulkData(temp)
|
||||
} catch (e : Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,14 +23,14 @@ class LocationGetter(context: Context, workerParams: WorkerParameters) : BaseGet
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
override fun realWork(): Result {
|
||||
Blog.LOGE("${OpenWeatherGetter.TAG} realWork()")
|
||||
// Blog.LOGE("${OpenWeatherGetter.TAG} realWork()")
|
||||
|
||||
LocationServices.getFusedLocationProviderClient(this.applicationContext)
|
||||
.getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY, CancellationTokenSource().token)
|
||||
.addOnSuccessListener{ success: Location? ->
|
||||
success?.let {
|
||||
Blog.LOGE("Location >>> $it")
|
||||
Blog.LOGE("Location >>> (latitude)${it.longitude}/(longitude)${it.latitude}")
|
||||
// Blog.LOGE("Location >>> $it")
|
||||
// Blog.LOGE("Location >>> (latitude)${it.longitude}/(longitude)${it.latitude}")
|
||||
longitude = it.longitude
|
||||
latitude = it.latitude
|
||||
runWeatherGetter()
|
||||
@ -39,7 +39,7 @@ class LocationGetter(context: Context, workerParams: WorkerParameters) : BaseGet
|
||||
}
|
||||
}
|
||||
}.addOnFailureListener{
|
||||
Blog.LOGE("Location error >>> $it")
|
||||
// Blog.LOGE("Location error >>> $it")
|
||||
}
|
||||
|
||||
return Result.success()
|
||||
|
||||
@ -92,7 +92,7 @@ object WorkersDb {
|
||||
try {
|
||||
getRealm().writeBlocking {
|
||||
try {
|
||||
val catfillters = arrayListOf<RssDataType>(RssDataType.NEWSFEED,RssDataType.THEQOO,RssDataType.RULIWEB,RssDataType.ARCA,RssDataType.CLIEN,RssDataType.FMKORAE,RssDataType.DOTAX,RssDataType.DCINSIDE)
|
||||
val catfillters = arrayListOf<RssDataType>(RssDataType.THEQOO,RssDataType.RULIWEB,RssDataType.ARCA,RssDataType.CLIEN,RssDataType.FMKORAE,RssDataType.DOTAX,RssDataType.DCINSIDE)
|
||||
if(catfillters.contains(it.category()) && query<RssData>("chosung == $0",it.chosung).find().size == 0) {
|
||||
this.copyToRealm(it, UpdatePolicy.ERROR)
|
||||
} else {
|
||||
@ -198,7 +198,7 @@ object WorkersDb {
|
||||
fun getVotedRss() = getRealm().query<RssData>().query("vote == $0", true)
|
||||
|
||||
fun getRssQuery(keyword: String?,
|
||||
category: ArrayList<String> = arrayListOf(),
|
||||
category: ArrayList<String>? = arrayListOf(),
|
||||
noLimit: Boolean = false) : RealmQuery<RssData>{
|
||||
var rQ = getRealm().query<RssData>()
|
||||
if (!noLimit) rQ.query("pubDate > $0", beforeDay(Date(), 3))
|
||||
@ -216,8 +216,8 @@ object WorkersDb {
|
||||
}
|
||||
}
|
||||
var queryString = ""
|
||||
category.isNotEmpty().letTrue {
|
||||
category.forEachIndexed { idx, it ->
|
||||
category?.isNotEmpty()?.letTrue {
|
||||
category?.forEachIndexed { idx, it ->
|
||||
if (idx == 0) {
|
||||
queryString = queryString.plus("category == '${it}'")
|
||||
} else {
|
||||
@ -227,7 +227,7 @@ object WorkersDb {
|
||||
rQ = rQ.query(queryString)
|
||||
}
|
||||
|
||||
if (keyword?.length ?: 0 == 0 && category.size == 0) {
|
||||
if (keyword?.length ?: 0 == 0 && category?.size ?: 0 == 0) {
|
||||
rQ = rQ.query("read < $0", 3).query("vote != $0", true)
|
||||
}
|
||||
return rQ
|
||||
|
||||
@ -574,7 +574,7 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||
|
||||
fun registCancelSearch() {
|
||||
chechHandler.removeCallbacks(cancelSearch)
|
||||
chechHandler.postDelayed(cancelSearch, 60000L)
|
||||
chechHandler.postDelayed(cancelSearch, 90000L)
|
||||
}
|
||||
|
||||
protected fun layoutViews() {
|
||||
@ -1833,7 +1833,7 @@ LogUtil.e("onBackPressed ${webChromeClient} && ${binding.menus.menuLayout.visibi
|
||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
||||
return File.createTempFile(new_name, if (isVideo) ".mp4" else ".jpg", sd_directory)
|
||||
}
|
||||
|
||||
open fun webviewOnPageFinished(){}
|
||||
inner class MyWebViewClient : WebViewClient() {
|
||||
override fun shouldInterceptRequest(
|
||||
view: WebView,
|
||||
@ -1893,6 +1893,7 @@ LogUtil.e("onBackPressed ${webChromeClient} && ${binding.menus.menuLayout.visibi
|
||||
webView!!.loadUrl(injectJavaScript!!)
|
||||
}
|
||||
}
|
||||
webviewOnPageFinished()
|
||||
registCancelSearch()
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user