...
This commit is contained in:
parent
edf88cdc4f
commit
f53ac1b089
@ -209,6 +209,40 @@ internal class AppDrawer : Fragment() {
|
||||
false
|
||||
}
|
||||
}
|
||||
binding.searchInput.setOnLongClickListener {
|
||||
WorkersDb.getRealm().apply {
|
||||
var newQ = query<AppInfo>()
|
||||
appQuery = newQ.sort(Pair("clickCount", Sort.DESCENDING),Pair("lastUseDate",Sort.DESCENDING)).find()
|
||||
appQuery?.let {
|
||||
if(it.size > 0) {
|
||||
WorkersDb.getRealm().apply {
|
||||
packageList.clear()
|
||||
packageList.addAll(copyFromRealm(it))
|
||||
binding.appsList.post { if (packageList.size > 0) {
|
||||
appsAdapter?.updateData(packageList)
|
||||
} }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
WorkersDb.getRealm().apply {
|
||||
var newQ = query<SimpleContact>()
|
||||
contactQuery = newQ.sort(Pair("touchCount", Sort.DESCENDING),Pair("lastedTouchDateTime",Sort.DESCENDING)).find()
|
||||
contactQuery?.let {
|
||||
if (it.size > 0) {
|
||||
contactList.clear()
|
||||
contactList.addAll(copyFromRealm(it).toList())
|
||||
binding.contactList.post {
|
||||
if (contactList.size > 0) {
|
||||
contactAdapter?.updateData(contactList)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
true
|
||||
}
|
||||
binding.searchInput.doOnTextChanged{ inputText, _, _, _ ->
|
||||
binding.searchInput.text?.let { binding.searchInput.setSelection(it.length) }
|
||||
filterAppsList(inputText.toString())
|
||||
@ -216,86 +250,9 @@ internal class AppDrawer : Fragment() {
|
||||
}
|
||||
|
||||
fun checkResult(keyword: String) {
|
||||
|
||||
// if(!isAdded || !isResumed || keyword.length < 1) return
|
||||
// var dialog : AlertDialog.Builder? = null
|
||||
// var filted = packageList.filter { it.appName.equals(keyword) }
|
||||
// BLog.LOGE("filted >> ${filted.size}")
|
||||
// var filtedContact = contactList.filter { it.name.equals(keyword) }
|
||||
// BLog.LOGE("filtedContact >> ${filtedContact.size}")
|
||||
// if (keyword.length > 0 && (packageList.size == 1 || filted.size > 0)) {
|
||||
// dialog = AlertDialog.Builder(requireContext())
|
||||
// dialog?.setTitle("앱 실행 확인")
|
||||
// if (packageList.size == 1) {
|
||||
// dialog?.setMessage("${keyword} 검색 결과 '${packageList[0].appName}' 준비됨")
|
||||
// dialog?.setPositiveButton("실행") { s, d ->
|
||||
// runonUi {
|
||||
// startActivity(packageManager?.getLaunchIntentForPackage(packageList[0].pkgName!!))
|
||||
// s.dismiss()
|
||||
// }
|
||||
// }
|
||||
// } else if (filted.size > 0) {
|
||||
// dialog?.setMessage("${keyword} 검색 결과 '${filted[0].appName}' 준비됨")
|
||||
// dialog?.setPositiveButton("${filted[0].appName} 실행") { s, d ->
|
||||
// runonUi {
|
||||
// startActivity(packageManager?.getLaunchIntentForPackage(filted[0].pkgName!!))
|
||||
// s.dismiss()
|
||||
// }
|
||||
// }
|
||||
// if(filted.size > 1) {
|
||||
// dialog?.setNeutralButton("${filted[1].appName} 실행") { s, d ->
|
||||
// runonUi {
|
||||
// startActivity(packageManager?.getLaunchIntentForPackage(filted[1].pkgName!!))
|
||||
// s.dismiss()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// dialog?.setCancelable(false)
|
||||
// dialog?.setNegativeButton("취소") { s, d ->
|
||||
// runonUi { s.dismiss() }
|
||||
// }
|
||||
// dialog?.setOnDismissListener { registCancelSearch() }
|
||||
// dialog?.show()
|
||||
// } else if (contactList.size == 1 || filtedContact.size > 0) {
|
||||
// dialog = AlertDialog.Builder(requireContext())
|
||||
// dialog?.setTitle("연락처 실행 확인")
|
||||
// dialog?.setCancelable(false)
|
||||
// dialog?.setNegativeButton("취소") { s, d ->
|
||||
// runonUi { s.dismiss() }
|
||||
// }
|
||||
// if (contactList.size == 1) {
|
||||
// dialog?.setMessage("${keyword} 검색 결과 '${contactList[0].name}' 준비됨")
|
||||
// dialog?.setPositiveButton("자세히 보기") { s, d ->
|
||||
// runonUi {
|
||||
// ContactMenu().show(childFragmentManager, contactList[0].id.toString())
|
||||
// s.dismiss()
|
||||
// }
|
||||
// }
|
||||
// } else if(filtedContact.size > 0) {
|
||||
// dialog?.setMessage("${keyword} 검색 결과 '${filtedContact[0].name}' 준비됨")
|
||||
// dialog?.setPositiveButton("'${filtedContact[0].name},\n${filtedContact[0].phoneNumber}'\n자세히 보기") { s, d ->
|
||||
// runonUi {
|
||||
// ContactMenu().show(childFragmentManager, filtedContact[0].id.toString())
|
||||
// s.dismiss()
|
||||
// }
|
||||
// }
|
||||
// if (filtedContact.size > 1) {
|
||||
// dialog?.setNeutralButton("'${filtedContact[1].name},\n${filtedContact[1].phoneNumber}'\n자세히 보기") { s, d ->
|
||||
// runonUi {
|
||||
// ContactMenu().show(childFragmentManager, filtedContact[1].id.toString())
|
||||
// s.dismiss()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// dialog?.setOnDismissListener { registCancelSearch() }
|
||||
// dialog?.show()
|
||||
// } else {
|
||||
lActivity?.openSearchMenus(keyword) {
|
||||
registCancelSearch()
|
||||
}
|
||||
// }
|
||||
lActivity?.openSearchMenus(keyword) {
|
||||
registCancelSearch()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -328,9 +285,8 @@ internal class AppDrawer : Fragment() {
|
||||
val cancelSearch = Runnable { lActivity?.viewPager?.currentItem = 1 }
|
||||
|
||||
fun registCancelSearch() {
|
||||
// BLog.LOGE("Called registCancelSearch")
|
||||
chechHandler.removeCallbacks(cancelSearch)
|
||||
chechHandler.postDelayed(cancelSearch, 8000L)
|
||||
chechHandler.postDelayed(cancelSearch, 15000L)
|
||||
}
|
||||
|
||||
fun clearCancelSearch() {
|
||||
@ -343,13 +299,6 @@ internal class AppDrawer : Fragment() {
|
||||
}
|
||||
|
||||
private fun setLayout() {
|
||||
// when (layoutType) {
|
||||
// 0, 1 -> {
|
||||
// binding.appsList.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL,false)
|
||||
// appsAdapter!!.updateGravity(settingsPrefs!!.getInt(KEY_DRAW_ALIGN, Gravity.CENTER))
|
||||
// }
|
||||
// 2 -> binding.appsList.layoutManager = GridLayoutManager(requireContext(), Math.min(settingsPrefs!!.getInt(KEY_GRID_COLUMNS, DEFAULT_GRID_COLUMNS), 4), GridLayoutManager.HORIZONTAL,false)
|
||||
// }
|
||||
binding.appsList.layoutManager = GridLayoutManager(requireContext(), 2, GridLayoutManager.HORIZONTAL,false)
|
||||
binding.contactList.layoutManager = GridLayoutManager(requireContext(), 2, GridLayoutManager.HORIZONTAL,false)
|
||||
/* initialize apps list adapter */
|
||||
@ -383,14 +332,9 @@ internal class AppDrawer : Fragment() {
|
||||
WorkersDb.getRealm().apply {
|
||||
packageList.clear()
|
||||
packageList.addAll(copyFromRealm(it))
|
||||
// BLog.LOGE("packageList >>> ${packageList.size}")
|
||||
binding.appsList.post { if (packageList.size > 0) {
|
||||
appsAdapter?.updateData(packageList)
|
||||
} }
|
||||
// val clo = packageList.clone()
|
||||
// appNames.clear()
|
||||
// appNames.addAll(packageList.filter { it.koreanName?.trim()?.length ?: 0 < 1 })
|
||||
// getHangule()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -405,30 +349,22 @@ internal class AppDrawer : Fragment() {
|
||||
var newQ = query<SimpleContact>()
|
||||
if (keyword != null && keyword.length > 0) {
|
||||
if(Pattern.matches("^[0-9]*\$", keyword)){
|
||||
keyword.split("").forEach {
|
||||
if (it.length > 0) newQ = newQ.query("phoneNumber CONTAINS $0", keyword)
|
||||
}
|
||||
keyword.split("").forEach { if (it.length > 0) newQ = newQ.query("phoneNumber CONTAINS $0", keyword) }
|
||||
} else {
|
||||
newQ = newQ.query(
|
||||
"name CONTAINS $0 OR chosung CONTAINS $0",
|
||||
keyword
|
||||
)
|
||||
newQ = newQ.query("name CONTAINS $0 OR chosung CONTAINS $0", keyword)
|
||||
}
|
||||
}
|
||||
|
||||
contactQuery = newQ.sort(Pair("touchCount", Sort.DESCENDING),Pair("lastedTouchDateTime",Sort.DESCENDING)).limit(18).find()
|
||||
contactQuery?.let {
|
||||
if (it.size > 0)
|
||||
WorkersDb.getRealm().apply {
|
||||
contactList.clear()
|
||||
contactList.addAll(copyFromRealm(it).toList())
|
||||
// BLog.LOGE("packageList >>> ${contactList.size}")
|
||||
binding.contactList.post { if (contactList.size > 0) {
|
||||
contactAdapter?.updateData(contactList)
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -519,53 +455,9 @@ internal class AppDrawer : Fragment() {
|
||||
// }
|
||||
}
|
||||
|
||||
var lastSearchStringLength = 0
|
||||
var lastSearchString : String = ""
|
||||
|
||||
private fun filterAppsList(searchString: String) {
|
||||
/* check each app name and add if it matches the search string */
|
||||
fetchApps(searchString)
|
||||
// if (searchString.length > 0 && (lastSearchStringLength != searchString.length || lastSearchString.equals(searchString) == false)) {
|
||||
// BLog.LOGE("START FILTER")
|
||||
// packageList.clear()
|
||||
// for (pkg in oringinPackageList) {
|
||||
// if (pkg.appName!!.contains(searchString,true) || pkg.category!!.contains(searchString,true) || pkg.pkgName!!.contains(searchString,true)) {
|
||||
// BLog.LOGE("pkg >>> ${pkg.category} , ${pkg.appName}")
|
||||
// packageList.add(pkg)
|
||||
// }
|
||||
// }
|
||||
// packageList.sortBy { it.appName }
|
||||
// BLog.LOGE("MIDDLE FILTER")
|
||||
//
|
||||
// appsAdapter?.updateData(packageList)
|
||||
//
|
||||
// contactList.clear()
|
||||
// for (item in originContactList) {
|
||||
// if (item.name!!.contains(searchString) || item.phoneNumber!!.contains(searchString)) {
|
||||
// contactList.add(item)
|
||||
// }
|
||||
// }
|
||||
// contactList.sortBy { it.name }
|
||||
// contactAdapter?.updateData(contactList)
|
||||
// BLog.LOGE("END FILTER")
|
||||
//
|
||||
//
|
||||
// } else if(lastSearchStringLength == 0){
|
||||
// contactList.clear()
|
||||
// for (item in originContactList) {
|
||||
// contactList.add(item)
|
||||
// }
|
||||
// packageList.clear()
|
||||
// for (resolver in oringinPackageList) {
|
||||
// packageList.add(resolver)
|
||||
// }
|
||||
// appsAdapter?.updateData(packageList)
|
||||
// contactAdapter?.updateData(contactList)
|
||||
// } else {
|
||||
// afterClearSearch()
|
||||
//
|
||||
// }
|
||||
lastSearchString = searchString
|
||||
lastSearchStringLength = searchString.length
|
||||
registCancelSearch()
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ internal class AppsAdapter(
|
||||
if(result.size > 0) {
|
||||
val app = result.first()
|
||||
app.clickCount = app.clickCount + 15
|
||||
app.lastUseDate = Math.max(app.lastUseDate, System.currentTimeMillis())
|
||||
// app.lastUseDate = Math.max(app.lastUseDate, System.currentTimeMillis())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,14 +362,14 @@ internal class LauncherHome : Fragment() {
|
||||
val hideListViewTime = 1000L * 60L * 15L
|
||||
val hideListView = {
|
||||
|
||||
binding.notiList.visibility = View.GONE
|
||||
binding.mainList.visibility = View.GONE
|
||||
binding.infoList.visibility = View.GONE
|
||||
binding.smsList.visibility = View.GONE
|
||||
binding.otherCheck.isSelected = false
|
||||
binding.recentSms.isSelected = false
|
||||
binding.missedCalls.isSelected = false
|
||||
binding.notice.isSelected = false
|
||||
// binding.notiList.visibility = View.GONE
|
||||
// binding.mainList.visibility = View.GONE
|
||||
// binding.infoList.visibility = View.GONE
|
||||
// binding.smsList.visibility = View.GONE
|
||||
// binding.otherCheck.isSelected = false
|
||||
// binding.recentSms.isSelected = false
|
||||
// binding.missedCalls.isSelected = false
|
||||
// binding.notice.isSelected = false
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user