Skip to content
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
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
applicationId "com.digiventure.ventnote"
minSdk 21
targetSdk 34
versionCode 40
versionName "1.0.7"
versionCode 41
versionName "1.0.8"

testInstrumentationRunner "com.digiventure.utils.CustomTestRunner"
vectorDrawables {
Expand Down Expand Up @@ -88,7 +88,7 @@ dependencies {
implementation "androidx.compose.ui:ui:1.7.4"
implementation "androidx.compose.ui:ui-tooling-preview:1.7.4"

implementation "androidx.compose.material3:material3:1.3.0"
implementation "androidx.compose.material3:material3:1.3.1"

// Lifecycle Livedata
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.6"
Expand Down
58 changes: 58 additions & 0 deletions app/schemas/com.digiventure.ventnote.config.NoteDatabase/1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "5ba0c0c61835cab478078d95b4bcb861",
"entities": [
{
"tableName": "note_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT NOT NULL, `note` TEXT NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "note",
"columnName": "note",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "createdAt",
"columnName": "created_at",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updatedAt",
"columnName": "updated_at",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5ba0c0c61835cab478078d95b4bcb861')"
]
}
}
58 changes: 58 additions & 0 deletions app/schemas/com.digiventure.ventnote.config.NoteDatabase/2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "5ba0c0c61835cab478078d95b4bcb861",
"entities": [
{
"tableName": "note_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT NOT NULL, `note` TEXT NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "note",
"columnName": "note",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "createdAt",
"columnName": "created_at",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updatedAt",
"columnName": "updated_at",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5ba0c0c61835cab478078d95b4bcb861')"
]
}
}
44 changes: 42 additions & 2 deletions app/src/main/java/com/digiventure/ventnote/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Surface
import androidx.compose.material3.rememberDrawerState
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.navigation.compose.rememberNavController
import com.digiventure.ventnote.components.dialog.TextDialog
import com.digiventure.ventnote.feature.notes.components.drawer.NavDrawer
import com.digiventure.ventnote.navigation.NavGraph
import com.digiventure.ventnote.navigation.PageNavigation
import com.digiventure.ventnote.ui.theme.VentNoteTheme
import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
Expand All @@ -21,6 +28,7 @@ import com.google.android.play.core.install.model.AppUpdateType.IMMEDIATE
import com.google.android.play.core.install.model.InstallStatus
import com.google.android.play.core.install.model.UpdateAvailability
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
Expand All @@ -44,12 +52,36 @@ class MainActivity : ComponentActivity() {

setContent {
VentNoteTheme {
val navController = rememberNavController()
val navigationActions = remember(navController) {
PageNavigation(navController)
}

val drawerState = rememberDrawerState(DrawerValue.Closed)

val coroutineScope = rememberCoroutineScope()

val snackBarHostState = remember { SnackbarHostState() }

Surface(
modifier = Modifier.safeDrawingPadding(),
color = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.secondary
) {
NavGraph(navHostController = rememberNavController())
NavDrawer(
drawerState = drawerState,
onError = {

},
onBackupPressed = {
navigationActions.navigateToBackupPage()
},
content = {
NavGraph(navHostController = navController, openDrawer = {
coroutineScope.launch { drawerState.open() }
})
},
)

TextDialog(
isOpened = isDialogShowed,
Expand All @@ -76,9 +108,11 @@ class MainActivity : ComponentActivity() {
// and request user confirmation to restart the app.
showDialogForCompleteUpdate()
}

InstallStatus.INSTALLED -> {
appUpdateManager.unregisterListener(installStateUpdatedListener)
}

else -> {}
}
}
Expand All @@ -98,11 +132,17 @@ class MainActivity : ComponentActivity() {
val updateTypes = arrayOf(AppUpdateType.FLEXIBLE, IMMEDIATE)
for (type in updateTypes) {
if (it.isUpdateTypeAllowed(type)) {
appUpdateManager.startUpdateFlowForResult(it, type, this, REQUEST_UPDATE_CODE)
appUpdateManager.startUpdateFlowForResult(
it,
type,
this,
REQUEST_UPDATE_CODE
)
break
}
}
}

else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.digiventure.ventnote.config

import android.content.Context
import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
Expand All @@ -25,8 +26,11 @@ object DateConverters {

@Database(
entities = [NoteModel::class],
version = 1,
exportSchema = true
version = 2,
exportSchema = true,
autoMigrations = [
AutoMigration (from = 1, to = 2)
]
)
@TypeConverters(DateConverters::class)
abstract class NoteDatabase: RoomDatabase() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.digiventure.ventnote.feature.note_creation

import android.content.pm.ActivityInfo
import android.view.ViewTreeObserver
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -24,23 +23,20 @@ import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
Expand Down Expand Up @@ -111,29 +107,6 @@ fun NoteCreationPage(
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(appBarState)
val rememberedScrollBehavior = remember { scrollBehavior }

val view = LocalView.current
val keyboardHeight = remember { mutableStateOf(0.dp) }

val viewTreeObserver = remember { view.viewTreeObserver }
val onGlobalLayoutListener = remember {
ViewTreeObserver.OnGlobalLayoutListener {
val rect = android.graphics.Rect().apply {
view.getWindowVisibleDisplayFrame(this)
}
val keyboardHeightNew = view.rootView.height - rect.bottom
if (keyboardHeightNew.dp != keyboardHeight.value) {
keyboardHeight.value = keyboardHeightNew.dp
}
}
}

DisposableEffect(view) {
viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener)
onDispose {
viewTreeObserver.removeOnGlobalLayoutListener(onGlobalLayoutListener)
}
}

Scaffold(
topBar = {
NoteCreationAppBar(
Expand Down Expand Up @@ -171,7 +144,6 @@ fun NoteCreationPage(
.fillMaxWidth()
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(bottom = keyboardHeight.value)
) {
TextField(
value = viewModel.titleText.value,
Expand Down
Loading
Loading