Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
Branch hadiyarajesh (#68)
Browse files Browse the repository at this point in the history
* Added new line in Constants.kt

* Note card ui component added which will be inflated in lazy column to show all notes (#35)

* Added CODEOWNERS files (#33)

* Adding CONTRIBUTING.md

* Added CONTRIBUTING.md and squashed commits

* Updated branch naming convention

Updated branch naming convention with github-username

* 1. Added database schema (entity)
2. Added database functions (dao)
3. Added how to fetch paging data
4. Added LazyColumn UI with paging data with different states like loading, success, error

Signed-off-by: Rajesh Hadiya <[email protected]>

* Added CODEOWNERS files. (#19)

* Adding CODEOWNERS files.

Still needed to add the Default reviewer for the two teams.

* Update CODEOWNERS

* fix the validation issues on GitHub.

* updated owners for all the branches.

* updated the Wrong branch combinations.

Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>

* NoteCardView for all notes ui made

* Create main.yml

* Update main.yml

* Update main.yml

* Some improvements done generalised the code

* Some ui improvements and code to inflate all card views added

Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>
Co-authored-by: Rajesh Hadiya <[email protected]>

* Narendra ju/feature/folders setup (#45)

* Added CODEOWNERS files (#33)

* Adding CONTRIBUTING.md

* Added CONTRIBUTING.md and squashed commits

* Updated branch naming convention

Updated branch naming convention with github-username

* 1. Added database schema (entity)
2. Added database functions (dao)
3. Added how to fetch paging data
4. Added LazyColumn UI with paging data with different states like loading, success, error

Signed-off-by: Rajesh Hadiya <[email protected]>

* Added CODEOWNERS files. (#19)

* Adding CODEOWNERS files.

Still needed to add the Default reviewer for the two teams.

* Update CODEOWNERS

* fix the validation issues on GitHub.

* updated owners for all the branches.

* updated the Wrong branch combinations.

Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>

* Create main.yml

* Update main.yml

* Update main.yml

* Added PR template + Updated .gitignore files (#42)

Added the PR Templates +  .gitignore

* added the groundwork for the folders section in NoteX App

Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>
Co-authored-by: Rajesh Hadiya <[email protected]>

* Repository and ViewModel implementation for all notes screen. Issue #16 (#61)

* Branch sajalsj (#62)

* 1. view model added for Add note screen
2. UI WIP for add note screen

* 1. view model added for Add note screen
2. Add and edit screen UI complete

* Made changes written in PR

* Narendra ju/feature/folders setup (#45)

* Added CODEOWNERS files (#33)

* Adding CONTRIBUTING.md

* Added CONTRIBUTING.md and squashed commits

* Updated branch naming convention

Updated branch naming convention with github-username

* 1. Added database schema (entity)
2. Added database functions (dao)
3. Added how to fetch paging data
4. Added LazyColumn UI with paging data with different states like loading, success, error

Signed-off-by: Rajesh Hadiya <[email protected]>

* Added CODEOWNERS files. (#19)

* Adding CODEOWNERS files.

Still needed to add the Default reviewer for the two teams.

* Update CODEOWNERS

* fix the validation issues on GitHub.

* updated owners for all the branches.

* updated the Wrong branch combinations.

Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>

* Create main.yml

* Update main.yml

* Update main.yml

* Added PR template + Updated .gitignore files (#42)

Added the PR Templates +  .gitignore

* added the groundwork for the folders section in NoteX App

Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>
Co-authored-by: Rajesh Hadiya <[email protected]>

* Repository and ViewModel implementation for all notes screen. Issue #16 (#61)

* 1. view model added for Add note screen
2. UI WIP for add note screen

* 1. view model added for Add note screen
2. Add and edit screen UI complete

* Made changes written in PR

Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: sajal jain <[email protected]>
Co-authored-by: Narendra Nath Chatterjee <[email protected]>
Co-authored-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>
Co-authored-by: Rajesh Hadiya <[email protected]>
Co-authored-by: virunarala <[email protected]>

* Simba/feature/note folder screen UI (#49)

* Adding more UI changes

* Working on NoteFolder UI section

* Update NoteFolderScreen.kt

* Undid changes

* Fixed spacing between two row elems

* Added viewModel & minor changes to FolderRepository

* Added routes and deleted redundant data classes

* Added folder icon and minor changes

* Added spacing and string resources

* Resolved merge conflicts

Co-authored-by: Rajesh Hadiya <[email protected]>

* Note card ui component added which will be inflated in lazy column to show all notes (#35)

* Added CODEOWNERS files (#33)

* Adding CONTRIBUTING.md

* Added CONTRIBUTING.md and squashed commits

* Updated branch naming convention

Updated branch naming convention with github-username

* 1. Added database schema (entity)
2. Added database functions (dao)
3. Added how to fetch paging data
4. Added LazyColumn UI with paging data with different states like loading, success, error

Signed-off-by: Rajesh Hadiya <[email protected]>

* Added CODEOWNERS files. (#19)

* Adding CODEOWNERS files.

Still needed to add the Default reviewer for the two teams.

* Update CODEOWNERS

* fix the validation issues on GitHub.

* updated owners for all the branches.

* updated the Wrong branch combinations.

Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>

* NoteCardView for all notes ui made

* Create main.yml

* Update main.yml

* Update main.yml

* Some improvements done generalised the code

* Some ui improvements and code to inflate all card views added

Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>
Co-authored-by: Rajesh Hadiya <[email protected]>

* Updated FoldersScreen with NoteFolderScreen in NoteXNavigation.kt

Signed-off-by: Rajesh Hadiya <[email protected]>

* Update Type.kt

* Update AllNotesComponents.kt

Signed-off-by: Rajesh Hadiya <[email protected]>
Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Swapnil bhojwani <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>
Co-authored-by: Narendra Nath Chatterjee <[email protected]>
Co-authored-by: virunarala <[email protected]>
Co-authored-by: Sajal Jain <[email protected]>
Co-authored-by: sajal jain <[email protected]>
  • Loading branch information
8 people authored Oct 17, 2022
1 parent e0a54c6 commit dddb701
Show file tree
Hide file tree
Showing 30 changed files with 1,014 additions and 28 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This is a workflow to verify that Android build is successful.

name: Android Build test

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ "master", "dev", "branch_hadiyarajesh", "branch_loveleen", "branch_geet", "branch_siddu"]
pull_request:
branches: [ "master", "dev", "branch_hadiyarajesh", "branch_loveleen", "branch_geet", "branch_siddu"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build_project"
build_project:
name: Build NoteX Android project
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11

# Provide required permission to gradle
- name: Change gradle wrapper permissions
run: chmod +x ./gradlew

# Build Android project
- name: Build Project
run: ./gradlew assemble
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

23 changes: 23 additions & 0 deletions .idea/misc.xml

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

1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ dependencies {
implementation("com.google.dagger:hilt-android:${rootProject.extra["hiltVersion"]}")
kapt("com.google.dagger:hilt-android-compiler:${rootProject.extra["hiltVersion"]}")

implementation("androidx.room:room-runtime:${LibVersion.roomVersion}")
implementation("androidx.room:room-ktx:${LibVersion.roomVersion}")
implementation("androidx.room:room-paging:${LibVersion.roomVersion}")
kapt("androidx.room:room-compiler:${LibVersion.roomVersion}")
Expand Down
33 changes: 26 additions & 7 deletions app/src/main/java/com/hadiyarajesh/notex/database/dao/NoteDao.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.hadiyarajesh.notex.database.dao

import androidx.paging.PagingSource
import androidx.room.*
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Transaction
import com.hadiyarajesh.notex.database.entity.Note
import com.hadiyarajesh.notex.utility.InternalUseOnly
import java.time.Instant
Expand All @@ -20,6 +25,17 @@ interface NoteDao {
updateFolderModificationProperty(parentFolderId)
}

/**
* This method will update the provided Note and also modify the updatedOn field of the containing Folder(if the note is in a folder)
*/
@Transaction
suspend fun updateNote(note: Note, parentFolderId: Long?) {
insertOrUpdate(note)
parentFolderId?.let {
updateFolderModificationProperty(folderId = parentFolderId, updatedOn = note.updatedOn)
}
}

@InternalUseOnly
@Query("UPDATE Note SET parentFolderId = :parentFolderId WHERE noteId = :noteId")
suspend fun attachNoteToFolder(noteId: Long, parentFolderId: Long)
Expand All @@ -29,7 +45,7 @@ interface NoteDao {
suspend fun updateFolderModificationProperty(folderId: Long, updatedOn: Instant = Instant.now())

@Query("SELECT * FROM Note WHERE noteId = :noteId")
fun getById(noteId: Long): Note
suspend fun getById(noteId: Long): Note

/**
* This method wil only return non-deleted notes.
Expand All @@ -49,24 +65,27 @@ interface NoteDao {
* Mark a note as deleted (archived)
*/
@Query("UPDATE Note SET archived = 1 WHERE noteId = :noteId")
fun markAsArchived(noteId: Long)
suspend fun markAsArchived(noteId: Long)

@Query("UPDATE Note SET archived = 0 WHERE noteId = :noteId")
suspend fun markAsUnarchived(noteId: Long)

@Delete
fun delete(note: Note)
suspend fun delete(note: Note): Int

@Query("DELETE FROM Note WHERE noteId = :noteId")
fun deleteById(noteId: Long)
suspend fun deleteById(noteId: Long): Int

/**
* Permanently delete all notes that are already archived.
*/
@Query("DELETE FROM Note WHERE archived = 1")
fun deleteAllArchivedNotes()
suspend fun deleteAllArchivedNotes(): Int

/**
* WARNING: USE WITH CAUTION
* Permanently delete all notes
*/
@Query("DELETE FROM Note")
fun deleteAll()
suspend fun deleteAll(): Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ data class Note(
val updatedOn: Instant,
val parentFolderId: Long? = null,
)

Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.hadiyarajesh.notex.repository.folder

import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.hadiyarajesh.notex.database.dao.FolderDao
import com.hadiyarajesh.notex.database.entity.Folder
import com.hadiyarajesh.notex.database.model.FolderType
import com.hadiyarajesh.notex.database.model.NoteFolder
import com.hadiyarajesh.notex.database.model.ReminderFolder
import kotlinx.coroutines.flow.Flow
import java.time.Instant
import javax.inject.Inject
import javax.inject.Singleton
Expand All @@ -26,4 +32,16 @@ class FolderRepository @Inject constructor(
)
)
}

fun getAllNoteFolders(): Flow<PagingData<NoteFolder>> = Pager(
config = PagingConfig(pageSize = 8)//since we want a maximum of 8 folders in one screen
){
folderDao.getAllNoteFolders(FolderType.NoteFolder)
}.flow

fun getAllReminderFolders(): Flow<PagingData<ReminderFolder>> = Pager(
config = PagingConfig(pageSize = 8)//since we want a maximum of 8 folders in one screen
){
folderDao.getAllReminderFolders(FolderType.ReminderFolder)
}.flow
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,36 @@ class NotesRepository @Inject constructor(
) {
noteDao.getAllUnArchivedByDesc()
}.flow

suspend fun getNote(noteId: Long): Note = noteDao.getById(noteId)

/**
* Inserts the provided Note into the database.
*/
suspend fun addNote(note: Note) = noteDao.insertOrUpdate(note)

/**
* Updates the provided Note in the database.
*/
suspend fun updateNote(note: Note,parentFolderId: Long?) = noteDao.updateNote(note, parentFolderId)



suspend fun deleteNote(note: Note): Int = noteDao.delete(note)

suspend fun deleteNote(noteId: Long): Int = noteDao.deleteById(noteId)

suspend fun deleteArchived(): Int = noteDao.deleteAllArchivedNotes()

suspend fun deleteAllNotes(): Int = noteDao.deleteAll()



suspend fun archive(noteId: Long) = noteDao.markAsArchived(noteId)

suspend fun unarchive(noteId: Long) = noteDao.markAsUnarchived(noteId)



suspend fun addToFolder(noteId: Long, folderId: Long) = noteDao.addToFolder(noteId,folderId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ fun NoteCard(note: Note) {
content = InstantConverter.getLocalDate(note.createdOn).toString()
)
}

}
}
}
Expand All @@ -85,4 +86,4 @@ fun NoteCardPrev() {
updatedOn = Instant.now()
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.hadiyarajesh.notex.ui.component

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.text.TextStyle
import com.hadiyarajesh.notex.ui.theme.hintColor

@Composable
fun BorderLessTextField(
text: String,
hint: String,
onValueChange: (String) -> Unit,
textStyle: TextStyle = TextStyle(),
maxLines: Int = Int.MAX_VALUE,
) {
BasicTextField(
value = text,
onValueChange = onValueChange,
maxLines = maxLines,
textStyle = textStyle,
cursorBrush = SolidColor(hintColor),
modifier = Modifier
.fillMaxWidth(),
decorationBox = { inlineTextField ->
AnimatedVisibility(visible = text.isBlank()) {
Text(
text = hint,
color = hintColor,
style = textStyle
)
}
inlineTextField()
}
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.hadiyarajesh.notex.ui.folders

import androidx.compose.foundation.layout.*
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import com.hadiyarajesh.notex.database.entity.Folder
import com.hadiyarajesh.notex.database.model.NoteFolder
import com.hadiyarajesh.notex.database.model.ReminderFolder


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FoldersScreen(
navController: NavController,
foldersViewModel: FoldersViewModel
) {
val scope = rememberCoroutineScope()
val context = LocalContext.current
val notesFolders = remember { foldersViewModel.noteFolders }.collectAsLazyPagingItems()
val reminderFolders = remember { foldersViewModel.reminderFolders }.collectAsLazyPagingItems()

Scaffold { innerPadding ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
AllFoldersView(onClick = {})
}

}

}



@Composable
private fun AllFoldersView(
modifier: Modifier = Modifier,
noteFolders: LazyPagingItems<NoteFolder>? = null,
reminderFolder: LazyPagingItems<ReminderFolder>? = null,
onClick: (Folder) -> Unit
) {
Column(modifier = Modifier.padding(16.dp)) {
Text(
text = "Folders Screen",
modifier = Modifier.fillMaxWidth()
)

}
}

@Preview(
name = "All Folders Preview",
showBackground = true,
showSystemUi = true,
device = Devices.PIXEL_2_XL
)
@Composable
fun AllFoldersViewPreview(){
AllFoldersView(onClick = {})
}
Loading

0 comments on commit dddb701

Please sign in to comment.