Skip to content

Commit

Permalink
15/05/2024.
Browse files Browse the repository at this point in the history
  • Loading branch information
youndon committed May 15, 2024
1 parent ddfe9dd commit 70b5b2f
Show file tree
Hide file tree
Showing 129 changed files with 1,768 additions and 1,035 deletions.
21 changes: 13 additions & 8 deletions app/src/main/java/city/zouitel/jetnote/NoteActivity.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package city.zouitel.jetnote

import android.content.Intent
import android.graphics.drawable.shapes.Shape
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ShapeDefaults
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.unit.dp
import androidx.core.view.WindowCompat
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.bottomSheet.BottomSheetNavigator
import city.zouitel.links.ui.LinkScreenModel
import city.zouitel.logic.asLongToast
import city.zouitel.screens.home_screen.HomeScreen
Expand Down Expand Up @@ -37,16 +43,15 @@ class NoteActivity : ComponentActivity(), KoinComponent, IntentHandler {
require(!isDeviceRooted.value.getOrNull()?.isDeviceRooted!!) {
"Cannot run JetNote on rooted device!".asLongToast()
}

IntentHandler(
intent,
navigator,
{}
)

MainTheme(dataStoreModel) {
Navigator(HomeScreen())
BottomSheetNavigator(
sheetShape = ShapeDefaults.Large,
sheetElevation = 150.dp
) {
Navigator(HomeScreen())
}
}
IntentHandler(intent, navigator) {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/city/zouitel/jetnote/NoteApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class NoteApplication: Application(), KoinComponent {
commonSystemDesignKoinModule,
navigationKoinModule,
initializerKoinModule,
rootKoinModule
rootKoinModule,
)
}

Expand Down
11 changes: 11 additions & 0 deletions common/logic/src/main/java/city/zouitel/logic/sounds.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package city.zouitel.logic

import android.content.Context
import android.media.AudioManager

context (Context)
infix fun Boolean.makeSoundFor(audioManager: Int) {
val systemService = this@Context.getSystemService(Context.AUDIO_SERVICE) as AudioManager

if (this) systemService.playSoundEffect(audioManager, 1.0f)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Cons {
const val NUL = "null"
const val NONE = "unspecified"

const val APP_VERSION = "5.3.0"
const val APP_VERSION = "5.4.0"

const val ID = "Id"
const val TITLE = "Title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ val callNumber: (Context,String) -> Unit = { ctx, number ->
}

//
val findUrlLink: (String?) -> String? = {
it?.split(' ')?.find { str -> str.matches("https?://.+".toRegex()) }
val findUrlLink: (String?) -> List<String>? = {
it?.split(' ')?.filter { str -> str.matches("https?://.+".toRegex()) }
}

//
Expand Down
125 changes: 92 additions & 33 deletions core/database/schemas/city.zouitel.database.Database/1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "db5056a70754850713de9991ac5db53a",
"identityHash": "6e5591204f402bd35478b761443df3d5",
"entities": [
{
"tableName": "notes_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`unique_id` TEXT NOT NULL, `title` TEXT, `description` TEXT, `priority` TEXT NOT NULL, `color` INTEGER NOT NULL, `text_color` INTEGER NOT NULL, `date` TEXT NOT NULL, `removed` INTEGER NOT NULL, `audio_duration` INTEGER NOT NULL, `reminding` INTEGER NOT NULL, `image_url` TEXT, `audio_url` TEXT, PRIMARY KEY(`unique_id`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`unique_id` TEXT NOT NULL, `title` TEXT, `description` TEXT, `priority` TEXT NOT NULL, `color` INTEGER NOT NULL, `text_color` INTEGER NOT NULL, `date` TEXT NOT NULL, `removed` INTEGER NOT NULL, `reminding` INTEGER NOT NULL, PRIMARY KEY(`unique_id`))",
"fields": [
{
"fieldPath": "uid",
Expand Down Expand Up @@ -56,29 +56,11 @@
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "audioDuration",
"columnName": "audio_duration",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "reminding",
"columnName": "reminding",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "imageUrl",
"columnName": "image_url",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "audioUrl",
"columnName": "audio_url",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
Expand Down Expand Up @@ -152,7 +134,7 @@
},
{
"tableName": "tasks_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `item` TEXT, `isDone` INTEGER NOT NULL)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT, `is_task_done` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
Expand All @@ -162,13 +144,13 @@
},
{
"fieldPath": "item",
"columnName": "item",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "isDone",
"columnName": "isDone",
"columnName": "is_task_done",
"affinity": "INTEGER",
"notNull": true
}
Expand All @@ -183,8 +165,8 @@
"foreignKeys": []
},
{
"tableName": "note_and_todo",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`noteUid` TEXT NOT NULL, `todoId` INTEGER NOT NULL, PRIMARY KEY(`noteUid`, `todoId`))",
"tableName": "note_and_task",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`noteUid` TEXT NOT NULL, `taskId` INTEGER NOT NULL, PRIMARY KEY(`noteUid`, `taskId`))",
"fields": [
{
"fieldPath": "noteUid",
Expand All @@ -193,8 +175,8 @@
"notNull": true
},
{
"fieldPath": "todoId",
"columnName": "todoId",
"fieldPath": "taskId",
"columnName": "taskId",
"affinity": "INTEGER",
"notNull": true
}
Expand All @@ -203,20 +185,20 @@
"autoGenerate": false,
"columnNames": [
"noteUid",
"todoId"
"taskId"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "links_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `host` TEXT NOT NULL, `imageLink` TEXT, `title` TEXT, `description` TEXT, PRIMARY KEY(`id`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `url` TEXT NOT NULL, `host` TEXT NOT NULL, `imageLink` TEXT, `title` TEXT, `description` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"affinity": "INTEGER",
"notNull": true
},
{
Expand Down Expand Up @@ -261,7 +243,7 @@
},
{
"tableName": "note_and_link",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`noteUid` TEXT NOT NULL, `linkId` TEXT NOT NULL, PRIMARY KEY(`noteUid`, `linkId`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`noteUid` TEXT NOT NULL, `linkId` INTEGER NOT NULL, PRIMARY KEY(`noteUid`, `linkId`))",
"fields": [
{
"fieldPath": "noteUid",
Expand All @@ -272,7 +254,7 @@
{
"fieldPath": "linkId",
"columnName": "linkId",
"affinity": "TEXT",
"affinity": "INTEGER",
"notNull": true
}
],
Expand All @@ -285,12 +267,89 @@
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "audios_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT NOT NULL, `media_path` TEXT NOT NULL, `uri` TEXT NOT NULL, `media_size` INTEGER NOT NULL, `media_duration` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "path",
"columnName": "media_path",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "uri",
"columnName": "uri",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "size",
"columnName": "media_size",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "duration",
"columnName": "media_duration",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "note_and_audio",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`noteUid` TEXT NOT NULL, `audioId` INTEGER NOT NULL, PRIMARY KEY(`noteUid`, `audioId`))",
"fields": [
{
"fieldPath": "noteUid",
"columnName": "noteUid",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "audioId",
"columnName": "audioId",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"noteUid",
"audioId"
]
},
"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, 'db5056a70754850713de9991ac5db53a')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6e5591204f402bd35478b761443df3d5')"
]
}
}
12 changes: 8 additions & 4 deletions core/database/src/main/java/city/zouitel/database/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ import city.zouitel.database.model.*
version = 1,
autoMigrations = [
// AutoMigration(from = 1, to = 2)
],
],
entities = [
DataEntity::class,
TagEntity::class,
NoteAndTagEntity::class,
TaskEntity::class,
NoteAndTaskEntity::class,
LinkEntity::class,
NoteAndLinkEntity::class
],
NoteAndLinkEntity::class,
AudioEntity::class,
NoteAndAudioEntity::class
],
exportSchema = true
)
abstract class Database:RoomDatabase() {
Expand All @@ -30,5 +32,7 @@ abstract class Database:RoomDatabase() {
abstract fun getTodoDao(): TaskDao
abstract fun getNoteAndTodoDao(): NoteAndTaskDao
abstract fun getLinkDao(): LinkDao
abstract fun getNoteAndLink(): NoteAndLinkDao
abstract fun getNoteAndLinkDao(): NoteAndLinkDao
abstract fun getAudioDao(): AudioDao
abstract fun getNoteAndAudioDao(): NoteAndAudioDao
}
10 changes: 4 additions & 6 deletions core/database/src/main/java/city/zouitel/database/Encryption.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package city.zouitel.database

import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.security.crypto.EncryptedFile
import androidx.security.crypto.MasterKeys
import city.zouitel.database.utils.Constants.CRYPTIC_PASS
import city.zouitel.database.utils.Constants.PASS
import java.io.File
import java.security.SecureRandom

class Encryption(private val ctx: Context) {
class Encryption(private val context: Context) {

fun getCrypticPass(): ByteArray {
val file = File(ctx.filesDir, CRYPTIC_PASS)
val file = File(context.filesDir, PASS)
val encryptedFile = EncryptedFile.Builder(
file,
ctx,
context,
MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC),
EncryptedFile.FileEncryptionScheme.AES256_GCM_HKDF_4KB
).build()
Expand Down
21 changes: 21 additions & 0 deletions core/database/src/main/java/city/zouitel/database/dao/AudioDao.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package city.zouitel.database.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import city.zouitel.database.model.AudioEntity
import kotlinx.coroutines.flow.Flow

@Dao
interface AudioDao {

@Query("SELECT * FROM AUDIOS_TABLE")
fun getAllAudios(): Flow<List<AudioEntity>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun addAudio(audioEntity: AudioEntity)

@Delete
suspend fun deleteAudio(audioEntity: AudioEntity)
}
Loading

0 comments on commit 70b5b2f

Please sign in to comment.