...
This commit is contained in:
@@ -21,6 +21,7 @@ package bums.lunatic.launcher
|
||||
//import rasel.lunar.launcher.home.LauncherHome.Companion.rssSet
|
||||
|
||||
import android.Manifest
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.NotificationManager
|
||||
import android.appwidget.AppWidgetManager
|
||||
@@ -85,7 +86,6 @@ import bums.lunatic.launcher.helpers.Constants.Companion.PREFS_FIRST_LAUNCH
|
||||
import bums.lunatic.launcher.helpers.Constants.Companion.PREFS_SETTINGS
|
||||
import bums.lunatic.launcher.helpers.Constants.Companion.widgetHostId
|
||||
import bums.lunatic.launcher.helpers.PrefHelper
|
||||
import bums.lunatic.launcher.helpers.ViewPagerAdapter
|
||||
import bums.lunatic.launcher.helpers.letTrue
|
||||
import bums.lunatic.launcher.home.LauncherHome
|
||||
import bums.lunatic.launcher.home.LauncherHome.Companion.lastedFinishedPageUrl
|
||||
@@ -142,7 +142,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: LauncherActivityBinding
|
||||
private lateinit var settingsPrefs: SharedPreferences
|
||||
lateinit var viewPager: ViewPager2
|
||||
// lateinit var viewPager: ViewPager2
|
||||
|
||||
companion object {
|
||||
private var mWorkManager: WorkManager? = null
|
||||
@@ -335,6 +335,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
|
||||
@@ -379,16 +380,37 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}
|
||||
// BLog.LOGE("onNewIntent intent?.dataString >> ${intent?.dataString}")
|
||||
// BLog.LOGE("onNewIntent intent?.data >> ${intent?.data}")
|
||||
} else {
|
||||
BLog.LOGE("onNewIntent intent?.hasExtra >> ${intent?.hasExtra(Intent.EXTRA_STREAM)}")
|
||||
|
||||
|
||||
if (intent?.action?.equals(Intent.ACTION_MAIN) == true && intent.categories.contains(
|
||||
Intent.CATEGORY_HOME
|
||||
) && intent.hasExtra("android.intent.extra.EXTRA_START_REASON") && intent.getStringExtra(
|
||||
"android.intent.extra.EXTRA_START_REASON"
|
||||
).equals("startDockOrHome")
|
||||
) {
|
||||
if (binding.home.visibility == View.VISIBLE) {
|
||||
switchAppDrawer()
|
||||
}
|
||||
} else {
|
||||
intent?.extras?.keySet()?.forEach {
|
||||
try {
|
||||
BLog.LOGE(
|
||||
"onNewIntent :: key >> ${it} :: value >> ${
|
||||
intent?.extras?.getString(
|
||||
it
|
||||
)
|
||||
}"
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
BLog.LOGE("onNewIntent intent?.hasExtra >> ${intent?.hasExtra(Intent.EXTRA_STREAM)}")
|
||||
|
||||
|
||||
intent?.extras?.keySet()?.forEach {
|
||||
try {
|
||||
BLog.LOGE("onNewIntent :: key >> ${it} :: value >> ${intent?.extras?.getString(it)}")
|
||||
} catch (e : Exception) {e.printStackTrace()}
|
||||
|
||||
}
|
||||
// android.intent.extra.EXTRA_START_REASON :: value >> startDockOrHome
|
||||
|
||||
|
||||
// binding.viewPager.invalidate()
|
||||
@@ -397,13 +419,13 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
// }
|
||||
super.onNewIntent(intent)
|
||||
}
|
||||
|
||||
lateinit var home : LauncherHome
|
||||
@SuppressLint("NewApi", "MissingPermission")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
installSplashScreen()
|
||||
mWorkManager = WorkManager.getInstance(this)
|
||||
DynamicColors.applyToActivityIfAvailable(this)
|
||||
|
||||
lActivity = this
|
||||
|
||||
settingsPrefs = getSharedPreferences(PREFS_SETTINGS, 0)
|
||||
AppCompatDelegate.setDefaultNightMode(settingsPrefs.getInt(KEY_APPLICATION_THEME, MODE_NIGHT_FOLLOW_SYSTEM))
|
||||
@@ -412,8 +434,6 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
binding = LauncherActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
lActivity = this
|
||||
appWidgetManager = AppWidgetManager.getInstance(applicationContext)
|
||||
appWidgetHost = WidgetHost(applicationContext, widgetHostId)
|
||||
appWidgetHost?.startListening()
|
||||
@@ -421,7 +441,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
/* if this is the first launch,
|
||||
then remember the event and show the welcome dialog */
|
||||
welcomeDialog()
|
||||
setupView()
|
||||
home = binding.home.getFragment<LauncherHome>()
|
||||
|
||||
/* handle navigation back events */
|
||||
handleBackPress()
|
||||
@@ -570,19 +590,45 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
/* set up viewpager2 */
|
||||
private fun setupView() {
|
||||
viewPager = binding.viewPager.apply {
|
||||
adapter = ViewPagerAdapter(
|
||||
supportFragmentManager,
|
||||
mutableListOf(Feeds(), LauncherHome(), AppDrawer()),
|
||||
lifecycle
|
||||
)
|
||||
offscreenPageLimit = 1
|
||||
setCurrentItem(1, false)
|
||||
reduceDragSensitivity()
|
||||
val feeds by lazy { Feeds() }
|
||||
val appDrawer by lazy { AppDrawer() }
|
||||
|
||||
fun switchFeeds(){
|
||||
if(supportFragmentManager.findFragmentByTag("Feeds") == null){
|
||||
val transaction = supportFragmentManager.beginTransaction()
|
||||
transaction.add(R.id.feeds, feeds,"Feeds")
|
||||
transaction.commit()
|
||||
}
|
||||
if(binding.feeds.visibility == View.GONE) {
|
||||
binding.home.visibility = View.GONE
|
||||
binding.feeds.visibility = View.VISIBLE
|
||||
supportFragmentManager.beginTransaction().show(feeds).commit()
|
||||
} else {
|
||||
binding.feeds.visibility = View.GONE
|
||||
binding.home.visibility = View.VISIBLE
|
||||
supportFragmentManager.beginTransaction().hide(feeds).commit()
|
||||
}
|
||||
}
|
||||
fun switchAppDrawer() {
|
||||
if(supportFragmentManager.findFragmentByTag("AppDrawer") == null){
|
||||
val transaction = supportFragmentManager.beginTransaction()
|
||||
transaction.add(R.id.app_drawer, appDrawer,"AppDrawer")
|
||||
transaction.commit()
|
||||
}
|
||||
if(binding.appDrawer.visibility == View.GONE) {
|
||||
supportFragmentManager.beginTransaction().show(appDrawer).commit()
|
||||
binding.home.visibility = View.GONE
|
||||
binding.appDrawer.visibility = View.VISIBLE
|
||||
appDrawer.openSearch()
|
||||
} else {
|
||||
supportFragmentManager.beginTransaction().hide(appDrawer).commit()
|
||||
binding.home.visibility = View.VISIBLE
|
||||
binding.appDrawer.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private fun setBgColor() {
|
||||
binding.root.setBackgroundColor(Color.parseColor("#22000000"))
|
||||
@@ -614,11 +660,14 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
private fun handleBackPress() {
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
/* while in to-do manager, go back to home screen */
|
||||
if (supportFragmentManager.backStackEntryCount != 0) supportFragmentManager.popBackStack()
|
||||
|
||||
/* while in feeds or app drawer, go back to home screen */
|
||||
if (viewPager.currentItem != 1) viewPager.currentItem = 1
|
||||
if (binding.feeds.visibility == View.VISIBLE) {
|
||||
switchFeeds()
|
||||
} else if (binding.appDrawer.visibility == View.VISIBLE) {
|
||||
switchAppDrawer()
|
||||
} else if (binding.home.visibility == View.VISIBLE) {
|
||||
switchAppDrawer()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -637,19 +686,6 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun ViewPager2.reduceDragSensitivity() {
|
||||
ViewPager2::class.java.getDeclaredField("mRecyclerView").apply {
|
||||
isAccessible = true
|
||||
}.let { recyclerViewField ->
|
||||
(recyclerViewField.get(this) as RecyclerView).let { recyclerView ->
|
||||
RecyclerView::class.java.getDeclaredField("mTouchSlop").apply {
|
||||
isAccessible = true
|
||||
set(recyclerView, this.get(recyclerView) as Int * 8)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun openSearchMenus(keyword : String, dismissCalback: DismissCalback) {
|
||||
SearchMenu().show(supportFragmentManager,keyword) {dismissCalback?.invoke()}
|
||||
}
|
||||
@@ -678,137 +714,6 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
startActivity(mapIntent)
|
||||
}
|
||||
|
||||
// fun doWebSavor(url : String, callBack :CommadCallabck?) {
|
||||
// if (true)return
|
||||
// this.callBack = callBack
|
||||
//
|
||||
// binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE }
|
||||
// BLog.LOGE("binding.otherCheck before ThreadRun")
|
||||
// binding.searcher01.bringToFront()
|
||||
// binding.searcher01.alpha = 1f
|
||||
// binding.searcher01.webViewClient = object : WebViewClient() {
|
||||
// override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
|
||||
// if (url?.contains("missav") == true && isF) {
|
||||
// BLog.LOGE("binding.otherCheck before reload")
|
||||
// view?.loadUrl(url!!)
|
||||
// isF = true
|
||||
// return false
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
|
||||
// BLog.LOGE("binding.otherCheck searcher01 in onPageStarted ${url}")
|
||||
// super.onPageStarted(view, url, favicon)
|
||||
// }
|
||||
// override fun onReceivedError(
|
||||
// view: WebView?,
|
||||
// request: WebResourceRequest?,
|
||||
// error: WebResourceError?
|
||||
// ) {
|
||||
//
|
||||
// }
|
||||
// override fun onReceivedSslError(
|
||||
// view: WebView?,
|
||||
// handler: SslErrorHandler?,
|
||||
// error: SslError?
|
||||
// ) {
|
||||
// handler?.proceed()
|
||||
// }
|
||||
//
|
||||
// override fun onPageFinished(view: WebView?, url: String?) {
|
||||
// super.onPageFinished(view, url)
|
||||
// autoScrollDown(view,url)
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// WebView.setWebContentsDebuggingEnabled(false)
|
||||
// binding.searcher01.apply {
|
||||
// setBackgroundColor(Color.WHITE) // 백그라운드 색상 설정
|
||||
// setLayerType(View.LAYER_TYPE_SOFTWARE, null) // 랜더링 이슈 해결
|
||||
// try {
|
||||
// settings.apply {
|
||||
// userAgentString = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"
|
||||
// javaScriptEnabled = true // 자바스크립트 사용 가능하도록 설정
|
||||
// loadWithOverviewMode = true // 전체 웹페이지를 화면에 맞게 로드
|
||||
// useWideViewPort = true // 화면에 맞게 페이지 확대/축소
|
||||
// domStorageEnabled = true // DOM 저장소 사용 가능하도록 설정
|
||||
// setSupportMultipleWindows(true)
|
||||
// javaScriptCanOpenWindowsAutomatically = true // 팝업창 차단 해제
|
||||
// cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK
|
||||
// textZoom = 100 // system 에 의한 글꼴 변형 방지
|
||||
// defaultTextEncodingName = "UTF-8" // 인코딩 설정
|
||||
// allowContentAccess = true // 웹뷰를 통해 content url에 접근할지 여부
|
||||
// layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING // 웹페이지의 레이아웃을 화면에 맞게 자동으로 조정
|
||||
// }
|
||||
// } catch (ignore: NoSuchMethodError) {
|
||||
//
|
||||
// }.apply {
|
||||
// loadUrl(url) // 웹페이지 연결
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// fun autoScrollDown(webView: WebView?, url: String?) {
|
||||
// webView?.let { webView ->
|
||||
// val ramdomTimeSec =
|
||||
// 800L.plus(Math.abs(Random(System.currentTimeMillis()).nextLong().rem(489L)))
|
||||
// BLog.LOGE("ramdomTime >>> ${ramdomTimeSec}")
|
||||
// if (((webView?.scrollY ?: 0) + (webView?.height
|
||||
// ?: 0)) < webView?.contentHeight ?: 0
|
||||
// ) {
|
||||
// webView?.postDelayed({
|
||||
// webView?.scrollY = (binding.searcher01.scrollY) + (binding.searcher01.height.toFloat() * 0.4).toInt()
|
||||
// autoScrollDown(webView, url)
|
||||
// }, ramdomTimeSec)
|
||||
// } else {
|
||||
// webView?.postDelayed({
|
||||
// binding.viewPager.bringToFront()
|
||||
// binding.searcher01.alpha = 0f
|
||||
// if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) {
|
||||
// val fileName = url?.toUri()?.path?.replace("/","_")?.replace(".","_")
|
||||
// val path = File(Environment.getExternalStorageDirectory(),"bums")
|
||||
// if (path.exists() == false) {
|
||||
// path.mkdirs()
|
||||
// }
|
||||
// val file = File(path, fileName.plus(".pdf"))
|
||||
//
|
||||
// BLog.LOGE("file >>> ${file.absolutePath}")
|
||||
// try {
|
||||
// PDFPrint.generatePDFFromWebView(file,webView, object : PDFPrint.OnPDFPrintListener {
|
||||
// override fun onSuccess(file: File?) {
|
||||
// BLog.LOGE("file >>>> ${file!!.absolutePath}")
|
||||
// val shareIntent: Intent = Intent().apply {
|
||||
// action = Intent.ACTION_SEND
|
||||
// this.`package` = "com.synology.dsdrive"
|
||||
// val imageUri = FileProvider.getUriForFile(
|
||||
// this@LauncherActivity,
|
||||
// "rasel.lunar.launcher.debug.fileprovider", //(use your app signature + ".provider" )
|
||||
// file
|
||||
// )
|
||||
// putExtra(Intent.EXTRA_STREAM, imageUri)
|
||||
// type = "pdf"
|
||||
// }
|
||||
// this@LauncherActivity.startActivity(shareIntent)
|
||||
// }
|
||||
//
|
||||
// override fun onError(exception: java.lang.Exception?) {
|
||||
// Toast.makeText(this@LauncherActivity,
|
||||
// "Pdf Save Failk ${exception?.localizedMessage}", Toast.LENGTH_LONG).show()
|
||||
// exception?.printStackTrace()
|
||||
// }
|
||||
// } )
|
||||
// } catch (e: IOException) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
// }, ramdomTimeSec)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
var callBack : CommadCallabck? = null
|
||||
var isF = false
|
||||
fun doWebParseStart(url : String, callBack :CommadCallabck?) {
|
||||
@@ -1084,7 +989,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
var postNext : Runnable = Runnable{
|
||||
callBack?.collectComplete()
|
||||
callBack?.collectComplete()
|
||||
}
|
||||
|
||||
val callBackHandler = Handler(Looper.getMainLooper())
|
||||
|
||||
@@ -73,7 +73,7 @@ internal class AppDrawer : Fragment() {
|
||||
private var isKeyboardShowing: Boolean = false
|
||||
|
||||
companion object {
|
||||
private var packageManager: PackageManager? = null
|
||||
lateinit var packageManager: PackageManager
|
||||
private var appsAdapter: AppsAdapter? = null
|
||||
private var contactAdapter : ContactAdapter? = null
|
||||
private var packageList = mutableListOf<AppInfo>()
|
||||
@@ -104,15 +104,26 @@ internal class AppDrawer : Fragment() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
packageManager = lActivity?.packageManager!!
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
}
|
||||
|
||||
fun getInputText() = binding.searchInput.text.toString()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
|
||||
binding = AppDrawerBinding.inflate(inflater, container, false)
|
||||
|
||||
settingsPrefs = requireContext().getSharedPreferences(PREFS_SETTINGS, 0)
|
||||
appNamesPrefs = requireContext().getSharedPreferences(PREFS_APP_NAMES, 0)
|
||||
layoutType = settingsPrefs!!.getInt(KEY_APPS_LAYOUT, 0)
|
||||
packageManager = lActivity?.packageManager
|
||||
|
||||
appsAdapter = AppsAdapter(layoutType, packageManager!!, childFragmentManager, binding.appsCount)
|
||||
contactAdapter = ContactAdapter(packageManager!!, childFragmentManager)
|
||||
|
||||
@@ -277,9 +288,10 @@ internal class AppDrawer : Fragment() {
|
||||
fetchApps()
|
||||
|
||||
binding.appsCount.visibility = if (PrefBoolean.showAppResultCount.get(false)) VISIBLE else GONE
|
||||
|
||||
PrefBoolean.openWithKayboard.get().letTrue { openSearch() }
|
||||
registCancelSearch()
|
||||
if (isAdded && isVisible) {
|
||||
PrefBoolean.openWithKayboard.get().letTrue { openSearch() }
|
||||
registCancelSearch()
|
||||
}
|
||||
// BLog.LOGE("onResume after chechHandler.postDelayed(cancelSearch, 3000L)")
|
||||
}
|
||||
|
||||
@@ -468,13 +480,17 @@ internal class AppDrawer : Fragment() {
|
||||
registCancelSearch()
|
||||
}
|
||||
|
||||
private fun openSearch() {
|
||||
binding.searchInput.apply {
|
||||
visibility = VISIBLE
|
||||
requestFocus()
|
||||
let {
|
||||
(lActivity?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager)?.showSoftInput(it, InputMethodManager.SHOW_IMPLICIT)
|
||||
fun openSearch() {
|
||||
try {
|
||||
binding.searchInput.apply {
|
||||
visibility = VISIBLE
|
||||
requestFocus()
|
||||
let {
|
||||
(lActivity?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager)?.showSoftInput(it, InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
}
|
||||
} catch (e : UninitializedPropertyAccessException) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -283,8 +283,8 @@ internal class AppMenu : BottomSheetDialogFragment() {
|
||||
/* show activity list */
|
||||
val activityAdapter: ArrayAdapter<String> =
|
||||
ArrayAdapter(requireContext(), R.layout.list_item, R.id.itemText, ArrayList())
|
||||
if (activityInfo.activities.isNotEmpty()) {
|
||||
for (activity in activityInfo.activities) {
|
||||
if (activityInfo.activities?.isNotEmpty() == true) {
|
||||
for (activity in activityInfo.activities!!) {
|
||||
if (packageName.contains("com.kakao") == true) {
|
||||
// BLog.LOGE("activity. >>>>> ${Gson().toJson(activity)}")
|
||||
}
|
||||
@@ -418,14 +418,14 @@ internal class AppMenu : BottomSheetDialogFragment() {
|
||||
packageManager.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS)
|
||||
}
|
||||
|
||||
return if (packageInfo.requestedPermissions.isNotEmpty()) {
|
||||
return if (packageInfo.requestedPermissions?.isNotEmpty() == true) {
|
||||
val stringBuilder = StringBuilder()
|
||||
packageInfo.requestedPermissions.indices.forEach { i: Int ->
|
||||
if (i != packageInfo.requestedPermissions.size - 1)
|
||||
stringBuilder.append("${packageInfo.requestedPermissions[i]}\n\n")
|
||||
packageInfo.requestedPermissions?.indices?.forEach { i: Int ->
|
||||
if (i != packageInfo.requestedPermissions!!.size - 1)
|
||||
stringBuilder.append("${packageInfo.requestedPermissions!![i]}\n\n")
|
||||
/* don't add any new line after the last entry */
|
||||
else
|
||||
stringBuilder.append(packageInfo.requestedPermissions[i])
|
||||
stringBuilder.append(packageInfo.requestedPermissions!![i])
|
||||
}
|
||||
stringBuilder.toString()
|
||||
} else {
|
||||
|
||||
@@ -34,12 +34,15 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.SystemClock
|
||||
import android.provider.AlarmClock
|
||||
import android.view.Gravity
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.CheckBox
|
||||
import android.widget.EditText
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.TableRow
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.NonNull
|
||||
@@ -246,31 +249,33 @@ 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) {
|
||||
|
||||
// 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 if (binding.otherCheck.isSelected) {
|
||||
//// searchData()
|
||||
//// }
|
||||
// else {
|
||||
// QuickAccess().show(fragManager, BOTTOM_SHEET_TAG)
|
||||
// }
|
||||
// else if (binding.otherCheck.isSelected) {
|
||||
// searchData()
|
||||
// }
|
||||
// else if (binding.otherCheck.isSelected) {
|
||||
// searchData()
|
||||
// }
|
||||
else {
|
||||
QuickAccess().show(fragManager, BOTTOM_SHEET_TAG)
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
arrayListOf(binding.mainList,binding.smsList,binding.infoList,binding.notiList).forEach {
|
||||
try {
|
||||
it.removeOnScrollListener(onScrChanged)
|
||||
@@ -415,21 +420,6 @@ internal class LauncherHome : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// .asFlow()
|
||||
// .collect { changes ->
|
||||
// if (changes.list.size > 0) {
|
||||
// Handler(Looper.getMainLooper()).post {
|
||||
// mWeatherAdapter?.let {
|
||||
// it.update(
|
||||
// mutableListOf<Hour>().apply {
|
||||
// this.addAll(it.filter(changes.list))
|
||||
// }
|
||||
// )
|
||||
// it.notifyDataSetChanged()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -545,11 +535,12 @@ internal class LauncherHome : Fragment() {
|
||||
rssStateVote = true
|
||||
}
|
||||
|
||||
//RssDataType.GURU,
|
||||
// RssDataType.MOST,
|
||||
// RssDataType.REDDIT_NSFW
|
||||
fun queryInfos(
|
||||
filter: Collection<RssDataType>? = arrayListOf(
|
||||
RssDataType.GURU,
|
||||
RssDataType.MOST,
|
||||
RssDataType.REDDIT_NSFW
|
||||
|
||||
), noLimit: Boolean = false
|
||||
) {
|
||||
beforeQuery()
|
||||
@@ -607,9 +598,11 @@ internal class LauncherHome : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
rootViewGestures()
|
||||
batteryProgressGestures()
|
||||
todosGestures()
|
||||
binding.batteryProgress.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.batteryProgress, mFingerGestureListener))
|
||||
binding.root.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.root, mFingerGestureListener))
|
||||
binding.functionLayer.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.functionLayer, mFingerGestureListener))
|
||||
binding.time.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.time, mFingerGestureListener))
|
||||
|
||||
BLog.LOGE("onViewCreated()")
|
||||
binding.missedCalls.visibility =
|
||||
if (PrefBoolean.showCallHistory.get(false)) View.VISIBLE else View.GONE
|
||||
@@ -721,6 +714,8 @@ internal class LauncherHome : Fragment() {
|
||||
enableSwipeToDeleteAndUndo()
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun searchData() {
|
||||
val builder: AlertDialog.Builder = AlertDialog.Builder(requireContext())
|
||||
builder.setTitle("Command Line")
|
||||
@@ -863,29 +858,45 @@ internal class LauncherHome : Fragment() {
|
||||
private fun enableSwipeToDeleteAndUndo() {
|
||||
val swipeToDeleteCallback: SwipeToDeleteCallback =
|
||||
object : SwipeToDeleteCallback(requireContext()) {
|
||||
override fun onSwiped(@NonNull viewHolder: RecyclerView.ViewHolder, i: Int) {
|
||||
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 {
|
||||
if(query<RssData>("chosung == $0",rss.chosung).find().size == 1) {
|
||||
if (rssStateVote && rss.vote) {
|
||||
rss.vote = false
|
||||
rss.read = 0
|
||||
} else {
|
||||
rss.read += nomoreShowCount
|
||||
}
|
||||
copyToRealm(rss, UpdatePolicy.ALL)
|
||||
} else {
|
||||
query<RssData>("chosung == $0",rss.chosung).find().forEach { it ->
|
||||
when(direction) {
|
||||
ItemTouchHelper.LEFT->{
|
||||
if (rssStateVote && rss.vote) {
|
||||
it.vote = false
|
||||
it.read = 0
|
||||
rss.vote = false
|
||||
rss.read = 0
|
||||
} else {
|
||||
it.read += nomoreShowCount
|
||||
rss.read += nomoreShowCount
|
||||
}
|
||||
copyToRealm(rss, UpdatePolicy.ALL)
|
||||
query<RssData>("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)
|
||||
}
|
||||
}
|
||||
copyToRealm(it, UpdatePolicy.ALL)
|
||||
}
|
||||
ItemTouchHelper.RIGHT->{
|
||||
if (rssStateVote && rss.vote) {
|
||||
rss.vote = false
|
||||
rss.read = 0
|
||||
} else {
|
||||
rss.vote = true
|
||||
|
||||
}
|
||||
copyToRealm(rss,UpdatePolicy.ALL)
|
||||
}
|
||||
else ->{}
|
||||
}
|
||||
binding.infoList.post { mRssAdapter.refresh() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -953,7 +964,9 @@ internal class LauncherHome : Fragment() {
|
||||
)
|
||||
startActivity(startIntene)
|
||||
}
|
||||
|
||||
1->{
|
||||
lActivity?.switchAppDrawer()
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
return false
|
||||
@@ -1009,6 +1022,22 @@ internal class LauncherHome : Fragment() {
|
||||
// mClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
// startActivity(mClockIntent)
|
||||
// }
|
||||
|
||||
BLog.LOGE("onSwipeLeft targetView. >>>> ${targetView} && ${targetView.equals(binding.functionLayer)}")
|
||||
if(targetView.equals(binding.functionLayer)){
|
||||
targetView?.performHapticFeedback(HapticFeedbackConstants.CONFIRM)
|
||||
when(fingers) {
|
||||
1->lActivity?.switchAppDrawer()
|
||||
2-> {
|
||||
|
||||
}
|
||||
else ->{}
|
||||
}
|
||||
} else if (targetView.equals(binding.time)) {
|
||||
val mClockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS)
|
||||
mClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(mClockIntent)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1018,8 +1047,16 @@ internal class LauncherHome : Fragment() {
|
||||
gestureDuration: Long,
|
||||
gestureDistance: Double
|
||||
): Boolean {
|
||||
if (targetView.equals(binding.time)) {
|
||||
|
||||
if(targetView.equals(binding.functionLayer)){
|
||||
targetView?.performHapticFeedback(HapticFeedbackConstants.CONFIRM)
|
||||
when(fingers) {
|
||||
1->lActivity?.switchFeeds()
|
||||
else ->{}
|
||||
}
|
||||
} else if (targetView.equals(binding.time)) {
|
||||
val intent = Intent(Intent.ACTION_MAIN)
|
||||
intent.addCategory(Intent.CATEGORY_APP_CALENDAR)
|
||||
startActivity(intent)
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -1030,6 +1067,7 @@ internal class LauncherHome : Fragment() {
|
||||
gestureDuration: Long,
|
||||
gestureDistance: Double
|
||||
): Boolean {
|
||||
BLog.LOGE("Maybe GA PINCH is Like Zoom out")
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1039,60 +1077,85 @@ internal class LauncherHome : Fragment() {
|
||||
gestureDuration: Long,
|
||||
gestureDistance: Double
|
||||
): Boolean {
|
||||
BLog.LOGE("Maybe GA UN PINCH is Like Zoom In")
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onDoubleTap(targetView: View, fingers: Int): Boolean {
|
||||
|
||||
targetView?.performHapticFeedback(HapticFeedbackConstants.CONFIRM)
|
||||
when (fingers) {
|
||||
1 -> lockMethod(
|
||||
settingsPrefs.getInt(KEY_LOCK_METHOD, 0),
|
||||
requireContext(),
|
||||
binding.favAppsGroup
|
||||
)
|
||||
1 -> lockMethod(settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), binding.functionLayer)
|
||||
else -> {
|
||||
|
||||
else -> {}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onLongPress(targetView: View, fingers: Int): Boolean {
|
||||
if (view?.equals(binding.batteryProgress) == true) {
|
||||
lActivity!!.startActivity(Intent(requireContext(), SettingsActivity::class.java))
|
||||
} else if (view?.equals(binding.mainList) == true) {
|
||||
when (settingsPrefs.getBoolean(KEY_TODO_LOCK, false)) {
|
||||
false -> launchTodoManager()
|
||||
/* show authentication screen if lock is on */
|
||||
true -> {
|
||||
if (canAuthenticate(requireContext())) {
|
||||
val biometricPrompt =
|
||||
BiometricPrompt(lActivity!!, authenticationCallback)
|
||||
try {
|
||||
biometricPrompt.authenticate(
|
||||
biometricPromptInfo(
|
||||
lActivity!!.getString(
|
||||
R.string.todo_manager
|
||||
)
|
||||
)
|
||||
)
|
||||
} catch (exception: Exception) {
|
||||
exception.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onLongPress(targetView: View, fingers: Int): Boolean {
|
||||
if (targetView?.equals(binding.batteryProgress) == true) {
|
||||
lActivity!!.startActivity(Intent(requireContext(), SettingsActivity::class.java))
|
||||
} else if (targetView?.equals(binding.mainList) == true) {
|
||||
// when (settingsPrefs.getBoolean(KEY_TODO_LOCK, false)) {
|
||||
// false -> launchTodoManager()
|
||||
// /* show authentication screen if lock is on */
|
||||
// true -> {
|
||||
// if (canAuthenticate(requireContext())) {
|
||||
// val biometricPrompt =
|
||||
// BiometricPrompt(lActivity!!, authenticationCallback)
|
||||
// try {
|
||||
// biometricPrompt.authenticate(
|
||||
// biometricPromptInfo(
|
||||
// lActivity!!.getString(
|
||||
// R.string.todo_manager
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
// } catch (exception: Exception) {
|
||||
// exception.printStackTrace()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} else if (targetView?.equals(binding.functionLayer) == true) {
|
||||
targetView?.performHapticFeedback(HapticFeedbackConstants.CONFIRM)
|
||||
if(binding.otherCheck.isSelected && rssStateVote) {
|
||||
queryInfos()
|
||||
} else {
|
||||
binding.otherCheck.isSelected = true
|
||||
queryVotes()
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onClick(targetView: View, fingers: Int): Boolean {
|
||||
// BLog.LOGE("onClick ${view} , fingers ${fingers}")
|
||||
BLog.LOGE("onClick ${view} , fingers ${fingers}")
|
||||
targetView.performHapticFeedback(HapticFeedbackConstants.CONFIRM)
|
||||
when (fingers) {
|
||||
1 -> {
|
||||
if (view?.equals(binding.batteryProgress) == true && fingers == 1) {
|
||||
requireContext().startActivity(
|
||||
Intent(AlarmClock.ACTION_SHOW_ALARMS).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
)
|
||||
if (targetView.equals(binding.batteryProgress) == true) {
|
||||
startActivity(Intent(android.provider.Settings.ACTION_SETTINGS))
|
||||
}else if(targetView.equals(binding.functionLayer)) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1100,7 +1163,7 @@ internal class LauncherHome : Fragment() {
|
||||
lockMethod(
|
||||
settingsPrefs.getInt(KEY_LOCK_METHOD, 0),
|
||||
requireContext(),
|
||||
binding.favAppsGroup
|
||||
binding.functionLayer
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1109,7 +1172,7 @@ internal class LauncherHome : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1164,13 +1227,6 @@ internal class LauncherHome : Fragment() {
|
||||
}
|
||||
|
||||
|
||||
/* gestures on battery progress indicator area */
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun batteryProgressGestures() {
|
||||
binding.batteryProgress.setOnClickListener { startActivity(Intent(android.provider.Settings.ACTION_SETTINGS)) }
|
||||
// binding.time.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.time , mFingerGestureListener))
|
||||
// binding.batteryProgress.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.batteryProgress , mFingerGestureListener))
|
||||
}
|
||||
|
||||
/* gestures on to-do area */
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.print.PDFPrint
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -71,47 +70,47 @@ internal class RssViewer : DialogFragment() {
|
||||
binding = RssViewerBinding.inflate(inflater, container, false)
|
||||
binding.webview.loadUrl(tag!!)
|
||||
binding.webview.setDesktopMode(false)
|
||||
binding.pdfPrint.setOnClickListener { pdfPring() }
|
||||
// binding.pdfPrint.setOnClickListener { pdfPring() }
|
||||
return binding.root
|
||||
}
|
||||
|
||||
fun pdfPring() {
|
||||
val fileName = tag?.toUri()?.path?.replace("/","_")?.replace(".","_")
|
||||
val path = File(Environment.getExternalStorageDirectory(),"bums")
|
||||
if (path.exists() == false) {
|
||||
path.mkdirs()
|
||||
}
|
||||
val file = File(path, fileName.plus(".pdf"))
|
||||
|
||||
BLog.LOGE("file >>> ${file.absolutePath}")
|
||||
try {
|
||||
PDFPrint.generatePDFFromWebView(file,binding.webview, object : PDFPrint.OnPDFPrintListener {
|
||||
override fun onSuccess(file: File?) {
|
||||
BLog.LOGE("file >>>> ${file!!.absolutePath}")
|
||||
val shareIntent: Intent = Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
this.`package` = "com.synology.dsdrive"
|
||||
val imageUri = FileProvider.getUriForFile(
|
||||
lActivity!!,
|
||||
"bums.lunatic.launcher.fileprovider", //(use your app signature + ".provider" )
|
||||
file
|
||||
)
|
||||
putExtra(Intent.EXTRA_STREAM, imageUri)
|
||||
type = "pdf"
|
||||
}
|
||||
lActivity!!.startActivity(shareIntent)
|
||||
}
|
||||
|
||||
override fun onError(exception: java.lang.Exception?) {
|
||||
Toast.makeText(lActivity!!,
|
||||
"Pdf Save Failk ${exception?.localizedMessage}", Toast.LENGTH_LONG).show()
|
||||
exception?.printStackTrace()
|
||||
}
|
||||
} )
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
// fun pdfPring() {
|
||||
// val fileName = tag?.toUri()?.path?.replace("/","_")?.replace(".","_")
|
||||
// val path = File(Environment.getExternalStorageDirectory(),"bums")
|
||||
// if (path.exists() == false) {
|
||||
// path.mkdirs()
|
||||
// }
|
||||
// val file = File(path, fileName.plus(".pdf"))
|
||||
//
|
||||
// BLog.LOGE("file >>> ${file.absolutePath}")
|
||||
// try {
|
||||
// PDFPrint.generatePDFFromWebView(file,binding.webview, object : PDFPrint.OnPDFPrintListener {
|
||||
// override fun onSuccess(file: File?) {
|
||||
// BLog.LOGE("file >>>> ${file!!.absolutePath}")
|
||||
// val shareIntent: Intent = Intent().apply {
|
||||
// action = Intent.ACTION_SEND
|
||||
// this.`package` = "com.synology.dsdrive"
|
||||
// val imageUri = FileProvider.getUriForFile(
|
||||
// lActivity!!,
|
||||
// "bums.lunatic.launcher.fileprovider", //(use your app signature + ".provider" )
|
||||
// file
|
||||
// )
|
||||
// putExtra(Intent.EXTRA_STREAM, imageUri)
|
||||
// type = "pdf"
|
||||
// }
|
||||
// lActivity!!.startActivity(shareIntent)
|
||||
// }
|
||||
//
|
||||
// override fun onError(exception: java.lang.Exception?) {
|
||||
// Toast.makeText(lActivity!!,
|
||||
// "Pdf Save Failk ${exception?.localizedMessage}", Toast.LENGTH_LONG).show()
|
||||
// exception?.printStackTrace()
|
||||
// }
|
||||
// } )
|
||||
// } catch (e: IOException) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
@@ -44,6 +44,8 @@ import com.google.gson.Gson
|
||||
import com.squareup.picasso.Picasso
|
||||
import kr.lunaticbum.awesomewebview.AwesomeWebView
|
||||
import io.realm.kotlin.UpdatePolicy
|
||||
import kr.lunaticbum.awesomewebview.listeners.WebViewListener
|
||||
import kr.lunaticbum.awesomewebview.objects.CustomMenu
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
@@ -54,7 +56,14 @@ internal class RssItemAdapter (
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
val dateFormat = SimpleDateFormat("a HH:mm / yy - MM - dd")
|
||||
val emptyDate = " - "
|
||||
val webViewListener = object : WebViewListener() {
|
||||
override fun onCustomMenuClick(menuCode: String?) {
|
||||
super.onCustomMenuClick(menuCode)
|
||||
if ("PDF".equals(menuCode)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
val dateViewClick = View.OnClickListener { v ->
|
||||
(v?.tag as? RssData)?.let { rss ->
|
||||
WorkersDb.getRealm().apply {
|
||||
@@ -81,7 +90,11 @@ internal class RssItemAdapter (
|
||||
// RssViewer().apply {
|
||||
// show(lActivity!!.supportFragmentManager,rss.originPage)
|
||||
// }
|
||||
AwesomeWebView.Builder(lActivity!!).showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0)
|
||||
AwesomeWebView.Builder(lActivity!!)
|
||||
// .setWebViewListener(webViewListener).addCustomMenu(
|
||||
// CustomMenu("PDF 저장","PDF")
|
||||
// ).
|
||||
.showIconClose(true).showIconBack(false).showProgressBar(true).backPressToClose(false).webViewMixedContentMode(1)
|
||||
.show(rss.originPage!!)
|
||||
// openOpera(rss.originPage())
|
||||
}
|
||||
@@ -95,18 +108,22 @@ internal class RssItemAdapter (
|
||||
// openReddit(rss.originPage())
|
||||
}
|
||||
RssDataType.DOTAX -> {
|
||||
RssViewer().apply {
|
||||
AwesomeWebView.Builder(lActivity!!).show(rss.originPage!!)
|
||||
// show(lActivity!!.supportFragmentManager,rss.originPage)
|
||||
}
|
||||
// openDotax(rss.originPage())
|
||||
AwesomeWebView.Builder(lActivity!!)
|
||||
// .setWebViewListener(webViewListener).addCustomMenu(
|
||||
// CustomMenu("PDF 저장","PDF")
|
||||
// ).
|
||||
.showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0)
|
||||
.show(rss.originPage!!)
|
||||
}
|
||||
RssDataType.YOUTUBE -> { openYouTube(rss.originPage())
|
||||
}
|
||||
else -> {
|
||||
RssViewer().apply {
|
||||
show(lActivity!!.supportFragmentManager,rss.originPage)
|
||||
}
|
||||
AwesomeWebView.Builder(lActivity!!)
|
||||
// .setWebViewListener(webViewListener).addCustomMenu(
|
||||
// CustomMenu("PDF 저장","PDF")
|
||||
// ).
|
||||
.showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0)
|
||||
.show(rss.originPage!!)
|
||||
// openNews(rss.originPage())
|
||||
}
|
||||
}
|
||||
@@ -148,9 +165,9 @@ internal class RssItemAdapter (
|
||||
} else {
|
||||
holder.view.date.text = emptyDate
|
||||
}
|
||||
if(RssDataType.FMKORAE.equals(rssData.category())) {
|
||||
BLog.LOGE("rssData >>>> ${Gson().toJson(rssData)}")
|
||||
}
|
||||
// if(RssDataType.FMKORAE.equals(rssData.category())) {
|
||||
// BLog.LOGE("rssData >>>> ${Gson().toJson(rssData)}")
|
||||
// }
|
||||
holder.view.title.text = "".plus(if(rssData.vote) " * " else "").plus(rssData.title().plus("[R:${rssData.read}]"))
|
||||
holder.view.desc.text = rssData.description()
|
||||
|
||||
@@ -203,6 +220,17 @@ internal class RssItemAdapter (
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
fun refresh() {
|
||||
try {
|
||||
val visibleItemCount = (layoutManager?.findLastVisibleItemPosition() ?: 0) - (layoutManager?.findFirstVisibleItemPosition() ?: 0)
|
||||
val first = layoutManager?.findLastVisibleItemPosition() ?: 0
|
||||
if (visibleItemCount > 0) {
|
||||
this@RssItemAdapter.notifyItemRangeChanged(first, visibleItemCount)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class RssHolder(var view: ListItemWithBinding) : RecyclerView.ViewHolder(view.root) {}
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.annotation.NonNull
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import bums.lunatic.launcher.utils.BLog
|
||||
|
||||
|
||||
abstract class SwipeToDeleteCallback internal constructor(context: Context) :
|
||||
@@ -21,6 +22,7 @@ abstract class SwipeToDeleteCallback internal constructor(context: Context) :
|
||||
private val mClearPaint = Paint()
|
||||
private val mBackground = ColorDrawable()
|
||||
private val backgroundColor = Color.parseColor("#55b80f0a")
|
||||
private val reverseColor = Color.parseColor("#55b80fb8")
|
||||
private val deleteDrawable: Drawable?
|
||||
private val intrinsicWidth: Int
|
||||
private val intrinsicHeight: Int
|
||||
@@ -38,7 +40,7 @@ abstract class SwipeToDeleteCallback internal constructor(context: Context) :
|
||||
@NonNull recyclerView: RecyclerView,
|
||||
@NonNull viewHolder: RecyclerView.ViewHolder
|
||||
): Int {
|
||||
return makeMovementFlags(0, ItemTouchHelper.LEFT)
|
||||
return makeMovementFlags(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT)
|
||||
}
|
||||
|
||||
override fun onMove(
|
||||
@@ -63,8 +65,7 @@ abstract class SwipeToDeleteCallback internal constructor(context: Context) :
|
||||
val itemView = viewHolder.itemView
|
||||
val itemHeight = itemView.height
|
||||
|
||||
val isCancelled = dX == 0f && !isCurrentlyActive
|
||||
|
||||
val isCancelled = (dX == 0f) && !isCurrentlyActive
|
||||
if (isCancelled) {
|
||||
clearCanvas(
|
||||
c,
|
||||
@@ -77,24 +78,35 @@ abstract class SwipeToDeleteCallback internal constructor(context: Context) :
|
||||
return
|
||||
}
|
||||
|
||||
mBackground.color = backgroundColor
|
||||
mBackground.setBounds(
|
||||
itemView.right + dX.toInt(),
|
||||
itemView.top,
|
||||
itemView.right,
|
||||
itemView.bottom
|
||||
)
|
||||
|
||||
if (dX.toInt() < 0) {
|
||||
mBackground.color = backgroundColor
|
||||
mBackground.setBounds(
|
||||
itemView.right + dX.toInt(),
|
||||
itemView.top,
|
||||
itemView.right,
|
||||
itemView.bottom
|
||||
)
|
||||
} else {
|
||||
mBackground.color = reverseColor
|
||||
mBackground.setBounds(
|
||||
itemView.left,
|
||||
itemView.top,
|
||||
itemView.left + dX.toInt(),
|
||||
itemView.bottom
|
||||
)
|
||||
}
|
||||
mBackground.draw(c)
|
||||
|
||||
val deleteIconTop = itemView.top + (itemHeight - intrinsicHeight) / 2
|
||||
val deleteIconMargin = (itemHeight - intrinsicHeight) / 2
|
||||
val deleteIconLeft = itemView.right - deleteIconMargin - intrinsicWidth
|
||||
val deleteIconRight = itemView.right - deleteIconMargin
|
||||
val deleteIconBottom = deleteIconTop + intrinsicHeight
|
||||
|
||||
|
||||
deleteDrawable!!.setBounds(deleteIconLeft, deleteIconTop, deleteIconRight, deleteIconBottom)
|
||||
deleteDrawable.draw(c)
|
||||
// val deleteIconTop = itemView.top + (itemHeight - intrinsicHeight) / 2
|
||||
// val deleteIconMargin = (itemHeight - intrinsicHeight) / 2
|
||||
// val deleteIconLeft = itemView.right - deleteIconMargin - intrinsicWidth
|
||||
// val deleteIconRight = itemView.right - deleteIconMargin
|
||||
// val deleteIconBottom = deleteIconTop + intrinsicHeight
|
||||
//
|
||||
//
|
||||
// deleteDrawable!!.setBounds(deleteIconLeft, deleteIconTop, deleteIconRight, deleteIconBottom)
|
||||
// deleteDrawable.draw(c)
|
||||
|
||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ class GestureAnalyser @JvmOverloads constructor(
|
||||
class SimpleFingerGestures : OnTouchListener {
|
||||
private var debug = BuildConfig.DEBUG
|
||||
var consumeTouchEvents: Boolean = false
|
||||
var screenHeight : Int = 100
|
||||
var screenUnit : Int = 100
|
||||
protected var tracking: BooleanArray = booleanArrayOf(false, false, false, false, false)
|
||||
private var ga: GestureAnalyser
|
||||
private var onFingerGestureListener: OnFingerGestureListener? = null
|
||||
@@ -432,8 +432,8 @@ class SimpleFingerGestures : OnTouchListener {
|
||||
this.targetView = targetView
|
||||
ga = GestureAnalyser()
|
||||
this.mContext?.resources?.displayMetrics?.let {
|
||||
screenHeight = (it.heightPixels * 0.2).toInt()
|
||||
ga.minValue = Math.max(screenHeight, 100)
|
||||
screenUnit = (Math.min(it.widthPixels,it.heightPixels) * 0.3).toInt()
|
||||
ga.minValue = Math.max(screenUnit, 100)
|
||||
}
|
||||
this.onFingerGestureListener = onFingerGestureListener
|
||||
this.targetView?.setOnClickListener { onFingerGestureListener.onClick(it,1) }
|
||||
@@ -685,17 +685,17 @@ class SimpleFingerGestures : OnTouchListener {
|
||||
}
|
||||
GestureAnalyser.CLICK_1 -> {
|
||||
// BLog.LOGE("GestureAnalyser.CLICK_1")
|
||||
onFingerGestureListener!!.onClick(targetView, 1)
|
||||
onFingerGestureListener!!.onClick(targetView, 1).apply { consumeTouchEvents = this }
|
||||
// onFingerGestureListener!!.onDoubleTap(1)
|
||||
}
|
||||
GestureAnalyser.CLICK_2 -> {
|
||||
// BLog.LOGE("GestureAnalyser.CLICK_2")
|
||||
onFingerGestureListener!!.onClick(targetView, 2)
|
||||
onFingerGestureListener!!.onClick(targetView, 2).apply { consumeTouchEvents = this }
|
||||
// onFingerGestureListener!!.onDoubleTap(1)
|
||||
}
|
||||
GestureAnalyser.CLICK_3 -> {
|
||||
// BLog.LOGE("GestureAnalyser.CLICK_3")
|
||||
onFingerGestureListener!!.onClick(targetView, 3)
|
||||
onFingerGestureListener!!.onClick(targetView, 3).apply { consumeTouchEvents = this }
|
||||
// onFingerGestureListener!!.onDoubleTap(1)
|
||||
}
|
||||
// GestureAnalyser.CLICK_2 -> {
|
||||
@@ -709,15 +709,15 @@ class SimpleFingerGestures : OnTouchListener {
|
||||
|
||||
GestureAnalyser.LONG_CLICK_1 -> {
|
||||
// BLog.LOGE("GestureAnalyser.LONG_CLICK_1")
|
||||
onFingerGestureListener!!.onLongPress(targetView,1)
|
||||
onFingerGestureListener!!.onLongPress(targetView,1).apply { consumeTouchEvents = this }
|
||||
}
|
||||
GestureAnalyser.LONG_CLICK_2 -> {
|
||||
// BLog.LOGE("GestureAnalyser.LONG_CLICK_2")
|
||||
onFingerGestureListener!!.onLongPress(targetView,2)
|
||||
onFingerGestureListener!!.onLongPress(targetView,2).apply { consumeTouchEvents = this }
|
||||
}
|
||||
GestureAnalyser.LONG_CLICK_3 -> {
|
||||
// BLog.LOGE("GestureAnalyser.LONG_CLICK_3")
|
||||
onFingerGestureListener!!.onLongPress(targetView,3)
|
||||
onFingerGestureListener!!.onLongPress(targetView,3).apply { consumeTouchEvents = this }
|
||||
}
|
||||
|
||||
GestureAnalyser.DOUBLE_TAP_1 -> onFingerGestureListener!!.onDoubleTap(targetView,1)
|
||||
|
||||
@@ -52,39 +52,39 @@ class DateTimeView : AppCompatTextView {
|
||||
val now = Date(System.currentTimeMillis())
|
||||
val time = SpannableString(simpleTimeFormat.format(now))
|
||||
val date = SpannableString(simpleDateFormat.format(now))
|
||||
val mClickableSpan = object: ClickableSpan(){
|
||||
override fun updateDrawState(textPaint: TextPaint) {
|
||||
// textPaint.color = this@MainActivity.getColor(R.color.blue)
|
||||
textPaint.isUnderlineText = false
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
val mClockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS)
|
||||
mClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(mClockIntent)
|
||||
}
|
||||
}
|
||||
val mClickableSpan2 = object: ClickableSpan(){
|
||||
override fun updateDrawState(textPaint: TextPaint) {
|
||||
// textPaint.color = this@MainActivity.getColor(R.color.blue)
|
||||
textPaint.isUnderlineText = false
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
val intent = Intent(Intent.ACTION_MAIN)
|
||||
intent.addCategory(Intent.CATEGORY_APP_CALENDAR)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
// val mClickableSpan = object: ClickableSpan(){
|
||||
// override fun updateDrawState(textPaint: TextPaint) {
|
||||
//// textPaint.color = this@MainActivity.getColor(R.color.blue)
|
||||
// textPaint.isUnderlineText = false
|
||||
// }
|
||||
//
|
||||
// override fun onClick(v: View) {
|
||||
// val mClockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS)
|
||||
// mClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
// context.startActivity(mClockIntent)
|
||||
// }
|
||||
// }
|
||||
// val mClickableSpan2 = object: ClickableSpan(){
|
||||
// override fun updateDrawState(textPaint: TextPaint) {
|
||||
//// textPaint.color = this@MainActivity.getColor(R.color.blue)
|
||||
// textPaint.isUnderlineText = false
|
||||
// }
|
||||
//
|
||||
// override fun onClick(v: View) {
|
||||
// val intent = Intent(Intent.ACTION_MAIN)
|
||||
// intent.addCategory(Intent.CATEGORY_APP_CALENDAR)
|
||||
// context.startActivity(intent)
|
||||
// }
|
||||
// }
|
||||
|
||||
spannableBuilder.append(time)
|
||||
spannableBuilder.setSpan(AbsoluteSizeSpan(resources.getDimensionPixelSize(R.dimen._26sp),false), 0, time.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
spannableBuilder.setSpan(mClickableSpan, 0, time.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
// spannableBuilder.setSpan(mClickableSpan, 0, time.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
spannableBuilder.append("\n")
|
||||
spannableBuilder.append(date)
|
||||
var start = time.length + "\n".length
|
||||
spannableBuilder.setSpan(AbsoluteSizeSpan(resources.getDimensionPixelSize(R.dimen._20sp),false), start , start+date.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
spannableBuilder.setSpan(mClickableSpan2, start , start+date.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
// spannableBuilder.setSpan(mClickableSpan2, start , start+date.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
mHandler.removeCallbacks(runable)
|
||||
setText(spannableBuilder)
|
||||
mHandler.postDelayed(runable, DateTimeView.DALEY)
|
||||
|
||||
@@ -8,6 +8,7 @@ import bums.lunatic.launcher.model.RssDataType
|
||||
import bums.lunatic.launcher.model.getRssData
|
||||
import bums.lunatic.launcher.model.getT
|
||||
import bums.lunatic.launcher.utils.beforeDay
|
||||
import bums.lunatic.launcher.workers.WorkersDb.blockKeyword
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Element
|
||||
import java.util.Date
|
||||
@@ -26,12 +27,12 @@ class ArcaGetter : BaseGetter {
|
||||
temp.clear()
|
||||
val urls = arrayListOf(
|
||||
"https://arca.live/b/singbung?mode=best",
|
||||
"https://arca.live/b/headline",
|
||||
// "https://arca.live/b/headline",
|
||||
// "https://arca.live/b/live",
|
||||
"https://arca.live/b/namuhotnow",
|
||||
"https://arca.live/b/society",
|
||||
// "https://arca.live/b/replay",
|
||||
"https://arca.live/b/breaking"
|
||||
// "https://arca.live/b/breaking"
|
||||
)
|
||||
urls.forEach {
|
||||
Jsoup.connect(it)
|
||||
@@ -73,20 +74,22 @@ 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) {
|
||||
Arca().apply {
|
||||
this.link = link
|
||||
this.title = title
|
||||
if (tumbnail.length > 0) {
|
||||
this.thumbnail = "https:".plus(tumbnail)
|
||||
if(blockKeyword.filter { desc.contains(it) }.size == 0) {
|
||||
Arca().apply {
|
||||
this.link = link
|
||||
this.title = title
|
||||
if (tumbnail.length > 0) {
|
||||
this.thumbnail = "https:".plus(tumbnail)
|
||||
//
|
||||
// BLog.LOGE("Arca thumbnail >>> ${thumbnail}")
|
||||
}
|
||||
this.desc = desc
|
||||
this.dateTiem = dateTime
|
||||
}.apply {
|
||||
}
|
||||
this.desc = desc
|
||||
this.dateTiem = dateTime
|
||||
}.apply {
|
||||
// BLog.LOGE("parseArcaLi >>>> ${this}")
|
||||
if(this.pubDate() > beforeDay(Date(),3)) {
|
||||
tempArray.add(this)
|
||||
if (this.pubDate() > beforeDay(Date(), 3)) {
|
||||
tempArray.add(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ object WorkersDb {
|
||||
}
|
||||
}
|
||||
|
||||
val blockKeyword = arrayListOf<String>("붕괴 스타레일","붕괴 스타일","트릭컬 RE:VIVE","원신","메이플스토리","")
|
||||
fun insertBulkData(rssDatas: Collection<RssData>) {
|
||||
rssDatas.forEach {
|
||||
try {
|
||||
|
||||
@@ -14,11 +14,25 @@
|
||||
android:alpha="0"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:background="@android:color/transparent"
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/home"
|
||||
android:name="bums.lunatic.launcher.home.LauncherHome"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/viewPager"
|
||||
android:orientation="horizontal" />
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/feeds"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/app_drawer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
@@ -215,7 +215,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/summaryChoose"
|
||||
app:layout_constraintBottom_toTopOf="@id/favAppsGroup"
|
||||
app:layout_constraintBottom_toTopOf="@id/functionLayer"
|
||||
>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
@@ -293,11 +293,11 @@
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_margin="@dimen/default_layout_margin"
|
||||
android:id="@+id/favAppsGroup"
|
||||
android:id="@+id/functionLayer"
|
||||
android:layout_width="@dimen/zero"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="@dimen/twentyTwo"
|
||||
android:layout_marginBottom="@dimen/twelve"
|
||||
android:layout_marginTop="@dimen/default_layout_margin"
|
||||
android:layout_marginBottom="@dimen/default_layout_margin"
|
||||
android:background="@drawable/base_bg"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
android:id="@+id/webview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<ImageButton
|
||||
app:layout_constraintTop_toBottomOf="@id/webview"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:id="@+id/pdf_print"
|
||||
android:src="@drawable/ic_down"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"/>
|
||||
<!-- <ImageButton-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/webview"-->
|
||||
<!-- app:layout_constraintRight_toRightOf="parent"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- android:id="@+id/pdf_print"-->
|
||||
<!-- android:src="@drawable/ic_down"-->
|
||||
<!-- android:layout_width="60dp"-->
|
||||
<!-- android:layout_height="60dp"/>-->
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user