...
This commit is contained in:
parent
ed24af2d41
commit
b1fdea3317
@ -1,3 +1,5 @@
|
|||||||
|
import org.jetbrains.kotlin.fir.scopes.debugCollectOverrides
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id ("com.android.application")
|
id ("com.android.application")
|
||||||
id ("kotlin-android")
|
id ("kotlin-android")
|
||||||
@ -22,17 +24,28 @@ android {
|
|||||||
isDebuggable = true
|
isDebuggable = true
|
||||||
applicationIdSuffix = ".debug"
|
applicationIdSuffix = ".debug"
|
||||||
versionNameSuffix = "-debug"
|
versionNameSuffix = "-debug"
|
||||||
resValue ("string", "app_name", "Lunar Launcher Debug")
|
resValue ("string", "app_name", "Bums Launcher Debug")
|
||||||
}
|
}
|
||||||
|
|
||||||
getByName("release") {
|
getByName("release") {
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
isShrinkResources = true
|
isShrinkResources = true
|
||||||
proguardFiles (getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
proguardFiles (getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||||
resValue ("string", "app_name", "Lunar Launcher")
|
resValue ("string", "app_name", "Bums Launcher")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signingConfigs {
|
||||||
|
|
||||||
|
getByName("debug") {
|
||||||
|
storeFile = file("./bs_debug.keystore")
|
||||||
|
storePassword = "android"
|
||||||
|
keyAlias = "androiddebugkey"
|
||||||
|
keyPassword = "android"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
applicationVariants.all {
|
applicationVariants.all {
|
||||||
if (buildType.name == "release") {
|
if (buildType.name == "release") {
|
||||||
outputs.all {
|
outputs.all {
|
||||||
@ -61,14 +74,17 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
val kotlinVersion: String? by extra
|
val kotlinVersion: String? by extra
|
||||||
|
|
||||||
implementation ("androidx.appcompat:appcompat:1.6.1")
|
implementation ("androidx.appcompat:appcompat:1.7.0")
|
||||||
implementation ("androidx.biometric:biometric-ktx:1.2.0-alpha05")
|
implementation ("androidx.biometric:biometric-ktx:1.2.0-alpha05")
|
||||||
implementation ("androidx.browser:browser:1.8.0")
|
implementation ("androidx.browser:browser:1.8.0")
|
||||||
implementation ("androidx.core:core-ktx:1.12.0")
|
implementation ("androidx.core:core-ktx:1.13.1")
|
||||||
implementation ("androidx.core:core-splashscreen:1.0.1")
|
implementation ("androidx.core:core-splashscreen:1.0.1")
|
||||||
implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
|
implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4")
|
||||||
implementation ("com.google.android.material:material:1.10.0")
|
implementation ("com.google.android.material:material:1.12.0")
|
||||||
implementation (kotlin("stdlib", version = kotlinVersion))
|
implementation (kotlin("stdlib", version = kotlinVersion))
|
||||||
implementation ("com.github.cachapa:ExpandableLayout:2.9.2")
|
implementation ("com.github.cachapa:ExpandableLayout:2.9.2")
|
||||||
implementation ("com.squareup.picasso:picasso:2.8")
|
implementation ("com.squareup.picasso:picasso:2.71828")
|
||||||
|
implementation ("androidx.work:work-runtime:2.9.1")
|
||||||
|
implementation ("com.google.code.gson:gson:2.11.0")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import android.os.Handler
|
|||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.KeyEvent
|
||||||
import android.view.KeyEvent.ACTION_UP
|
import android.view.KeyEvent.ACTION_UP
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -201,25 +202,29 @@ internal class AppDrawer : Fragment() {
|
|||||||
ContactsContract.CommonDataKinds.Phone.NUMBER,
|
ContactsContract.CommonDataKinds.Phone.NUMBER,
|
||||||
)
|
)
|
||||||
|
|
||||||
val cursor = resolver.query(phoneUri, projection, null, null, null)
|
try {
|
||||||
if (cursor != null) {
|
val cursor = resolver.query(phoneUri, projection, null, null, null)
|
||||||
while (cursor.moveToNext()) {
|
if (cursor != null) {
|
||||||
val idx =cursor.getColumnIndex(projection[0])
|
while (cursor.moveToNext()) {
|
||||||
val nameIndex = cursor.getColumnIndex(projection[1])
|
val idx =cursor.getColumnIndex(projection[0])
|
||||||
val numberIndex = cursor.getColumnIndex(projection[2])
|
val nameIndex = cursor.getColumnIndex(projection[1])
|
||||||
var contactId = cursor.getString(idx)
|
val numberIndex = cursor.getColumnIndex(projection[2])
|
||||||
val name = cursor.getString(nameIndex)
|
var contactId = cursor.getString(idx)
|
||||||
var number = cursor.getString(numberIndex)
|
val name = cursor.getString(nameIndex)
|
||||||
number = number.replace("-", "")
|
var number = cursor.getString(numberIndex)
|
||||||
if (name?.length ?: 0 > 0 && number?.length ?: 0 > 0) {
|
number = number.replace("-", "")
|
||||||
contactList.add(SimpleContact(contactId,name, number))
|
if (name?.length ?: 0 > 0 && number?.length ?: 0 > 0) {
|
||||||
originContactList.add(SimpleContact(contactId,name, number))
|
contactList.add(SimpleContact(contactId,name, number))
|
||||||
}
|
originContactList.add(SimpleContact(contactId,name, number))
|
||||||
Log.d("GetContact", "이름 : $name 번호 : $number ")
|
}
|
||||||
}
|
Log.d("GetContact", "이름 : $name 번호 : $number ")
|
||||||
}
|
}
|
||||||
// 데이터 계열은 반드시 닫아줘야 한다.
|
}
|
||||||
cursor!!.close()
|
// 데이터 계열은 반드시 닫아줘야 한다.
|
||||||
|
cursor?.close()
|
||||||
|
} catch ( e : Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,8 +243,8 @@ internal class AppDrawer : Fragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.searchInput.setOnKeyListener { v, keyCode, event ->
|
binding.searchInput.setOnKeyListener { v, keyCode, event ->
|
||||||
if (keyCode == 66 && contactList.size < 1 && packageList.size < 1) {
|
if (keyCode == 66 && contactList.size < 1 && packageList.size < 1 && event.action == KeyEvent.ACTION_UP) {
|
||||||
binding.searchGoogle.performClick()
|
checkResult(binding.searchInput.text.toString())
|
||||||
true
|
true
|
||||||
}else {
|
}else {
|
||||||
false
|
false
|
||||||
@ -415,7 +420,8 @@ internal class AppDrawer : Fragment() {
|
|||||||
fun fetchApps() {
|
fun fetchApps() {
|
||||||
packageList.clear()
|
packageList.clear()
|
||||||
oringinPackageList.clear()
|
oringinPackageList.clear()
|
||||||
GlobalScope.launch {
|
try {
|
||||||
|
|
||||||
packageInfoList = (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
packageInfoList = (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
packageManager?.queryIntentActivities(
|
packageManager?.queryIntentActivities(
|
||||||
Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER),
|
Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER),
|
||||||
@ -436,7 +442,8 @@ internal class AppDrawer : Fragment() {
|
|||||||
appsAdapter?.updateData(packageList)
|
appsAdapter?.updateData(packageList)
|
||||||
} }
|
} }
|
||||||
}!!
|
}!!
|
||||||
}
|
|
||||||
|
} catch (e : Exception) {e.printStackTrace()}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAlphabetItems() {
|
private fun getAlphabetItems() {
|
||||||
|
|||||||
@ -95,19 +95,23 @@ internal class ContactMenu : BottomSheetDialogFragment() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
BLog.LOGE("GetContact", "packageName ${packageName}")
|
BLog.LOGE("GetContact", "packageName ${packageName}")
|
||||||
val cursor = resolver.query(phoneUri, projection, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + packageName, null , null)
|
try {
|
||||||
if (cursor != null) {
|
val cursor = resolver.query(phoneUri, projection, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + packageName, null , null)
|
||||||
while (cursor.moveToNext()) {
|
if (cursor != null) {
|
||||||
val nameIndex = cursor.getColumnIndex(projection[0])
|
while (cursor.moveToNext()) {
|
||||||
val numberIndex = cursor.getColumnIndex(projection[1])
|
val nameIndex = cursor.getColumnIndex(projection[0])
|
||||||
contactName = cursor.getString(nameIndex)
|
val numberIndex = cursor.getColumnIndex(projection[1])
|
||||||
var number = cursor.getString(numberIndex)
|
contactName = cursor.getString(nameIndex)
|
||||||
contactPhoneNumber = number.replace("-", "")
|
var number = cursor.getString(numberIndex)
|
||||||
BLog.LOGE("GetContact", "이름 : $contactName 번호 : $contactPhoneNumber ")
|
contactPhoneNumber = number.replace("-", "")
|
||||||
}
|
BLog.LOGE("GetContact", "이름 : $contactName 번호 : $contactPhoneNumber ")
|
||||||
}
|
}
|
||||||
// 데이터 계열은 반드시 닫아줘야 한다.
|
}
|
||||||
cursor!!.close()
|
// 데이터 계열은 반드시 닫아줘야 한다.
|
||||||
|
cursor!!.close()
|
||||||
|
} catch ( e : Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
/* get application info */
|
/* get application info */
|
||||||
|
|
||||||
|
|||||||
@ -25,23 +25,20 @@ import android.content.IntentFilter
|
|||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.AlarmClock
|
import android.provider.AlarmClock
|
||||||
import android.provider.CallLog
|
|
||||||
import android.text.format.DateFormat
|
import android.text.format.DateFormat
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.RadioButton
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.biometric.BiometricPrompt
|
import androidx.biometric.BiometricPrompt
|
||||||
import androidx.core.view.get
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import androidx.lifecycle.LiveData
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import androidx.work.OneTimeWorkRequest
|
||||||
import kotlinx.coroutines.GlobalScope
|
import androidx.work.OneTimeWorkRequestBuilder
|
||||||
import kotlinx.coroutines.MainScope
|
import androidx.work.WorkInfo
|
||||||
import kotlinx.coroutines.async
|
import androidx.work.WorkManager
|
||||||
import kotlinx.coroutines.launch
|
import com.google.gson.Gson
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||||
import rasel.lunar.launcher.R
|
import rasel.lunar.launcher.R
|
||||||
import rasel.lunar.launcher.databinding.LauncherHomeBinding
|
import rasel.lunar.launcher.databinding.LauncherHomeBinding
|
||||||
@ -52,7 +49,6 @@ import rasel.lunar.launcher.helpers.Constants.Companion.KEY_LOCK_METHOD
|
|||||||
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TIME_FORMAT
|
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TIME_FORMAT
|
||||||
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_LOCK
|
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_LOCK
|
||||||
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
|
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
|
||||||
import rasel.lunar.launcher.helpers.SwipeTouchListener
|
|
||||||
import rasel.lunar.launcher.helpers.UniUtils.Companion.biometricPromptInfo
|
import rasel.lunar.launcher.helpers.UniUtils.Companion.biometricPromptInfo
|
||||||
import rasel.lunar.launcher.helpers.UniUtils.Companion.canAuthenticate
|
import rasel.lunar.launcher.helpers.UniUtils.Companion.canAuthenticate
|
||||||
import rasel.lunar.launcher.helpers.UniUtils.Companion.expandNotificationPanel
|
import rasel.lunar.launcher.helpers.UniUtils.Companion.expandNotificationPanel
|
||||||
@ -61,12 +57,11 @@ import rasel.lunar.launcher.home.weather.WeatherExecutor
|
|||||||
import rasel.lunar.launcher.qaccess.QuickAccess
|
import rasel.lunar.launcher.qaccess.QuickAccess
|
||||||
import rasel.lunar.launcher.settings.SettingsActivity
|
import rasel.lunar.launcher.settings.SettingsActivity
|
||||||
import rasel.lunar.launcher.todos.MissedCallsAdapter
|
import rasel.lunar.launcher.todos.MissedCallsAdapter
|
||||||
import rasel.lunar.launcher.todos.TodoAdapter
|
|
||||||
import rasel.lunar.launcher.todos.TodoManager
|
|
||||||
import rasel.lunar.launcher.utils.BLog
|
import rasel.lunar.launcher.utils.BLog
|
||||||
|
import rasel.lunar.launcher.utils.MissedCallGetter
|
||||||
import rasel.lunar.launcher.utils.SimpleFingerGestures
|
import rasel.lunar.launcher.utils.SimpleFingerGestures
|
||||||
import java.text.SimpleDateFormat
|
import java.util.Calendar
|
||||||
import java.util.*
|
import java.util.Locale
|
||||||
|
|
||||||
|
|
||||||
internal class LauncherHome : Fragment() {
|
internal class LauncherHome : Fragment() {
|
||||||
@ -85,12 +80,18 @@ internal class LauncherHome : Fragment() {
|
|||||||
batteryReceiver = BatteryReceiver(binding.batteryProgress)
|
batteryReceiver = BatteryReceiver(binding.batteryProgress)
|
||||||
|
|
||||||
binding.favAppsGroup.visibility = View.GONE
|
binding.favAppsGroup.visibility = View.GONE
|
||||||
Thread("CALLED").run {
|
|
||||||
getCallDetails()
|
mWorkManager = WorkManager.getInstance(lActivity!!.application);
|
||||||
}
|
mWorkManager?.enqueue(OneTimeWorkRequestBuilder<MissedCallGetter>().addTag("MissedCallGetter").build())
|
||||||
|
BLog.LOGE("onCreateView()")
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var mSavedWorkInfo: LiveData<List<WorkInfo>>? = null
|
||||||
|
fun getOutputWorkInfo(): LiveData<List<WorkInfo>> {
|
||||||
|
return mSavedWorkInfo!!
|
||||||
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
/* handle gesture events */
|
/* handle gesture events */
|
||||||
@ -98,11 +99,14 @@ internal class LauncherHome : Fragment() {
|
|||||||
batteryProgressGestures()
|
batteryProgressGestures()
|
||||||
todosGestures()
|
todosGestures()
|
||||||
|
|
||||||
|
BLog.LOGE("onViewCreated()")
|
||||||
|
|
||||||
|
// mWorkManager.
|
||||||
/* refresh the to-do list after getting back from TodoManager */
|
/* refresh the to-do list after getting back from TodoManager */
|
||||||
fragManager.addOnBackStackChangedListener {
|
fragManager.addOnBackStackChangedListener {
|
||||||
|
BLog.LOGE("addOnBackStackChangedListener()")
|
||||||
shouldResume = if (fragManager.backStackEntryCount == 0) {
|
shouldResume = if (fragManager.backStackEntryCount == 0) {
|
||||||
binding.root.visibility = View.VISIBLE
|
binding.root.visibility = View.VISIBLE
|
||||||
showTodoList()
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
binding.root.visibility = View.GONE
|
binding.root.visibility = View.GONE
|
||||||
@ -113,6 +117,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
BLog.LOGE("onResume()")
|
||||||
if (shouldResume) {
|
if (shouldResume) {
|
||||||
/* register battery changes */
|
/* register battery changes */
|
||||||
requireContext().registerReceiver(batteryReceiver, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
|
requireContext().registerReceiver(batteryReceiver, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
|
||||||
@ -130,83 +135,31 @@ internal class LauncherHome : Fragment() {
|
|||||||
|
|
||||||
/* show weather */
|
/* show weather */
|
||||||
WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather)
|
WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather)
|
||||||
/* show to-do list */
|
mSavedWorkInfo = mWorkManager?.getWorkInfosByTagLiveData("MissedCallGetter");
|
||||||
showTodoList()
|
getOutputWorkInfo().observeForever {
|
||||||
|
it.last()?.outputData?.keyValueMap?.forEach { t, u ->
|
||||||
|
try {
|
||||||
|
if (u is String) {
|
||||||
|
Gson().fromJson(u,MissedCall::class.java)?.let {
|
||||||
|
callList.add(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e : Exception) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
showTodoList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var mWorkManager: WorkManager? = null
|
||||||
|
|
||||||
var callList = arrayListOf<MissedCall>()
|
var callList = arrayListOf<MissedCall>()
|
||||||
|
|
||||||
|
|
||||||
private fun getCallDetails() {
|
|
||||||
var dateParam = Date(System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 3)).time.toString()
|
|
||||||
val managedCursor = lActivity!!.managedQuery(
|
|
||||||
CallLog.Calls.CONTENT_URI, arrayOf(
|
|
||||||
CallLog.Calls.NUMBER,
|
|
||||||
CallLog.Calls.TYPE,
|
|
||||||
CallLog.Calls.DATE,
|
|
||||||
CallLog.Calls.DURATION,
|
|
||||||
CallLog.Calls.CACHED_NAME,
|
|
||||||
), CallLog.Calls.DATE + "> ? AND " + CallLog.Calls.TYPE + " > ?", arrayOf<String>(dateParam, "2"), CallLog.Calls.DATE + " desc")
|
|
||||||
val number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER)
|
|
||||||
val type = managedCursor.getColumnIndex(CallLog.Calls.TYPE)
|
|
||||||
val date = managedCursor.getColumnIndex(CallLog.Calls.DATE)
|
|
||||||
val duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION)
|
|
||||||
val name = managedCursor.getColumnIndex(CallLog.Calls.CACHED_NAME)
|
|
||||||
var missedCalls = hashMapOf<String, MissedCall>()
|
|
||||||
if (missedCalls.size != callList.size) {
|
|
||||||
while (managedCursor.moveToNext()) {
|
|
||||||
val phNumber = managedCursor.getString(number) // mobile number
|
|
||||||
val callType = managedCursor.getString(type) // call type
|
|
||||||
val callDate = managedCursor.getString(date) // call date
|
|
||||||
val callDayTime: Date = Date(callDate.toLong())
|
|
||||||
val callDuration = managedCursor.getString(duration)
|
|
||||||
val callerName = managedCursor.getString(name)
|
|
||||||
|
|
||||||
var dir: String = ""
|
|
||||||
val dircode = callType.toInt()
|
|
||||||
when (dircode) {
|
|
||||||
CallLog.Calls.INCOMING_TYPE -> {
|
|
||||||
dir = "INCOMING_TYPE"
|
|
||||||
}
|
|
||||||
CallLog.Calls.OUTGOING_TYPE -> {
|
|
||||||
dir = "OUTGOING_TYPE"
|
|
||||||
}
|
|
||||||
CallLog.Calls.MISSED_TYPE -> {
|
|
||||||
dir = "MISSED_TYPE"
|
|
||||||
}
|
|
||||||
CallLog.Calls.VOICEMAIL_TYPE -> {
|
|
||||||
dir = "VOICEMAIL_TYPE"
|
|
||||||
}
|
|
||||||
CallLog.Calls.REJECTED_TYPE -> {
|
|
||||||
dir = "REJECTED_TYPE"
|
|
||||||
}
|
|
||||||
CallLog.Calls.BLOCKED_TYPE -> {
|
|
||||||
dir = "BLOCKED_TYPE"
|
|
||||||
}
|
|
||||||
CallLog.Calls.ANSWERED_EXTERNALLY_TYPE -> {
|
|
||||||
dir = "ANSWERED_EXTERNALLY_TYPE"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var missed: MissedCall = if (missedCalls.containsKey(phNumber)) {
|
|
||||||
missedCalls.get(phNumber)!!.apply {
|
|
||||||
count = count + 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MissedCall(1,callerName,phNumber, dircode, dir, SimpleDateFormat("yyy/MM/dd-HH:mm:ss").format(callDayTime))
|
|
||||||
}
|
|
||||||
missedCalls.put(phNumber, missed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
managedCursor.close()
|
|
||||||
if (callList.size == missedCalls.size) {
|
|
||||||
} else {
|
|
||||||
callList.clear()
|
|
||||||
missedCalls.forEach { t, u ->
|
|
||||||
callList.add(u)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
@ -463,22 +416,23 @@ internal class LauncherHome : Fragment() {
|
|||||||
|
|
||||||
/* launch TodoManager fragment */
|
/* launch TodoManager fragment */
|
||||||
private fun launchTodoManager() {
|
private fun launchTodoManager() {
|
||||||
fragManager.beginTransaction().replace(R.id.mainFragmentsContainer, TodoManager())
|
// fragManager.beginTransaction().replace(R.id.mainFragmentsContainer, TodoManager())
|
||||||
.addToBackStack("").commit()
|
// .addToBackStack("").commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* to-do list */
|
/* to-do list */
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
|
||||||
private fun showTodoList() {
|
private fun showTodoList() {
|
||||||
if (binding.missedCalls.isChecked == true) {
|
if (binding.missedCalls.isChecked) {
|
||||||
if (callList.size > 0) {
|
if (callList.size > 0 && isAdded && isResumed && isVisible) {
|
||||||
BLog.LOGE("callList >>> ${callList.size}")
|
try {
|
||||||
binding.notes.adapter = MissedCallsAdapter(callList, requireContext())?.apply {
|
BLog.LOGE("callList >>> ${callList.size}")
|
||||||
this.notifyDataSetChanged()
|
binding.notes.adapter = MissedCallsAdapter(callList, requireContext())
|
||||||
|
} catch (e : Exception) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.notes.adapter = TodoAdapter(null, requireContext())
|
// binding.notes.adapter = TodoAdapter(null, requireContext())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,4 +490,9 @@ class MissedCall {
|
|||||||
var type : Int = 0
|
var type : Int = 0
|
||||||
var typeString : String = ""
|
var typeString : String = ""
|
||||||
var date : String = ""
|
var date : String = ""
|
||||||
|
|
||||||
|
fun toJson() : String {
|
||||||
|
return Gson().toJson(this)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,107 +1,107 @@
|
|||||||
/*
|
///*
|
||||||
* Lunar Launcher
|
// * Lunar Launcher
|
||||||
* Copyright (C) 2022 Md Rasel Hossain
|
// * Copyright (C) 2022 Md Rasel Hossain
|
||||||
*
|
// *
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
// * it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// * the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// * (at your option) any later version.
|
||||||
*
|
// *
|
||||||
* This program is distributed in the hope that it will be useful,
|
// * This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// * GNU General Public License for more details.
|
||||||
*
|
// *
|
||||||
* You should have received a copy of the GNU General Public License
|
// * You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
package rasel.lunar.launcher.todos
|
//package rasel.lunar.launcher.todos
|
||||||
|
//
|
||||||
import android.database.sqlite.SQLiteOpenHelper
|
//import android.database.sqlite.SQLiteOpenHelper
|
||||||
import android.database.sqlite.SQLiteDatabase
|
//import android.database.sqlite.SQLiteDatabase
|
||||||
import android.content.ContentValues
|
//import android.content.ContentValues
|
||||||
import android.annotation.SuppressLint
|
//import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
//import android.content.Context
|
||||||
import android.database.DatabaseUtils
|
//import android.database.DatabaseUtils
|
||||||
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_COLUMN_CREATED
|
//import rasel.lunar.launcher.helpers.Constants.Companion.TODO_COLUMN_CREATED
|
||||||
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_COLUMN_ID
|
//import rasel.lunar.launcher.helpers.Constants.Companion.TODO_COLUMN_ID
|
||||||
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_COLUMN_NAME
|
//import rasel.lunar.launcher.helpers.Constants.Companion.TODO_COLUMN_NAME
|
||||||
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_DATABASE_NAME
|
//import rasel.lunar.launcher.helpers.Constants.Companion.TODO_DATABASE_NAME
|
||||||
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_DATABASE_VERSION
|
//import rasel.lunar.launcher.helpers.Constants.Companion.TODO_DATABASE_VERSION
|
||||||
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_TABLE_NAME
|
//import rasel.lunar.launcher.helpers.Constants.Companion.TODO_TABLE_NAME
|
||||||
import java.util.ArrayList
|
//import java.util.ArrayList
|
||||||
|
//
|
||||||
|
//
|
||||||
internal class DatabaseHandler(context: Context?) :
|
//internal class DatabaseHandler(context: Context?) :
|
||||||
SQLiteOpenHelper(context, TODO_DATABASE_NAME, null, TODO_DATABASE_VERSION) {
|
// SQLiteOpenHelper(context, TODO_DATABASE_NAME, null, TODO_DATABASE_VERSION) {
|
||||||
|
//
|
||||||
/* create database */
|
// /* create database */
|
||||||
override fun onCreate(database: SQLiteDatabase) {
|
// override fun onCreate(database: SQLiteDatabase) {
|
||||||
val createTodoTable = "CREATE TABLE " + TODO_TABLE_NAME + " (" +
|
// val createTodoTable = "CREATE TABLE " + TODO_TABLE_NAME + " (" +
|
||||||
TODO_COLUMN_ID + " integer PRIMARY KEY AUTOINCREMENT," +
|
// TODO_COLUMN_ID + " integer PRIMARY KEY AUTOINCREMENT," +
|
||||||
TODO_COLUMN_CREATED + " datetime DEFAULT CURRENT_TIMESTAMP," +
|
// TODO_COLUMN_CREATED + " datetime DEFAULT CURRENT_TIMESTAMP," +
|
||||||
TODO_COLUMN_NAME + " varchar)"
|
// TODO_COLUMN_NAME + " varchar)"
|
||||||
database.execSQL(createTodoTable)
|
// database.execSQL(createTodoTable)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onUpgrade(sqLiteDatabase: SQLiteDatabase, i: Int, i1: Int) {}
|
// override fun onUpgrade(sqLiteDatabase: SQLiteDatabase, i: Int, i1: Int) {}
|
||||||
|
//
|
||||||
/* add new to-do entry */
|
// /* add new to-do entry */
|
||||||
fun addTodo(todo: Todo) {
|
// fun addTodo(todo: Todo) {
|
||||||
val database = writableDatabase
|
// val database = writableDatabase
|
||||||
val contentValues = ContentValues()
|
// val contentValues = ContentValues()
|
||||||
contentValues.put(TODO_COLUMN_NAME, todo.name)
|
// contentValues.put(TODO_COLUMN_NAME, todo.name)
|
||||||
database.insert(TODO_TABLE_NAME, null, contentValues)
|
// database.insert(TODO_TABLE_NAME, null, contentValues)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/* update or edit existing to-do */
|
// /* update or edit existing to-do */
|
||||||
fun updateTodo(todo: Todo) {
|
// fun updateTodo(todo: Todo) {
|
||||||
val database = writableDatabase
|
// val database = writableDatabase
|
||||||
val contentValues = ContentValues()
|
// val contentValues = ContentValues()
|
||||||
contentValues.put(TODO_COLUMN_NAME, todo.name)
|
// contentValues.put(TODO_COLUMN_NAME, todo.name)
|
||||||
database.update(
|
// database.update(
|
||||||
TODO_TABLE_NAME,
|
// TODO_TABLE_NAME,
|
||||||
contentValues,
|
// contentValues,
|
||||||
"$TODO_COLUMN_ID=?",
|
// "$TODO_COLUMN_ID=?",
|
||||||
arrayOf(todo.id.toString())
|
// arrayOf(todo.id.toString())
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/* delete a single to-do */
|
// /* delete a single to-do */
|
||||||
fun deleteTodo(todoId: Long) {
|
// fun deleteTodo(todoId: Long) {
|
||||||
writableDatabase.delete(TODO_TABLE_NAME,
|
// writableDatabase.delete(TODO_TABLE_NAME,
|
||||||
"$TODO_COLUMN_ID=?", arrayOf(todoId.toString()))
|
// "$TODO_COLUMN_ID=?", arrayOf(todoId.toString()))
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/* delete all existing todos at once */
|
// /* delete all existing todos at once */
|
||||||
fun deleteAll() {
|
// fun deleteAll() {
|
||||||
writableDatabase.delete(TODO_TABLE_NAME, null, null)
|
// writableDatabase.delete(TODO_TABLE_NAME, null, null)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@get:SuppressLint("Range")
|
// @get:SuppressLint("Range")
|
||||||
val todos: ArrayList<Todo>
|
// val todos: ArrayList<Todo>
|
||||||
get() {
|
// get() {
|
||||||
val todoList = ArrayList<Todo>()
|
// val todoList = ArrayList<Todo>()
|
||||||
val queryResult =
|
//// val queryResult =
|
||||||
readableDatabase.rawQuery("SELECT * from $TODO_TABLE_NAME", null)
|
//// readableDatabase.rawQuery("SELECT * from $TODO_TABLE_NAME", null)
|
||||||
|
////
|
||||||
if (queryResult.moveToFirst()) {
|
//// if (queryResult.moveToFirst()) {
|
||||||
do {
|
//// do {
|
||||||
val todo = Todo()
|
//// val todo = Todo()
|
||||||
todo.id = queryResult.getLong(queryResult.getColumnIndex(TODO_COLUMN_ID))
|
//// todo.id = queryResult.getLong(queryResult.getColumnIndex(TODO_COLUMN_ID))
|
||||||
todo.name = queryResult.getString(queryResult.getColumnIndex(TODO_COLUMN_NAME))
|
//// todo.name = queryResult.getString(queryResult.getColumnIndex(TODO_COLUMN_NAME))
|
||||||
todoList.add(todo)
|
//// todoList.add(todo)
|
||||||
} while (queryResult.moveToNext())
|
//// } while (queryResult.moveToNext())
|
||||||
}
|
//// }
|
||||||
|
////
|
||||||
queryResult.close()
|
//// queryResult.close()
|
||||||
return todoList
|
// return todoList
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/* check if any item exists in the database */
|
// /* check if any item exists in the database */
|
||||||
val isTodoExists: Boolean get() {
|
// val isTodoExists: Boolean get() {
|
||||||
return DatabaseUtils.queryNumEntries(readableDatabase, TODO_TABLE_NAME, 1.toString()) > 0
|
// return DatabaseUtils.queryNumEntries(readableDatabase, TODO_TABLE_NAME, 1.toString()) > 0
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@ -75,39 +75,39 @@ internal class MissedCallsAdapter(
|
|||||||
|
|
||||||
/* update dialog */
|
/* update dialog */
|
||||||
private fun updateDialog(position: Int) {
|
private fun updateDialog(position: Int) {
|
||||||
val bottomSheetDialog = BottomSheetDialog(lActivity!!, R.style.BottomSheetDialog)
|
// val bottomSheetDialog = BottomSheetDialog(lActivity!!, R.style.BottomSheetDialog)
|
||||||
val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(context))
|
// val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(context))
|
||||||
bottomSheetDialog.setContentView(dialogBinding.root)
|
// bottomSheetDialog.setContentView(dialogBinding.root)
|
||||||
bottomSheetDialog.show()
|
// bottomSheetDialog.show()
|
||||||
bottomSheetDialog.dismissWithAnimation = true
|
// bottomSheetDialog.dismissWithAnimation = true
|
||||||
|
//
|
||||||
val databaseHandler = DatabaseHandler(context)
|
// val databaseHandler = DatabaseHandler(context)
|
||||||
val todo = databaseHandler.todos[position]
|
// val todo = databaseHandler.todos[position]
|
||||||
|
//
|
||||||
dialogBinding.apply {
|
// dialogBinding.apply {
|
||||||
deleteAllConfirmation.visibility = View.GONE
|
// deleteAllConfirmation.visibility = View.GONE
|
||||||
todoInput.setText(todo.name)
|
// todoInput.setText(todo.name)
|
||||||
todoCancel.text = context.getString(R.string.delete)
|
// todoCancel.text = context.getString(R.string.delete)
|
||||||
todoCancel.setTextColor(ContextCompat.getColor(context, android.R.color.holo_red_light))
|
// todoCancel.setTextColor(ContextCompat.getColor(context, android.R.color.holo_red_light))
|
||||||
todoOk.text = context.getString(R.string.update)
|
// todoOk.text = context.getString(R.string.update)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/* delete the item */
|
// /* delete the item */
|
||||||
dialogBinding.todoCancel.setOnClickListener {
|
// dialogBinding.todoCancel.setOnClickListener {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/* update the item */
|
// /* update the item */
|
||||||
dialogBinding.todoOk.setOnClickListener {
|
// dialogBinding.todoOk.setOnClickListener {
|
||||||
val updatedTodoString = Objects.requireNonNull(dialogBinding.todoInput.text).toString().trim { it <= ' ' }
|
// val updatedTodoString = Objects.requireNonNull(dialogBinding.todoInput.text).toString().trim { it <= ' ' }
|
||||||
if (updatedTodoString.isNotEmpty()) {
|
// if (updatedTodoString.isNotEmpty()) {
|
||||||
todo.name = updatedTodoString
|
// todo.name = updatedTodoString
|
||||||
databaseHandler.updateTodo(todo)
|
// databaseHandler.updateTodo(todo)
|
||||||
bottomSheetDialog.dismiss()
|
// bottomSheetDialog.dismiss()
|
||||||
} else {
|
// } else {
|
||||||
dialogBinding.todoInput.error = context.getString(R.string.empty_text_field)
|
// dialogBinding.todoInput.error = context.getString(R.string.empty_text_field)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
/*
|
///*
|
||||||
* Lunar Launcher
|
// * Lunar Launcher
|
||||||
* Copyright (C) 2022 Md Rasel Hossain
|
// * Copyright (C) 2022 Md Rasel Hossain
|
||||||
*
|
// *
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
// * it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// * the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// * (at your option) any later version.
|
||||||
*
|
// *
|
||||||
* This program is distributed in the hope that it will be useful,
|
// * This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// * GNU General Public License for more details.
|
||||||
*
|
// *
|
||||||
* You should have received a copy of the GNU General Public License
|
// * You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
package rasel.lunar.launcher.todos
|
//package rasel.lunar.launcher.todos
|
||||||
|
//
|
||||||
|
//
|
||||||
internal class Todo {
|
//internal class Todo {
|
||||||
var id: Long = -1
|
// var id: Long = -1
|
||||||
var name = ""
|
// var name = ""
|
||||||
}
|
//}
|
||||||
|
|||||||
@ -1,127 +1,129 @@
|
|||||||
/*
|
///*
|
||||||
* Lunar Launcher
|
// * Lunar Launcher
|
||||||
* Copyright (C) 2022 Md Rasel Hossain
|
// * Copyright (C) 2022 Md Rasel Hossain
|
||||||
*
|
// *
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
// * it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// * the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// * (at your option) any later version.
|
||||||
*
|
// *
|
||||||
* This program is distributed in the hope that it will be useful,
|
// * This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// * GNU General Public License for more details.
|
||||||
*
|
// *
|
||||||
* You should have received a copy of the GNU General Public License
|
// * You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
package rasel.lunar.launcher.todos
|
//package rasel.lunar.launcher.todos
|
||||||
|
//
|
||||||
import android.annotation.SuppressLint
|
//import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
//import android.content.Context
|
||||||
import android.view.LayoutInflater
|
//import android.view.LayoutInflater
|
||||||
import android.view.View
|
//import android.view.View
|
||||||
import android.view.ViewGroup
|
//import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
//import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
//import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
//import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
//import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||||
import rasel.lunar.launcher.R
|
//import rasel.lunar.launcher.R
|
||||||
import rasel.lunar.launcher.databinding.ListItemBinding
|
//import rasel.lunar.launcher.databinding.ListItemBinding
|
||||||
import rasel.lunar.launcher.databinding.TodoDialogBinding
|
//import rasel.lunar.launcher.databinding.TodoDialogBinding
|
||||||
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_COUNTS
|
//import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_COUNTS
|
||||||
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
|
//import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
|
||||||
import rasel.lunar.launcher.helpers.UniUtils.Companion.copyToClipboard
|
//import rasel.lunar.launcher.helpers.UniUtils.Companion.copyToClipboard
|
||||||
import java.util.*
|
//import java.util.*
|
||||||
|
//
|
||||||
|
//
|
||||||
internal class TodoAdapter(
|
//internal class TodoAdapter(
|
||||||
private val todoManager: TodoManager?,
|
// private val todoManager: TodoManager?,
|
||||||
private val context: Context) : RecyclerView.Adapter<TodoAdapter.TodoViewHolder>() {
|
// private val context: Context) : RecyclerView.Adapter<TodoAdapter.TodoViewHolder>() {
|
||||||
|
//
|
||||||
private val currentFragment = lActivity!!.supportFragmentManager.findFragmentById(R.id.mainFragmentsContainer)
|
// private val currentFragment = lActivity!!.supportFragmentManager.findFragmentById(R.id.mainFragmentsContainer)
|
||||||
private val todoList = DatabaseHandler(context).todos
|
//// private val todoList = DatabaseHandler(context).todos
|
||||||
|
//
|
||||||
override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): TodoViewHolder {
|
// override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): TodoViewHolder {
|
||||||
val binding = ListItemBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
|
// val binding = ListItemBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
|
||||||
return TodoViewHolder(binding)
|
// return TodoViewHolder(binding)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun getItemCount(): Int {
|
// override fun getItemCount(): Int {
|
||||||
/* if current fragment is LauncherHome,
|
// /* if current fragment is LauncherHome,
|
||||||
then return size following the settings value */
|
// then return size following the settings value */
|
||||||
val sharedPreferences = context.getSharedPreferences(PREFS_SETTINGS, 0)
|
// val sharedPreferences = context.getSharedPreferences(PREFS_SETTINGS, 0)
|
||||||
val numberOfTodos = sharedPreferences.getInt(KEY_TODO_COUNTS, 3)
|
// val numberOfTodos = sharedPreferences.getInt(KEY_TODO_COUNTS, 3)
|
||||||
return if (currentFragment !is TodoManager) {
|
// return if (currentFragment !is TodoManager) {
|
||||||
todoList.size.coerceAtMost(numberOfTodos)
|
//// todoList.size.coerceAtMost(numberOfTodos)
|
||||||
} else {
|
// 0
|
||||||
todoList.size
|
// } else {
|
||||||
}
|
//// todoList.size
|
||||||
}
|
// 0
|
||||||
|
// }
|
||||||
@SuppressLint("SetTextI18n")
|
// }
|
||||||
override fun onBindViewHolder(holder: TodoViewHolder, position: Int) {
|
//
|
||||||
val todo = todoList[position]
|
// @SuppressLint("SetTextI18n")
|
||||||
|
// override fun onBindViewHolder(holder: TodoViewHolder, position: Int) {
|
||||||
holder.view.itemText.text = "\u25CF ${todo.name}"
|
//// val todo = todoList[position]
|
||||||
|
//
|
||||||
if (currentFragment is TodoManager) {
|
//// holder.view.itemText.text = "\u25CF ${todo.name}"
|
||||||
/* multiline texts are enabled for TodoManager */
|
////
|
||||||
holder.view.itemText.isSingleLine = false
|
//// if (currentFragment is TodoManager) {
|
||||||
/* launch edit or update dialog on item click */
|
//// /* multiline texts are enabled for TodoManager */
|
||||||
holder.view.itemText.setOnClickListener { updateDialog(position) }
|
//// holder.view.itemText.isSingleLine = false
|
||||||
/* copy texts on long click */
|
//// /* launch edit or update dialog on item click */
|
||||||
holder.view.itemText.setOnLongClickListener {
|
//// holder.view.itemText.setOnClickListener { updateDialog(position) }
|
||||||
copyToClipboard(context, todo.name)
|
//// /* copy texts on long click */
|
||||||
true
|
//// holder.view.itemText.setOnLongClickListener {
|
||||||
}
|
//// copyToClipboard(context, todo.name)
|
||||||
} else {
|
//// true
|
||||||
/* single line text for home screen */
|
//// }
|
||||||
holder.view.itemText.isSingleLine = true
|
//// } else {
|
||||||
}
|
//// /* single line text for home screen */
|
||||||
}
|
//// holder.view.itemText.isSingleLine = true
|
||||||
|
//// }
|
||||||
inner class TodoViewHolder(var view: ListItemBinding) : RecyclerView.ViewHolder(view.root)
|
// }
|
||||||
|
//
|
||||||
/* update dialog */
|
// inner class TodoViewHolder(var view: ListItemBinding) : RecyclerView.ViewHolder(view.root)
|
||||||
private fun updateDialog(position: Int) {
|
//
|
||||||
val bottomSheetDialog = BottomSheetDialog(lActivity!!, R.style.BottomSheetDialog)
|
// /* update dialog */
|
||||||
val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(context))
|
// private fun updateDialog(position: Int) {
|
||||||
bottomSheetDialog.setContentView(dialogBinding.root)
|
// val bottomSheetDialog = BottomSheetDialog(lActivity!!, R.style.BottomSheetDialog)
|
||||||
bottomSheetDialog.show()
|
// val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(context))
|
||||||
bottomSheetDialog.dismissWithAnimation = true
|
// bottomSheetDialog.setContentView(dialogBinding.root)
|
||||||
|
// bottomSheetDialog.show()
|
||||||
val databaseHandler = DatabaseHandler(context)
|
// bottomSheetDialog.dismissWithAnimation = true
|
||||||
val todo = databaseHandler.todos[position]
|
//
|
||||||
|
// val databaseHandler = DatabaseHandler(context)
|
||||||
dialogBinding.apply {
|
// val todo = databaseHandler.todos[position]
|
||||||
deleteAllConfirmation.visibility = View.GONE
|
//
|
||||||
todoInput.setText(todo.name)
|
// dialogBinding.apply {
|
||||||
todoCancel.text = context.getString(R.string.delete)
|
// deleteAllConfirmation.visibility = View.GONE
|
||||||
todoCancel.setTextColor(ContextCompat.getColor(context, android.R.color.holo_red_light))
|
// todoInput.setText(todo.name)
|
||||||
todoOk.text = context.getString(R.string.update)
|
// todoCancel.text = context.getString(R.string.delete)
|
||||||
}
|
// todoCancel.setTextColor(ContextCompat.getColor(context, android.R.color.holo_red_light))
|
||||||
|
// todoOk.text = context.getString(R.string.update)
|
||||||
/* delete the item */
|
// }
|
||||||
dialogBinding.todoCancel.setOnClickListener {
|
//
|
||||||
databaseHandler.deleteTodo(todo.id)
|
// /* delete the item */
|
||||||
bottomSheetDialog.dismiss()
|
// dialogBinding.todoCancel.setOnClickListener {
|
||||||
todoManager?.refreshList()
|
// databaseHandler.deleteTodo(todo.id)
|
||||||
}
|
// bottomSheetDialog.dismiss()
|
||||||
|
// todoManager?.refreshList()
|
||||||
/* update the item */
|
// }
|
||||||
dialogBinding.todoOk.setOnClickListener {
|
//
|
||||||
val updatedTodoString = Objects.requireNonNull(dialogBinding.todoInput.text).toString().trim { it <= ' ' }
|
// /* update the item */
|
||||||
if (updatedTodoString.isNotEmpty()) {
|
// dialogBinding.todoOk.setOnClickListener {
|
||||||
todo.name = updatedTodoString
|
// val updatedTodoString = Objects.requireNonNull(dialogBinding.todoInput.text).toString().trim { it <= ' ' }
|
||||||
databaseHandler.updateTodo(todo)
|
// if (updatedTodoString.isNotEmpty()) {
|
||||||
bottomSheetDialog.dismiss()
|
// todo.name = updatedTodoString
|
||||||
todoManager?.refreshList()
|
// databaseHandler.updateTodo(todo)
|
||||||
} else {
|
// bottomSheetDialog.dismiss()
|
||||||
dialogBinding.todoInput.error = context.getString(R.string.empty_text_field)
|
// todoManager?.refreshList()
|
||||||
}
|
// } else {
|
||||||
}
|
// dialogBinding.todoInput.error = context.getString(R.string.empty_text_field)
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|||||||
@ -1,129 +1,129 @@
|
|||||||
/*
|
///*
|
||||||
* Lunar Launcher
|
// * Lunar Launcher
|
||||||
* Copyright (C) 2022 Md Rasel Hossain
|
// * Copyright (C) 2022 Md Rasel Hossain
|
||||||
*
|
// *
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
// * it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// * the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// * (at your option) any later version.
|
||||||
*
|
// *
|
||||||
* This program is distributed in the hope that it will be useful,
|
// * This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// * GNU General Public License for more details.
|
||||||
*
|
// *
|
||||||
* You should have received a copy of the GNU General Public License
|
// * You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
package rasel.lunar.launcher.todos
|
//package rasel.lunar.launcher.todos
|
||||||
|
//
|
||||||
import android.content.Context
|
//import android.content.Context
|
||||||
import android.os.Bundle
|
//import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
//import android.view.LayoutInflater
|
||||||
import android.view.View
|
//import android.view.View
|
||||||
import android.view.ViewGroup
|
//import android.view.ViewGroup
|
||||||
import android.view.inputmethod.InputMethodManager
|
//import android.view.inputmethod.InputMethodManager
|
||||||
import androidx.core.content.ContextCompat
|
//import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.Fragment
|
//import androidx.fragment.app.Fragment
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
//import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
//import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||||
import rasel.lunar.launcher.R
|
//import rasel.lunar.launcher.R
|
||||||
import rasel.lunar.launcher.databinding.TodoDialogBinding
|
//import rasel.lunar.launcher.databinding.TodoDialogBinding
|
||||||
import rasel.lunar.launcher.databinding.TodoManagerBinding
|
//import rasel.lunar.launcher.databinding.TodoManagerBinding
|
||||||
import java.util.*
|
//import java.util.*
|
||||||
|
//
|
||||||
|
//
|
||||||
internal class TodoManager : Fragment() {
|
//internal class TodoManager : Fragment() {
|
||||||
|
//
|
||||||
private lateinit var binding: TodoManagerBinding
|
// private lateinit var binding: TodoManagerBinding
|
||||||
private lateinit var databaseHandler: DatabaseHandler
|
// private lateinit var databaseHandler: DatabaseHandler
|
||||||
|
//
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
// override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
//
|
||||||
binding = TodoManagerBinding.inflate(inflater, container, false)
|
// binding = TodoManagerBinding.inflate(inflater, container, false)
|
||||||
databaseHandler = DatabaseHandler(requireContext())
|
// databaseHandler = DatabaseHandler(requireContext())
|
||||||
|
//
|
||||||
return binding.root
|
// return binding.root
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
// override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
// super.onViewCreated(view, savedInstanceState)
|
||||||
/* click listeners for add new and delete all buttons */
|
// /* click listeners for add new and delete all buttons */
|
||||||
binding.addNew.setOnClickListener { addNewDialog() }
|
// binding.addNew.setOnClickListener { addNewDialog() }
|
||||||
binding.deleteAll.setOnClickListener { deleteAllDialog() }
|
// binding.deleteAll.setOnClickListener { deleteAllDialog() }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onResume() {
|
// override fun onResume() {
|
||||||
super.onResume()
|
// super.onResume()
|
||||||
refreshList()
|
// refreshList()
|
||||||
lActivity!!.viewPager.isUserInputEnabled = false
|
// lActivity!!.viewPager.isUserInputEnabled = false
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onPause() {
|
// override fun onPause() {
|
||||||
super.onPause()
|
// super.onPause()
|
||||||
lActivity!!.viewPager.isUserInputEnabled = true
|
// lActivity!!.viewPager.isUserInputEnabled = true
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
fun refreshList() {
|
// fun refreshList() {
|
||||||
binding.todos.adapter = TodoAdapter(this, requireContext())
|
// binding.todos.adapter = TodoAdapter(this, requireContext())
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/* add new dialog */
|
// /* add new dialog */
|
||||||
private fun addNewDialog() {
|
// private fun addNewDialog() {
|
||||||
val bottomSheetDialog = BottomSheetDialog(lActivity!!, R.style.BottomSheetDialog)
|
// val bottomSheetDialog = BottomSheetDialog(lActivity!!, R.style.BottomSheetDialog)
|
||||||
val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(requireContext()))
|
// val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(requireContext()))
|
||||||
bottomSheetDialog.setContentView(dialogBinding.root)
|
// bottomSheetDialog.setContentView(dialogBinding.root)
|
||||||
bottomSheetDialog.show()
|
// bottomSheetDialog.show()
|
||||||
bottomSheetDialog.dismissWithAnimation = true
|
// bottomSheetDialog.dismissWithAnimation = true
|
||||||
|
//
|
||||||
dialogBinding.deleteAllConfirmation.visibility = View.GONE
|
// dialogBinding.deleteAllConfirmation.visibility = View.GONE
|
||||||
/* automatic keyboard popup */
|
// /* automatic keyboard popup */
|
||||||
dialogBinding.todoInput.requestFocus()
|
// dialogBinding.todoInput.requestFocus()
|
||||||
val inputMethodManager = lActivity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
// val inputMethodManager = lActivity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
inputMethodManager.showSoftInput(dialogBinding.todoInput, InputMethodManager.SHOW_IMPLICIT)
|
// inputMethodManager.showSoftInput(dialogBinding.todoInput, InputMethodManager.SHOW_IMPLICIT)
|
||||||
|
//
|
||||||
/* dismiss the dialog on cancel button click */
|
// /* dismiss the dialog on cancel button click */
|
||||||
dialogBinding.todoCancel.setOnClickListener { bottomSheetDialog.dismiss() }
|
// dialogBinding.todoCancel.setOnClickListener { bottomSheetDialog.dismiss() }
|
||||||
/* add new item to the database */
|
// /* add new item to the database */
|
||||||
dialogBinding.todoOk.setOnClickListener {
|
// dialogBinding.todoOk.setOnClickListener {
|
||||||
val todo = Todo()
|
// val todo = Todo()
|
||||||
val todoString = Objects.requireNonNull(dialogBinding.todoInput.text).toString().trim { it <= ' ' }
|
// val todoString = Objects.requireNonNull(dialogBinding.todoInput.text).toString().trim { it <= ' ' }
|
||||||
if (todoString.isNotEmpty()) {
|
// if (todoString.isNotEmpty()) {
|
||||||
todo.name = todoString
|
// todo.name = todoString
|
||||||
databaseHandler.addTodo(todo)
|
// databaseHandler.addTodo(todo)
|
||||||
bottomSheetDialog.dismiss()
|
// bottomSheetDialog.dismiss()
|
||||||
refreshList()
|
// refreshList()
|
||||||
} else {
|
// } else {
|
||||||
dialogBinding.todoInput.error = getString(R.string.empty_text_field)
|
// dialogBinding.todoInput.error = getString(R.string.empty_text_field)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/* delete all dialog */
|
// /* delete all dialog */
|
||||||
private fun deleteAllDialog() {
|
// private fun deleteAllDialog() {
|
||||||
val bottomSheetDialog = BottomSheetDialog(lActivity!!)
|
// val bottomSheetDialog = BottomSheetDialog(lActivity!!)
|
||||||
val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(requireContext()))
|
// val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(requireContext()))
|
||||||
bottomSheetDialog.setContentView(dialogBinding.root)
|
// bottomSheetDialog.setContentView(dialogBinding.root)
|
||||||
bottomSheetDialog.show()
|
// bottomSheetDialog.show()
|
||||||
bottomSheetDialog.dismissWithAnimation = true
|
// bottomSheetDialog.dismissWithAnimation = true
|
||||||
|
//
|
||||||
/* if any item does not exist, then disable the ok button */
|
// /* if any item does not exist, then disable the ok button */
|
||||||
if (!databaseHandler.isTodoExists) {
|
// if (!databaseHandler.isTodoExists) {
|
||||||
dialogBinding.todoOk.isEnabled = false
|
// dialogBinding.todoOk.isEnabled = false
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
dialogBinding.todoInput.visibility = View.GONE
|
// dialogBinding.todoInput.visibility = View.GONE
|
||||||
dialogBinding.todoOk.setTextColor(ContextCompat.getColor(requireContext(), android.R.color.holo_red_light))
|
// dialogBinding.todoOk.setTextColor(ContextCompat.getColor(requireContext(), android.R.color.holo_red_light))
|
||||||
|
//
|
||||||
/* dismiss the dialog on cancel button click */
|
// /* dismiss the dialog on cancel button click */
|
||||||
dialogBinding.todoCancel.setOnClickListener { bottomSheetDialog.dismiss() }
|
// dialogBinding.todoCancel.setOnClickListener { bottomSheetDialog.dismiss() }
|
||||||
/* delete all the existing items from the database */
|
// /* delete all the existing items from the database */
|
||||||
dialogBinding.todoOk.setOnClickListener {
|
// dialogBinding.todoOk.setOnClickListener {
|
||||||
databaseHandler.deleteAll()
|
// databaseHandler.deleteAll()
|
||||||
bottomSheetDialog.dismiss()
|
// bottomSheetDialog.dismiss()
|
||||||
refreshList()
|
// refreshList()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
113
app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt
Normal file
113
app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
package rasel.lunar.launcher.utils
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.IntentService
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.database.Cursor
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.provider.CallLog
|
||||||
|
import androidx.work.Data
|
||||||
|
import androidx.work.Worker
|
||||||
|
import androidx.work.WorkerParameters
|
||||||
|
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||||
|
import rasel.lunar.launcher.home.MissedCall
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
class MissedCallGetter : Worker {
|
||||||
|
|
||||||
|
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun doWork(): Result {
|
||||||
|
var resultData = Data.Builder()
|
||||||
|
var dateParam = Date(System.currentTimeMillis() - (1000 * 60 * 60 * 24)).time.toString()
|
||||||
|
lActivity?.contentResolver?.query(
|
||||||
|
CallLog.Calls.CONTENT_URI, arrayOf(
|
||||||
|
CallLog.Calls.NUMBER,
|
||||||
|
CallLog.Calls.TYPE,
|
||||||
|
CallLog.Calls.DATE,
|
||||||
|
CallLog.Calls.DURATION,
|
||||||
|
CallLog.Calls.CACHED_NAME,
|
||||||
|
), CallLog.Calls.DATE + "> ? AND " + CallLog.Calls.TYPE + " > ?", arrayOf<String>(dateParam, "2"), CallLog.Calls.DATE + " desc")?.let { managedCursor ->
|
||||||
|
try {
|
||||||
|
val number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER)
|
||||||
|
val type = managedCursor.getColumnIndex(CallLog.Calls.TYPE)
|
||||||
|
val date = managedCursor.getColumnIndex(CallLog.Calls.DATE)
|
||||||
|
val duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION)
|
||||||
|
val name = managedCursor.getColumnIndex(CallLog.Calls.CACHED_NAME)
|
||||||
|
var missedCalls = hashMapOf<String, MissedCall>()
|
||||||
|
while (managedCursor.moveToNext()) {
|
||||||
|
val phNumber = managedCursor.getString(number) // mobile number
|
||||||
|
val callType = managedCursor.getString(type) // call type
|
||||||
|
val callDate = managedCursor.getString(date) // call date
|
||||||
|
val callDayTime: Date = Date(callDate.toLong())
|
||||||
|
val callDuration = managedCursor.getString(duration)
|
||||||
|
val callerName = managedCursor.getString(name)
|
||||||
|
|
||||||
|
var dir: String = ""
|
||||||
|
val dircode = callType.toInt()
|
||||||
|
when (dircode) {
|
||||||
|
CallLog.Calls.INCOMING_TYPE -> {
|
||||||
|
dir = "INCOMING_TYPE"
|
||||||
|
}
|
||||||
|
|
||||||
|
CallLog.Calls.OUTGOING_TYPE -> {
|
||||||
|
dir = "OUTGOING_TYPE"
|
||||||
|
}
|
||||||
|
|
||||||
|
CallLog.Calls.MISSED_TYPE -> {
|
||||||
|
dir = "MISSED_TYPE"
|
||||||
|
}
|
||||||
|
|
||||||
|
CallLog.Calls.VOICEMAIL_TYPE -> {
|
||||||
|
dir = "VOICEMAIL_TYPE"
|
||||||
|
}
|
||||||
|
|
||||||
|
CallLog.Calls.REJECTED_TYPE -> {
|
||||||
|
dir = "REJECTED_TYPE"
|
||||||
|
}
|
||||||
|
|
||||||
|
CallLog.Calls.BLOCKED_TYPE -> {
|
||||||
|
dir = "BLOCKED_TYPE"
|
||||||
|
}
|
||||||
|
|
||||||
|
CallLog.Calls.ANSWERED_EXTERNALLY_TYPE -> {
|
||||||
|
dir = "ANSWERED_EXTERNALLY_TYPE"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var missed: MissedCall = if (missedCalls.containsKey(phNumber)) {
|
||||||
|
missedCalls.get(phNumber)!!.apply {
|
||||||
|
count = count + 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MissedCall(
|
||||||
|
1,
|
||||||
|
callerName,
|
||||||
|
phNumber,
|
||||||
|
dircode,
|
||||||
|
dir,
|
||||||
|
SimpleDateFormat("yyy/MM/dd-HH:mm:ss").format(callDayTime)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
missedCalls.put(phNumber, missed)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
missedCalls.forEach { t, u ->
|
||||||
|
resultData.put(t, u.toJson())
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e: Exception) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
managedCursor.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.success(resultData.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user