This commit is contained in:
lunaticbum 2024-11-15 17:48:20 +09:00
parent b81e12c61b
commit caf5601a71
21 changed files with 217 additions and 178 deletions

View File

@ -68,6 +68,7 @@ import androidx.core.view.updatePadding
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
import androidx.work.ListenableWorker
import androidx.work.OneTimeWorkRequest import androidx.work.OneTimeWorkRequest
import androidx.work.PeriodicWorkRequestBuilder import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager import androidx.work.WorkManager
@ -185,21 +186,12 @@ internal class LauncherActivity : AppCompatActivity() {
.addTag(ContactInfoGetter.TAG) .addTag(ContactInfoGetter.TAG)
.build()) .build())
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
delay = delay + 3L
// Executors.newSingleThreadScheduledExecutor().schedule({
// mWorkManager?.cancelAllWorkByTag(AppInfoGetter.TAG)
// mWorkManager?.enqueueUniquePeriodicWork(
// AppInfoGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
// PeriodicWorkRequestBuilder<AppInfoGetter>(12, TimeUnit.HOURS)
// .addTag(AppInfoGetter.TAG)
// .build())
// }, delay, TimeUnit.SECONDS)
// delay = delay + 3L
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.enqueue(OneTimeWorkRequest.from(AppInfoGetter::class.java)) mWorkManager?.enqueue(OneTimeWorkRequest.from(AppInfoGetter::class.java))
}, 5, TimeUnit.SECONDS) }, 5, TimeUnit.SECONDS)
} }
fun runWeatherGetter() { fun runWeatherGetter() {
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.enqueue(OneTimeWorkRequest.from(OpenWeatherGetter::class.java)) mWorkManager?.enqueue(OneTimeWorkRequest.from(OpenWeatherGetter::class.java))
@ -212,14 +204,10 @@ internal class LauncherActivity : AppCompatActivity() {
}, 5, TimeUnit.SECONDS) }, 5, TimeUnit.SECONDS)
} }
val defaultDelay = 10L
fun refreshFeeds() { fun refreshFeeds() {
// Fri, 15 11 2024 15:06:28 +0900 var delay = defaultDelay
// Fri, 15 11 2024 15:28:04 +0900
var parseDateFormat2: SimpleDateFormat = SimpleDateFormat("E, dd MM yyyy HH:mm:ss zz", Locale.ENGLISH)
BLog.LOGE("TEST DATE FORMAT ${parseDateFormat2.format(Date())}")
var parseDateFormat3: SimpleDateFormat = SimpleDateFormat("E, dd MM yyyy HH:mm:ss ZZ", Locale.ENGLISH)
BLog.LOGE("TEST DATE FORMAT ${parseDateFormat3.format(Date())}")
var delay = 5L
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(FEDDS_WORK_TAG) mWorkManager?.cancelAllWorkByTag(FEDDS_WORK_TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -228,7 +216,7 @@ internal class LauncherActivity : AppCompatActivity() {
.addTag(FEDDS_WORK_TAG) .addTag(FEDDS_WORK_TAG)
.build()) .build())
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
delay= delay + 5 delay += defaultDelay
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(YT_WORK_TAG) mWorkManager?.cancelAllWorkByTag(YT_WORK_TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -237,7 +225,7 @@ internal class LauncherActivity : AppCompatActivity() {
.addTag(YT_WORK_TAG) .addTag(YT_WORK_TAG)
.build()) .build())
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
delay= delay + 5 delay += defaultDelay
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(REDDIT_WORK_TAG) mWorkManager?.cancelAllWorkByTag(REDDIT_WORK_TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -246,7 +234,7 @@ internal class LauncherActivity : AppCompatActivity() {
.addTag(REDDIT_WORK_TAG) .addTag(REDDIT_WORK_TAG)
.build()) .build())
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
delay= delay + 5 delay += defaultDelay
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG) mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -255,7 +243,7 @@ internal class LauncherActivity : AppCompatActivity() {
.addTag(COMIC_WORK_TAG) .addTag(COMIC_WORK_TAG)
.build()) .build())
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
delay= delay + 5 delay += defaultDelay
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG) mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -264,7 +252,7 @@ internal class LauncherActivity : AppCompatActivity() {
.addTag(COMIC2_WORK_TAG) .addTag(COMIC2_WORK_TAG)
.build()) .build())
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
delay= delay + 5 delay += defaultDelay
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(ClienGetter.TAG) mWorkManager?.cancelAllWorkByTag(ClienGetter.TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -273,7 +261,7 @@ internal class LauncherActivity : AppCompatActivity() {
.addTag(ClienGetter.TAG) .addTag(ClienGetter.TAG)
.build()) .build())
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
delay= delay + 5 delay += defaultDelay
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(DCGetter.TAG) mWorkManager?.cancelAllWorkByTag(DCGetter.TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -282,7 +270,7 @@ internal class LauncherActivity : AppCompatActivity() {
.addTag(DCGetter.TAG) .addTag(DCGetter.TAG)
.build()) .build())
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
delay= delay + 5 delay += defaultDelay
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(RuliWebGetter.TAG) mWorkManager?.cancelAllWorkByTag(RuliWebGetter.TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -291,7 +279,7 @@ internal class LauncherActivity : AppCompatActivity() {
.addTag(RuliWebGetter.TAG) .addTag(RuliWebGetter.TAG)
.build()) .build())
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
delay= delay + 5 delay += defaultDelay
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(TheQooGetter.TAG) mWorkManager?.cancelAllWorkByTag(TheQooGetter.TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -300,7 +288,7 @@ internal class LauncherActivity : AppCompatActivity() {
.addTag(TheQooGetter.TAG) .addTag(TheQooGetter.TAG)
.build()) .build())
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
delay= delay + 5 delay += defaultDelay
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(ArcaGetter.TAG) mWorkManager?.cancelAllWorkByTag(ArcaGetter.TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
@ -311,26 +299,6 @@ internal class LauncherActivity : AppCompatActivity() {
}, delay, TimeUnit.SECONDS) }, delay, TimeUnit.SECONDS)
// val weatherDelay = 3L
// Executors.newSingleThreadScheduledExecutor().schedule({
// //de574a260b1f474d99955729241909
// mWorkManager?.cancelAllWorkByTag(LocationGetter.TAG)
// mWorkManager?.enqueueUniquePeriodicWork(
// LocationGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
// PeriodicWorkRequestBuilder<LocationGetter>(PrefLong.longTimePeriod.get(), TimeUnit.MINUTES)
// .addTag(LocationGetter.TAG)
// .build())
// }, weatherDelay, TimeUnit.SECONDS)
// Executors.newSingleThreadScheduledExecutor().schedule({
// //de574a260b1f474d99955729241909
// mWorkManager?.cancelAllWorkByTag(OpenWeatherGetter.TAG)
// mWorkManager?.enqueueUniquePeriodicWork(
// OpenWeatherGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
// PeriodicWorkRequestBuilder<OpenWeatherGetter>(midTimePeriod, TimeUnit.MINUTES)
// .addTag(OpenWeatherGetter.TAG)
// .build())
// }, weatherDelay + 3, TimeUnit.SECONDS)
} }

