diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f97b9142..9dbd33df 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -89,7 +89,7 @@ dependencies { implementation ("androidx.core:core-splashscreen:1.0.1") implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7") implementation ("com.google.android.material:material:1.12.0") - + implementation ("com.ibm.icu:icu4j:68.1") implementation (kotlin("stdlib", version = kotlinVersion)) implementation ("com.github.cachapa:ExpandableLayout:2.9.2") implementation ("com.squareup.picasso:picasso:2.71828") diff --git a/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt b/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt index fc74664b..5422170b 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt @@ -45,6 +45,7 @@ import android.telephony.TelephonyManager import android.view.KeyEvent import android.view.KeyEvent.ACTION_UP import android.view.KeyEvent.KEYCODE_BUTTON_A +import android.view.KeyEvent.KEYCODE_BUTTON_B import android.view.KeyEvent.KEYCODE_BUTTON_SELECT import android.view.KeyEvent.KEYCODE_BUTTON_START import android.view.KeyEvent.KEYCODE_BUTTON_X @@ -143,7 +144,6 @@ internal class LauncherActivity : CommonActivity() { companion object { private var mWorkManager: WorkManager? = null - var isOpendFold = false val qDayPeriod = 60L * 8L @@ -152,37 +152,30 @@ internal class LauncherActivity : CommonActivity() { @JvmStatic var appWidgetHost: WidgetHost? = null fun refreshDeviceData() { - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(SMS_WORK_TAG) - mWorkManager?.enqueueUniquePeriodicWork( - SMS_WORK_TAG, - ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.longTimePeriod.get(), TimeUnit.MINUTES) - .addTag(SMS_WORK_TAG) - .build()) - }, 500, TimeUnit.MILLISECONDS) - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(RecentCallGetter.TAG) - mWorkManager?.enqueueUniquePeriodicWork( - RecentCallGetter.TAG, - ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.longTimePeriod.get(), TimeUnit.MINUTES) - .addTag(RecentCallGetter.TAG) - .build()) - }, 500, TimeUnit.MILLISECONDS) - var delay = 3L - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(ContactInfoGetter.TAG) - mWorkManager?.enqueueUniquePeriodicWork( - ContactInfoGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(12, TimeUnit.HOURS) - .addTag(ContactInfoGetter.TAG) - .build()) - }, delay, TimeUnit.SECONDS) - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.enqueue(OneTimeWorkRequest.from(AppInfoGetter::class.java)) - }, 5, TimeUnit.SECONDS) + mWorkManager?.cancelAllWorkByTag(SMS_WORK_TAG) + mWorkManager?.enqueueUniquePeriodicWork( + SMS_WORK_TAG, + ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.longTimePeriod.get(), TimeUnit.MINUTES) + .addTag(SMS_WORK_TAG) + .build()) + mWorkManager?.cancelAllWorkByTag(RecentCallGetter.TAG) + mWorkManager?.enqueueUniquePeriodicWork( + RecentCallGetter.TAG, + ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.longTimePeriod.get(), TimeUnit.MINUTES) + .addTag(RecentCallGetter.TAG) + .build()) + + mWorkManager?.cancelAllWorkByTag(ContactInfoGetter.TAG) + mWorkManager?.enqueueUniquePeriodicWork( + ContactInfoGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(12, TimeUnit.HOURS) + .addTag(ContactInfoGetter.TAG) + .build()) + + mWorkManager?.enqueue(OneTimeWorkRequest.from(AppInfoGetter::class.java)) } @@ -201,109 +194,75 @@ internal class LauncherActivity : CommonActivity() { val defaultDelay = 10L fun refreshFeeds() { - var delay = defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(FEDDS_WORK_TAG) - mWorkManager?.enqueueUniquePeriodicWork( - FEDDS_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.shortTimePeriod.get(), TimeUnit.MINUTES) - .addTag(FEDDS_WORK_TAG) - .build()) - }, delay, TimeUnit.SECONDS) - delay += defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(YT_WORK_TAG) - mWorkManager?.enqueueUniquePeriodicWork( - YT_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.longTimePeriod.get(), TimeUnit.MINUTES) - .addTag(YT_WORK_TAG) - .build()) - }, delay, TimeUnit.SECONDS) - delay += defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(REDDIT_WORK_TAG) - mWorkManager?.enqueueUniquePeriodicWork( - REDDIT_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) - .addTag(REDDIT_WORK_TAG) - .build()) - }, delay, TimeUnit.SECONDS) - delay += defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG) - mWorkManager?.enqueueUniquePeriodicWork( - COMIC_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) - .addTag(COMIC_WORK_TAG) - .build()) - }, delay, TimeUnit.SECONDS) - delay += defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG) - mWorkManager?.enqueueUniquePeriodicWork( - COMIC2_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) - .addTag(COMIC2_WORK_TAG) - .build()) - }, delay, TimeUnit.SECONDS) - delay += defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(ClienGetter.TAG) - mWorkManager?.enqueueUniquePeriodicWork( - ClienGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) - .addTag(ClienGetter.TAG) - .build()) - }, delay, TimeUnit.SECONDS) - delay += defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(DCGetter.TAG) - mWorkManager?.enqueueUniquePeriodicWork( - DCGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) - .addTag(DCGetter.TAG) - .build()) - }, delay, TimeUnit.SECONDS) - delay += defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(RuliWebGetter.TAG) - mWorkManager?.enqueueUniquePeriodicWork( - RuliWebGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) - .addTag(RuliWebGetter.TAG) - .build()) - }, delay, TimeUnit.SECONDS) - delay += defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(TheQooGetter.TAG) - mWorkManager?.enqueueUniquePeriodicWork( - TheQooGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) - .addTag(TheQooGetter.TAG) - .build()) - }, delay, TimeUnit.SECONDS) - delay += defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(ArcaGetter.TAG) - mWorkManager?.enqueueUniquePeriodicWork( - ArcaGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) - .addTag(ArcaGetter.TAG) - .build()) + mWorkManager?.cancelAllWork() + mWorkManager?.cancelAllWorkByTag(RuliWebGetter.TAG) + mWorkManager?.enqueueUniquePeriodicWork( + RuliWebGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) + .addTag(RuliWebGetter.TAG) + .build()) - }, delay, TimeUnit.SECONDS) - - delay += defaultDelay - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager?.cancelAllWorkByTag(LocationGetter.TAG) - mWorkManager?.enqueueUniquePeriodicWork( - LocationGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(PrefLong.locationTimePeriod.get(), TimeUnit.MINUTES) - .addTag(LocationGetter.TAG) - .build()) - - }, delay, TimeUnit.SECONDS) + mWorkManager?.cancelAllWorkByTag(FEDDS_WORK_TAG) + mWorkManager?.enqueueUniquePeriodicWork( + FEDDS_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.shortTimePeriod.get(), TimeUnit.MINUTES) + .addTag(FEDDS_WORK_TAG) + .build()) + mWorkManager?.cancelAllWorkByTag(YT_WORK_TAG) + mWorkManager?.enqueueUniquePeriodicWork( + YT_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.longTimePeriod.get(), TimeUnit.MINUTES) + .addTag(YT_WORK_TAG) + .build()) + mWorkManager?.cancelAllWorkByTag(REDDIT_WORK_TAG) + mWorkManager?.enqueueUniquePeriodicWork( + REDDIT_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) + .addTag(REDDIT_WORK_TAG) + .build()) + mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG) + mWorkManager?.enqueueUniquePeriodicWork( + COMIC_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) + .addTag(COMIC_WORK_TAG) + .build()) + mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG) + mWorkManager?.enqueueUniquePeriodicWork( + COMIC2_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) + .addTag(COMIC2_WORK_TAG) + .build()) + mWorkManager?.cancelAllWorkByTag(ClienGetter.TAG) + mWorkManager?.enqueueUniquePeriodicWork( + ClienGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) + .addTag(ClienGetter.TAG) + .build()) + mWorkManager?.cancelAllWorkByTag(DCGetter.TAG) + mWorkManager?.enqueueUniquePeriodicWork( + DCGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) + .addTag(DCGetter.TAG) + .build()) + mWorkManager?.cancelAllWorkByTag(TheQooGetter.TAG) + mWorkManager?.enqueueUniquePeriodicWork( + TheQooGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) + .addTag(TheQooGetter.TAG) + .build()) + mWorkManager?.cancelAllWorkByTag(ArcaGetter.TAG) + mWorkManager?.enqueueUniquePeriodicWork( + ArcaGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.midTimePeriod.get(), TimeUnit.MINUTES) + .addTag(ArcaGetter.TAG) + .build()) + mWorkManager?.cancelAllWorkByTag(LocationGetter.TAG) + mWorkManager?.enqueueUniquePeriodicWork( + LocationGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(PrefLong.locationTimePeriod.get(), TimeUnit.MINUTES) + .addTag(LocationGetter.TAG) + .build()) } @@ -375,6 +334,13 @@ internal class LauncherActivity : CommonActivity() { } } } + KEYCODE_BUTTON_B->{ + RssViewBuilder(lActivity!!) + .setRssId("https://jav.guru") + .webViewJavaScriptEnabled(true) + .showIconClose(true).showIconBack(false).showProgressBar(true).backPressToClose(false).webViewMixedContentMode(1) + .show("https://jav.guru") + } KEYCODE_DPAD_DOWN->{ } @@ -382,7 +348,7 @@ internal class LauncherActivity : CommonActivity() { } KEYCODE_BUTTON_START->{ - onClickCenterButton() + onClickCenterButton() } KEYCODE_BUTTON_SELECT->{ WorkersDb.getRealm().apply { @@ -417,12 +383,13 @@ internal class LauncherActivity : CommonActivity() { writeBlocking { var ddd = copyFromRealm(WorkersDb.getRssQuery("", RssDataType.getExcAdt(),false).limit(100).query("read == $0", 0).query("vote != $0", true).find()).map { it.originPage() } var origin = ddd.first() + var jjjj = hashSetOf() + jjjj.addAll(ddd) RssViewBuilder(lActivity!!) .setRssList(arrayListOf().apply { - var jjjj = hashSetOf() - jjjj.addAll(ddd) - this.addAll(jjjj) }) + this.addAll(jjjj)}) .setRssId(origin) +// .webViewDesktopMode(true) .showIconClose(true).showIconBack(false).showProgressBar(true).backPressToClose(false).webViewMixedContentMode(1) .show(origin) } @@ -574,6 +541,7 @@ internal class LauncherActivity : CommonActivity() { @SuppressLint("NewApi", "MissingPermission") override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() + mWorkManager = WorkManager.getInstance(this) DynamicColors.applyToActivityIfAvailable(this) lActivity = this diff --git a/app/src/main/kotlin/bums/lunatic/launcher/apps/AppDrawer.kt b/app/src/main/kotlin/bums/lunatic/launcher/apps/AppDrawer.kt index ca54da32..d79685fe 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/apps/AppDrawer.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/apps/AppDrawer.kt @@ -35,6 +35,7 @@ import android.view.inputmethod.InputMethodManager import androidx.core.widget.doOnTextChanged import androidx.recyclerview.widget.GridLayoutManager import bums.lunatic.launcher.BuildConfig +import bums.lunatic.launcher.LauncherActivity import bums.lunatic.launcher.common.CommonActivity import bums.lunatic.launcher.common.letTrue import bums.lunatic.launcher.databinding.AppDrawerBinding @@ -66,7 +67,7 @@ internal class AppDrawer : CommonActivity() { private var isKeyboardShowing: Boolean = false companion object { - lateinit var packageManager: PackageManager + private var appsAdapter: AppsAdapter? = null private var contactAdapter : ContactAdapter? = null private var packageList = mutableListOf() @@ -74,34 +75,14 @@ internal class AppDrawer : CommonActivity() { @JvmStatic var appNamesPrefs: SharedPreferences? = null - fun appName(resolver: ResolveInfo): String { - return resolver.loadLabel(packageManager).toString().apply { - appNamesPrefs?.edit()?.putString(resolver.activityInfo.packageName, this)?.apply() - } - } - fun getCategory(category : Int) : String { - return when(category) { - ApplicationInfo.CATEGORY_UNDEFINED -> "UNDEFINED" - ApplicationInfo.CATEGORY_GAME -> "GAME" - ApplicationInfo.CATEGORY_AUDIO -> "AUDIO" - ApplicationInfo.CATEGORY_VIDEO -> "VIDEO" - ApplicationInfo.CATEGORY_IMAGE -> "IMAGE" - ApplicationInfo.CATEGORY_SOCIAL -> "SOCIAL" - ApplicationInfo.CATEGORY_NEWS -> "NEWS" - ApplicationInfo.CATEGORY_MAPS -> "MAPS" - ApplicationInfo.CATEGORY_PRODUCTIVITY -> "PRODUCTIVITY" - ApplicationInfo.CATEGORY_ACCESSIBILITY -> "ACCESSIBILITY" - else -> {"UNKNOWN"} - } - } } fun getInputText() = binding.searchInput.text.toString() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // setStyle(STYLE_NO_TITLE, R.style.FilterFullScreenDialog) -// packageManager = lActivity?.packageManager!! +// packageManager // } // override fun onAttach(context: Context) { @@ -118,7 +99,7 @@ internal class AppDrawer : CommonActivity() { appNamesPrefs = this.getSharedPreferences(PREFS_APP_NAMES, 0) layoutType = settingsPrefs!!.getInt(KEY_APPS_LAYOUT, 0) - appsAdapter = AppsAdapter(layoutType, packageManager!!, supportFragmentManager, binding.appsCount) + appsAdapter = AppsAdapter(packageManager!!, supportFragmentManager, binding.appsCount) contactAdapter = ContactAdapter(packageManager!!, supportFragmentManager) binding.appsCount.visibility = if (settingsPrefs!!.getBoolean(KEY_APPS_COUNT, true)) VISIBLE else GONE @@ -496,9 +477,3 @@ internal class AppDrawer : CommonActivity() { } -fun normalize(str: String): String { - val normalizedString = - Normalizer.normalize(str.replace("\\W".toRegex(), ""), Normalizer.Form.NFC) - val pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+") - return pattern.matcher(normalizedString).replaceAll("").toLowerCase() -} \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/apps/AppsAdapter.kt b/app/src/main/kotlin/bums/lunatic/launcher/apps/AppsAdapter.kt index e732d6f8..2a4a8dff 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/apps/AppsAdapter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/apps/AppsAdapter.kt @@ -41,10 +41,9 @@ import kotlinx.coroutines.async internal class AppsAdapter( - private val layoutType: Int, private val packageManager: PackageManager, private val fragmentManager: FragmentManager, - private val appsCount: TextView) : RecyclerView.Adapter() { + private val appsCount: TextView?) : RecyclerView.Adapter() { private var oldList = mutableListOf() // private var appGravity: Int = Gravity.CENTER @@ -125,7 +124,7 @@ internal class AppsAdapter( oldList.clear() oldList.addAll(newList) newList.size.let { - appsCount.text = it.toString() + appsCount?.text = it.toString() appsSize = it } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/helpers/BluetoothManager.kt b/app/src/main/kotlin/bums/lunatic/launcher/helpers/BluetoothManager.kt index f0fd5ca1..5afd84ee 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/helpers/BluetoothManager.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/helpers/BluetoothManager.kt @@ -134,7 +134,7 @@ class BluetoothManager { //블루투스 상태(켜짐 / 꺼짐 / 지원 불가 기기) fun blueToothState(): String { if (blueToothAdapter != null) { - if (blueToothAdapter!!.isEnabled) { + if (blueToothAdapter?.isEnabled == true) { return BLUETOOTH_STATE.ENABLED.statestr } else { return BLUETOOTH_STATE.DISABLED.statestr @@ -167,7 +167,6 @@ class BluetoothManager { val action = intent!!.action if (context == null) return if (ActivityCompat.checkSelfPermission(context!!, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) return - val device: BluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)!! getPairedDevices() } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/helpers/PrefHelper.kt b/app/src/main/kotlin/bums/lunatic/launcher/helpers/PrefHelper.kt index 2ab27b9f..1eb63ccf 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/helpers/PrefHelper.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/helpers/PrefHelper.kt @@ -2,6 +2,7 @@ package bums.lunatic.launcher.helpers import android.content.SharedPreferences import bums.lunatic.launcher.model.RssDataType +import bums.lunatic.launcher.utils.Blog import kr.lunaticbum.utils.preferences.PrefJsonConvert import kr.lunaticbum.utils.preferences.PrefKey import kr.lunaticbum.utils.preferences.PreferencesHelper @@ -30,7 +31,13 @@ enum class PrefLong(val def : Long) : PrefKey { midTimePeriod(30L), maxQueryCount(18L); override fun set(value : Long) { PrefHelper.putLong(this.name, value) } - override fun get(def : Long?) : Long = PrefHelper.getLong(this.name, def as? Long ?: this.def) ?: 0L + override fun get(def : Long?) : Long { + val value = PrefHelper.getLong(this.name, def ?: this.def) ?: this.def + +// Blog.LOGE("$name : $value") + + return value + } override fun getKey() = this.name } @@ -97,7 +104,7 @@ object PrefHelper : PreferencesHelper() { fun getBoolean(key: String, def: Boolean) = get(getBooleanPrefix().plus(key), def) fun putBoolean(key: String, value: Boolean) = put(getBooleanPrefix().plus(key), value) fun getLong(key: String, def: Long) = get(getLongPrefix().plus(key), def) - fun putLong(key: String, value: Long) = put(getBooleanPrefix().plus(key), value) + fun putLong(key: String, value: Long) = put(getLongPrefix().plus(key), value) fun getString(key: String, def: String) = get(getStringPrefix().plus(key), def) fun putString(key: String, value: String) = put(getStringPrefix().plus(key), value) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt index a97ba620..6132764a 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt @@ -53,6 +53,7 @@ import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 import bums.lunatic.launcher.LauncherActivity.Companion.lActivity import bums.lunatic.launcher.R +import bums.lunatic.launcher.apps.AppsAdapter import bums.lunatic.launcher.behavior.Behavior import bums.lunatic.launcher.common.letTrue import bums.lunatic.launcher.databinding.LauncherHomeBinding @@ -70,6 +71,7 @@ import bums.lunatic.launcher.home.adapters.SwipeToDeleteCallback import bums.lunatic.launcher.home.adapters.WeatherAdapter import bums.lunatic.launcher.home.adapters.WeatherDressAdatper import bums.lunatic.launcher.home.adapters.WeatherHourlyAdapter +import bums.lunatic.launcher.model.AppInfo import bums.lunatic.launcher.model.CurrentPlayItem import bums.lunatic.launcher.model.Hour import bums.lunatic.launcher.model.NotificationItem @@ -103,6 +105,8 @@ import io.realm.kotlin.query.Sort import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.cancellable +import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch import org.json.JSONArray import org.json.JSONObject @@ -158,6 +162,7 @@ internal class LauncherHome : Fragment() { lateinit var mSmsLogsAdapter: SmsLogsAdapter lateinit var mRssAdapter: RssItemAdapter lateinit var mNotiAdapter: NotificationItemAdapter + lateinit var mAppsAdapter: AppsAdapter var mWeatherAdapter: WeatherAdapter? = null var weatherDressAdapter: WeatherDressAdatper? = null var weatherHourlyAdapter: WeatherHourlyAdapter? = null @@ -182,6 +187,7 @@ internal class LauncherHome : Fragment() { mRecentCallsAdapter = RecentCallsAdapter(arrayListOf(), requireContext()) mSmsLogsAdapter = SmsLogsAdapter(arrayListOf(), requireContext()) mNotiAdapter = NotificationItemAdapter(requireContext()) + mAppsAdapter = AppsAdapter(requireContext().packageManager , fragManager, null) mRssAdapter = RssItemAdapter(requireContext()) weatherDressAdapter = WeatherDressAdatper(arrayListOf()) @@ -212,6 +218,7 @@ internal class LauncherHome : Fragment() { binding.smsList.adapter = mSmsLogsAdapter binding.infoList.adapter = mRssAdapter binding.notiList.adapter = mNotiAdapter + binding.appsList.adapter = mAppsAdapter binding.weathers.weatherViewPager.adapter = mWeatherAdapter binding.weathers.weatherViewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { @@ -224,31 +231,14 @@ internal class LauncherHome : Fragment() { }) -// binding.favAppsGroup.setOnLongClickListener { -// binding.otherCheck.isSelected = true -// queryVotes() -// true -// } -// binding.favAppsGroup.setOnClickListener { -// if (binding.otherCheck.isSelected) { -// searchData() -// } -//// else if (binding.otherCheck.isSelected) { -//// searchData() -//// } -//// else if (binding.otherCheck.isSelected) { -//// searchData() -//// } -//// else if (binding.otherCheck.isSelected) { -//// searchData() -//// } -//// else if (binding.otherCheck.isSelected) { -//// searchData() -//// } -// else { -// QuickAccess().show(fragManager, BOTTOM_SHEET_TAG) -// } -// } + binding.notice.setOnLongClickListener { + RssViewBuilder(lActivity!!) + .setRssId("https://jav.guru") + .webViewJavaScriptEnabled(true) + .showIconClose(true).showIconBack(false).showProgressBar(true).backPressToClose(false).webViewMixedContentMode(1) + .show("https://jav.guru") + true + } arrayListOf(binding.mainList,binding.smsList,binding.infoList,binding.notiList).forEach { try { @@ -264,10 +254,26 @@ internal class LauncherHome : Fragment() { queryInfos() queryNotice() queryWeather() + queryApps() setMusicFunction() return binding.root } + private fun queryApps() { + WorkersDb.getRealm().apply { + var newQ = query() + newQ.sort(Pair("clickCount", Sort.DESCENDING),Pair("lastUseDate",Sort.DESCENDING)).limit(30).find()?.let { + if(it.size > 0) { + WorkersDb.getRealm().apply { + var packageList = arrayListOf() + packageList.addAll(copyFromRealm(it)) + mAppsAdapter?.updateData(packageList) + } + } + } + } + } + fun setMusicFunction() { binding.currentMusic.setOnClickListener { lActivity?.apply { @@ -484,8 +490,8 @@ internal class LauncherHome : Fragment() { try { System.gc() } catch (e: Exception) { e.printStackTrace() } } fun beforeQuery() { - mRssDataResult = null clearJob(infosJob) + mRssDataResult = null WorkersDb.getRealm().writeBlocking { delete( query() @@ -498,24 +504,28 @@ internal class LauncherHome : Fragment() { fun updateQuery(q: RealmQuery) { mRssDataResult = q.sort("pubDate ", Sort.DESCENDING).limit(300).distinct("title").find() - infosJob = CoroutineScope(Dispatchers.Default).launch { - mRssDataResult?.asFlow()?.collect { changes: ResultsChange -> - commandHandler.removeCallbacks(hideListView) - commandHandler.removeCallbacks(infoUpdate) - when (changes) { - is InitialResults, is UpdatedResults -> { - WorkersDb.getRealm().apply { - lasted = copyFromRealm(changes.list) - } - commandHandler.postDelayed(infoUpdate, UPDATE_DELAY) + mRssDataResult?.asFlow()?.let { flow -> + infosJob = CoroutineScope(Dispatchers.IO).launch { + flow.collect { changes: ResultsChange -> + commandHandler.removeCallbacks(hideListView) + commandHandler.removeCallbacks(infoUpdate) +// when (changes) { +// is InitialResults, is UpdatedResults -> { + WorkersDb.getRealm().apply { + lasted = copyFromRealm(changes.list) } - else -> { + commandHandler.postDelayed(infoUpdate, UPDATE_DELAY) +// } - } +// else -> { + +// } +// } } } + infosJob?.start() } - infosJob?.start() + } @@ -589,8 +599,8 @@ 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,binding.appsList) + var chechboxs = arrayListOf(binding.missedCalls, binding.recentSms, binding.otherCheck, binding.notice, binding.favApps) chechboxs.remove(v) when (v) { binding.missedCalls -> { @@ -635,6 +645,15 @@ internal class LauncherHome : Fragment() { binding.notiList.visibility = View.VISIBLE } } + binding.favApps -> { + if (binding.favApps.isSelected) { + binding.favApps.isSelected = false + } else { + binding.favApps.isSelected = true + views.remove(binding.appsList) + binding.appsList.visibility = View.VISIBLE + } + } } chechboxs.forEach { it.isSelected = false } views.forEach { it.visibility = View.GONE } @@ -646,6 +665,7 @@ internal class LauncherHome : Fragment() { binding.recentSms.setOnClickListener(checkListner) binding.missedCalls.setOnClickListener(checkListner) binding.notice.setOnClickListener(checkListner) + binding.favApps.setOnClickListener(checkListner) binding.otherCheck.setOnLongClickListener { queryInfos() true @@ -740,6 +760,12 @@ internal class LauncherHome : Fragment() { fun chooseAdpater() { commandHandler.removeCallbacks(hideListView) + var tabs = arrayOf(binding.missedCalls,binding.recentSms,binding.otherCheck,binding.notice,binding.favApps) + fun unsel(view: View) { + tabs.filter { + it.equals(view) == false + }.forEach { it.isSelected = false } + } binding.mainList.visibility = View.INVISIBLE binding.smsList.visibility = View.INVISIBLE binding.infoList.visibility = View.INVISIBLE @@ -754,9 +780,6 @@ internal class LauncherHome : Fragment() { binding.missedCalls.text = "통화 목록 [${list.size}]" binding.mainList.visibility = View.VISIBLE mRecentCallsAdapter.updateData(list) - binding.recentSms.isSelected = false - binding.otherCheck.isSelected = false - binding.notice.isSelected = false } } else if (binding.recentSms.isSelected) { WorkersDb.getRealm().apply { @@ -768,28 +791,25 @@ internal class LauncherHome : Fragment() { binding.smsList.visibility = View.VISIBLE val list = copyFromRealm(result) mSmsLogsAdapter.updateData(list) - binding.missedCalls.isSelected = false - binding.otherCheck.isSelected = false - binding.notice.isSelected = false + } catch (e: Exception) { } } } } else if (binding.otherCheck.isSelected) { - binding.missedCalls.isSelected = false - binding.recentSms.isSelected = false - binding.notice.isSelected = false + unsel(binding.otherCheck) binding.infoList.visibility = View.VISIBLE - binding.otherCheck.text = "글타래 [${lasted?.size ?: "-"}]" +// binding.otherCheck.text = "글타래 [${lasted?.size ?: "-"}]" lasted?.let { mRssAdapter.updateData(it) } } else if (binding.notice.isSelected) { - binding.missedCalls.isSelected = false - binding.recentSms.isSelected = false - binding.otherCheck.isSelected = false + unsel(binding.notice) binding.notiList.visibility = View.VISIBLE - binding.notice.text = "알림 [${lastedNoti?.size ?: "-"}]" +// binding.notice.text = "알림 [${lastedNoti?.size ?: "-"}]" lastedNoti?.let { mNotiAdapter.updateData(it) } + } else if (binding.favApps.isSelected) { + unsel(binding.favApps) + binding.appsList.visibility = View.VISIBLE } commandHandler.postDelayed(hideListView, hideListViewTime) } @@ -810,16 +830,13 @@ internal class LauncherHome : Fragment() { } else { rss.read += nomoreShowCount } - copyToRealm(rss, UpdatePolicy.ALL) +// copyToRealm(rss, UpdatePolicy.ALL) + query("originPage == $0",rss.originPage).find().forEach { it -> + it.read += nomoreShowCount + } query("chosung == $0",rss.chosung).find().forEach { it -> if (!rss.originPage().equals(it.originPage())) { - if (rssStateVote() && rss.vote) { - it.vote = false - it.read = 0 - } else { - it.read += nomoreShowCount - } - copyToRealm(it, UpdatePolicy.ALL) + it.read += nomoreShowCount } } } @@ -831,11 +848,11 @@ internal class LauncherHome : Fragment() { rss.vote = true } - copyToRealm(rss,UpdatePolicy.ALL) +// copyToRealm(rss,UpdatePolicy.ALL) } else ->{} } - binding.infoList.post { mRssAdapter.refresh() } +// binding.infoList.post { mRssAdapter.refresh() } } } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/OfflineContents.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/OfflineContents.kt index 956d9562..cc350ae2 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/OfflineContents.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/OfflineContents.kt @@ -5,6 +5,7 @@ import android.content.Intent import android.os.Environment import android.webkit.CookieManager import androidx.core.content.FileProvider +import bums.lunatic.launcher.utils.CompressStringUtil import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay @@ -66,34 +67,38 @@ class OfflineContents(val context: Context, val host : String, val cookie: Strin fun enofLoop() { if (onItEndof) return onItEndof = true - LogUtil.e("on it enofLoop") - urlPathMap.forEach { t, u -> - val file = File(u) - var contentsUriString = FileProvider.getUriForFile( - context, - "${context.packageName}.fileprovider", - file - ).toString() + LogUtil.e("on it enofLoop before compressString ${htmlString.length}") - var targetString = t - var targetIdx = htmlString.indexOf(targetString) - if (targetIdx > 0) { - htmlString?.replace( - targetIdx, - targetIdx.plus(targetString.length), - contentsUriString - ) - } - targetString = t.replace("&", "&") - targetIdx = htmlString.indexOf(targetString) - if (targetIdx > 0) { - htmlString?.replace( - targetIdx, - targetIdx.plus(targetString.length), - contentsUriString - ) - } + CompressStringUtil.compressString(htmlString.toString())?.apply { + LogUtil.e("on it enofLoop 2 compressed String ${this.length}") } +// urlPathMap.forEach { t, u -> +// val file = File(u) +// var contentsUriString = FileProvider.getUriForFile( +// context, +// "${context.packageName}.fileprovider", +// file +// ).toString() +// +// var targetString = t +// var targetIdx = htmlString.indexOf(targetString) +// if (targetIdx > 0) { +// htmlString?.replace( +// targetIdx, +// targetIdx.plus(targetString.length), +// contentsUriString +// ) +// } +// targetString = t.replace("&", "&") +// targetIdx = htmlString.indexOf(targetString) +// if (targetIdx > 0) { +// htmlString?.replace( +// targetIdx, +// targetIdx.plus(targetString.length), +// contentsUriString +// ) +// } +// } if (autoCheck) { LogUtil.e("on it enofLoop autoCheck ${autoCheck}") diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewerActivity.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewerActivity.kt index d7b340f0..eb99ceb8 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewerActivity.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewerActivity.kt @@ -1,9 +1,10 @@ package bums.lunatic.launcher.home +import android.content.ClipData +import android.content.ClipboardManager import android.content.Context import android.content.Intent import android.os.Bundle -import android.os.Environment import android.print.PDFPrint import android.util.Base64 import android.view.KeyEvent @@ -23,39 +24,34 @@ import android.view.MotionEvent.ACTION_MOVE import android.view.View import android.webkit.CookieManager import android.webkit.CookieSyncManager +import android.webkit.JavascriptInterface import android.webkit.ValueCallback import android.widget.Toast -import androidx.core.content.FileProvider +import androidx.appcompat.app.AlertDialog import androidx.core.net.toUri +import androidx.core.view.postDelayed +import bums.lunatic.launcher.model.CiliMagnet import bums.lunatic.launcher.model.RssData import bums.lunatic.launcher.utils.Blog import bums.lunatic.launcher.workers.WorkersDb import io.realm.kotlin.ext.query import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kr.lunaticbum.awesomewebview.AwesomeWebView import kr.lunaticbum.awesomewebview.AwesomeWebViewActivity -import kr.lunaticbum.awesomewebview.helpers.DownPicUtil -import kr.lunaticbum.awesomewebview.helpers.DownPicUtil.DownFinishListener import kr.lunaticbum.awesomewebview.listeners.BroadCastManager import kr.lunaticbum.utils.content.ContextUtil import kr.lunaticbum.utils.log.LogUtil import org.jsoup.Jsoup -import org.jsoup.UnsupportedMimeTypeException -import java.io.BufferedWriter import java.io.ByteArrayOutputStream import java.io.File import java.io.FileInputStream -import java.io.FileWriter import java.io.IOException import java.io.InputStream -import java.lang.Thread.sleep -import java.net.URL +import java.net.URLEncoder +import java.nio.charset.Charset import java.security.MessageDigest -import java.text.SimpleDateFormat -import java.util.Date import java.util.concurrent.Executors import java.util.concurrent.TimeUnit import kotlin.text.Charsets.UTF_8 @@ -93,7 +89,7 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene var actionButtonPressX = 0f var actionButtonPressY = 0f var rssId : String = "" - var currentIdx = 0 + // var currentIdx = 0 var double = false var rssList: MutableList = ArrayList() @@ -108,6 +104,7 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene } else { loadWithIntent = false } + } override fun onResume() { @@ -131,7 +128,7 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene if(ev.action == ACTION_MOVE && ev.x != ev.y) { val correctTime = (ev.eventTime - lasteventTime) > 2 if (correctTime) { - Blog.LOGE("onGenericMotionEvent webviews ${p0} ev?.device?.name >>> ${ev?.device?.name} >> ${ev}") +// Blog.LOGE("onGenericMotionEvent webviews ${p0} ev?.device?.name >>> ${ev?.device?.name} >> ${ev}") if (ev.x <= -1.0f) { leftClick() } else if (ev.x >= 1.0f) { @@ -154,15 +151,15 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene override fun onGenericMotionEvent(ev: MotionEvent?): Boolean { if (ev?.device?.name?.contains("SM-031N Mouse") == true) { - Blog.LOGE("onGenericMotionEvent ev?.device?.name >>> ${ev?.device?.name} >> ${ev}") +// Blog.LOGE("onGenericMotionEvent ev?.device?.name >>> ${ev?.device?.name} >> ${ev}") return true } return super.onGenericMotionEvent(ev) } override fun dispatchKeyEvent(ev: KeyEvent): Boolean { - Blog.LOGE("dispatch ev?.device?.name >>> ${ev?.device?.name}") +// Blog.LOGE("dispatch ev?.device?.name >>> ${ev?.device?.name}") if (ev?.device?.name?.contains("SM-031N Mouse") == true) { - Blog.LOGE("onGenericMotionEvent ev?.device?.name >>> ${ev?.device?.name} >> ${ev}") +// Blog.LOGE("onGenericMotionEvent ev?.device?.name >>> ${ev?.device?.name} >> ${ev}") when(ev.action) { ACTION_UP -> { when(ev.keyCode) { @@ -229,16 +226,9 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene } fun doNextPage() { - rssList.remove(rssId) - if (currentIdx < rssList.size - 1) { - currentIdx += 1 - rssId = rssList.get(currentIdx) - Blog.LOGE("Arrow Right Click ${currentIdx} ${rssId}") - load(rssId) - } else if (currentIdx > 0) { - currentIdx -= 1 - rssId = rssList.get(currentIdx) - Blog.LOGE("Arrow Left Click ${currentIdx} ${rssId}") + rssList.removeAll { it.equals(rssId) } + if (rssList.size > 0) { + rssId = rssList.removeAt(0) load(rssId) } else { Toast.makeText(this, "없어 끄자", Toast.LENGTH_LONG).show() @@ -379,26 +369,33 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene Blog.LOGE("Arrow Up Click") registCancelSearch() } + protected fun load(newUrl: String) { - LogUtil.e("newUrl >>> ${newUrl}") - newUrl.toUri().host?.let { - val splits = it.replace("http://","").replace("https://","").split(".") - when(splits.size) { - 1-> host = splits[0] - 2-> host = splits[0] - 3-> host = splits[1] - 4-> host = splits[2] - else -> { - host = null + newUrl?.let { it -> + var url = if(it.startsWith("http://")) { + "https://${it.replace("http://","")}" + } else it +// LogUtil.e("newUrl >>> ${url}") + url.toUri().host?.let { + val splits = it.replace("http://","").replace("https://","").split(".") + when(splits.size) { + 1-> host = splits[0] + 2-> host = splits[0] + 3-> host = splits[1] + 4-> host = splits[2] + else -> { + host = null + } } } + if (extraHeaders == null) { + webView!!.loadUrl(url) + } else { + webView!!.loadUrl(url, extraHeaders!!) + } + registCancelSearch() } - if (extraHeaders == null) { - webView!!.loadUrl(newUrl!!) - } else { - webView!!.loadUrl(newUrl!!, extraHeaders!!) - } - registCancelSearch() + } override fun initializeOptions() { @@ -410,10 +407,15 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene builder?.rssList?.let { this.rssList.addAll(it) } Blog.LOGE("this.rssList >>>> ${this.rssList}") - this.rssList.forEachIndexed { index, s -> - if (s.equals(rssId)) { - currentIdx = index - return@forEachIndexed} + } + + override fun bindViews() { + super.bindViews() + if (this.rssId.contains(".guru")) { + Blog.LOGE("this.webView >>>> ${this.rssId}") + Blog.LOGE("this.webView >>>> ${this.webView}") + webView?.alpha = 0.2f + webView?.addJavascriptInterface(gji, "GJI") } } @@ -470,6 +472,126 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene } } + override fun onTrimMemory(level: Int) { + LogUtil.e("onTrimMemory >>> ${level} current ${url} current ${webView?.url ?: ""}") + super.onTrimMemory(level) + + } + fun showDi(code : String, items : ArrayList, links : ArrayList) { + runOnUiThread { + registCancelSearch() + hideBlock() + val builder = AlertDialog.Builder(this@RssViewerActivity) + builder.setTitle("code : ${code}") + builder?.setItems( + items.toTypedArray() + ) { dialog, which -> + LogUtil.e("hitTestResult.extra >>> ${dialog} ,${which}") + links?.get(which)?.let { link -> + (this.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager)?.let { mng -> + Blog.LOGE("link >>> ${link}") + mng.clearPrimaryClip() + mng.addPrimaryClipChangedListener { + mng.primaryClip?.getItemAt(0)?.text?.let { + if (it.length > 0 && it.startsWith("magnet:?xt=urn:")) { + Blog.LOGE("magnet >>>> $it") + try { + val launchIntent = + packageManager.getLaunchIntentForPackage("com.pikcloud.pikpak") + launchIntent?.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) + startActivity(launchIntent) + }catch (e:Exception) {e.printStackTrace()} + + } + } + } + mng.setPrimaryClip(ClipData.newPlainText("",link)) + } + + } + } + val dialog = builder?.create() + dialog?.show() + } + } + val gji = GJInterface(this) + inner class GJInterface(val context: Context) { + @JavascriptInterface + fun onResult(result : String?) { + registCancelSearch() + result.toString()?.replace("\\u003C","<")?.replace("\\"","")?.let { + Jsoup.parse(it)?.let { guru -> + Blog.LOGE("guru >>> ${guru.title()} ") + guru.getElementsByClass("row")?.forEach { row -> + row.getElementsByClass("grid1").first().getElementsByTag("a")?.first()?.attr("title")?.let { title -> + Blog.LOGE("row >>> ${title.split("]")?.first()?.replace("[","")}") + } + } + } + } + } + + + + + @JavascriptInterface + fun onCode(code : String) { + Blog.LOGE("onCode ${code}") + registCancelSearch() + CoroutineScope(Dispatchers.IO).launch { + var temp = arrayListOf() + Jsoup.connect("https://cili.site/search?q=${URLEncoder.encode(code, Charset.defaultCharset().name())}").get().let { cili -> + + cili.getElementsByTag("tr").forEach { cili_tr -> + CiliMagnet().let { ciliMgn -> + ciliMgn.link = if(cili_tr.getElementsByTag("a").size > 0)cili_tr.getElementsByTag("a").get(0).attr("href") else "" + ciliMgn.title = if(cili_tr.getElementsByTag("p").size > 0)cili_tr.getElementsByTag("p").text() else "" + ciliMgn.size = if(cili_tr.getElementsByClass("td-size").size > 0)cili_tr.getElementsByClass("td-size").text() else "" + Blog.LOGE("ciliMgn.size >>>> ${ciliMgn.size}") + Blog.LOGE("ciliMgn.size >>>> ${ciliMgn.title}") + if(ciliMgn.isValid() && temp.size < 8 ) { + try { + Jsoup.connect(ciliMgn.getMagnetPageLink()).get() + .let { mgn_Page -> + if (mgn_Page.getElementsByClass("input-group magnet-box").size > 0) { + mgn_Page.getElementsByClass("input-group magnet-box") + .get(0)?.let { magnet_box -> + magnet_box.getElementById( + "input-magnet" + )?.let { input_magnet -> + Blog.LOGE("input_magnet >>> ${input_magnet}") + ciliMgn.magnetLink = + input_magnet.attr("value") + .replace("&", "&") + } + } + } + }.apply { + temp.add(ciliMgn) + + } + }catch (e:Exception) {} + } + } + if(temp.size > 3) { + return@forEach + } + }.apply { + if (temp.size > 0) { + showDi( + code, + temp.map { + it.title.plus(" | ").plus(it.size).plus(" | ") + } as ArrayList, temp.map { + it.magnetLink + } as ArrayList) + } + } + } + }.start() + } + } + override fun onHtml(value: String?, autoCheck : Boolean) { chechHandler.removeCallbacks(cancelSearch) if (loadWithIntent){ @@ -528,52 +650,73 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene + + + + + override fun webviewOnPageFinished() { - double = false - if(hasYoutubePlayer) { - LogUtil.e("hasYoutubePlayer >>> ${hasYoutubePlayer}") - } - WorkersDb.getRealm().apply { - writeBlocking { - val result = - query().query("originPage == $0", rssId) - .find() - if (result.size == 1) { - result.first().read += 1 - } else { + if (rssId.contains(".guru")) { + registCancelSearch() +// webView?.scaleX = 0.2f +// webView?.scaleY = 0.2f +// webView?.post { webView?.addJavascriptInterface(gji,"GJI") } + webView?.postDelayed(2000L,{ + webView?.evaluateJavascript("try{GJI.log();}catch(e){console.log(e);}", {}) + webView?.evaluateJavascript("try{GJI.onResult(document.documentElement.outerHTML);}catch(e){console.log(e);}", {}) + webView?.evaluateJavascript("document.getElementsByClassName('banner-ad-wrapper')[0].remove()",{}) + }) + } else { + double = false + registCancelSearch() + if (hasYoutubePlayer) { + LogUtil.e("hasYoutubePlayer >>> ${hasYoutubePlayer}") + } + WorkersDb.getRealm().apply { + writeBlocking { + val result = + query().query("originPage == $0", rssId) + .find() +// if (result.size == 1) { +// result.first().read += 1 +// } else { result.forEach { it.read += 1 } +// } } } - } - registCancelSearch() - // - if (loadWithIntent) { - webView?.evaluateJavascript( - "try{document.querySelector('meta[name=viewport]').setAttribute('content','initial-scale=1.0')}catch(e){}", - null - ) - webView?.evaluateJavascript( - "try{document.querySelector('meta[name=viewport]').setAttribute('content','initial-scale=1.0')}catch(e){}", - null - ) - webView?.settings?.useWideViewPort = true - } - if (webView?.url?.contains("dcinside") == true){ - webView?.evaluateJavascript("try{document.querySelector('#div_adnmore_area').hidden = true;}catch(e){}",null) - } else if(webView?.url?.contains("fmkorea") == true) { - if (loadWithIntent) { - } else { - webView?.postDelayed({ - webView?.evaluateJavascript( - "try{document.querySelector('.m_rd_nav_side').hidden = true;}catch(e){}", - null - ) - webView?.evaluateJavascript( - "try{document.querySelector('[class*='bd bd_mobile ']').remove();}catch(e){}", - null - ) - }, 500L) + // + if (loadWithIntent) { + webView?.evaluateJavascript( + "try{document.querySelector('meta[name=viewport]').setAttribute('content','initial-scale=1.0')}catch(e){}", + null + ) + webView?.evaluateJavascript( + "try{document.querySelector('meta[name=viewport]').setAttribute('content','initial-scale=1.0')}catch(e){}", + null + ) + webView?.settings?.useWideViewPort = true + } + if (webView?.url?.contains("dcinside") == true) { + webView?.evaluateJavascript( + "try{document.querySelector('#div_adnmore_area').hidden = true;}catch(e){}", + null + ) + } else if (webView?.url?.contains("fmkorea") == true) { + if (loadWithIntent) { + + } else { + webView?.postDelayed({ + webView?.evaluateJavascript( + "try{document.querySelector('.m_rd_nav_side').hidden = true;}catch(e){}", + null + ) + webView?.evaluateJavascript( + "try{document.querySelector('[class*='bd bd_mobile ']').remove();}catch(e){}", + null + ) + }, 500L) + } } } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/WeatherHourlyAdater.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/WeatherHourlyAdater.kt index 3cbf0d49..f433f3df 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/WeatherHourlyAdater.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/WeatherHourlyAdater.kt @@ -48,7 +48,6 @@ class WeatherHourlyAdapter(private val dataSet: ArrayList): RecyclerView.A override fun getItemCount(): Int = dataSet.size fun update(li: Collection) { - Blog.LOGE("${this.javaClass.simpleName} update") li.toList() this.dataSet.clear() this.dataSet.addAll(li) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt b/app/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt index 96ac81ec..42e22bb4 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt @@ -179,7 +179,7 @@ open class DcInside : RssDataInterface { dateTiemL = cal.timeInMillis dateTiemL } else { - 0L + Date().time } } else { return dateTiemL @@ -232,7 +232,7 @@ class RssData : RealmObject, RssDataInterface { } else -> title ?: "" }.apply { - chosung = JamoUtils.split(this).joinToString("") + chosung = JamoUtils.split(title).joinToString("") } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt b/app/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt new file mode 100644 index 00000000..6d270974 --- /dev/null +++ b/app/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt @@ -0,0 +1,40 @@ +package bums.lunatic.launcher.model + +import com.ibm.icu.util.ChineseCalendar +import io.realm.kotlin.types.RealmObject +import java.util.Calendar +import java.util.Date + +class UserActionModel: RealmObject { + + var actionType: String = "" + var timestamp: Date = Date() + + var weekOfYear : Int = 0 + var weekOfMonth : Int = 0 + var dayOfWeek : Int = 0 + var dayOfYear : Int = 0 + var dayOfMonth : Int = 0 + var hourOfDay : Int = 0 + var month: Int = 0 + var lunMonth : Int = 0 + var lunDayOFMonth : Int = 0 + var lunDayOfYear : Int = 0 + + init { + val cal = Calendar.getInstance() + cal.time = timestamp + weekOfYear = cal.get(Calendar.WEEK_OF_YEAR) + weekOfMonth = cal.get(Calendar.WEEK_OF_MONTH) + dayOfWeek = cal.get(Calendar.DAY_OF_WEEK) + hourOfDay = cal.get(Calendar.HOUR_OF_DAY) + month = cal.get(Calendar.MONTH) + dayOfYear = cal.get(Calendar.DAY_OF_YEAR) + dayOfMonth = cal.get(Calendar.DAY_OF_MONTH) + var cinCal = ChineseCalendar() + cinCal.time = timestamp + lunMonth = cinCal.get(ChineseCalendar.MONTH) + lunDayOFMonth = cinCal.get(ChineseCalendar.DAY_OF_MONTH) + lunDayOfYear = cinCal.get(ChineseCalendar.DAY_OF_YEAR) + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/receiver/NLService.kt b/app/src/main/kotlin/bums/lunatic/launcher/receiver/NLService.kt index c41b5123..ee2f1666 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/receiver/NLService.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/receiver/NLService.kt @@ -47,38 +47,43 @@ class NLService : NotificationListenerService() { // sbn.notification.extras.keySet().forEach { // BLog.LOGE("NLService********** keySet >> ${it} ${sbn.notification.extras.get(it)}") // } - if (sbn.id != 0 && (sbn.packageName.contains(".") || sbn.packageName.contains("android")) && sbn.packageName.length > 0) { - NotificationItem().apply { - notiId = sbn.id - pkgName = sbn.packageName - title = sbn.notification?.extras?.getString("android.title") ?: "" - subtext = sbn.notification?.extras?.getString("android.subText") ?: "" - selfDisplayName = sbn.notification?.extras?.getString("android.selfDisplayName") ?: "" - tikerMsg = sbn.notification?.tickerText?.toString() ?: "" - postTime = sbn.postTime - var uniq = title ?: subtext ?: selfDisplayName ?: tikerMsg ?: "" - uniq_id = "${sbn.id}_${sbn.packageName}_${if (uniq.length > 3) uniq.substring(0,3) else uniq}" + try { + if (sbn.id != 0 && (sbn.packageName.contains(".") || sbn.packageName.contains("android")) && sbn.packageName.length > 0) { + NotificationItem().apply { + notiId = sbn.id + pkgName = sbn.packageName + title = sbn.notification?.extras?.getString("android.title") ?: "" + subtext = sbn.notification?.extras?.getString("android.subText") ?: "" + selfDisplayName = sbn.notification?.extras?.getString("android.selfDisplayName") ?: "" + tikerMsg = sbn.notification?.tickerText?.toString() ?: "" + postTime = sbn.postTime + var uniq = title ?: subtext ?: selfDisplayName ?: tikerMsg ?: "" + uniq_id = "${sbn.id}_${sbn.packageName}_${if (uniq.length > 3) uniq.substring(0,3) else uniq}" // BLog.LOGE("NLService********** enqueue TelegramBotGetter ${true == "bumssavor".equals(title)}") // BLog.LOGE("NLService********** enqueue TelegramBotGetter ${(true == "org.telegram.messenger".equals(pkgName))}") // BLog.LOGE("NLService********** enqueue TelegramBotGetter ${sbn.notification?.extras?.getString("android.text")?.startsWith("/") == true}") - }.apply { - if (skips.contains(pkgName)) { + }.apply { + if (skips.contains(pkgName)) { - } else { - WorkersDb.insertNoti(this) + } else { +// WorkersDb.insertNoti(this) // BLog.LOGE("NLService********** onNotificationPosted ${Gson().toJson(this)}") + } } } + } catch (e : Exception) { + e.printStackTrace() } + try { if (sbn.packageName.contains("youtube")) { val m = getSystemService()!! val component = ComponentName(this, NLService::class.java) val sessions = m.getActiveSessions(component) sessions.forEach { session -> WorkersDb.getRealm().writeBlocking { - Blog.LOGE("session.playbackState >>> ${session.playbackState}") +// Blog.LOGE("session.playbackState >>> ${session.playbackState}") if (session.playbackState != null) { if (session.playbackState?.isActive == true && session.playbackState?.state?.equals( STATE_PLAYING @@ -111,6 +116,8 @@ class NLService : NotificationListenerService() { } } + }}catch (e : Exception) { + e.printStackTrace() } // val i = Intent("com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE") // i.putExtra("notification_event", "onNotificationPosted :" + sbn.packageName + "\n") @@ -118,19 +125,19 @@ class NLService : NotificationListenerService() { } override fun onNotificationRemoved(sbn: StatusBarNotification) { -// BLog.LOGE("NLService********** onNOtificationRemoved") -// BLog.LOGE("NLService ID :" + sbn.id + "\t" + sbn.notification.tickerText + "\t" + sbn.packageName) - var uniq_id = "${sbn.id}_${sbn.packageName}" - try { - WorkersDb.getRealm()?.apply { - this.writeBlocking { -// delete(query().query("pkgName == $0", sbn.packageName).find()) - } - } - }catch (e : Exception){e.printStackTrace()} -// val i = Intent("com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE") -// i.putExtra("notification_event", "onNotificationRemoved :" + sbn.packageName + "\n") -// sendBroadcast(i) +//// BLog.LOGE("NLService********** onNOtificationRemoved") +//// BLog.LOGE("NLService ID :" + sbn.id + "\t" + sbn.notification.tickerText + "\t" + sbn.packageName) +// var uniq_id = "${sbn.id}_${sbn.packageName}" +// try { +// WorkersDb.getRealm()?.apply { +// this.writeBlocking { +//// delete(query().query("pkgName == $0", sbn.packageName).find()) +// } +// } +// }catch (e : Exception){e.printStackTrace()} +//// val i = Intent("com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE") +//// i.putExtra("notification_event", "onNotificationRemoved :" + sbn.packageName + "\n") +//// sendBroadcast(i) } internal inner class NLServiceReceiver : BroadcastReceiver() { diff --git a/app/src/main/kotlin/bums/lunatic/launcher/settings/childs/Apps.kt b/app/src/main/kotlin/bums/lunatic/launcher/settings/childs/Apps.kt index d6485b29..aa687c9f 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/settings/childs/Apps.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/settings/childs/Apps.kt @@ -30,6 +30,7 @@ import bums.lunatic.launcher.databinding.SettingsAppsBinding import bums.lunatic.launcher.helpers.PrefBoolean import bums.lunatic.launcher.helpers.PrefHelper import bums.lunatic.launcher.helpers.PrefLong +import bums.lunatic.launcher.utils.Blog import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment @@ -132,16 +133,19 @@ internal class Apps : BottomSheetDialogFragment() { settingsChanged = true PrefLong.shortTimePeriod.set(value.toLong()) binding.shortTimeTitle.text = getString(R.string.shortTimeTitle) +" [${value.toInt()}분 마다]" + Blog.LOGE("binding.shortTimeTitle.text >>> ${binding.shortTimeTitle.text}") }) binding.middleTime.addOnChangeListener(Slider.OnChangeListener { _, value, _ -> settingsChanged = true PrefLong.midTimePeriod.set(value.toLong()) binding.middleTimeTitle.text = getString(R.string.middleTimeTitle) +" [${value.toInt()}분 마다]" + Blog.LOGE("binding.shortTimeTitle.text >>> ${binding.middleTimeTitle.text}") }) binding.longTime.addOnChangeListener(Slider.OnChangeListener { _, value, _ -> settingsChanged = true PrefLong.longTimePeriod.set(value.toLong()) binding.longTimeTitle.text = getString(R.string.longTimeTitle) +" [${value.toInt()}]분 마다]" + Blog.LOGE("binding.shortTimeTitle.text >>> ${binding.longTimeTitle.text}") }) binding.locationDistance.addOnChangeListener(Slider.OnChangeListener { _, value, _ -> diff --git a/app/src/main/kotlin/bums/lunatic/launcher/utils/CompressStringUtil.kt b/app/src/main/kotlin/bums/lunatic/launcher/utils/CompressStringUtil.kt new file mode 100644 index 00000000..7f8f7737 --- /dev/null +++ b/app/src/main/kotlin/bums/lunatic/launcher/utils/CompressStringUtil.kt @@ -0,0 +1,99 @@ +package bums.lunatic.launcher.utils + +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import java.io.IOException +import java.io.InputStream +import java.io.OutputStream +import java.io.UnsupportedEncodingException +import java.util.zip.DeflaterOutputStream +import java.util.zip.InflaterInputStream +import kotlin.math.floor + + +object CompressStringUtil { + val charsetName: String = "UTF-8" + + /** + * String 객체를 압축하여 String 으로 리턴한다. + * @param string + * @return + */ + @Synchronized + fun compressString(string: String): String? { + return byteToString(compress(string)) + } + + /** + * 압축된 스트링을 복귀시켜서 String 으로 리턴한다. + * @param compressed + * @return + */ + @Synchronized + fun decompressString(compressed: String?): String { + return decompress(hexToByteArray(compressed)) + } + + private fun byteToString(bytes: ByteArray?): String? { + val sb = StringBuilder() + try { + for (b in bytes!!) { + sb.append(String.format("%02X", b)) + } + } catch (e: Exception) { + e.printStackTrace() + return null + } + + return sb.toString() + } + + private fun compress(text: String): ByteArray? { + val baos = ByteArrayOutputStream() + try { + val out: OutputStream = DeflaterOutputStream(baos) + out.write(text.toByteArray(charset(charsetName))) + out.close() + } catch (e: UnsupportedEncodingException) { + e.printStackTrace() + return null + } catch (e: IOException) { + e.printStackTrace() + return null + } + return baos.toByteArray() + } + + + private fun decompress(bytes: ByteArray): String { + val `in`: InputStream = InflaterInputStream(ByteArrayInputStream(bytes)) + val baos = ByteArrayOutputStream() + try { + val buffer = ByteArray(8192) + var len: Int + while ((`in`.read(buffer).also { len = it }) > 0) baos.write(buffer, 0, len) + return String(baos.toByteArray(), charset(charsetName)) + } catch (e: IOException) { + e.printStackTrace() + throw AssertionError(e) + } + } + + /** + * 16진 문자열을 byte 배열로 변환한다. + */ + private fun hexToByteArray(hex: String?): ByteArray { + if (hex == null || hex.length % 2 != 0) { + return byteArrayOf() + } + + val bytes = ByteArray(hex.length / 2) + var i = 0 + while (i < hex.length) { + val value = hex.substring(i, i + 2).toInt(16).toByte() + bytes[floor((i / 2).toDouble()).toInt()] = value + i += 2 + } + return bytes + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/utils/DataUtils.kt b/app/src/main/kotlin/bums/lunatic/launcher/utils/DataUtils.kt index 38d085fc..baaa113a 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/utils/DataUtils.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/utils/DataUtils.kt @@ -18,8 +18,8 @@ fun before30Min(date: Date): Long { fun beforeOneDay(): Long { val cal: Calendar = Calendar.getInstance() cal.setTime(Date()) - cal.add(Calendar.DAY_OF_YEAR, -1) - cal.add(Calendar.HOUR_OF_DAY, -3) +// cal.add(Calendar.DAY_OF_YEAR, -1) + cal.add(Calendar.HOUR_OF_DAY, -4) return cal.timeInMillis } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/AppInfoGetter.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/AppInfoGetter.kt index 7a41d415..3a7625e0 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/AppInfoGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/AppInfoGetter.kt @@ -2,19 +2,21 @@ package bums.lunatic.launcher.workers import android.content.Context import android.content.Intent +import android.content.pm.ApplicationInfo import android.content.pm.PackageManager import android.content.pm.ResolveInfo import android.os.Build import androidx.work.WorkerParameters import bums.lunatic.launcher.BuildConfig +import bums.lunatic.launcher.LauncherActivity import bums.lunatic.launcher.LauncherActivity.Companion.lActivity -import bums.lunatic.launcher.apps.AppDrawer.Companion.appName -import bums.lunatic.launcher.apps.AppDrawer.Companion.getCategory -import bums.lunatic.launcher.apps.normalize +import bums.lunatic.launcher.apps.AppDrawer.Companion.appNamesPrefs import bums.lunatic.launcher.model.AppInfo import bums.lunatic.launcher.utils.AlphabetToChosungMap import bums.lunatic.launcher.utils.JamoUtils import io.realm.kotlin.ext.query +import java.text.Normalizer +import java.util.regex.Pattern class AppInfoGetter : BaseGetter { companion object { @@ -61,4 +63,32 @@ class AppInfoGetter : BaseGetter { } catch (e : Exception) {e.printStackTrace()} return Result.success() } -} \ No newline at end of file + + fun appName(resolver: ResolveInfo): String { + return resolver.loadLabel(lActivity?.packageManager!!).toString().apply { + appNamesPrefs?.edit()?.putString(resolver.activityInfo.packageName, this)?.apply() + } + } + + fun getCategory(category : Int) : String { + return when(category) { + ApplicationInfo.CATEGORY_UNDEFINED -> "UNDEFINED" + ApplicationInfo.CATEGORY_GAME -> "GAME" + ApplicationInfo.CATEGORY_AUDIO -> "AUDIO" + ApplicationInfo.CATEGORY_VIDEO -> "VIDEO" + ApplicationInfo.CATEGORY_IMAGE -> "IMAGE" + ApplicationInfo.CATEGORY_SOCIAL -> "SOCIAL" + ApplicationInfo.CATEGORY_NEWS -> "NEWS" + ApplicationInfo.CATEGORY_MAPS -> "MAPS" + ApplicationInfo.CATEGORY_PRODUCTIVITY -> "PRODUCTIVITY" + ApplicationInfo.CATEGORY_ACCESSIBILITY -> "ACCESSIBILITY" + else -> {"UNKNOWN"} + } + } + fun normalize(str: String): String { + val normalizedString = + Normalizer.normalize(str.replace("\\W".toRegex(), ""), Normalizer.Form.NFC) + val pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+") + return pattern.matcher(normalizedString).replaceAll("").toLowerCase() + } +} diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/ArcaGetter.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/ArcaGetter.kt index f3c48306..6e379003 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/ArcaGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/ArcaGetter.kt @@ -8,13 +8,13 @@ import bums.lunatic.launcher.model.RssDataType import bums.lunatic.launcher.model.getRssData import bums.lunatic.launcher.model.getT import bums.lunatic.launcher.utils.beforeOneDay -import bums.lunatic.launcher.workers.WorkersDb.blockKeyword +//import bums.lunatic.launcher.workers.WorkersDb.blockKeyword import org.jsoup.Jsoup import org.jsoup.nodes.Element class ArcaGetter : BaseGetter { companion object { - val TAG = "DCGetter" + val TAG = "ArcaGetter" } constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) { @@ -73,7 +73,7 @@ class ArcaGetter : BaseGetter { var tumbnail = aracaLi.getElementsByTag("img").attr("src") var link = "https://arca.live".plus(if(aracaLi.getElementsByClass("title hybrid-title").size > 0) aracaLi.getElementsByClass("title hybrid-title").get(0).attr("href") else if(aracaLi.getElementsByTag("a").size > 0) aracaLi.getElementsByTag("a").get(0).attr("href") else "") if (title.length > 0 && link.length > 20) { - if(blockKeyword.filter { desc.contains(it) }.size == 0) { +// if(blockKeyword.filter { desc.contains(it) }.size == 0) { Arca().apply { this.link = link this.title = title @@ -90,7 +90,7 @@ class ArcaGetter : BaseGetter { tempArray.add(this) } } - } +// } } return tempArray } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/AudioRecordService.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/AudioRecordService.kt new file mode 100644 index 00000000..83254439 --- /dev/null +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/AudioRecordService.kt @@ -0,0 +1,46 @@ +package bums.lunatic.launcher.workers + +import android.Manifest +import android.app.Service +import android.content.Intent +import android.media.AudioFormat +import android.media.AudioManager +import android.media.AudioRecord +import android.media.MediaRecorder +import android.os.IBinder +import androidx.annotation.RequiresPermission + + + +class AudioRecordService : Service() { + override fun onBind(intent: Intent?): IBinder? { + TODO("Not yet implemented") + } + + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + return super.onStartCommand(intent, flags, startId) + } + + + var sampleRate: Int = 44100 // 샘플링 레이트 (Hz) + var channelConfig: Int = AudioFormat.CHANNEL_IN_MONO // 채널 구성 (모노) + var audioFormat: Int = AudioFormat.ENCODING_PCM_16BIT // 오디오 포맷 (16비트 PCM) + var bufferSize: Int = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat) + + var recorder: AudioRecord? = null + @RequiresPermission(Manifest.permission.RECORD_AUDIO) + fun startAudioRec() { + recorder = AudioRecord( + MediaRecorder.AudioSource.MIC, + sampleRate, + channelConfig, + audioFormat, + bufferSize + ) + + recorder?.registerAudioRecordingCallback({},object : AudioManager.AudioRecordingCallback() { + + }) + } + +} \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/DCGetter.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/DCGetter.kt index fc16ba9a..92b76881 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/DCGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/DCGetter.kt @@ -2,13 +2,17 @@ package bums.lunatic.launcher.workers import android.annotation.SuppressLint import android.content.Context +import androidx.core.net.toUri import androidx.work.WorkerParameters +import bums.lunatic.launcher.helpers.PrefHelper import bums.lunatic.launcher.model.DcInside import bums.lunatic.launcher.model.RssData import bums.lunatic.launcher.model.RssDataInterface import bums.lunatic.launcher.model.RssDataType import bums.lunatic.launcher.model.getRssData +import bums.lunatic.launcher.utils.Blog import org.jsoup.Jsoup +import java.text.SimpleDateFormat class DCGetter : BaseGetter { companion object { @@ -20,6 +24,9 @@ class DCGetter : BaseGetter { fun parseDcLi(dc_li : org.jsoup.nodes.Element) : ArrayList{ var temp = arrayListOf() if (dc_li.html().contains("
    ") && dc_li.html().contains("con_list img")) { + + } + else if (dc_li.html().contains("
      ") && dc_li.html().contains("con_list img")) { dc_li.child(0).getElementsByTag("li").forEach { parseDcLi(it) } @@ -64,31 +71,94 @@ class DCGetter : BaseGetter { } return temp } - + val df = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") @SuppressLint("RestrictedApi") override fun realWork(): Result { +// Blog.LOGE("${TAG} RssDataType.DCINSIDE.isOn >>>> ${PrefHelper.getBoolean(RssDataType.DCINSIDE.name,false)}") RssDataType.DCINSIDE.isOn { temp.clear() +// https://m.dcinside.com/board/singlebungle1472 + var urls = arrayListOf( + "https://m.dcinside.com", + "https://m.dcinside.com/board/singlebungle1472", + "https://m.dcinside.com/board/programming", + "https://m.dcinside.com/board/cartoon", + "https://m.dcinside.com/board/reading", + "https://m.dcinside.com/board/chiangmai", + "https://m.dcinside.com/board/hit", + "https://m.dcinside.com/board/dcbest" + ) try { - val testUrl2 = "https://www.dcinside.com/" - Jsoup.connect(testUrl2) - .userAgent(USAGT) - .get().let { dc -> -// BLog.LOGE("test ${testUrl2} >> ${this}") - dc.getElementsByTag("li").forEach { dc_li -> - if (dc_li.html().contains("main_log") == true) { - parseDcLi(dc_li).apply { - this.forEach { - if (it.pubDate() > commicsDateTime) { - temp.add(it.getRssData()) + urls.forEach { testUrl2 -> + try { +// Blog.LOGE("${TAG} ${testUrl2} ") + Jsoup.connect(testUrl2) + .userAgent(USAGT) + .get().let { dc -> +// Blog.LOGE("${TAG} ${testUrl2} >> ${this}") + var tbody = dc.getElementsByTag("tbody") + + + if((tbody?.size ?: 0) == 1) { + + var from = dc.getElementsByClass("page_head clear")?.first()?.getElementsByTag("a")?.first()?.text() +// Blog.LOGE("${TAG} ${from} ") + dc.getElementsByTag("tbody").first().children().forEach { + var title = it.getElementsByClass("gall_tit ub-word")?.first()?.text() + var date = it.getElementsByClass("gall_date")?.first()?.attr("title") + var link = it.getElementsByTag("a")?.first()?.attr("href") + if (link?.length ?: 0 > 10 && title?.length ?: 0 > 2 && date?.length ?: 0 > 1) { +// Blog.LOGE("${TAG} ${title} ") +// Blog.LOGE("${TAG} ${date} ${df.parse(date)}") +// Blog.LOGE("${TAG} ${link} ") + DcInside().apply { + "https://gall.dcinside.com".plus( + link?.replace( + "&", + "&" + ) + )?.toUri()?.apply { + + link = "https://m.dcinside.com/board/".plus(getQueryParameter("id")).plus("/").plus(getQueryParameter("no")) + } +// this.link = "https://gall.dcinside.com".plus( +// link?.replace( +// "&", +// "&" +// ) +// ) + + this.link = link +// Blog.LOGE("${TAG} ${link} ") +// Blog.LOGE("${TAG} ${from} ") + this.title = title + this.desc = from + this.dateTiemL = df.parse(date).time + }.apply { + if (this.pubDate() > limitDateTime) { + temp.add(this.getRssData()) + } + } + } + } + } else { + dc.getElementsByTag("li").forEach { dc_li -> + if (dc_li.html().contains("main_log") == true) { + parseDcLi(dc_li).apply { + this.forEach { + + if (it.pubDate() > commicsDateTime) { +// Blog.LOGE("${TAG} ${it.title()}") + temp.add(it.getRssData()) + } + } + } } } } } - } - } - - + }catch (e :Exception){e.printStackTrace()} + } } catch (e: Exception) { e.printStackTrace() } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/FmKoreaGetter.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/FmKoreaGetter.kt index 5c90fee5..c4e1b1c9 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/FmKoreaGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/FmKoreaGetter.kt @@ -6,6 +6,7 @@ import androidx.work.WorkerParameters import bums.lunatic.launcher.model.FmKorea import bums.lunatic.launcher.model.RssDataType import bums.lunatic.launcher.model.getRssData +import bums.lunatic.launcher.utils.Blog import org.jsoup.Jsoup import java.util.Date @@ -22,42 +23,49 @@ class FmKoreaGetter : BaseGetter { RssDataType.FMKORAE.isOn { val now = Date() try { - val fmkoreaUrls = arrayListOf("https://www.fmkorea.com/best","https://www.fmkorea.com/best2") + val fmkoreaUrls = arrayListOf("https://m.fmkorea.com","https://m.fmkorea.com/best","https://m.fmkorea.com/best2") fmkoreaUrls.forEach { - Jsoup.connect(it).userAgent(USAGT).get().let { fmkorea -> -// BLog.LOGE("fmkorea >>> ${fmkorea.title()}") - fmkorea.getElementsByTag("li").forEach { fmkorea_li -> - if (fmkorea_li.getElementsByClass("title") - .text().length > 0 && fmkorea_li.getElementsByTag("a").size > 0 && fmkorea_li.getElementsByTag( - "a" - ).get(0).attr("href").length > 0 - ) { -// BLog.LOGE("fmkorea_li >>> ${fmkorea_li}") - val title = fmkorea_li.getElementsByClass("title").text() - val tumb = "https://".plus( - fmkorea_li.getElementsByClass("thumb").attr("data-original") - ) - val pageUrl = "https://www.fmkorea.com".plus( - fmkorea_li.getElementsByTag("a").get(0).attr("href") - ) - val desc = fmkorea_li.getElementsByClass("category").text() - val date = fmkorea_li.getElementsByClass("regdate").text() - FmKorea(pageUrl, desc, date, title, tumb).apply { - if (desc?.contains("유머") == true || desc?.contains("음악") == true || desc?.contains( - "영화" - ) == true || - desc?.contains("TV") == true || desc?.contains("미스터리") == true || desc?.contains( - "역사" - ) == true + try { + Jsoup.connect(it).userAgent(USAGT).timeout(5000).ignoreHttpErrors(true).get().let { fmkorea -> + if (it.contains("guru")) { +// Blog.LOGE("GURU -> ${fmkorea}") + } else { + fmkorea.getElementsByTag("li").forEach { fmkorea_li -> + if (fmkorea_li.getElementsByClass("title") + .text().length > 0 && fmkorea_li.getElementsByTag("a").size > 0 && fmkorea_li.getElementsByTag( + "a" + ).get(0).attr("href").length > 0 ) { - if (this.pubDate() > commicsDateTime && tumb.length > 10) { - temp.add(this.getRssData()) + val title = fmkorea_li.getElementsByClass("title").text() + val tumb = "https://".plus( + fmkorea_li.getElementsByClass("thumb") + .attr("data-original") + ) + val pageUrl = "https://www.fmkorea.com".plus( + fmkorea_li.getElementsByTag("a").get(0).attr("href") + ) + val desc = fmkorea_li.getElementsByClass("category").text() + val date = fmkorea_li.getElementsByClass("regdate").text() + FmKorea(pageUrl, desc, date, title, tumb).apply { + if (desc?.contains("유머") == true || desc?.contains("음악") == true || desc?.contains( + "영화" + ) == true || + desc?.contains("TV") == true || desc?.contains("미스터리") == true || desc?.contains( + "역사" + ) == true + ) { + if (this.pubDate() > commicsDateTime && tumb.length > 10) { + temp.add(this.getRssData()) + } + } } + } } - } } + }catch (e:Exception){ + e.printStackTrace() } } } catch (e: Exception) { diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt index 47371bd8..466d2f17 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt @@ -152,6 +152,7 @@ class LocationUpdateService : Service(), LocationListener { try{ locationManager = applicationContext .getSystemService(LOCATION_SERVICE) as LocationManager + checkGPS = locationManager!! .isProviderEnabled(LocationManager.GPS_PROVIDER) checkNetwork = locationManager!! diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/NewsFeedsGetter.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/NewsFeedsGetter.kt index e72cf6d4..1458dc97 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/NewsFeedsGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/NewsFeedsGetter.kt @@ -24,10 +24,10 @@ class NewsFeedsGetter : BaseGetter { feddsUrls.addAll(RssList.getFeedUrls()) for (url in feddsUrls) { - for (it in RssFeedsParser.getFeeds(url)) { - if (it.pubDate() >= limitDateTime) { - temp.add(it.getRssData()) - } + try { + for (it in RssFeedsParser.getFeeds(url)) { if (it.pubDate() >= limitDateTime) { try {temp.add(it.getRssData())}catch (e : Exception) {e.printStackTrace()} } } + }catch (e : Exception) { + e.printStackTrace() } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/RuliWebGetter.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/RuliWebGetter.kt index ec16ad98..c4edd306 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/RuliWebGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/RuliWebGetter.kt @@ -7,6 +7,7 @@ import androidx.work.WorkerParameters import bums.lunatic.launcher.model.RssDataType import bums.lunatic.launcher.model.RuliWeb import bums.lunatic.launcher.model.getRssData +import bums.lunatic.launcher.utils.Blog import org.jsoup.Jsoup class RuliWebGetter : BaseGetter { @@ -26,7 +27,9 @@ class RuliWebGetter : BaseGetter { var dateTimeTxt = "" if(ruli_tr.getElementsByTag("a").size > tagIdx) { pageLink = aTags.get(tagIdx).attr("href").replace("&","&") - thumbnailUrl = aTags.get(tagIdx).attr("style").split("(")[1].replace(");","") + if(aTags.get(tagIdx).attr("style").split("(").size > 1) { + thumbnailUrl = aTags.get(tagIdx).attr("style").split("(")[1].replace(");", "") + } } tagIdx = 1 if(ruli_tr.getElementsByTag("a").size > tagIdx) { title = aTags.get(tagIdx).text() } @@ -37,11 +40,11 @@ class RuliWebGetter : BaseGetter { var timeClass = ruli_tr.getElementsByClass("time") if(timeClass.size > 0) { dateTimeTxt = timeClass.get(0).text() } -// BLog.LOGE("pageLink >>>> $pageLink ") -// BLog.LOGE("thumbnailUrl >>>> $thumbnailUrl ") -// BLog.LOGE("title >>>> $title ") -// BLog.LOGE("desc >>>> $desc ") -// BLog.LOGE("dateTimeTxt >>>> $dateTimeTxt ") +// Blog.LOGE(TAG.plus("pageLink >>>> $pageLink ")) +// Blog.LOGE(TAG.plus("thumbnailUrl >>>> $thumbnailUrl ")) +// Blog.LOGE(TAG.plus("title >>>> $title ")) +// Blog.LOGE(TAG.plus("desc >>>> $desc ")) +// Blog.LOGE(TAG.plus("dateTimeTxt >>>> $dateTimeTxt ")) if (title.length > 0 && pageLink.length > 0) { RuliWeb().let { ru -> ru.title = title @@ -62,10 +65,10 @@ class RuliWebGetter : BaseGetter { try { val testUrl2 = arrayListOf("https://bbs.ruliweb.com/best/humor_only","https://bbs.ruliweb.com/best/humor_only/now?m=humor_only&t=default&page=2") testUrl2.forEach { url -> - Jsoup.connect(url) + Jsoup.connect(url).timeout(5000).ignoreHttpErrors(true) .userAgent(USAGT) .get().let { ruli -> -// BLog.LOGE("test ${testUrl2} >> ${ruli.title()}") +// Blog.LOGE(TAG.plus("test ${testUrl2} >> ${ruli.title()}")) ruli.getElementsByTag("tr").forEach { ruli_tr -> parseRuli(ruli_tr) } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt index e99b51cc..94a7d055 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt @@ -24,6 +24,7 @@ import bums.lunatic.launcher.model.TelegramChat import bums.lunatic.launcher.model.TelegramData import bums.lunatic.launcher.model.TelegramFrom import bums.lunatic.launcher.model.TelegramMessage +import bums.lunatic.launcher.model.UserActionModel import bums.lunatic.launcher.model.WeatherForcast import bums.lunatic.launcher.utils.Blog import bums.lunatic.launcher.utils.JamoUtils @@ -36,6 +37,8 @@ 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.Calendar +import java.util.Date import java.util.Locale import java.util.regex.Pattern import kotlin.reflect.KClass @@ -48,12 +51,21 @@ class CustMigration : AutomaticSchemaMigration { } object WorkersDb { - + fun recommendApps() { + val cal = Calendar.getInstance() + cal.time = Date() + val weekOfYear = cal.get(Calendar.WEEK_OF_YEAR) + val weekOfMonth = cal.get(Calendar.WEEK_OF_MONTH) + val dayOfWeek = cal.get(Calendar.DAY_OF_WEEK) + getRealm().apply { + this.query().query("weekOfYear == $0 OR weekOfMonth == $1 OR dayOfWeek == $2").limit() + } + } val clazz : Set> = setOf(RssData::class, NotificationItem::class, AppInfo::class,SimpleContact::class, RecentCall::class, RecentSms::class, CurrentPlayItem::class, TelegramBotUpdate::class, TelegramData::class, TelegramMessage::class, TelegramChat::class, BotCommandEentitie::class, TelegramFrom::class, WeatherForcast::class, Location::class, Current::class, Forecast::class, Condition::class, Forecastday::class, Day::class, Astro::class, Hour::class, - LocationLog::class + LocationLog::class,UserActionModel::class ) val schemaVersion : Long = BuildConfig.BuildDateTime @@ -85,7 +97,7 @@ object WorkersDb { } } - val blockKeyword = arrayListOf("붕괴 스타레일","붕괴 스타일","트릭컬 RE:VIVE","원신","메이플스토리","") +// val blockKeyword = arrayListOf("붕괴 스타레일","붕괴 스타일","트릭컬 RE:VIVE","원신","메이플스토리","") fun insertBulkData(rssDatas: Collection) { rssDatas.forEach { try { @@ -94,7 +106,7 @@ object WorkersDb { val catfillters = arrayListOf(RssDataType.THEQOO,RssDataType.RULIWEB,RssDataType.ARCA,RssDataType.CLIEN,RssDataType.FMKORAE,RssDataType.DOTAX,RssDataType.DCINSIDE) if(catfillters.contains(it.category()) && query("chosung == $0",it.chosung).find().size == 0) { this.copyToRealm(it, UpdatePolicy.ERROR) - } else { + } else if(!catfillters.contains(it.category())){ this.copyToRealm(it, UpdatePolicy.ERROR) } } catch (e : Exception) { diff --git a/app/src/main/res/layout/launcher_home.xml b/app/src/main/res/layout/launcher_home.xml index feaea6db..856ae530 100644 --- a/app/src/main/res/layout/launcher_home.xml +++ b/app/src/main/res/layout/launcher_home.xml @@ -189,6 +189,18 @@ android:layout_width="wrap_content" android:layout_height="wrap_content"/> + + + + var code = if(last.contains("_") && last.split("_")?.first()?.length ?: 0 > 2) { + last.split("_").first() + } else if(last.contains("-") && last.split("-")?.first()?.length ?: 0 > 2) { + last.split("-").first() + } else { + last + } + LogUtil.e("hitTestResult code >>> ${code}") + webView?.evaluateJavascript("try{GJI.onCode('${code}');}catch(e){console.log(e);}", {}) + } + showBlock() + return@OnLongClickListener false + } + builder?.setItems( items ) { dialog, which -> LogUtil.e("hitTestResult.extra >>> ${dialog} ,${which}") val url = hitTestResult.extra - LogUtil.e("hitTestResult.extra >>> ${hitTestResult.extra}") + CookieSyncManager.createInstance(applicationContext) CookieSyncManager.getInstance().sync() val cookieManager = @@ -1253,8 +1270,16 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, protected fun showBlock() { binding.blocking.visibility = View.VISIBLE - val ress = arrayListOf(R.raw.lt_lodaing_01,R.raw.lt_lodaing_02,R.raw.lt_lodaing_03) - binding.lotti.setAnimation(ress[Math.abs(Random(8736).nextInt()) % ress.size]) + val ress = arrayListOf(R.raw.dlottie_001,R.raw.lt_lodaing_01,R.raw.dlottie_003,R.raw.lt_lodaing_02,R.raw.lt_lodaing_03,R.raw.dlottie_002) + var isEven = ((System.currentTimeMillis() % 2).toInt() == 0) + var firstSeed = Random(if(isEven)8739 else 7531) + var randomSeed_01 = Math.abs(firstSeed.nextInt()) % if(isEven) 879 else 56 + var randomSeed_02 = Math.abs(firstSeed.nextInt()) % if(!isEven) 758 else 397 + var randomSeed_03 = Math.abs(firstSeed.nextInt()) % if(!isEven) 353 else 49 + var totalSeed = Math.abs((Math.abs(randomSeed_01) * Math.abs(randomSeed_02)) + Math.abs(randomSeed_03)) + var randomResult = Math.abs(totalSeed % ress.size) + LogUtil.e("randomResult >>> randomSeed_01 {${randomSeed_01}} | randomSeed_02 {${randomSeed_02}} | randomSeed_03 {${randomSeed_03}} | resSize {${ress.size}} | ${randomResult}") + binding.lotti.setAnimation(ress[Math.abs(randomResult)]) binding.lotti.playAnimation() } @@ -1912,7 +1937,7 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, url.toLowerCase(Locale.ROOT).contains(".svg") || url.toLowerCase(Locale.ROOT).contains(".webp")) { mediaUrls.add(url) - LogUtil.e("mediaUrls >>>>> add(${url})") +// LogUtil.e("mediaUrls >>>>> add(${url})") } if(!hasYoutubePlayer) { @@ -1924,9 +1949,11 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, if (url.toLowerCase(Locale.ROOT) .contains("ads".toLowerCase(Locale.ROOT))) { - LogUtil.e("shouldInterceptRequest request url contains ads >>> ${request.url.toString()}") +// LogUtil.e("shouldInterceptRequest request url contains ads >>> ${request.url.toString()}") } - var adblockKeyWords = arrayOf("adcr.naver.com","daumcdn.net/biz/ui/ad/adcm","imgad","ad.daum.net","cr.adsappier.com","ar-adview","adtrafficquality","criteo","adlib.nhnace.com","google.com/ads","googleads.","/pagead","/adpost/","ads/search","plugin.adplex","google-analytics.com") + var callSupers = arrayListOf("google-analytics.com","analytics.google.com","api.dable.io") + var adblockKeyWords = arrayOf("adcr.naver.com","daumcdn.net/biz/ui/ad/adcm","imgad","ad.daum.net","cr.adsappier.com","ar-adview","adtrafficquality","criteo","adlib.nhnace.com","google.com/ads","googleads.","/pagead","/adpost/","ads/search","plugin.adplex") + val supers = callSupers.filter { url.toLowerCase(Locale.ROOT).contains(it.toLowerCase(Locale.ROOT)) }.size > 0 val adblock = adblockKeyWords.filter { url.toLowerCase(Locale.ROOT).contains(it.toLowerCase(Locale.ROOT)) }.size > 0 return if(adblock) { try { @@ -1935,7 +1962,9 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, } catch (e : Exception) { super.shouldInterceptRequest(view, url) } - }else if(url.toLowerCase(Locale.ROOT).contains(".jpg") || url.toLowerCase(Locale.ROOT).contains(".jpeg")){ + } else if(supers) { + super.shouldInterceptRequest(view, url) + } else if(url.toLowerCase(Locale.ROOT).contains(".jpg") || url.toLowerCase(Locale.ROOT).contains(".jpeg")){ try { val bitmap = Glide.with(this@AwesomeWebViewActivity).asBitmap().timeout(30000).diskCacheStrategy(DiskCacheStrategy.ALL).load(url).submit().get() WebResourceResponse("image/jpg", "UTF-8",getBitmapInputStream(bitmap,Bitmap.CompressFormat.JPEG)).apply { @@ -1958,7 +1987,7 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, try { val bitmap = Glide.with(this@AwesomeWebViewActivity).asBitmap().timeout(30000).diskCacheStrategy(DiskCacheStrategy.ALL).load(url).submit().get() WebResourceResponse("image/webp", "UTF-8",getBitmapInputStream(bitmap,Bitmap.CompressFormat.WEBP)).apply { - LogUtil.e("shouldInterceptRequest request url down from Glide >>> ${request.url.toString()}") +// LogUtil.e("shouldInterceptRequest request url down from Glide >>> ${request.url.toString()}") } } catch (e : Exception) { super.shouldInterceptRequest(view, url) @@ -1980,7 +2009,7 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, // } override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { - + mediaUrls.clear() BroadCastManager.onPageStarted(this@AwesomeWebViewActivity, key, url) if (!url.contains("docs.google.com") && url.endsWith(".pdf")) { @@ -2038,7 +2067,15 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean { handler.sendEmptyMessage(MSG_CLICK_ON_URL) - + if (url.contains("http:")) { + var newUrl = url.replace("http:","https:") + LogUtil.e("is StartWith ${url} , ${newUrl}") + if (newUrl.length > 10) { + view.stopLoading() + view.loadUrl(newUrl) + } + return true + } var skipResource = host!= null && ((url.contains(host!!) ?: true) == false) && (host!!.contains("google") == false) if (skipResource || loadWithIntent) { LogUtil.e("shouldOverrideUrlLoading block url $url , host >>>> $host ") diff --git a/library/src/main/res/raw/dlottie_001 b/library/src/main/res/raw/dlottie_001 new file mode 100644 index 00000000..343ea894 Binary files /dev/null and b/library/src/main/res/raw/dlottie_001 differ diff --git a/library/src/main/res/raw/dlottie_002 b/library/src/main/res/raw/dlottie_002 new file mode 100644 index 00000000..6f0050b5 Binary files /dev/null and b/library/src/main/res/raw/dlottie_002 differ diff --git a/library/src/main/res/raw/dlottie_003 b/library/src/main/res/raw/dlottie_003 new file mode 100644 index 00000000..91bc36e8 Binary files /dev/null and b/library/src/main/res/raw/dlottie_003 differ