This commit is contained in:
lunaticbum 2024-11-14 16:03:38 +09:00
parent d2dd6e8cd0
commit 8ba7005c53
10 changed files with 172 additions and 191 deletions

View File

@ -392,6 +392,8 @@ internal class LauncherActivity : AppCompatActivity() {
) { ) {
if (binding.home.visibility == View.VISIBLE) { if (binding.home.visibility == View.VISIBLE) {
switchAppDrawer() switchAppDrawer()
} else {
} }
} else { } else {
intent?.extras?.keySet()?.forEach { intent?.extras?.keySet()?.forEach {
@ -666,7 +668,7 @@ internal class LauncherActivity : AppCompatActivity() {
} else if (binding.appDrawer.visibility == View.VISIBLE) { } else if (binding.appDrawer.visibility == View.VISIBLE) {
switchAppDrawer() switchAppDrawer()
} else if (binding.home.visibility == View.VISIBLE) { } else if (binding.home.visibility == View.VISIBLE) {
switchAppDrawer() // switchAppDrawer()
} }
} }
}) })

View File

@ -480,13 +480,18 @@ internal class AppDrawer : Fragment() {
registCancelSearch() registCancelSearch()
} }
fun openSearch() { fun openSearch() {
try { try {
binding.searchInput.apply { if(isAdded && isVisible) {
visibility = VISIBLE binding.searchInput.apply {
requestFocus() visibility = VISIBLE
let { requestFocus()
(lActivity?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager)?.showSoftInput(it, InputMethodManager.SHOW_IMPLICIT) let {
(lActivity?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager)?.showSoftInput(
it,
InputMethodManager.SHOW_IMPLICIT
)
}
} }
} }
} catch (e : UninitializedPropertyAccessException) { } catch (e : UninitializedPropertyAccessException) {

View File

@ -162,7 +162,7 @@ internal class LauncherHome : Fragment() {
} }
val nomoreShowCount = 5 val nomoreShowCount = 5
var rssStateVote = false fun rssStateVote() = lasted?.filter { it.vote == false }?.size ?: 0 == 0
var lasted: List<RssData>? = null var lasted: List<RssData>? = null
var lastedNoti: List<NotificationItem>? = null var lastedNoti: List<NotificationItem>? = null
@ -205,23 +205,12 @@ internal class LauncherHome : Fragment() {
var weatherPages = arrayListOf<Int>() var weatherPages = arrayListOf<Int>()
var weatherAdapter = arrayListOf<RecyclerView.Adapter<out RecyclerView.ViewHolder>?>() var weatherAdapter = arrayListOf<RecyclerView.Adapter<out RecyclerView.ViewHolder>?>()
PrefBoolean.weatherDress.get(false).letTrue { (PrefBoolean.weatherDress.get(false) || PrefBoolean.weatherState.get(false)).letTrue {
weatherPages.add(R.layout.hourly_weather); weatherAdapter.add(weatherDressAdapter!!) PrefBoolean.weatherDress.get(false).letTrue { weatherPages.add(R.layout.hourly_weather); weatherAdapter.add(weatherDressAdapter!!) }
} PrefBoolean.weatherState.get(false).letTrue { weatherPages.add(R.layout.recommended_hourly_dress); weatherAdapter.add(weatherHourlyAdapter!!) }
PrefBoolean.weatherState.get(false).letTrue { binding.weathers.root.visibility = View.VISIBLE
weatherPages.add(R.layout.recommended_hourly_dress); weatherAdapter.add( mWeatherAdapter = WeatherAdapter(weatherPages, adatpers = weatherAdapter, binding.weathers)
weatherHourlyAdapter!! binding.weathers.weatherViewPager.offscreenPageLimit = 2
)
}
if (weatherPages.size > 0) {
mWeatherAdapter = WeatherAdapter(
weatherPages,
adatpers = weatherAdapter,
binding.noticeSummary
)
binding.noticeSummary.weatherViewPager.offscreenPageLimit = 2
} else {
binding.noticeSummary.root.visibility = View.GONE
} }
val decoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) val decoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL)
@ -232,14 +221,14 @@ internal class LauncherHome : Fragment() {
binding.smsList.visibility = View.GONE binding.smsList.visibility = View.GONE
binding.infoList.visibility = View.GONE binding.infoList.visibility = View.GONE
binding.noticeSummary.weatherViewPager.orientation = ViewPager2.ORIENTATION_VERTICAL binding.weathers.weatherViewPager.orientation = ViewPager2.ORIENTATION_VERTICAL
binding.mainList.adapter = mRecentCallsAdapter binding.mainList.adapter = mRecentCallsAdapter
binding.smsList.adapter = mSmsLogsAdapter binding.smsList.adapter = mSmsLogsAdapter
binding.infoList.adapter = mRssAdapter binding.infoList.adapter = mRssAdapter
binding.notiList.adapter = mNotiAdapter binding.notiList.adapter = mNotiAdapter
binding.noticeSummary.weatherViewPager.adapter = mWeatherAdapter binding.weathers.weatherViewPager.adapter = mWeatherAdapter
binding.noticeSummary.weatherViewPager.registerOnPageChangeCallback(object : binding.weathers.weatherViewPager.registerOnPageChangeCallback(object :
ViewPager2.OnPageChangeCallback() { ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) { override fun onPageSelected(position: Int) {
super.onPageSelected(position) super.onPageSelected(position)
@ -413,7 +402,7 @@ internal class LauncherHome : Fragment() {
it.notifyDataSetChanged() it.notifyDataSetChanged()
} }
mWeatherAdapter?.let { mWeatherAdapter?.let {
binding.noticeSummary.textLocation = binding.weathers.textLocation =
if (hours.isNotEmpty()) WeatherInfoManager.getShowingInfo(hours.first()).textLocation else "도시 / 나라" if (hours.isNotEmpty()) WeatherInfoManager.getShowingInfo(hours.first()).textLocation else "도시 / 나라"
it.notifyDataSetChanged() it.notifyDataSetChanged()
} }
@ -527,30 +516,19 @@ internal class LauncherHome : Fragment() {
infosJob?.start() infosJob?.start()
} }
fun queryVotes() { fun queryVotes() {
beforeQuery() beforeQuery()
var rQ = WorkersDb.getRealm().query<RssData>().query("vote == $0", true) updateQuery(WorkersDb.getVotedRss())
updateQuery(rQ)
rssStateVote = true
} }
//RssDataType.GURU,
// RssDataType.MOST,
// RssDataType.REDDIT_NSFW
fun queryInfos( fun queryInfos(
filter: Collection<RssDataType>? = arrayListOf( filter: Collection<RssDataType>? = arrayListOf(), noLimit: Boolean = false
), 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)
if (!noLimit) rQ.query("pubDate > $0", beforeDay(Date(), 3)) if (!noLimit) rQ.query("pubDate > $0", beforeDay(Date(), 3))
filter!!.forEach { ((filter?.size ?: 0) > 0).letTrue {filter!!.forEach {rQ = rQ.query("category != $0", it.name)}}
rQ = rQ.query("category != $0", it.name)
}
updateQuery(rQ) updateQuery(rQ)
rssStateVote = false
} }
fun queryInfos( fun queryInfos(
@ -559,38 +537,7 @@ internal class LauncherHome : Fragment() {
noLimit: Boolean = false noLimit: Boolean = false
) { ) {
beforeQuery() beforeQuery()
var rQ = WorkersDb.getRealm().query<RssData>() updateQuery(WorkersDb.getRssQuery(keyword,category,noLimit))
if (!noLimit) rQ.query("pubDate > $0", beforeDay(Date(), 3))
keyword.isNotEmpty().letTrue {
if (JamoUtils.CHOSUNG.contains(keyword.split("")[0])) {
rQ = rQ.query("title CONTAINS $0 OR chosung CONTAINS $1 ", keyword, keyword)
} else if (Pattern.matches("^[가-힣]*\$", keyword)) {
rQ = rQ.query("title CONTAINS $0", keyword)
} else {
rQ = rQ.query(
"title CONTAINS $0 OR title CONTAINS $1",
keyword.uppercase(Locale.getDefault()),
keyword.lowercase(Locale.getDefault())
)
}
}
var queryString = ""
category.isNotEmpty().letTrue {
category.forEachIndexed { idx, it ->
if (idx == 0) {
queryString = queryString.plus("category == '${it}'")
} else {
queryString = queryString.plus(" OR category == '${it}' ")
}
}
rQ = rQ.query(queryString)
}
if (keyword.length == 0 && category.size == 0) {
rQ = rQ.query("read < $0", 3).query("vote != $0", true)
}
updateQuery(rQ)
rssStateVote = false
} }
@ -604,21 +551,15 @@ internal class LauncherHome : Fragment() {
binding.time.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.time, mFingerGestureListener)) binding.time.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.time, mFingerGestureListener))
BLog.LOGE("onViewCreated()") BLog.LOGE("onViewCreated()")
binding.missedCalls.visibility =
if (PrefBoolean.showCallHistory.get(false)) View.VISIBLE else View.GONE
binding.recentSms.visibility =
if (PrefBoolean.showSMSHistory.get(false)) View.VISIBLE else View.GONE
binding.notice.visibility =
if (PrefBoolean.showNotificationHistory.get(false)) View.VISIBLE else View.GONE
binding.otherCheck.visibility =
if (PrefBoolean.showNewsHistory.get(false)) View.VISIBLE else View.GONE
binding.summaryChoose.visibility = View.GONE
(PrefBoolean.showCallHistory.get(false) || PrefBoolean.showSMSHistory.get(false) || PrefBoolean.showNotificationHistory.get(
false
) || PrefBoolean.showNewsHistory.get(false)).letTrue {
binding.summaryChoose.visibility = View.VISIBLE
}
binding.summaryChoose.visibility = View.GONE
(PrefBoolean.showCallHistory.get(false) || PrefBoolean.showSMSHistory.get(false) || PrefBoolean.showNotificationHistory.get(false) || PrefBoolean.showNewsHistory.get(false)).letTrue {
binding.summaryChoose.visibility = View.VISIBLE
binding.missedCalls.visibility = if (PrefBoolean.showCallHistory.get(false)) View.VISIBLE else View.GONE
binding.recentSms.visibility = if (PrefBoolean.showSMSHistory.get(false)) View.VISIBLE else View.GONE
binding.notice.visibility = if (PrefBoolean.showNotificationHistory.get(false)) View.VISIBLE else View.GONE
binding.otherCheck.visibility = if (PrefBoolean.showNewsHistory.get(false)) View.VISIBLE else View.GONE
}
fragManager.addOnBackStackChangedListener { fragManager.addOnBackStackChangedListener {
BLog.LOGE("addOnBackStackChangedListener()") BLog.LOGE("addOnBackStackChangedListener()")
@ -634,37 +575,21 @@ internal class LauncherHome : Fragment() {
var checkListner = object : View.OnClickListener { var checkListner = object : View.OnClickListener {
override fun onClick(v: View?) { override fun onClick(v: View?) {
commandHandler.removeCallbacks(hideListView) commandHandler.removeCallbacks(hideListView)
var views = arrayListOf( var views = arrayListOf(binding.mainList, binding.smsList, binding.infoList, binding.notiList)
binding.mainList, var chechboxs = arrayListOf(binding.missedCalls, binding.recentSms, binding.otherCheck, binding.notice)
binding.smsList,
binding.infoList,
binding.notiList
)
var chechboxs = arrayListOf(
binding.missedCalls,
binding.recentSms,
binding.otherCheck,
binding.notice
)
chechboxs.remove(v) chechboxs.remove(v)
when (v) { when (v) {
binding.missedCalls -> { binding.missedCalls -> {
binding.missedCalls.isSelected = !binding.missedCalls.isSelected
if (binding.missedCalls.isSelected) { if (binding.missedCalls.isSelected) {
binding.missedCalls.isSelected = false
} else {
binding.missedCalls.isSelected = true
views.remove(binding.mainList) views.remove(binding.mainList)
binding.mainList.visibility = View.VISIBLE binding.mainList.visibility = View.VISIBLE
} }
} }
binding.recentSms -> { binding.recentSms -> {
binding.recentSms.isSelected = !binding.recentSms.isSelected
if (binding.recentSms.isSelected) { if (binding.recentSms.isSelected) {
binding.recentSms.isSelected = false
} else {
binding.recentSms.isSelected = true
views.remove(binding.smsList) views.remove(binding.smsList)
binding.smsList.visibility = View.VISIBLE binding.smsList.visibility = View.VISIBLE
} }
@ -672,7 +597,7 @@ internal class LauncherHome : Fragment() {
binding.otherCheck -> { binding.otherCheck -> {
if (binding.otherCheck.isSelected) { if (binding.otherCheck.isSelected) {
if (rssStateVote) { if (rssStateVote() || lasted?.size ?: 0 < 200) {
queryInfos() queryInfos()
} else { } else {
binding.otherCheck.isSelected = false binding.otherCheck.isSelected = false
@ -865,7 +790,7 @@ internal class LauncherHome : Fragment() {
writeBlocking { writeBlocking {
when(direction) { when(direction) {
ItemTouchHelper.LEFT->{ ItemTouchHelper.LEFT->{
if (rssStateVote && rss.vote) { if (rssStateVote() && rss.vote) {
rss.vote = false rss.vote = false
rss.read = 0 rss.read = 0
} else { } else {
@ -874,7 +799,7 @@ internal class LauncherHome : Fragment() {
copyToRealm(rss, UpdatePolicy.ALL) copyToRealm(rss, UpdatePolicy.ALL)
query<RssData>("chosung == $0",rss.chosung).find().forEach { it -> query<RssData>("chosung == $0",rss.chosung).find().forEach { it ->
if (!rss.originPage().equals(it.originPage())) { if (!rss.originPage().equals(it.originPage())) {
if (rssStateVote && rss.vote) { if (rssStateVote() && rss.vote) {
it.vote = false it.vote = false
it.read = 0 it.read = 0
} else { } else {
@ -885,7 +810,7 @@ internal class LauncherHome : Fragment() {
} }
} }
ItemTouchHelper.RIGHT->{ ItemTouchHelper.RIGHT->{
if (rssStateVote && rss.vote) { if (rssStateVote() && rss.vote) {
rss.vote = false rss.vote = false
rss.read = 0 rss.read = 0
} else { } else {
@ -1033,7 +958,7 @@ internal class LauncherHome : Fragment() {
} }
else ->{} else ->{}
} }
} else if (targetView.equals(binding.time)) { } else if (targetView.equals(binding.time) && fingers == 2) {
val mClockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS) val mClockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS)
mClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) mClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(mClockIntent) startActivity(mClockIntent)
@ -1053,7 +978,7 @@ internal class LauncherHome : Fragment() {
1->lActivity?.switchFeeds() 1->lActivity?.switchFeeds()
else ->{} else ->{}
} }
} else if (targetView.equals(binding.time)) { } else if (targetView.equals(binding.time) && fingers == 2) {
val intent = Intent(Intent.ACTION_MAIN) val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_APP_CALENDAR) intent.addCategory(Intent.CATEGORY_APP_CALENDAR)
startActivity(intent) startActivity(intent)
@ -1119,7 +1044,7 @@ internal class LauncherHome : Fragment() {
// } // }
} else if (targetView?.equals(binding.functionLayer) == true) { } else if (targetView?.equals(binding.functionLayer) == true) {
targetView?.performHapticFeedback(HapticFeedbackConstants.CONFIRM) targetView?.performHapticFeedback(HapticFeedbackConstants.CONFIRM)
if(binding.otherCheck.isSelected && rssStateVote) { if(binding.otherCheck.isSelected && rssStateVote()) {
queryInfos() queryInfos()
} else { } else {
binding.otherCheck.isSelected = true binding.otherCheck.isSelected = true
@ -1136,7 +1061,7 @@ internal class LauncherHome : Fragment() {
when (fingers) { when (fingers) {
1 -> { 1 -> {
if (targetView.equals(binding.batteryProgress) == true) { if (targetView.equals(binding.batteryProgress) == true) {
startActivity(Intent(android.provider.Settings.ACTION_SETTINGS)) startActivity(Intent(android.provider.Settings.ACTION_SETTINGS))
}else if(targetView.equals(binding.functionLayer)) { }else if(targetView.equals(binding.functionLayer)) {
if (binding.otherCheck.isSelected) { if (binding.otherCheck.isSelected) {
searchData() searchData()

View File

@ -83,9 +83,6 @@ internal class RssItemAdapter (
} else { } else {
if (RssDataType.REDDIT_NSFW.equals(rss.category())) { if (RssDataType.REDDIT_NSFW.equals(rss.category())) {
openReddit(rss.originPage()) openReddit(rss.originPage())
// RssViewer().apply {
// show(lActivity!!.supportFragmentManager,rss.originPage)
// }
} else { } else {
// RssViewer().apply { // RssViewer().apply {
// show(lActivity!!.supportFragmentManager,rss.originPage) // show(lActivity!!.supportFragmentManager,rss.originPage)
@ -102,16 +99,12 @@ internal class RssItemAdapter (
} }
} }
RssDataType.REDDIT -> { RssDataType.REDDIT -> {
RssViewer().apply { AwesomeWebView.Builder(lActivity!!)
show(lActivity!!.supportFragmentManager,rss.originPage) .showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0)
} .show(rss.originPage!!)
// openReddit(rss.originPage())
} }
RssDataType.DOTAX -> { RssDataType.DOTAX -> {
AwesomeWebView.Builder(lActivity!!) AwesomeWebView.Builder(lActivity!!)
// .setWebViewListener(webViewListener).addCustomMenu(
// CustomMenu("PDF 저장","PDF")
// ).
.showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0) .showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0)
.show(rss.originPage!!) .show(rss.originPage!!)
} }
@ -119,12 +112,8 @@ internal class RssItemAdapter (
} }
else -> { else -> {
AwesomeWebView.Builder(lActivity!!) AwesomeWebView.Builder(lActivity!!)
// .setWebViewListener(webViewListener).addCustomMenu(
// CustomMenu("PDF 저장","PDF")
// ).
.showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0) .showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0)
.show(rss.originPage!!) .show(rss.originPage!!)
// openNews(rss.originPage())
} }
} }
} }

View File

@ -49,6 +49,7 @@ enum class RssDataType {
block.invoke() block.invoke()
} }
} }
} }
interface RssDataInterface { interface RssDataInterface {

View File

@ -278,7 +278,8 @@ class Data : RssDataInterface {
} else RssDataType.REDDIT } else RssDataType.REDDIT
} }
override fun getCho(): String? { override fun getCho(): String? {
return JamoUtils.split(title!!).joinToString("") val realChoSung = JamoUtils.split(title!!).joinToString("").trim()
return if(realChoSung.length > 0 ) realChoSung else title
} }
} }

View File

@ -2,6 +2,7 @@ package bums.lunatic.launcher.workers
import bums.lunatic.launcher.BuildConfig import bums.lunatic.launcher.BuildConfig
import bums.lunatic.launcher.apps.SimpleContact import bums.lunatic.launcher.apps.SimpleContact
import bums.lunatic.launcher.helpers.letTrue
import bums.lunatic.launcher.model.AppInfo import bums.lunatic.launcher.model.AppInfo
import bums.lunatic.launcher.model.Astro import bums.lunatic.launcher.model.Astro
import bums.lunatic.launcher.model.BotCommandEentitie import bums.lunatic.launcher.model.BotCommandEentitie
@ -17,6 +18,7 @@ import bums.lunatic.launcher.model.LocationLog
import bums.lunatic.launcher.model.NotificationItem import bums.lunatic.launcher.model.NotificationItem
import bums.lunatic.launcher.model.RssData import bums.lunatic.launcher.model.RssData
import bums.lunatic.launcher.model.RssDataInterface import bums.lunatic.launcher.model.RssDataInterface
import bums.lunatic.launcher.model.RssDataType
import bums.lunatic.launcher.model.TelegramBotUpdate import bums.lunatic.launcher.model.TelegramBotUpdate
import bums.lunatic.launcher.model.TelegramChat import bums.lunatic.launcher.model.TelegramChat
import bums.lunatic.launcher.model.TelegramData import bums.lunatic.launcher.model.TelegramData
@ -24,14 +26,20 @@ import bums.lunatic.launcher.model.TelegramFrom
import bums.lunatic.launcher.model.TelegramMessage import bums.lunatic.launcher.model.TelegramMessage
import bums.lunatic.launcher.model.WeatherForcast import bums.lunatic.launcher.model.WeatherForcast
import bums.lunatic.launcher.utils.BLog import bums.lunatic.launcher.utils.BLog
import bums.lunatic.launcher.utils.JamoUtils
import bums.lunatic.launcher.utils.beforeDay
import io.realm.kotlin.Realm import io.realm.kotlin.Realm
import io.realm.kotlin.RealmConfiguration import io.realm.kotlin.RealmConfiguration
import io.realm.kotlin.UpdatePolicy import io.realm.kotlin.UpdatePolicy
import io.realm.kotlin.dynamic.getValue import io.realm.kotlin.dynamic.getValue
import io.realm.kotlin.ext.query import io.realm.kotlin.ext.query
import io.realm.kotlin.migration.AutomaticSchemaMigration import io.realm.kotlin.migration.AutomaticSchemaMigration
import io.realm.kotlin.query.RealmQuery
import io.realm.kotlin.types.BaseRealmObject import io.realm.kotlin.types.BaseRealmObject
import io.realm.kotlin.types.TypedRealmObject import io.realm.kotlin.types.TypedRealmObject
import java.util.Date
import java.util.Locale
import java.util.regex.Pattern
import kotlin.reflect.KClass import kotlin.reflect.KClass
class CustMigration : AutomaticSchemaMigration { class CustMigration : AutomaticSchemaMigration {
@ -86,8 +94,11 @@ object WorkersDb {
try { try {
getRealm().writeBlocking { getRealm().writeBlocking {
try { try {
if(query<RssData>("chosung == $0",it.chosung).find().size == 0) { val catfillters = arrayListOf<RssDataType>(RssDataType.NEWSFEED,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) this.copyToRealm(it, UpdatePolicy.ERROR)
} else {
this.copyToRealm(it, UpdatePolicy.ALL)
} }
} catch (e : Exception) { } catch (e : Exception) {
@ -184,4 +195,42 @@ object WorkersDb {
} }
} }
fun getVotedRss() = getRealm().query<RssData>().query("vote == $0", true)
fun getRssQuery(keyword: String?,
category: ArrayList<String> = arrayListOf(),
noLimit: Boolean = false) : RealmQuery<RssData>{
var rQ = getRealm().query<RssData>()
if (!noLimit) rQ.query("pubDate > $0", beforeDay(Date(), 3))
keyword?.isNotEmpty()?.letTrue {
if (JamoUtils.CHOSUNG.contains(keyword.split("")[0])) {
rQ = rQ.query("title CONTAINS $0 OR chosung CONTAINS $1 ", keyword, keyword)
} else if (Pattern.matches("^[가-힣]*\$", keyword)) {
rQ = rQ.query("title CONTAINS $0", keyword)
} else {
rQ = rQ.query(
"title CONTAINS $0 OR title CONTAINS $1",
keyword.uppercase(Locale.getDefault()),
keyword.lowercase(Locale.getDefault())
)
}
}
var queryString = ""
category.isNotEmpty().letTrue {
category.forEachIndexed { idx, it ->
if (idx == 0) {
queryString = queryString.plus("category == '${it}'")
} else {
queryString = queryString.plus(" OR category == '${it}' ")
}
}
rQ = rQ.query(queryString)
}
if (keyword?.length ?: 0 == 0 && category.size == 0) {
rQ = rQ.query("read < $0", 3).query("vote != $0", true)
}
return rQ
}
} }

View File

@ -140,8 +140,9 @@
<include <include
android:layout_margin="@dimen/default_layout_margin" android:layout_margin="@dimen/default_layout_margin"
android:id="@+id/noticeSummary" android:id="@+id/weathers"
layout="@layout/weather_book" layout="@layout/weather_book"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/current_music" app:layout_constraintTop_toBottomOf="@id/current_music"
@ -159,7 +160,7 @@
android:orientation="horizontal" android:orientation="horizontal"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
android:layout_height="40dp" android:layout_height="40dp"
app:layout_constraintTop_toBottomOf="@+id/noticeSummary" app:layout_constraintTop_toBottomOf="@+id/weathers"
> >
<TextView <TextView

View File

@ -15,11 +15,11 @@
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:id="@+id/imageView" android:id="@+id/imageView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="0dp" android:layout_height="0dp"
android:contentDescription="시계 아이콘" android:contentDescription="시계 아이콘"
app:srcCompat="@drawable/ico_time" app:srcCompat="@drawable/ico_time"
tools:ignore="ImageContrastCheck" tools:ignore="ImageContrastCheck"
android:layout_marginStart="@dimen/default_layout_margin"
app:tint="@android:color/white" app:tint="@android:color/white"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="@id/textView2" app:layout_constraintBottom_toBottomOf="@id/textView2"
@ -29,17 +29,16 @@
android:id="@+id/textView2" android:id="@+id/textView2"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_layout_margin" android:layout_marginLeft="@dimen/default_layout_margin"
android:fontFamily="sans-serif-medium" android:fontFamily="sans-serif-medium"
android:gravity="left|center_vertical" android:gravity="left|center_vertical"
android:text="시간별 예보" android:text="시간별 예보"
style="@style/normal" style="@style/normal"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="@dimen/_14sp" android:textSize="@dimen/_14sp"
app:layout_constraintBottom_toBottomOf="@id/imageView" app:layout_constraintRight_toLeftOf="@id/textViewLocation"
app:layout_constraintEnd_toStartOf="@id/textViewLocation" app:layout_constraintLeft_toRightOf="@id/imageView"
app:layout_constraintStart_toEndOf="@id/imageView" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="@id/imageView" />
<TextView <TextView
android:id="@+id/textViewLocation" android:id="@+id/textViewLocation"
@ -51,15 +50,14 @@
android:gravity="center_vertical|right" android:gravity="center_vertical|right"
android:textSize="@dimen/_12sp" android:textSize="@dimen/_12sp"
style="@style/normal" style="@style/normal"
android:layout_marginEnd="@dimen/default_layout_margin" android:layout_marginRight="@dimen/default_layout_margin"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/imageView" app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintBottom_toBottomOf="@id/imageView"/>
<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="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/imageView" /> app:layout_constraintTop_toBottomOf="@+id/textView2" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</layout> </layout>

View File

@ -35,6 +35,7 @@ import android.webkit.CookieSyncManager
import android.webkit.DownloadListener import android.webkit.DownloadListener
import android.webkit.GeolocationPermissions import android.webkit.GeolocationPermissions
import android.webkit.PermissionRequest import android.webkit.PermissionRequest
import android.webkit.URLUtil
import android.webkit.ValueCallback import android.webkit.ValueCallback
import android.webkit.WebChromeClient import android.webkit.WebChromeClient
import android.webkit.WebResourceRequest import android.webkit.WebResourceRequest
@ -86,6 +87,7 @@ import kr.lunaticbum.utils.ui.ViewUtil
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
import java.net.URL
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Date import java.util.Date
import kotlin.math.abs import kotlin.math.abs
@ -1268,10 +1270,14 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
CommonJsHelper.getInstance().addJavascriptInterface(webView) CommonJsHelper.getInstance().addJavascriptInterface(webView)
} }
var host : String? = ""
protected fun load() { protected fun load() {
if (data != null) { if (data != null) {
webView!!.loadData(data!!, mimeType, encoding) webView!!.loadData(data!!, mimeType, encoding)
} else if (url != null) { } else if (url != null) {
// host = url!!.toUri().host?.replace("www.","")?.replace("m.","")
LogUtil.e("url!!.toUri(). >> ${url!!.toUri().authority}")
LogUtil.e("url!!.toUri(). >> ${url!!.toUri().encodedFragment}")
if (extraHeaders == null) { if (extraHeaders == null) {
webView!!.loadUrl(url!!) webView!!.loadUrl(url!!)
} else { } else {
@ -1861,57 +1867,61 @@ LogUtil.e("onBackPressed ${webChromeClient} && ${binding.menus.menuLayout.visibi
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean { override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
handler.sendEmptyMessage(MSG_CLICK_ON_URL) handler.sendEmptyMessage(MSG_CLICK_ON_URL)
LogUtil.e("host >>> ${host} , url >>> ${url}")
if (url.endsWith(".mp4")) { // if (host?.length ?: 0 > 2 && url.contains(host!!)) {
val intent = Intent(Intent.ACTION_VIEW) if (url.endsWith(".mp4")) {
intent.setDataAndType(Uri.parse(url), "video/*") val intent = Intent(Intent.ACTION_VIEW)
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent.setDataAndType(Uri.parse(url), "video/*")
view.context.startActivity(intent) intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
// If we return true, onPageStarted, onPageFinished won't be called. view.context.startActivity(intent)
return true // If we return true, onPageStarted, onPageFinished won't be called.
} else if (url.startsWith("tel:") || url.startsWith("sms:") || url.startsWith("smsto:") || url
.startsWith("mms:") || url.startsWith("mmsto:")
) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
view.context.startActivity(intent)
return true // If we return true, onPageStarted, onPageFinished won't be called.
} else if (url.startsWith("mailto:")) {
val mt = MailTo.parse(url)
val emailIntent = Intent(Intent.ACTION_SEND)
emailIntent.setType("text/html")
emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf(mt.to))
emailIntent.putExtra(Intent.EXTRA_SUBJECT, mt.subject)
emailIntent.putExtra(Intent.EXTRA_CC, mt.cc)
emailIntent.putExtra(Intent.EXTRA_TEXT, mt.body)
startActivity(emailIntent)
return true
} else if (url.startsWith("http") || url.startsWith("https") || url.startsWith("ftp")) {
if (extraHeaders == null || extraHeadersMainPage!! && url != this@AwesomeWebViewActivity.url) {
return super.shouldOverrideUrlLoading(view, url)
} else {
view.loadUrl(url, extraHeaders!!)
return true return true
} } else if (url.startsWith("tel:") || url.startsWith("sms:") || url.startsWith("smsto:") || url
} else { .startsWith("mms:") || url.startsWith("mmsto:")
if (webViewAppJumpEnabled!!) { ) {
try { val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) view.context.startActivity(intent)
view.context.startActivity(intent) return true // If we return true, onPageStarted, onPageFinished won't be called.
return true // If we return true, onPageStarted, onPageFinished won't be called. } else if (url.startsWith("mailto:")) {
} catch (exception: Exception) { val mt = MailTo.parse(url)
exception.printStackTrace()
val emailIntent = Intent(Intent.ACTION_SEND)
emailIntent.setType("text/html")
emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf(mt.to))
emailIntent.putExtra(Intent.EXTRA_SUBJECT, mt.subject)
emailIntent.putExtra(Intent.EXTRA_CC, mt.cc)
emailIntent.putExtra(Intent.EXTRA_TEXT, mt.body)
startActivity(emailIntent)
return true
} else if (url.startsWith("http") || url.startsWith("https") || url.startsWith("ftp")) {
if (extraHeaders == null || extraHeadersMainPage!! && url != this@AwesomeWebViewActivity.url) {
return super.shouldOverrideUrlLoading(view, url)
} else {
view.loadUrl(url, extraHeaders!!)
return true return true
} }
} else { } else {
return super.shouldOverrideUrlLoading(view, url) if (webViewAppJumpEnabled!!) {
try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
view.context.startActivity(intent)
return true // If we return true, onPageStarted, onPageFinished won't be called.
} catch (exception: Exception) {
exception.printStackTrace()
return true
}
} else {
return super.shouldOverrideUrlLoading(view, url)
}
} }
} // } else {
// return true
// }
} }
override fun onLoadResource(view: WebView, url: String) { override fun onLoadResource(view: WebView, url: String) {