View File

@ -261,17 +261,17 @@ internal class Feeds : Fragment() , CommadCallabck {
home?.queryInfos(keyword = cmd[1]) home?.queryInfos(keyword = cmd[1])
} }
"jf" -> { "jf" -> {
consoleLog("on Cmd JF") CoroutineScope(Dispatchers.IO).launch {
// CoroutineScope(Dispatchers.IO).launch { consoleLog("${cmd[0]} Start ${cmd[1]}")
// consoleLog("${cmd[0]} Start ${cmd[1]}") String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9qYXZtb3N0LnRvL3NlYXJjaC9tb3ZpZS8lcw==".toByteArray())),cmd[1]).getJ().let { doc -> FeedParseManager.parse(doc){consoleLog(it)} }
// String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9qYXZtb3N0LnRvL3NlYXJjaC9tb3ZpZS8lcw==".toByteArray())),cmd[1]).getJ().let { doc -> FeedParseManager.parse(doc){consoleLog(it)} } consoleLog("current j req() ${WorkersDb.getRealm().query<RssData>("category == $0", RssDataType.GURU.name).find().size}")
// consoleLog("current j req() ${WorkersDb.getRealm().query<RssData>("category == $0", RssDataType.GURU.name).find().size}") consoleLog("${cmd[0]} END ${cmd[1]}")
// consoleLog("${cmd[0]} END ${cmd[1]}") }
// }
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
consoleLog("on Cmd JF with MOST") consoleLog("on Cmd JF with MOST")
consoleLog("${cmd[0]} Start ${cmd[1]}") consoleLog("${cmd[0]} Start ${cmd[1]}")
String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9rcjcwLnNvZ2lybC5zby8/cz0lcw==".toByteArray())),cmd[1]).getJ().let { doc -> FeedParseManager.parse(doc){consoleLog(it)} } String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9rcjcxLnNvZ2lybC5zby8/cz0lcw==".toByteArray())),cmd[1]).getJ().let { doc -> FeedParseManager.parse(doc){consoleLog(it)} }
consoleLog("current j req() ${WorkersDb.getRealm().query<RssData>("category == $0", RssDataType.MOST.name).find().size}") consoleLog("current j req() ${WorkersDb.getRealm().query<RssData>("category == $0", RssDataType.MOST.name).find().size}")
consoleLog("${cmd[0]} END ${cmd[1]}") consoleLog("${cmd[0]} END ${cmd[1]}")
} }
@ -478,28 +478,28 @@ internal class Feeds : Fragment() , CommadCallabck {
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
var isOk = false var isOk = false
// plist.forEach { // plist.forEach {
if (!isOk) { if (!isOk) {
try { try {
Jsoup.connect(jGuruMain) Jsoup.connect(jGuruMain)
.userAgent("Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.5414.117 Mobile Safari/537.36") .userAgent("Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.5414.117 Mobile Safari/537.36")
.referrer("http://www.google.com") .referrer("http://www.google.com")
.header("Accept-Language", "it-IT,en;q=0.8,en-US;q=0.6,de;q=0.4,it;q=0.2,es;q=0.2") .header("Accept-Language", "it-IT,en;q=0.8,en-US;q=0.6,de;q=0.4,it;q=0.2,es;q=0.2")
.header("Connection", "keep-alive") .header("Connection", "keep-alive")
.header("scheme", "https") .header("scheme", "https")
.header("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8") .header("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
.header("accept-encoding", "gzip, deflate, br") .header("accept-encoding", "gzip, deflate, br")
.header("cache-control", "no-cache") .header("cache-control", "no-cache")
.header("pragma", "no-cache") .header("pragma", "no-cache")
.header("upgrade-insecure-requests", "1") .header("upgrade-insecure-requests", "1")
.ignoreContentType(true) .ignoreContentType(true)
.timeout(30000).execute().let { .timeout(30000).execute().let {
BLog.LOGE("DOC -> ${it}") BLog.LOGE("DOC -> ${it}")
isOk = true isOk = true
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
}
} }
}
// } // }
BLog.LOGE("last state ${isOk}") BLog.LOGE("last state ${isOk}")
} }

View File

@ -33,6 +33,8 @@ enum class PrefLong(val def : Long) : PrefKey<Long> {
} }
enum class PrefBoolean : PrefKey<Boolean> { enum class PrefBoolean : PrefKey<Boolean> {
displayBattery,
displayDateTime,
location, location,
rootPermisssion, rootPermisssion,
isConnectedCar, isConnectedCar,

View File

@ -496,7 +496,7 @@ internal class LauncherHome : Fragment() {
} }
fun updateQuery(q: RealmQuery<RssData>) { fun updateQuery(q: RealmQuery<RssData>) {
mRssDataResult = q.sort("pubDate ", Sort.DESCENDING).limit(300).distinct("chosung").find() mRssDataResult = q.sort("pubDate ", Sort.DESCENDING).limit(300).distinct("title").find()
infosJob = CoroutineScope(Dispatchers.Default).launch { infosJob = CoroutineScope(Dispatchers.Default).launch {
mRssDataResult?.asFlow()?.collect { changes: ResultsChange<RssData> -> mRssDataResult?.asFlow()?.collect { changes: ResultsChange<RssData> ->
commandHandler.removeCallbacks(hideListView) commandHandler.removeCallbacks(hideListView)
@ -522,7 +522,7 @@ internal class LauncherHome : Fragment() {
} }
fun queryInfos( fun queryInfos(
filter: Collection<RssDataType>? = arrayListOf(), noLimit: Boolean = false filter: Collection<RssDataType>? = arrayListOf(RssDataType.GURU, RssDataType.MOST,RssDataType.REDDIT_NSFW), noLimit: Boolean = false
) { ) {
beforeQuery() beforeQuery()
var rQ = WorkersDb.getRealm().query<RssData>().query("read < $0", nomoreShowCount) var rQ = WorkersDb.getRealm().query<RssData>().query("read < $0", nomoreShowCount)
@ -545,6 +545,16 @@ internal class LauncherHome : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
PrefBoolean.displayDateTime.get().letTrue {
binding.time.visibility = View.VISIBLE
}
PrefBoolean.displayBattery.get().letTrue {
binding.batteryProgress.visibility = View.VISIBLE
}
binding.batteryProgress.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.batteryProgress, mFingerGestureListener)) binding.batteryProgress.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.batteryProgress, mFingerGestureListener))
binding.root.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.root, mFingerGestureListener)) binding.root.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.root, mFingerGestureListener))
binding.functionLayer.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.functionLayer, mFingerGestureListener)) binding.functionLayer.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.functionLayer, mFingerGestureListener))
@ -597,7 +607,7 @@ internal class LauncherHome : Fragment() {
binding.otherCheck -> { binding.otherCheck -> {
if (binding.otherCheck.isSelected) { if (binding.otherCheck.isSelected) {
if (rssStateVote() || lasted?.size ?: 0 < 200) { if (rssStateVote()) {
queryInfos() queryInfos()
} else { } else {
binding.otherCheck.isSelected = false binding.otherCheck.isSelected = false
@ -649,15 +659,15 @@ internal class LauncherHome : Fragment() {
val input = viewInflated.findViewById<View>(R.id.input) as EditText val input = viewInflated.findViewById<View>(R.id.input) as EditText
val categoryz = val categoryz =
viewInflated.findViewById<TableRadioGroup>(R.id.categoryz) as TableRadioGroup viewInflated.findViewById<TableRadioGroup>(R.id.categoryz) as TableRadioGroup
categoryz.setMaxColumns(5) categoryz.setMaxColumns(3)
categoryz.setMaxRows(5) categoryz.setMaxRows(8)
categoryz.setOnCheckedChangeListener(object : TableRadioGroup.OnCheckedChangeListener { categoryz.setOnCheckedChangeListener(object : TableRadioGroup.OnCheckedChangeListener {
override fun onCheckedChanged(group: TableRadioGroup?, checkedId: Int) { override fun onCheckedChanged(group: TableRadioGroup?, checkedId: Int) {
} }
}) })
var idx = 0 var idx = 0
RssDataType.values().reversed().toList().chunked(5).forEach { RssDataType.values().reversed().toList().chunked(3).forEach {
var tb = TableRow(requireContext()) var tb = TableRow(requireContext())
it.forEach { c -> it.forEach { c ->
if (c.equals(RssDataType.NO_DATA) == false) { if (c.equals(RssDataType.NO_DATA) == false) {

View File

@ -100,7 +100,7 @@ object RssFeedsParser {
link = readLink(parser) link = readLink(parser)
} else if (name == "pubDate") { } else if (name == "pubDate") {
val dateStr = readDate(parser) val dateStr = readDate(parser)
try { date = parseDateFormat.parse(dateStr)?.time ?: 0L } catch (e : Exception) { date = 0L } finally { BLog.LOGE("readFeed >>> parse 1 date ${date}") } try { date = parseDateFormat.parse(dateStr)?.time ?: 0L } catch (e : Exception) { date = 0L }
if (date == 0L) { try { date = parseDateFormat2.parse(dateStr)?.time ?: 0L } catch (e: Exception) { } } if (date == 0L) { try { date = parseDateFormat2.parse(dateStr)?.time ?: 0L } catch (e: Exception) { } }
} else if (name == "description") { } else if (name == "description") {
desc = readDesc(parser) desc = readDesc(parser)

View File

@ -69,6 +69,9 @@ internal class RssItemAdapter (
WorkersDb.getRealm().apply { WorkersDb.getRealm().apply {
writeBlocking { writeBlocking {
rss.read = rss.read + 1 rss.read = rss.read + 1
if(rss.getCho()?.length ?: 0 < 1) {
rss.chosung = rss.title
}
copyToRealm(rss,UpdatePolicy.ALL) copyToRealm(rss,UpdatePolicy.ALL)
} }
} }

View File

@ -64,7 +64,7 @@ class WeatherDressAdatper (private val dataSet: ArrayList<Hour>) : RecyclerView.
this@apply.isSelected = false this@apply.isSelected = false
} }
} }
holder.viewItem.imgDress.setImageLevel(it.temp_c.toInt()) holder.viewItem.imgWeather.setImageLevel(it.temp_c.toInt())
} }
} }

View File

@ -36,7 +36,7 @@ import bums.lunatic.launcher.settings.childs.Appearances
import bums.lunatic.launcher.settings.childs.Apps import bums.lunatic.launcher.settings.childs.Apps
import bums.lunatic.launcher.settings.childs.HomeSettings import bums.lunatic.launcher.settings.childs.HomeSettings
import bums.lunatic.launcher.settings.childs.Misc import bums.lunatic.launcher.settings.childs.Misc
import bums.lunatic.launcher.settings.childs.TimeDate import bums.lunatic.launcher.settings.childs.TopInfos
import bums.lunatic.launcher.settings.childs.WeatherSettings import bums.lunatic.launcher.settings.childs.WeatherSettings
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.color.DynamicColors import com.google.android.material.color.DynamicColors
@ -65,7 +65,7 @@ internal class SettingsActivity : AppCompatActivity() {
/* launch child settings dialogs on button clicks */ /* launch child settings dialogs on button clicks */
binding.timeDate.setOnClickListener { binding.timeDate.setOnClickListener {
TimeDate().show(supportFragmentManager, BOTTOM_SHEET_TAG) TopInfos().show(supportFragmentManager, BOTTOM_SHEET_TAG)
} }
binding.weather.setOnClickListener { binding.weather.setOnClickListener {

View File

@ -26,36 +26,67 @@ import android.view.ViewGroup
import androidx.core.widget.doAfterTextChanged import androidx.core.widget.doAfterTextChanged
import bums.lunatic.launcher.R import bums.lunatic.launcher.R
import bums.lunatic.launcher.databinding.SettingsTimeDateBinding import bums.lunatic.launcher.databinding.SettingsTimeDateBinding
import bums.lunatic.launcher.helpers.Constants.Companion.DEFAULT_DATE_FORMAT import bums.lunatic.launcher.helpers.PrefBoolean
import bums.lunatic.launcher.helpers.Constants.Companion.KEY_DATE_FORMAT import bums.lunatic.launcher.helpers.PrefHelper
import bums.lunatic.launcher.helpers.Constants.Companion.KEY_TIME_FORMAT import bums.lunatic.launcher.helpers.PrefString
import bums.lunatic.launcher.settings.SettingsActivity.Companion.settingsPrefs import bums.lunatic.launcher.utils.BLog
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.gson.Gson
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Date import java.util.Date
import java.util.Objects
import kotlin.system.exitProcess import kotlin.system.exitProcess
internal class TimeDate : BottomSheetDialogFragment() { internal class TopInfos : BottomSheetDialogFragment() {
private lateinit var binding : SettingsTimeDateBinding private lateinit var binding : SettingsTimeDateBinding
private var settingsChanged: Boolean = false private var settingsChanged: Boolean = false
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = SettingsTimeDateBinding.inflate(inflater, container, false) binding = SettingsTimeDateBinding.inflate(inflater, container, false)
binding.useBattery.isChecked = PrefBoolean.displayBattery.get(true)
binding.useDateTime.isChecked = PrefBoolean.displayDateTime.get(true)
BLog.LOGE("PrefHelper.getSettings() >>> ${Gson().toJson(PrefHelper.getSettings())}")
binding.useBattery.setOnCheckedChangeListener { button, b ->
PrefBoolean.displayBattery.set(b)
settingsChanged = true
}
updateViews()
binding.useDateTime.setOnCheckedChangeListener { button, b ->
PrefBoolean.displayDateTime.set(b)
settingsChanged = true
updateViews()
}
binding.timeFormat.setText(PrefString.defaultTimeFormat.get("a HH:mm:ss"))
binding.dateFormat.setText(PrefString.defaultDateFormat.get("yyyy년 MM월 W주차 dd일 E요일"))
binding.previewDateTime.defaultTimeFormat = PrefString.defaultTimeFormat.get("a HH:mm:ss")
binding.previewDateTime.defaultDateFormat = PrefString.defaultDateFormat.get("yyyy년 MM월 W주차 dd일 E요일")
binding.timeFormat.doAfterTextChanged { binding.timeFormat.doAfterTextChanged {
try { try {
SimpleDateFormat(it.toString()).format(Date()) SimpleDateFormat(it.toString()).format(Date())
binding.previewDateTime binding.previewDateTime.defaultTimeFormat = it.toString()
settingsChanged = true
PrefString.defaultTimeFormat.set(it.toString())
} catch (e : Exception) { } catch (e : Exception) {
} }
} }
binding.dateFormat.doAfterTextChanged { binding.dateFormat.doAfterTextChanged {
try { try {
it.toString() try {
SimpleDateFormat(it.toString()).format(Date())
binding.previewDateTime.defaultDateFormat = it.toString()
settingsChanged = true
PrefString.defaultDateFormat.set(it.toString())
} catch (e : Exception) {
}
} catch (e : Exception) { } catch (e : Exception) {
} }
@ -63,7 +94,14 @@ internal class TimeDate : BottomSheetDialogFragment() {
return binding.root return binding.root
} }
fun updateViews() {
with(if (binding.useBattery.isChecked) View.VISIBLE else View.GONE){
binding.timeFormat.visibility = this
binding.dateFormat.visibility = this
binding.previewDateTime.visibility = this
binding.previewDateTime.visibility = this
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true (requireDialog() as BottomSheetDialog).dismissWithAnimation = true

View File

@ -24,6 +24,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.widget.doOnTextChanged import androidx.core.widget.doOnTextChanged
import bums.lunatic.launcher.R
import bums.lunatic.launcher.databinding.SettingsWeatherBinding import bums.lunatic.launcher.databinding.SettingsWeatherBinding
import bums.lunatic.launcher.helpers.Constants.Companion.KEY_CITY_NAME import bums.lunatic.launcher.helpers.Constants.Companion.KEY_CITY_NAME
import bums.lunatic.launcher.helpers.Constants.Companion.KEY_OWM_API import bums.lunatic.launcher.helpers.Constants.Companion.KEY_OWM_API
@ -34,10 +35,28 @@ import bums.lunatic.launcher.helpers.PrefString
import bums.lunatic.launcher.settings.SettingsActivity.Companion.settingsPrefs import bums.lunatic.launcher.settings.SettingsActivity.Companion.settingsPrefs
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.util.Objects import java.util.Objects
import kotlin.system.exitProcess
open class SettingChild : BottomSheetDialogFragment() {
protected var settingsChanged: Boolean = false
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
if (settingsChanged) {
MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.restart_now)
.setMessage(R.string.restart_message)
.setPositiveButton(R.string.restart) { _, _ ->
exitProcess(0)
}
.setNeutralButton(R.string.later, null)
.show()
}
}
}
internal class WeatherSettings : BottomSheetDialogFragment() { internal class WeatherSettings : SettingChild() {
private lateinit var binding : SettingsWeatherBinding private lateinit var binding : SettingsWeatherBinding
@ -49,11 +68,14 @@ internal class WeatherSettings : BottomSheetDialogFragment() {
binding.inputOwm.setText(PrefString.weatherApiKey.get("")) binding.inputOwm.setText(PrefString.weatherApiKey.get(""))
binding.inputOwm.doOnTextChanged { text, start, before, count -> binding.inputOwm.doOnTextChanged { text, start, before, count ->
PrefString.weatherApiKey.set(text.toString()) PrefString.weatherApiKey.set(text.toString())
settingsChanged = true
} }
binding.dress.isChecked = PrefBoolean.weatherDress.get(false) binding.dress.isChecked = PrefBoolean.weatherDress.get(false)
binding.weather.isChecked = PrefBoolean.weatherState.get(false) binding.weather.isChecked = PrefBoolean.weatherState.get(false)
binding.weather.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.weatherState.set(isChecked)} binding.weather.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.weatherState.set(isChecked)
binding.dress.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.weatherDress.set(isChecked)} settingsChanged = true}
binding.dress.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.weatherDress.set(isChecked)
settingsChanged = true}
return binding.root return binding.root
} }

View File

@ -17,20 +17,25 @@ import android.util.AttributeSet
import android.view.View import android.view.View
import androidx.appcompat.widget.AppCompatTextView import androidx.appcompat.widget.AppCompatTextView
import bums.lunatic.launcher.R import bums.lunatic.launcher.R
import bums.lunatic.launcher.helpers.PrefString
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Date import java.util.Date
class DateTimeView : AppCompatTextView { class DateTimeView : AppCompatTextView {
lateinit var mHandler : Handler lateinit var mHandler : Handler
var defaultTimeFormat = "a HH:mm:ss" var defaultTimeFormat = PrefString.defaultTimeFormat.get("a HH:mm:ss")
set(value) { set(value) {
field = value field = value
simpleTimeFormat = SimpleDateFormat(defaultTimeFormat)
} }
var defaultDateFormat = "yyyy년 MM월 W주차 dd일 E요일" var defaultDateFormat = PrefString.defaultDateFormat.get("yyyy년 MM월 W주차 dd일 E요일")
set(value) { set(value) {
field = value field = value
simpleDateFormat = SimpleDateFormat(defaultDateFormat)
} }
var simpleTimeFormat = SimpleDateFormat(defaultTimeFormat) var simpleTimeFormat = SimpleDateFormat(defaultTimeFormat)
var simpleDateFormat = SimpleDateFormat(defaultDateFormat) var simpleDateFormat = SimpleDateFormat(defaultDateFormat)
var runable = { var runable = {

View File

@ -20,6 +20,7 @@ open abstract class BaseGetter : Worker {
return cal.timeInMillis return cal.timeInMillis
} }
} }
val USAGT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15" val USAGT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15"
val now = Date() val now = Date()
val limitDateTime = beforeDay(now,3) val limitDateTime = beforeDay(now,3)

View File

@ -166,66 +166,26 @@ class LocationUpdateService : Service(), LocationListener {
PrefLong.locationDistance.get(200).toFloat(), PrefLong.locationDistance.get(200).toFloat(),
this this
) )
// val fusedLocationClient = LocationServices.getFusedLocationProviderClient(this) val fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
// fusedLocationClient.lastLocation.addOnSuccessListener { location -> fusedLocationClient.lastLocation.addOnSuccessListener { location ->
// if (location != null) { if (location != null) {
// Toast.makeText( Toast.makeText(
// applicationContext, applicationContext,
// java.lang.Double.toString(location.latitude) + location.longitude + "from method", java.lang.Double.toString(location.latitude) + location.longitude + "from method",
// Toast.LENGTH_LONG Toast.LENGTH_LONG
// ).show() ).show()
// longitude = location.longitude longitude = location.longitude
// latitude = location.latitude latitude = location.latitude
// runWeatherGetter() runWeatherGetter()
// pushLocation(this.applicationContext, location.latitude, location.longitude) pushLocation(this.applicationContext, location.latitude, location.longitude)
// } }
// } }
} catch (e : Exception) { } catch (e : Exception) {
} }
} }
private val location: Location?
get() {
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) !=
PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
)
!= PackageManager.PERMISSION_GRANTED
) {
}
locationManager = applicationContext
.getSystemService(LOCATION_SERVICE) as LocationManager
checkGPS = locationManager!!
.isProviderEnabled(LocationManager.GPS_PROVIDER)
checkNetwork = locationManager!!
.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
locationManager?.requestLocationUpdates(LocationManager.GPS_PROVIDER, PrefLong.locationTimePeriod.get(30), PrefLong.locationDistance.get(200).toFloat(), this)
if (locationManager != null) {
val fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
fusedLocationClient.lastLocation.addOnSuccessListener { location ->
if (location != null) {
Toast.makeText(
applicationContext,
java.lang.Double.toString(location.latitude) + location.longitude + "from method",
Toast.LENGTH_LONG
).show()
longitude = location.longitude
latitude = location.latitude
runWeatherGetter()
pushLocation(this.applicationContext, location.latitude, location.longitude)
}
}
}
return loc
}

View File

@ -25,7 +25,6 @@ class NewsFeedsGetter : BaseGetter {
feddsUrls.addAll(RssList.getFeedUrls()) feddsUrls.addAll(RssList.getFeedUrls())
for (url in feddsUrls) { for (url in feddsUrls) {
BLog.LOGE("start newsFeeds Load By url >>>> ${url}")
for (it in RssFeedsParser.getFeeds(url)) { for (it in RssFeedsParser.getFeeds(url)) {
if (it.pubDate() >= limitDateTime) { if (it.pubDate() >= limitDateTime) {
temp.add(it.getRssData()) temp.add(it.getRssData())

View File

@ -2,6 +2,7 @@ package bums.lunatic.launcher.workers
import android.content.Context import android.content.Context
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import bums.lunatic.launcher.helpers.PrefString
import bums.lunatic.launcher.model.WeatherForcast import bums.lunatic.launcher.model.WeatherForcast
import bums.lunatic.launcher.model.WeatherInfoManager import bums.lunatic.launcher.model.WeatherInfoManager
import bums.lunatic.launcher.utils.BLog import bums.lunatic.launcher.utils.BLog
@ -53,7 +54,7 @@ class OpenWeatherGetter(context: Context, workerParams: WorkerParameters) : Base
.create<RestrofitService>() .create<RestrofitService>()
.getForecast( // weatherApi .getForecast( // weatherApi
ver = VER_WEATHERAPI, ver = VER_WEATHERAPI,
key = KEY_WEATHERAPI, key = PrefString.weatherApiKey.get(),
q = "$latitude,$longitude", q = "$latitude,$longitude",
days = (System.currentTimeMillis() % 5L).toInt().toString() days = (System.currentTimeMillis() % 5L).toInt().toString()
)?.execute()?.let { response -> )?.execute()?.let { response ->

View File

@ -3,51 +3,70 @@
<data> <data>
<variable name="info" type="bums.lunatic.launcher.model.ShowingWeatherInfo"/> <variable name="info" type="bums.lunatic.launcher.model.ShowingWeatherInfo"/>
</data> </data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="80dp" android:layout_width="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
android:layout_height="wrap_content" android:layout_height="90dp"
android:gravity="center" android:gravity="center">
android:id="@+id/weather_item">
<TextView <TextView
style="@style/normal" android:padding="4dp"
android:layout_width="match_parent" app:layout_constraintLeft_toLeftOf="parent"
style="@style/small"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/amOrPm" android:id="@+id/amOrPm"
android:gravity="center" android:gravity="center"
android:text="@{info.amOrPm}" android:text="@{info.amOrPm}"
android:fontFamily="sans-serif-medium"
/> />
<TextView <TextView
style="@style/normal" android:layout_margin="@dimen/default_layout_margin"
android:layout_width="50dp" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
style="@style/small"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/hour" android:id="@+id/hour"
android:background="@drawable/date_bg" android:background="@drawable/date_bg"
android:fontFamily="sans-serif-medium"
android:gravity="center" android:gravity="center"
android:text="@{info.textHour}" android:text="@{info.textHour}"
android:textAlignment="center"/> android:textAlignment="center"/>
<ImageView <ImageView
android:id="@+id/imgDress" android:padding="12dp"
android:layout_width="40dp" android:layout_margin="@dimen/default_layout_margin"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:id="@+id/imgWeather"
app:layout_constraintTop_toBottomOf="@id/hour"
app:layout_constraintBottom_toTopOf="@id/textDress"
android:layout_width="60dp"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:src="@drawable/level_dress_img" android:src="@drawable/level_dress_img"
android:layout_height="40dp" android:layout_height="wrap_content"
android:contentDescription="온도별 옷차림" android:contentDescription="온도별 옷차림"
app:tint="@android:color/white"/> app:tint="@android:color/white"/>
<TextView <TextView
app:layout_constraintBottom_toTopOf="@id/temperature"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:includeFontPadding="false"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/textDress" android:id="@+id/textDress"
style="@style/small" style="@style/small"
android:text="@{info.dress}" android:text="@{info.textCondition}"
android:gravity="center" android:gravity="center"
android:textAlignment="center"/> android:textAlignment="center"/>
<TextView <TextView
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
style="@style/normal" style="@style/normal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -57,5 +76,5 @@
android:fontFamily="sans-serif-medium" android:fontFamily="sans-serif-medium"
android:gravity="center" android:gravity="center"
android:textAlignment="center"/> android:textAlignment="center"/>
</LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</layout> </layout>

View File

@ -13,6 +13,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/default_layout_margin" android:layout_margin="@dimen/default_layout_margin"
android:indeterminate="false" android:indeterminate="false"
android:visibility="gone"
style="@style/normal" style="@style/normal"
android:text="빠떼뤼 ~> 0%" android:text="빠떼뤼 ~> 0%"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
@ -25,6 +26,7 @@
android:background="@drawable/base_bg" android:background="@drawable/base_bg"
android:text="this is init sentence" android:text="this is init sentence"
android:id="@+id/time" android:id="@+id/time"
android:visibility="gone"
android:gravity="center" android:gravity="center"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"

View File

@ -45,7 +45,7 @@
style="@style/Widget.Material3.Button.ElevatedButton" style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/time_date" android:text="Display Info"
android:textAllCaps="true" android:textAllCaps="true"
android:textStyle="bold" /> android:textStyle="bold" />

View File

@ -6,11 +6,20 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/twelve"> android:padding="@dimen/twelve">
<CheckBox
android:id="@+id/useBattery"
android:text="USE Battery Display"
android:textColor="@color/white"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox <CheckBox
android:id="@+id/useDateTime" android:id="@+id/useDateTime"
android:text="USE DateTimeView" android:text="USE DateTimeView"
android:textColor="@color/white" android:textColor="@color/white"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toBottomOf="@+id/useBattery"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>

View File

@ -52,7 +52,7 @@
android:id="@+id/weatherTitle" android:id="@+id/weatherTitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="재생중인 곡" android:text="날씨 보기"
android:textSize="@dimen/normalText" android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View File

@ -8,7 +8,7 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:padding="@dimen/default_padding" android:padding="@dimen/default_padding"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp"> android:layout_height="120dp">
<ImageView <ImageView
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:padding="0dp" android:padding="0dp"
@ -57,7 +57,7 @@
<androidx.viewpager2.widget.ViewPager2 <androidx.viewpager2.widget.ViewPager2
android:id="@+id/weatherViewPager" android:id="@+id/weatherViewPager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="90dp"
app:layout_constraintTop_toBottomOf="@+id/textView2" /> app:layout_constraintTop_toBottomOf="@+id/textView2" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</layout> </layout>