Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

update merge #78

Merged
merged 6 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ jobs:
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Build Debug APK
# Create APK Debug
- name: Build apk debug project (APK)
run: ./gradlew assembleDebug
- name: Create APK directory
run: mkdir -p apk
- name: Copy APK to directory
run: cp app/build/outputs/apk/debug/*.apk apk/
# Create an artifacts folder if it doesn't exist, and move APK into it
- name: Move APK to artifacts folder
run: |
mkdir -p ${{ github.workspace }}/artifacts/
mv ${{ env.main_project_module }}/build/outputs/apk/debug/* ${{ github.workspace }}/artifacts/
- name: Upload APK Debug - ${{ env.repository_name }}
uses: actions/upload-artifact@v3
with:
name: Tasky_debug
path: ${{ github.workspace }}/artifacts/
17 changes: 5 additions & 12 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.thatsmanmeet.taskyapp"
minSdk 26
targetSdk 34
versionCode 25
versionName "2.4.1"
versionCode 26
versionName "2.4.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
Expand Down Expand Up @@ -71,7 +71,7 @@ dependencies {
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
def room_version = "2.6.0"
def room_version = "2.6.1"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.compose.runtime:runtime-livedata:1.5.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ fun ActionDialogBox(
if(isDialogShowing.value){
AlertDialog(
onDismissRequest = {
onDismissClick()
isDialogShowing.value = false
},
confirmButton = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fun addTodoDialog(
},
confirmButton = {
Button(onClick = {
if (enteredText1.isNotEmpty() && descriptionText.isNotEmpty()){
if (enteredText1.isNotEmpty()){
val todo = Todo(
ID = null,
title = enteredText1,
Expand Down Expand Up @@ -216,7 +216,7 @@ fun addTodoDialog(
isRepeating = false
}
else{
Toast.makeText(context,"Fill in all fields",Toast.LENGTH_SHORT).show()
Toast.makeText(context,"Task name is required.",Toast.LENGTH_SHORT).show()
}
}
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.thatsmanmeet.taskyapp.components

import android.content.Context
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.thatsmanmeet.taskyapp.room.Todo
import com.thatsmanmeet.taskyapp.room.TodoViewModel
import com.thatsmanmeet.taskyapp.room.deletedtodo.DeletedTodo
import com.thatsmanmeet.taskyapp.room.deletedtodo.DeletedTodoViewModel
import com.thatsmanmeet.taskyapp.screens.currentDateTimeComparator
import com.thatsmanmeet.taskyapp.screens.scheduleNotification


@Composable
fun DeletedTodoItem(
deletedTodo: DeletedTodo,
todoViewModel: TodoViewModel,
deletedTodoViewModel: DeletedTodoViewModel,
context:Context = LocalContext.current,
modifier: Modifier = Modifier
) {
val isShowing = remember {
mutableStateOf(false)
}
Row(
modifier = modifier
.fillMaxWidth()
.padding(10.dp)
.heightIn(60.dp)
.clip(RoundedCornerShape(10.dp))
.clickable {
isShowing.value = true
}
.background(MaterialTheme.colorScheme.inverseOnSurface),
verticalAlignment = Alignment.CenterVertically
) {
Box(modifier = modifier
.fillMaxWidth()
.padding(10.dp)){
Text(
text = deletedTodo.title!!,
fontSize = 20.sp,
textDecoration = if(deletedTodo.isCompleted) TextDecoration.LineThrough else TextDecoration.None
)
}
}
if(isShowing.value){
ActionDialogBox(
isDialogShowing = isShowing,
title = "Choose Action",
message = "Do you want to restore or delete this task?",
confirmButtonText = "Restore" ,
dismissButtonText = "Delete",
onConfirmClick = {
val newTodo = Todo(
ID = deletedTodo.ID,
title = deletedTodo.title,
todoDescription = deletedTodo.todoDescription,
isCompleted = deletedTodo.isCompleted,
date = deletedTodo.date,
time = deletedTodo.time,
notificationID = deletedTodo.notificationID,
isRecurring = deletedTodo.isRecurring
)
todoViewModel.insertTodo(newTodo)
if(newTodo.time!!.isNotEmpty()){
currentDateTimeComparator(inputDate = newTodo.date!!, inputTime = newTodo.time!!) {
scheduleNotification(
context = context,
titleText = newTodo.title!!,
messageText = newTodo.todoDescription!!,
time = "${newTodo.date} ${newTodo.time}",
todo = newTodo
)
}
}
deletedTodoViewModel.deleteDeletedTodo(deletedTodo)
},
onDismissClick = {
deletedTodoViewModel.deleteDeletedTodo(deletedTodo)
},

)
}
}
73 changes: 42 additions & 31 deletions app/src/main/java/com/thatsmanmeet/taskyapp/components/TaskList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.SwipeToDismiss
import androidx.compose.material3.rememberDismissState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.movableContentOf
import androidx.compose.runtime.mutableStateOf
Expand All @@ -40,6 +41,8 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import com.thatsmanmeet.taskyapp.room.Todo
import com.thatsmanmeet.taskyapp.room.TodoViewModel
import com.thatsmanmeet.taskyapp.room.deletedtodo.DeletedTodo
import com.thatsmanmeet.taskyapp.room.deletedtodo.DeletedTodoViewModel
import com.thatsmanmeet.taskyapp.screens.CurrentDateTimeComparator
import com.thatsmanmeet.taskyapp.screens.cancelNotification
import com.thatsmanmeet.taskyapp.screens.scheduleNotification
Expand All @@ -56,6 +59,7 @@ fun TaskList(
state: LazyListState,
list : List<Todo>,
todoViewModel: TodoViewModel,
deletedTodoViewModel: DeletedTodoViewModel,
onClick : (Int) -> Unit,
searchText: String,
coroutineScope: CoroutineScope,
Expand Down Expand Up @@ -96,39 +100,37 @@ fun TaskList(

if(dismissState.isDismissed(direction = DismissDirection.EndToStart)){
isSwipeDeleteDialogShowing.value = true
ActionDialogBox(
isDialogShowing = isSwipeDeleteDialogShowing,
title = "Delete Task?",
message = "Do you want to delete this task?",
confirmButtonText = "Delete",
dismissButtonText = "Cancel",
onConfirmClick = {
todoViewModel.deleteTodo(currentItem)
},
onDismissClick = {
isSwipeDeleteDialogShowing.value = false
coroutineScope.launch {
dismissState.reset()
}
},
confirmButtonColor = Color(0xFFF75F5F),
confirmButtonContentColor = Color.White
)
// LaunchedEffect(Unit){
// val result = snackbarHostState.showSnackbar(
// message = "Task will be deleted soon!",
// actionLabel = "Undo",
// duration = SnackbarDuration.Short
// )
// when(result){
// SnackbarResult.Dismissed -> {
// todoViewModel.deleteTodo(currentItem)
// }
// SnackbarResult.ActionPerformed -> {
deletedTodoViewModel.insertDeletedTodo(DeletedTodo(
ID = currentItem.ID,
title = currentItem.title,
todoDescription = currentItem.todoDescription,
isCompleted = currentItem.isCompleted,
date = currentItem.date,
time = currentItem.time,
isRecurring = currentItem.isRecurring,
notificationID = currentItem.notificationID,
todoDeletionDate = getDate30DaysLater(currentItem.date!!)
))
todoViewModel.deleteTodo(currentItem)
cancelNotification(context,currentItem)
// ActionDialogBox(
// isDialogShowing = isSwipeDeleteDialogShowing,
// title = "Delete Task?",
// message = "Do you want to delete this task?",
// confirmButtonText = "Delete",
// dismissButtonText = "Cancel",
// onConfirmClick = {
// todoViewModel.deleteTodo(currentItem)
// },
// onDismissClick = {
// isSwipeDeleteDialogShowing.value = false
// coroutineScope.launch {
// dismissState.reset()
// }
// }
// }
// },
// confirmButtonColor = Color(0xFFF75F5F),
// confirmButtonContentColor = Color.White
// )
}

if(dismissState.isDismissed(direction = DismissDirection.StartToEnd)){
Expand Down Expand Up @@ -214,4 +216,13 @@ fun TaskList(
}
}
}
}

fun getDate30DaysLater(enteredDate:String):String{
val sdf = SimpleDateFormat("dd/MM/yyyy",Locale.getDefault())
val date = sdf.parse(enteredDate)
val calendar = Calendar.getInstance()
calendar.time = date!!
calendar.add(Calendar.DAY_OF_MONTH,30)
return sdf.format(calendar.time)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.room.Room
import com.thatsmanmeet.taskyapp.constants.Constants
import com.thatsmanmeet.taskyapp.room.Todo
import com.thatsmanmeet.taskyapp.room.TodoDatabase
import com.thatsmanmeet.taskyapp.room.deletedtodo.DeletedTodoDatabase
import com.thatsmanmeet.taskyapp.screens.scheduleNotification
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand All @@ -28,6 +29,11 @@ class RepeatingTasksReceiver : BroadcastReceiver() {
TodoDatabase::class.java,
"todo_database"
).build()
val deletedTodoDatabase = Room.databaseBuilder(
context!!.applicationContext,
DeletedTodoDatabase::class.java,
"deleted_todo_database"
).build()
coroutineScope.launch {
withTimeout(10000) {
todoDatabase.todoDao().getAllTodosFlow().collect{todos->
Expand Down Expand Up @@ -60,6 +66,21 @@ class RepeatingTasksReceiver : BroadcastReceiver() {
}
}
}
coroutineScope.launch {
withTimeout(10000){
deletedTodoDatabase.deletedTodoDao().getAllTodosFlow().collect{deletedTodos->
val currentDate =
SimpleDateFormat("dd/MM/yyyy", Locale.getDefault()).format(
Date()
)
for(todo in deletedTodos){
if(currentDate == todo.todoDeletionDate){
deletedTodoDatabase.deletedTodoDao().deleteTodo(todo)
}
}
}
}
}
val nextAlarmIntent = Intent(context.applicationContext,RepeatingTasksReceiver::class.java).also {
it.action = "repeating_tasks"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ class TodoRepository(private val todoDao: TodoDao) {
}

fun getAllTodosFlow() : Flow<List<Todo>> = todoDao.getAllTodosFlow()

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.thatsmanmeet.taskyapp.room.deletedtodo

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "deleted_todo_table")
data class DeletedTodo(
@PrimaryKey(autoGenerate = true) var ID:Long? = null,
@ColumnInfo(name = "title") var title:String? = "",
@ColumnInfo(name = "completed") var isCompleted:Boolean = false,
@ColumnInfo(name = "date") var date:String? = "",
@ColumnInfo(name = "time") var time:String? = "",
@ColumnInfo(name = "notificationID", defaultValue = "0") var notificationID:Int = 0,
@ColumnInfo(name = "is_Recurring", defaultValue = "false") var isRecurring : Boolean = false,
@ColumnInfo(name = "description", defaultValue = "") var todoDescription : String? = "",
@ColumnInfo(name = "deletionDate", defaultValue = "") var todoDeletionDate: String ? = ""
)

Loading
Loading