...
This commit is contained in:
parent
b81e12c61b
commit
caf5601a71
@ -68,6 +68,7 @@ import androidx.core.view.updatePadding
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.ListenableWorker
|
||||
import androidx.work.OneTimeWorkRequest
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
@ -185,21 +186,12 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.addTag(ContactInfoGetter.TAG)
|
||||
.build())
|
||||
}, 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({
|
||||
mWorkManager?.enqueue(OneTimeWorkRequest.from(AppInfoGetter::class.java))
|
||||
}, 5, TimeUnit.SECONDS)
|
||||
|
||||
}
|
||||
|
||||
fun runWeatherGetter() {
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.enqueue(OneTimeWorkRequest.from(OpenWeatherGetter::class.java))
|
||||
@ -212,14 +204,10 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}, 5, TimeUnit.SECONDS)
|
||||
}
|
||||
|
||||
val defaultDelay = 10L
|
||||
|
||||
fun refreshFeeds() {
|
||||
// Fri, 15 11 2024 15:06:28 +0900
|
||||
// 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
|
||||
var delay = defaultDelay
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(FEDDS_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -228,7 +216,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.addTag(FEDDS_WORK_TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
delay= delay + 5
|
||||
delay += defaultDelay
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(YT_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -237,7 +225,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.addTag(YT_WORK_TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
delay= delay + 5
|
||||
delay += defaultDelay
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(REDDIT_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -246,7 +234,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.addTag(REDDIT_WORK_TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
delay= delay + 5
|
||||
delay += defaultDelay
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -255,7 +243,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.addTag(COMIC_WORK_TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
delay= delay + 5
|
||||
delay += defaultDelay
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -264,7 +252,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.addTag(COMIC2_WORK_TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
delay= delay + 5
|
||||
delay += defaultDelay
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(ClienGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -273,7 +261,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.addTag(ClienGetter.TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
delay= delay + 5
|
||||
delay += defaultDelay
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(DCGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -282,7 +270,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.addTag(DCGetter.TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
delay= delay + 5
|
||||
delay += defaultDelay
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(RuliWebGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -291,7 +279,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.addTag(RuliWebGetter.TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
delay= delay + 5
|
||||
delay += defaultDelay
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(TheQooGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -300,7 +288,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.addTag(TheQooGetter.TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
delay= delay + 5
|
||||
delay += defaultDelay
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(ArcaGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -311,26 +299,6 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
|
||||
}, 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)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -261,17 +261,17 @@ internal class Feeds : Fragment() , CommadCallabck {
|
||||
home?.queryInfos(keyword = cmd[1])
|
||||
}
|
||||
"jf" -> {
|
||||
consoleLog("on Cmd JF")
|
||||
// CoroutineScope(Dispatchers.IO).launch {
|
||||
// consoleLog("${cmd[0]} Start ${cmd[1]}")
|
||||
// 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("${cmd[0]} END ${cmd[1]}")
|
||||
// }
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
consoleLog("${cmd[0]} Start ${cmd[1]}")
|
||||
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("${cmd[0]} END ${cmd[1]}")
|
||||
}
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
consoleLog("on Cmd JF with MOST")
|
||||
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("${cmd[0]} END ${cmd[1]}")
|
||||
}
|
||||
@ -478,28 +478,28 @@ internal class Feeds : Fragment() , CommadCallabck {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
var isOk = false
|
||||
// plist.forEach {
|
||||
if (!isOk) {
|
||||
try {
|
||||
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")
|
||||
.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("Connection", "keep-alive")
|
||||
.header("scheme", "https")
|
||||
.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("cache-control", "no-cache")
|
||||
.header("pragma", "no-cache")
|
||||
.header("upgrade-insecure-requests", "1")
|
||||
.ignoreContentType(true)
|
||||
.timeout(30000).execute().let {
|
||||
BLog.LOGE("DOC -> ${it}")
|
||||
isOk = true
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
if (!isOk) {
|
||||
try {
|
||||
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")
|
||||
.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("Connection", "keep-alive")
|
||||
.header("scheme", "https")
|
||||
.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("cache-control", "no-cache")
|
||||
.header("pragma", "no-cache")
|
||||
.header("upgrade-insecure-requests", "1")
|
||||
.ignoreContentType(true)
|
||||
.timeout(30000).execute().let {
|
||||
BLog.LOGE("DOC -> ${it}")
|
||||
isOk = true
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
// }
|
||||
BLog.LOGE("last state ${isOk}")
|
||||
}
|
||||
|
||||
@ -33,6 +33,8 @@ enum class PrefLong(val def : Long) : PrefKey<Long> {
|
||||
}
|
||||
|
||||
enum class PrefBoolean : PrefKey<Boolean> {
|
||||
displayBattery,
|
||||
displayDateTime,
|
||||
location,
|
||||
rootPermisssion,
|
||||
isConnectedCar,
|
||||
|
||||
@ -496,7 +496,7 @@ internal class LauncherHome : Fragment() {
|
||||
}
|
||||
|
||||
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 {
|
||||
mRssDataResult?.asFlow()?.collect { changes: ResultsChange<RssData> ->
|
||||
commandHandler.removeCallbacks(hideListView)
|
||||
@ -522,7 +522,7 @@ internal class LauncherHome : Fragment() {
|
||||
}
|
||||
|
||||
fun queryInfos(
|
||||
filter: Collection<RssDataType>? = arrayListOf(), noLimit: Boolean = false
|
||||
filter: Collection<RssDataType>? = arrayListOf(RssDataType.GURU, RssDataType.MOST,RssDataType.REDDIT_NSFW), noLimit: Boolean = false
|
||||
) {
|
||||
beforeQuery()
|
||||
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?) {
|
||||
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.root.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.root, mFingerGestureListener))
|
||||
binding.functionLayer.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.functionLayer, mFingerGestureListener))
|
||||
@ -597,7 +607,7 @@ internal class LauncherHome : Fragment() {
|
||||
|
||||
binding.otherCheck -> {
|
||||
if (binding.otherCheck.isSelected) {
|
||||
if (rssStateVote() || lasted?.size ?: 0 < 200) {
|
||||
if (rssStateVote()) {
|
||||
queryInfos()
|
||||
} else {
|
||||
binding.otherCheck.isSelected = false
|
||||
@ -649,15 +659,15 @@ internal class LauncherHome : Fragment() {
|
||||
val input = viewInflated.findViewById<View>(R.id.input) as EditText
|
||||
val categoryz =
|
||||
viewInflated.findViewById<TableRadioGroup>(R.id.categoryz) as TableRadioGroup
|
||||
categoryz.setMaxColumns(5)
|
||||
categoryz.setMaxRows(5)
|
||||
categoryz.setMaxColumns(3)
|
||||
categoryz.setMaxRows(8)
|
||||
categoryz.setOnCheckedChangeListener(object : TableRadioGroup.OnCheckedChangeListener {
|
||||
override fun onCheckedChanged(group: TableRadioGroup?, checkedId: Int) {
|
||||
|
||||
}
|
||||
})
|
||||
var idx = 0
|
||||
RssDataType.values().reversed().toList().chunked(5).forEach {
|
||||
RssDataType.values().reversed().toList().chunked(3).forEach {
|
||||
var tb = TableRow(requireContext())
|
||||
it.forEach { c ->
|
||||
if (c.equals(RssDataType.NO_DATA) == false) {
|
||||
|
||||
@ -100,7 +100,7 @@ object RssFeedsParser {
|
||||
link = readLink(parser)
|
||||
} else if (name == "pubDate") {
|
||||
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) { } }
|
||||
} else if (name == "description") {
|
||||
desc = readDesc(parser)
|
||||
|
||||
@ -69,6 +69,9 @@ internal class RssItemAdapter (
|
||||
WorkersDb.getRealm().apply {
|
||||
writeBlocking {
|
||||
rss.read = rss.read + 1
|
||||
if(rss.getCho()?.length ?: 0 < 1) {
|
||||
rss.chosung = rss.title
|
||||
}
|
||||
copyToRealm(rss,UpdatePolicy.ALL)
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ class WeatherDressAdatper (private val dataSet: ArrayList<Hour>) : RecyclerView.
|
||||
this@apply.isSelected = false
|
||||
}
|
||||
}
|
||||
holder.viewItem.imgDress.setImageLevel(it.temp_c.toInt())
|
||||
holder.viewItem.imgWeather.setImageLevel(it.temp_c.toInt())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ import bums.lunatic.launcher.settings.childs.Appearances
|
||||
import bums.lunatic.launcher.settings.childs.Apps
|
||||
import bums.lunatic.launcher.settings.childs.HomeSettings
|
||||
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 com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.color.DynamicColors
|
||||
@ -65,7 +65,7 @@ internal class SettingsActivity : AppCompatActivity() {
|
||||
|
||||
/* launch child settings dialogs on button clicks */
|
||||
binding.timeDate.setOnClickListener {
|
||||
TimeDate().show(supportFragmentManager, BOTTOM_SHEET_TAG)
|
||||
TopInfos().show(supportFragmentManager, BOTTOM_SHEET_TAG)
|
||||
}
|
||||
|
||||
binding.weather.setOnClickListener {
|
||||
|
||||
@ -26,36 +26,67 @@ import android.view.ViewGroup
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import bums.lunatic.launcher.R
|
||||
import bums.lunatic.launcher.databinding.SettingsTimeDateBinding
|
||||
import bums.lunatic.launcher.helpers.Constants.Companion.DEFAULT_DATE_FORMAT
|
||||
import bums.lunatic.launcher.helpers.Constants.Companion.KEY_DATE_FORMAT
|
||||
import bums.lunatic.launcher.helpers.Constants.Companion.KEY_TIME_FORMAT
|
||||
import bums.lunatic.launcher.settings.SettingsActivity.Companion.settingsPrefs
|
||||
import bums.lunatic.launcher.helpers.PrefBoolean
|
||||
import bums.lunatic.launcher.helpers.PrefHelper
|
||||
import bums.lunatic.launcher.helpers.PrefString
|
||||
import bums.lunatic.launcher.utils.BLog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.gson.Gson
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Objects
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
|
||||
internal class TimeDate : BottomSheetDialogFragment() {
|
||||
internal class TopInfos : BottomSheetDialogFragment() {
|
||||
|
||||
private lateinit var binding : SettingsTimeDateBinding
|
||||
private var settingsChanged: Boolean = false
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
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 {
|
||||
try {
|
||||
SimpleDateFormat(it.toString()).format(Date())
|
||||
binding.previewDateTime
|
||||
binding.previewDateTime.defaultTimeFormat = it.toString()
|
||||
settingsChanged = true
|
||||
PrefString.defaultTimeFormat.set(it.toString())
|
||||
} catch (e : Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
binding.dateFormat.doAfterTextChanged {
|
||||
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) {
|
||||
|
||||
}
|
||||
@ -63,7 +94,14 @@ internal class TimeDate : BottomSheetDialogFragment() {
|
||||
|
||||
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?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
|
||||
@ -24,6 +24,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import bums.lunatic.launcher.R
|
||||
import bums.lunatic.launcher.databinding.SettingsWeatherBinding
|
||||
import bums.lunatic.launcher.helpers.Constants.Companion.KEY_CITY_NAME
|
||||
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 com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
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
|
||||
|
||||
@ -49,11 +68,14 @@ internal class WeatherSettings : BottomSheetDialogFragment() {
|
||||
binding.inputOwm.setText(PrefString.weatherApiKey.get(""))
|
||||
binding.inputOwm.doOnTextChanged { text, start, before, count ->
|
||||
PrefString.weatherApiKey.set(text.toString())
|
||||
settingsChanged = true
|
||||
}
|
||||
binding.dress.isChecked = PrefBoolean.weatherDress.get(false)
|
||||
binding.weather.isChecked = PrefBoolean.weatherState.get(false)
|
||||
binding.weather.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.weatherState.set(isChecked)}
|
||||
binding.dress.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.weatherDress.set(isChecked)}
|
||||
binding.weather.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.weatherState.set(isChecked)
|
||||
settingsChanged = true}
|
||||
binding.dress.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.weatherDress.set(isChecked)
|
||||
settingsChanged = true}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
||||
@ -17,20 +17,25 @@ import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import bums.lunatic.launcher.R
|
||||
import bums.lunatic.launcher.helpers.PrefString
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
|
||||
class DateTimeView : AppCompatTextView {
|
||||
lateinit var mHandler : Handler
|
||||
var defaultTimeFormat = "a HH:mm:ss"
|
||||
var defaultTimeFormat = PrefString.defaultTimeFormat.get("a HH:mm:ss")
|
||||
|
||||
set(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) {
|
||||
field = value
|
||||
simpleDateFormat = SimpleDateFormat(defaultDateFormat)
|
||||
}
|
||||
|
||||
var simpleTimeFormat = SimpleDateFormat(defaultTimeFormat)
|
||||
var simpleDateFormat = SimpleDateFormat(defaultDateFormat)
|
||||
var runable = {
|
||||
|
||||
@ -20,6 +20,7 @@ open abstract class BaseGetter : Worker {
|
||||
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 now = Date()
|
||||
val limitDateTime = beforeDay(now,3)
|
||||
|
||||
@ -166,66 +166,26 @@ class LocationUpdateService : Service(), LocationListener {
|
||||
PrefLong.locationDistance.get(200).toFloat(),
|
||||
this
|
||||
)
|
||||
// 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)
|
||||
// }
|
||||
// }
|
||||
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)
|
||||
}
|
||||
}
|
||||
} 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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -25,7 +25,6 @@ class NewsFeedsGetter : BaseGetter {
|
||||
feddsUrls.addAll(RssList.getFeedUrls())
|
||||
|
||||
for (url in feddsUrls) {
|
||||
BLog.LOGE("start newsFeeds Load By url >>>> ${url}")
|
||||
for (it in RssFeedsParser.getFeeds(url)) {
|
||||
if (it.pubDate() >= limitDateTime) {
|
||||
temp.add(it.getRssData())
|
||||
|
||||
@ -2,6 +2,7 @@ package bums.lunatic.launcher.workers
|
||||
|
||||
import android.content.Context
|
||||
import androidx.work.WorkerParameters
|
||||
import bums.lunatic.launcher.helpers.PrefString
|
||||
import bums.lunatic.launcher.model.WeatherForcast
|
||||
import bums.lunatic.launcher.model.WeatherInfoManager
|
||||
import bums.lunatic.launcher.utils.BLog
|
||||
@ -53,7 +54,7 @@ class OpenWeatherGetter(context: Context, workerParams: WorkerParameters) : Base
|
||||
.create<RestrofitService>()
|
||||
.getForecast( // weatherApi
|
||||
ver = VER_WEATHERAPI,
|
||||
key = KEY_WEATHERAPI,
|
||||
key = PrefString.weatherApiKey.get(),
|
||||
q = "$latitude,$longitude",
|
||||
days = (System.currentTimeMillis() % 5L).toInt().toString()
|
||||
)?.execute()?.let { response ->
|
||||
|
||||
@ -3,51 +3,70 @@
|
||||
<data>
|
||||
<variable name="info" type="bums.lunatic.launcher.model.ShowingWeatherInfo"/>
|
||||
</data>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="80dp"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:id="@+id/weather_item">
|
||||
android:layout_height="90dp"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
style="@style/normal"
|
||||
android:layout_width="match_parent"
|
||||
android:padding="4dp"
|
||||
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:id="@+id/amOrPm"
|
||||
android:gravity="center"
|
||||
android:text="@{info.amOrPm}"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
style="@style/normal"
|
||||
android:layout_width="50dp"
|
||||
android:layout_margin="@dimen/default_layout_margin"
|
||||
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:id="@+id/hour"
|
||||
android:background="@drawable/date_bg"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:gravity="center"
|
||||
|
||||
android:text="@{info.textHour}"
|
||||
android:textAlignment="center"/>
|
||||
<ImageView
|
||||
android:id="@+id/imgDress"
|
||||
android:layout_width="40dp"
|
||||
android:padding="12dp"
|
||||
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:layout_height="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="온도별 옷차림"
|
||||
app:tint="@android:color/white"/>
|
||||
<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_height="wrap_content"
|
||||
android:id="@+id/textDress"
|
||||
style="@style/small"
|
||||
android:text="@{info.dress}"
|
||||
android:text="@{info.textCondition}"
|
||||
android:gravity="center"
|
||||
android:textAlignment="center"/>
|
||||
<TextView
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
style="@style/normal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -57,5 +76,5 @@
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:gravity="center"
|
||||
android:textAlignment="center"/>
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@ -13,6 +13,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/default_layout_margin"
|
||||
android:indeterminate="false"
|
||||
android:visibility="gone"
|
||||
style="@style/normal"
|
||||
android:text="빠떼뤼 ~> 0%"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
@ -25,6 +26,7 @@
|
||||
android:background="@drawable/base_bg"
|
||||
android:text="this is init sentence"
|
||||
android:id="@+id/time"
|
||||
android:visibility="gone"
|
||||
android:gravity="center"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
style="@style/Widget.Material3.Button.ElevatedButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/time_date"
|
||||
android:text="Display Info"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
@ -6,11 +6,20 @@
|
||||
android:layout_height="wrap_content"
|
||||
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
|
||||
android:id="@+id/useDateTime"
|
||||
android:text="USE DateTimeView"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/useBattery"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
android:id="@+id/weatherTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="재생중인 곡"
|
||||
android:text="날씨 보기"
|
||||
android:textSize="@dimen/normalText"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:padding="@dimen/default_padding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp">
|
||||
android:layout_height="120dp">
|
||||
<ImageView
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="0dp"
|
||||
@ -57,7 +57,7 @@
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/weatherViewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="90dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView2" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user