diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9dbd33df..dcd6be4f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -65,6 +65,8 @@ android { buildFeatures { viewBinding = true dataBinding = true + buildConfig = true + resValues = true } compileOptions { @@ -111,7 +113,12 @@ dependencies { implementation(project(":utils")) // implementation ("org.apache.tika:tika-parsers:1.12") + +// implementation("org.opencv:opencv-android:4.11.0") + + implementation ("androidx.media:media:1.7.0") + implementation(project(":sdk")) // implementation ("me.everything:providers-android:1.0.1") // implementation ("me.everything:providers-core:1.0.1") // implementation ("androidx.window:window:1.0.0") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3702af54..0e830b9b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -109,6 +109,11 @@ + + >> ${ev?.device?.name}") if (ev?.device?.name?.contains("SM-031N Mouse") == true) { @@ -298,6 +299,7 @@ internal class LauncherActivity : CommonActivity() { Blog.LOGE("dispatch dispatchKeyEvent>>> ${ev}") when(ev.keyCode) { KEYCODE_BUTTON_Y->{ + CoroutineScope(Dispatchers.IO).launch { String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9qYXZtb3N0LnRvL2xhdGVzdC11cGRhdGVzCg==".toByteArray())).getJ().let { doc -> FeedParseManager.parse(doc){Blog.LOGE(it)} } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/PhotoFilter.kt b/app/src/main/kotlin/bums/lunatic/launcher/PhotoFilter.kt new file mode 100644 index 00000000..11e3880f --- /dev/null +++ b/app/src/main/kotlin/bums/lunatic/launcher/PhotoFilter.kt @@ -0,0 +1,139 @@ +package bums.lunatic.launcher + +import bums.lunatic.launcher.common.CommonActivity +import android.Manifest +import android.app.Activity +import android.content.Intent +import android.content.pm.PackageManager +import android.graphics.Bitmap +import android.net.Uri +import android.os.Build +import android.os.Bundle +import android.provider.MediaStore +import android.widget.Button +import android.widget.ImageView +import androidx.activity.result.ActivityResultLauncher +import androidx.activity.result.contract.ActivityResultContracts +import androidx.annotation.RequiresApi +import androidx.appcompat.app.AppCompatActivity +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat +import bums.lunatic.launcher.utils.Blog +import org.opencv.android.OpenCVLoader +import org.opencv.android.Utils +import org.opencv.core.Mat +import org.opencv.photo.Photo + +class PhotoFilter : CommonActivity() { + private lateinit var originalImageView: ImageView + private lateinit var filteredImageView: ImageView + private lateinit var selectImageButton: Button + private val PICK_IMAGE_REQUEST = 1 + private val PERMISSION_REQUEST_CODE = 200 + + init { + OpenCVLoader.initDebug() + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.photo_filter) + + originalImageView = findViewById(R.id.originalImageView) + filteredImageView = findViewById(R.id.filteredImageView) + selectImageButton = findViewById(R.id.selectImageButton) + + selectImageButton.setOnClickListener { + Blog.LOGE("imagePickerLauncher checkPermission() ${checkPermission()}") + if (checkPermission()) { + openGallery() + } else { + requestPermission() + } + } + + imagePickerLauncher = registerForActivityResult( + ActivityResultContracts.GetContent(), + {result -> + Blog.LOGE("imagePickerLauncher result ${result}") + if (result != null) { + // Handle the selected image + FilePathUri = result; + try { + var bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), FilePathUri) + Blog.LOGE("imagePickerLauncher result ${result} 2") + originalImageView.setImageBitmap(bitmap) + Blog.LOGE("imagePickerLauncher result ${result} 3") + val filteredBitmap = applyCartoonFilter(bitmap) + Blog.LOGE("imagePickerLauncher result ${result} 4") + filteredImageView.setImageBitmap(filteredBitmap) + } catch (e : Exception ) { + e.printStackTrace(); + } + } + } + ); + } + + var FilePathUri : Uri? = null + + private var imagePickerLauncher : ActivityResultLauncher? = null + + + private fun openGallery() { +// val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI) +// startActivityForResult(intent, PICK_IMAGE_REQUEST) + + imagePickerLauncher?.launch("image/*"); + Blog.LOGE("imagePickerLauncher ") + + } + +// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { +// super.onActivityResult(requestCode, resultCode, data) +// if (requestCode == PICK_IMAGE_REQUEST && resultCode == Activity.RESULT_OK && data != null) { +// val selectedImage = data.data +// val bitmap = MediaStore.Images.Media.getBitmap(contentResolver, selectedImage) +// originalImageView.setImageBitmap(bitmap) +// +// val filteredBitmap = applyCartoonFilter(bitmap) +// filteredImageView.setImageBitmap(filteredBitmap) +// } +// } + + private fun applyCartoonFilter(inputBitmap: Bitmap): Bitmap { + Blog.LOGE("applyCartoonFilter") + val src = Mat() + Blog.LOGE("applyCartoonFilter 2") + Utils.bitmapToMat(inputBitmap, src) + Blog.LOGE("applyCartoonFilter 3") + val dst = Mat() + Blog.LOGE("applyCartoonFilter 4") + Photo.stylization(src, dst, 60f, 0.07f) + + val resultBitmap = Bitmap.createBitmap(inputBitmap.width, inputBitmap.height, Bitmap.Config.ARGB_8888) + Utils.matToBitmap(dst, resultBitmap) + + return resultBitmap + } + + + @RequiresApi(Build.VERSION_CODES.TIRAMISU) + private fun checkPermission(): Boolean { + return ContextCompat.checkSelfPermission(this, Manifest.permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED + } + + @RequiresApi(Build.VERSION_CODES.TIRAMISU) + private fun requestPermission() { + ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_MEDIA_IMAGES), PERMISSION_REQUEST_CODE) + } + + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + if (requestCode == PERMISSION_REQUEST_CODE) { + if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + openGallery() + } + } + } +} \ No newline at end of file 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 d79685fe..78b72ead 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/apps/AppDrawer.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/apps/AppDrawer.kt @@ -36,6 +36,7 @@ import androidx.core.widget.doOnTextChanged import androidx.recyclerview.widget.GridLayoutManager import bums.lunatic.launcher.BuildConfig import bums.lunatic.launcher.LauncherActivity +import bums.lunatic.launcher.LauncherActivity.Companion.lActivity import bums.lunatic.launcher.common.CommonActivity import bums.lunatic.launcher.common.letTrue import bums.lunatic.launcher.databinding.AppDrawerBinding @@ -45,6 +46,7 @@ import bums.lunatic.launcher.helpers.Constants.Companion.PREFS_APP_NAMES import bums.lunatic.launcher.helpers.Constants.Companion.PREFS_SETTINGS import bums.lunatic.launcher.helpers.PrefBoolean import bums.lunatic.launcher.helpers.PrefLong +import bums.lunatic.launcher.helpers.PrefString import bums.lunatic.launcher.model.AppInfo import bums.lunatic.launcher.utils.Blog import bums.lunatic.launcher.utils.JamoUtils @@ -139,7 +141,7 @@ internal class AppDrawer : CommonActivity() { sendMsg() } binding.runTelegram.setOnClickListener { - sendMsg("tg://msg?text=${getInputText()}&to=","org.telegram.messenger") + sendMsg("tg://msg?text=${getInputText()}&to=${PrefString.telegramSendTarget.get()}","org.telegram.messenger") } binding.runKatalk.setOnClickListener { sendMsg(pkg = "com.kakao.talk") @@ -160,6 +162,8 @@ internal class AppDrawer : CommonActivity() { false } } + var packageManager = lActivity?.packageManager + binding.searchInput.setOnLongClickListener { WorkersDb.getRealm().apply { var newQ = query() @@ -168,10 +172,18 @@ internal class AppDrawer : CommonActivity() { if(it.size > 0) { WorkersDb.getRealm().apply { packageList.clear() - packageList.addAll(copyFromRealm(it)) - binding.appsList.post { if (packageList.size > 0) { - appsAdapter?.updateData(packageList) - } } + writeBlocking { + it.filter { + var installed = isPackageInstalled(it.pkgName ?: "fffffffail", packageManager!!) +// it.isInstalled = installed + installed + }.let { result -> + packageList.addAll(copyFromRealm(result)) + binding.appsList.post { if (result.size > 0) { + appsAdapter?.updateData(packageList) + }} + } + } } } } @@ -200,6 +212,14 @@ internal class AppDrawer : CommonActivity() { } // return binding.root } + fun isPackageInstalled( packageName : String, packageManager : PackageManager?) : Boolean{ + try { + packageManager!!.getPackageInfo(packageName, 0) + return true; + } catch ( e : Exception) { + return false; + } + } fun sendMsg(scheme : String? = null , pkg : String? = null) { var postIntent : Intent? = null @@ -317,10 +337,18 @@ internal class AppDrawer : CommonActivity() { if(it.size > 0) { WorkersDb.getRealm().apply { packageList.clear() - packageList.addAll(copyFromRealm(it)) - binding.appsList.post { if (packageList.size > 0) { - appsAdapter?.updateData(packageList) - } } + writeBlocking { + it.filter { + var installed = isPackageInstalled(it.pkgName ?: "fffffffail", packageManager!!) +// it.isInstalled = installed + installed + }.let { result -> + packageList.addAll(copyFromRealm(result)) + binding.appsList.post { if (result.size > 0) { + appsAdapter?.updateData(packageList) + }} + } + } } } } 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 6132764a..42e09de9 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt @@ -25,6 +25,7 @@ import android.content.DialogInterface import android.content.Intent import android.content.IntentFilter import android.content.SharedPreferences +import android.content.pm.PackageManager import android.media.AudioManager import android.net.Uri import android.os.Bundle @@ -37,6 +38,8 @@ import android.view.KeyEvent import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.webkit.WebSettings.LOAD_NO_CACHE +import android.webkit.WebSettings.MIXED_CONTENT_ALWAYS_ALLOW import android.widget.CheckBox import android.widget.EditText import android.widget.TableRow @@ -52,6 +55,7 @@ import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 import bums.lunatic.launcher.LauncherActivity.Companion.lActivity +import bums.lunatic.launcher.PhotoFilter import bums.lunatic.launcher.R import bums.lunatic.launcher.apps.AppsAdapter import bums.lunatic.launcher.behavior.Behavior @@ -85,6 +89,7 @@ import bums.lunatic.launcher.settings.SettingsActivity import bums.lunatic.launcher.utils.Blog import bums.lunatic.launcher.utils.BitmapConverter import bums.lunatic.launcher.utils.SimpleFingerGestures +import bums.lunatic.launcher.utils.USAGT import bums.lunatic.launcher.utils.beforeDay import bums.lunatic.launcher.utils.beforeOneDay import bums.lunatic.launcher.view.TableRadioGroup @@ -108,12 +113,14 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.flow.cancellable import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch +import okhttp3.Dns import org.json.JSONArray import org.json.JSONObject import java.math.BigDecimal import java.math.RoundingMode import java.net.URLEncoder import java.util.Calendar +import kotlin.jvm.java internal class LauncherHome : Fragment() { @@ -231,15 +238,43 @@ internal class LauncherHome : Fragment() { }) - binding.notice.setOnLongClickListener { + binding.favApps.setOnLongClickListener { RssViewBuilder(lActivity!!) .setRssId("https://jav.guru") + .webViewDomStorageEnabled(true) .webViewJavaScriptEnabled(true) - .showIconClose(true).showIconBack(false).showProgressBar(true).backPressToClose(false).webViewMixedContentMode(1) + .webViewUserAgentAppend(false) + .webViewAllowContentAccess(true) + .webViewCookieEnabled(true) + .webViewCacheMode(LOAD_NO_CACHE) + .webViewUserAgentString(USAGT) + .webViewMixedContentMode(MIXED_CONTENT_ALWAYS_ALLOW) + .showIconClose(true) + .showIconBack(false) + .showProgressBar(true) + .backPressToClose(false) + .webViewCookieEnabled(true) .show("https://jav.guru") true } + binding.missedCalls.setOnLongClickListener { + lActivity?.startActivity(Intent(lActivity, PhotoFilter::class.java)) +// RssViewBuilder(lActivity!!) +// .setRssId("https://booktoki468.com/") +// .webViewMixedContentMode(MIXED_CONTENT_ALWAYS_ALLOW) +// .webViewCacheMode(LOAD_NO_CACHE) +// .webViewJavaScriptEnabled(true) +// .webViewUserAgentAppend(false) +// .webViewAllowContentAccess(true) +// .webViewCookieEnabled(true) +// .webViewDomStorageEnabled(true) +// .webViewUserAgentString(USAGT) +// .showIconClose(true).showIconBack(false).showProgressBar(true).backPressToClose(false) +// .show("https://booktoki468.com/") + true + } + arrayListOf(binding.mainList,binding.smsList,binding.infoList,binding.notiList).forEach { try { it.removeOnScrollListener(onScrChanged) @@ -259,6 +294,15 @@ internal class LauncherHome : Fragment() { return binding.root } + fun isPackageInstalled( packageName : String, packageManager : PackageManager?) : Boolean{ + try { + packageManager!!.getPackageInfo(packageName, 0); + return true; + } catch ( e : Exception) { + return false; + } + } + private fun queryApps() { WorkersDb.getRealm().apply { var newQ = query() @@ -266,8 +310,18 @@ internal class LauncherHome : Fragment() { if(it.size > 0) { WorkersDb.getRealm().apply { var packageList = arrayListOf() - packageList.addAll(copyFromRealm(it)) - mAppsAdapter?.updateData(packageList) + writeBlocking { + it.filter { + var installed = isPackageInstalled(it.pkgName ?: "fffffffail", lActivity?.packageManager) +// it.isInstalled = installed + installed + }.let { result -> + packageList.addAll(copyFromRealm(result)) + binding.appsList.post { if (result.size > 0) { + mAppsAdapter?.updateData(packageList) + }} + } + } } } } @@ -495,7 +549,7 @@ internal class LauncherHome : Fragment() { WorkersDb.getRealm().writeBlocking { delete( query() - .query("pubDate < $0", beforeOneDay()) + .query("pubDate < $0", beforeDay(30)) .query("category != $0 AND category != $1 ", RssDataType.GURU.name, RssDataType.MOST.name) .query("vote != $0", true).find() ) @@ -503,24 +557,18 @@ internal class LauncherHome : Fragment() { } fun updateQuery(q: RealmQuery) { - mRssDataResult = q.sort("pubDate ", Sort.DESCENDING).limit(300).distinct("title").find() + mRssDataResult = q.sort("pubDate ", Sort.DESCENDING).limit(300).distinct("originPage", "title").find() 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) } commandHandler.postDelayed(infoUpdate, UPDATE_DELAY) -// } -// else -> { - -// } -// } } } infosJob?.start() @@ -539,7 +587,7 @@ internal class LauncherHome : Fragment() { filter: Collection? = arrayListOf(RssDataType.GURU, RssDataType.MOST,RssDataType.REDDIT_NSFW), noLimit: Boolean = false ) { beforeQuery() - var rQ = WorkersDb.getRealm().query().query("read < $0", nomoreShowCount).distinct("originPage").distinct("title") + var rQ = WorkersDb.getRealm().query().query("read < $0", nomoreShowCount).distinct("originPage", "title") if (!noLimit) rQ.query("pubDate > $0", beforeOneDay()) ((filter?.size ?: 0) > 0).letTrue {filter!!.forEach {rQ = rQ.query("category != $0", it.name)}} updateQuery(rQ) @@ -820,39 +868,39 @@ internal class LauncherHome : Fragment() { override fun onSwiped(@NonNull viewHolder: RecyclerView.ViewHolder, direction: Int) { Blog.LOGE("onSwiped direction >>>> $direction") (viewHolder.itemView.tag as? RssData)?.let { rss -> - WorkersDb.getRealm().apply { - writeBlocking { - when(direction) { - ItemTouchHelper.LEFT->{ - if (rssStateVote() && rss.vote) { - rss.vote = false - rss.read = 0 - } else { - rss.read += nomoreShowCount - } -// 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())) { + CoroutineScope(Dispatchers.IO).launch { + WorkersDb.getRealm().apply { + writeBlocking { + when (direction) { + ItemTouchHelper.LEFT -> { + if (rssStateVote() && rss.vote) { + rss.vote = false + rss.read = 0 + } else { + rss.read += nomoreShowCount + } + query( + "originPage == $0", + rss.originPage + ).find().forEach { it -> it.read += nomoreShowCount } } - } - ItemTouchHelper.RIGHT->{ - if (rssStateVote() && rss.vote) { - rss.vote = false - rss.read = 0 - } else { - rss.vote = true + ItemTouchHelper.RIGHT -> { + if (rssStateVote() && rss.vote) { + rss.vote = false + rss.read = 0 + } else { + rss.vote = true + + } } -// copyToRealm(rss,UpdatePolicy.ALL) + + else -> {} } - else ->{} + binding.infoList.post { mRssAdapter.refresh() } } -// binding.infoList.post { mRssAdapter.refresh() } } } } 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 eb99ceb8..c57c53fd 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewerActivity.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewerActivity.kt @@ -4,6 +4,7 @@ import android.content.ClipData import android.content.ClipboardManager import android.content.Context import android.content.Intent +import android.net.Uri import android.os.Bundle import android.print.PDFPrint import android.util.Base64 @@ -34,7 +35,10 @@ 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 com.google.gson.Gson +import io.realm.kotlin.UpdatePolicy import io.realm.kotlin.ext.query +import io.realm.kotlin.ext.realmListOf import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -411,11 +415,15 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene override fun bindViews() { super.bindViews() - if (this.rssId.contains(".guru")) { + if (this.rssId.contains(".guru")|| this.rssId.contains("bookto")) { + webView?.clearCache(true) Blog.LOGE("this.webView >>>> ${this.rssId}") Blog.LOGE("this.webView >>>> ${this.webView}") - webView?.alpha = 0.2f + if (this.rssId.contains(".guru")) webView?.alpha = 0.2f + webView?.addJavascriptInterface(gji, "GJI") + + } } @@ -520,13 +528,21 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene 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("[","")}") + if (rssId.contains("guru")) { + 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("[", "")}") + } } } + } else if(rssId.contains("book")){ + Jsoup.parse(it)?.let { book -> + Blog.LOGE("book.title() >>> ${book.title()}") + + } } } } @@ -655,18 +671,23 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene + var isFirst = true override fun webviewOnPageFinished() { 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 { + } + else if(rssId.contains("booktoki")) { + registCancelSearch() + webView?.postDelayed(2000L,{ + + }) + } + else { double = false registCancelSearch() if (hasYoutubePlayer) { @@ -685,7 +706,6 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene } } - // if (loadWithIntent) { webView?.evaluateJavascript( "try{document.querySelector('meta[name=viewport]').setAttribute('content','initial-scale=1.0')}catch(e){}", @@ -720,4 +740,24 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene } } } -} \ No newline at end of file + + inner class BookHelper { + @JavascriptInterface + fun sendValueFromHtml(string: String) { + + Jsoup.parse(string)?.let { html -> + + val toon_intro = html.getElementsByClass("toon_index")?.first() + val view_padding = html.select("#bo_v_con") + if (toon_intro != null) { + + }else if (view_padding.size > 0){ +// + } else { + Blog.LOGE("finishedUrl >>> ${rssId} :::: ${html.title()}") + + } + } + } + } +} diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/AppInfo.kt b/app/src/main/kotlin/bums/lunatic/launcher/model/AppInfo.kt index b97c5e51..8edb077c 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/model/AppInfo.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/model/AppInfo.kt @@ -17,4 +17,5 @@ class AppInfo : RealmObject { var lastUseDate : Long = 0L var category : String? = null var currentInstalled : Boolean = false + var isInstalled : Boolean = false } \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt b/app/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt index 6d270974..94d5f9a7 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt @@ -8,7 +8,7 @@ import java.util.Date class UserActionModel: RealmObject { var actionType: String = "" - var timestamp: Date = Date() +// var timestamp: Date = Realm() var weekOfYear : Int = 0 var weekOfMonth : Int = 0 @@ -22,19 +22,19 @@ class UserActionModel: RealmObject { 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) +// 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/workers/ClienGetter.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/ClienGetter.kt index 67c2688b..a80a0be4 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/ClienGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/ClienGetter.kt @@ -33,6 +33,9 @@ class ClienGetter : BaseGetter { Clien().let { c -> c.title = title c.link = "https://www.clien.net".plus(link) + if (c.link?.contains("?") == true) { + try { c.link = c.link?.split("?")?.first() }catch (e : Exception) {} + } c.desc = desc c.dateTiem = timeStamp if (c.pubDate() > limitDateTime) { 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 92b76881..ce2634fd 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/DCGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/DCGetter.kt @@ -84,7 +84,6 @@ class DCGetter : BaseGetter { "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" ) 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 c4e1b1c9..6276d0ca 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/FmKoreaGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/FmKoreaGetter.kt @@ -18,6 +18,20 @@ class FmKoreaGetter : BaseGetter { } + fun extractDocumentSrl(url: String): String? { + val uri = java.net.URI(url) + val query = uri.query ?: return null // 쿼리 문자열이 없으면 null 반환 + + val params = query.split("&") + for (param in params) { + val parts = param.split("=") + if (parts.size == 2 && parts[0] == "document_srl") { + return "${uri.scheme}://${uri.host}${uri.path}?document_srl=${parts[1]}" + } + } + return null // document_srl 파라미터를 찾지 못하면 null 반환 + } + @SuppressLint("RestrictedApi") override fun realWork(): Result { RssDataType.FMKORAE.isOn { @@ -41,9 +55,19 @@ class FmKoreaGetter : BaseGetter { fmkorea_li.getElementsByClass("thumb") .attr("data-original") ) - val pageUrl = "https://www.fmkorea.com".plus( + var pageUrl = "https://www.fmkorea.com".plus( fmkorea_li.getElementsByTag("a").get(0).attr("href") ) + try { + val originalUrl = pageUrl + val extractedUrl = extractDocumentSrl(originalUrl) + if (extractedUrl != null) { + pageUrl = extractedUrl + } else { + + } + } catch (e: Exception) {} + val desc = fmkorea_li.getElementsByClass("category").text() val date = fmkorea_li.getElementsByClass("regdate").text() FmKorea(pageUrl, desc, date, title, tumb).apply { diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/TheQooGetter.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/TheQooGetter.kt index f8011b1e..ee26c0c6 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/TheQooGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/TheQooGetter.kt @@ -33,6 +33,11 @@ class TheQooGetter : BaseGetter { TheQoo().let { tq -> tq.title = title tq.link = "https://theqoo.net".plus(pageLink) + if (tq.link?.contains("?") == true) { + try { + tq.link = tq.link?.split("?")?.first() + }catch (e:Exception){} + } tq.dateTiem = dateTime tq.desc = desc if (tq.pubDate() > limitDateTime) { 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 94a7d055..85cbcf82 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt @@ -58,15 +58,16 @@ object WorkersDb { 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() +// 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,UserActionModel::class + LocationLog::class ) + //,UserActionModel::class val schemaVersion : Long = BuildConfig.BuildDateTime @@ -89,7 +90,9 @@ object WorkersDb { getRealm().apply { this.writeBlocking { try { - this.copyToRealm(rssData, UpdatePolicy.ERROR) + if (query("originPage == $0", rssData.originPage).find().isEmpty()) { + this.copyToRealm(rssData, UpdatePolicy.ERROR) + } } catch (e : Exception) { } @@ -103,12 +106,19 @@ object WorkersDb { try { getRealm().writeBlocking { try { - 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 if(!catfillters.contains(it.category())){ - this.copyToRealm(it, UpdatePolicy.ERROR) + rssDatas.forEach { t -> + if (query("originPage == $0", t.originPage).find().isEmpty()) { +// 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(t, UpdatePolicy.ERROR) +// } else if(!catfillters.contains(it.category())){ +// this.copyToRealm(it, UpdatePolicy.ERROR) +// } else { +// +// } + } } + } catch (e : Exception) { } @@ -206,7 +216,7 @@ object WorkersDb { } } - fun getVotedRss() = getRealm().query().query("vote == $0", true).distinct("originPage").distinct("title") + fun getVotedRss() = getRealm().query().query("vote == $0", true).distinct("originPage", "title") fun getRssQuery(keyword: String?, category: Collection? = arrayListOf(), @@ -241,7 +251,7 @@ object WorkersDb { if (keyword?.length ?: 0 == 0 && category?.size ?: 0 == 0) { rQ = rQ.query("read < $0", 3).query("vote != $0", true) } - return rQ.distinct("originPage").distinct("title") + return rQ.distinct("originPage", "title") } } \ No newline at end of file diff --git a/app/src/main/res/layout/photo_filter.xml b/app/src/main/res/layout/photo_filter.xml new file mode 100644 index 00000000..467cd946 --- /dev/null +++ b/app/src/main/res/layout/photo_filter.xml @@ -0,0 +1,36 @@ + + + +