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) {
switchAppDrawer()
} else {
}
} else {
intent?.extras?.keySet()?.forEach {
@ -666,7 +668,7 @@ internal class LauncherActivity : AppCompatActivity() {
} else if (binding.appDrawer.visibility == View.VISIBLE) {
switchAppDrawer()
} else if (binding.home.visibility == View.VISIBLE) {
switchAppDrawer()
// switchAppDrawer()
}
}
})

View File

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

View File

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

View File

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

View File

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

View File

@ -278,7 +278,8 @@ class Data : RssDataInterface {
} else RssDataType.REDDIT
}
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.apps.SimpleContact
import bums.lunatic.launcher.helpers.letTrue
import bums.lunatic.launcher.model.AppInfo
import bums.lunatic.launcher.model.Astro
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.RssData
import bums.lunatic.launcher.model.RssDataInterface
import bums.lunatic.launcher.model.RssDataType
import bums.lunatic.launcher.model.TelegramBotUpdate
import bums.lunatic.launcher.model.TelegramChat
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.WeatherForcast
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.RealmConfiguration
import io.realm.kotlin.UpdatePolicy
import io.realm.kotlin.dynamic.getValue
import io.realm.kotlin.ext.query
import io.realm.kotlin.migration.AutomaticSchemaMigration
import io.realm.kotlin.query.RealmQuery
import io.realm.kotlin.types.BaseRealmObject
import io.realm.kotlin.types.TypedRealmObject
import java.util.Date
import java.util.Locale
import java.util.regex.Pattern
import kotlin.reflect.KClass
class CustMigration : AutomaticSchemaMigration {
@ -86,8 +94,11 @@ object WorkersDb {
try {
getRealm().writeBlocking {
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)
} else {
this.copyToRealm(it, UpdatePolicy.ALL)
}
} 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
android:layout_margin="@dimen/default_layout_margin"
android:id="@+id/noticeSummary"
android:id="@+id/weathers"
layout="@layout/weather_book"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/current_music"
@ -159,7 +160,7 @@
android:orientation="horizontal"
app:layout_constraintRight_toRightOf="parent"
android:layout_height="40dp"
app:layout_constraintTop_toBottomOf="@+id/noticeSummary"
app:layout_constraintTop_toBottomOf="@+id/weathers"
>
<TextView

View File

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

View File

@ -35,6 +35,7 @@ import android.webkit.CookieSyncManager
import android.webkit.DownloadListener
import android.webkit.GeolocationPermissions
import android.webkit.PermissionRequest
import android.webkit.URLUtil
import android.webkit.ValueCallback
import android.webkit.WebChromeClient
import android.webkit.WebResourceRequest
@ -86,6 +87,7 @@ import kr.lunaticbum.utils.ui.ViewUtil
import java.io.ByteArrayInputStream
import java.io.File
import java.io.IOException
import java.net.URL
import java.text.SimpleDateFormat
import java.util.Date
import kotlin.math.abs
@ -1268,10 +1270,14 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
CommonJsHelper.getInstance().addJavascriptInterface(webView)
}
var host : String? = ""
protected fun load() {
if (data != null) {
webView!!.loadData(data!!, mimeType, encoding)
} 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) {
webView!!.loadUrl(url!!)
} else {
@ -1861,57 +1867,61 @@ LogUtil.e("onBackPressed ${webChromeClient} && ${binding.menus.menuLayout.visibi
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
handler.sendEmptyMessage(MSG_CLICK_ON_URL)
if (url.endsWith(".mp4")) {
val intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(Uri.parse(url), "video/*")
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
view.context.startActivity(intent)
// If we return true, onPageStarted, onPageFinished won't be called.
return true
} 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!!)
LogUtil.e("host >>> ${host} , url >>> ${url}")
// if (host?.length ?: 0 > 2 && url.contains(host!!)) {
if (url.endsWith(".mp4")) {
val intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(Uri.parse(url), "video/*")
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
view.context.startActivity(intent)
// If we return true, onPageStarted, onPageFinished won't be called.
return true
}
} else {
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()
} 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
}
} 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) {