Skip to content

Commit

Permalink
01/02/2024.
Browse files Browse the repository at this point in the history
  • Loading branch information
youndon committed Feb 1, 2024
1 parent 36cf384 commit deaff87
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 21 deletions.
1 change: 0 additions & 1 deletion .idea/kotlinScripting.xml

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

6 changes: 5 additions & 1 deletion app/src/main/java/city/zouitel/jetnote/NoteApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package city.zouitel.jetnote

import android.app.Application
import android.content.Context
import android.util.Log
import androidx.startup.AppInitializer
import androidx.work.Configuration
import city.zouitel.audios.di.exoPlayerKoinModule
import city.zouitel.database.di.databaseKoinModule
import city.zouitel.datastore.datastoreKoinModule
Expand All @@ -24,10 +26,11 @@ import com.karacca.beetle.Beetle
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.androidx.workmanager.koin.workManagerFactory
import org.koin.core.component.KoinComponent
import org.koin.core.context.startKoin
import org.koin.core.logger.Level

class NoteApplication: Application() {
class NoteApplication: Application(), KoinComponent {

override fun onCreate() {
super.onCreate()
Expand Down Expand Up @@ -56,6 +59,7 @@ class NoteApplication: Application() {
)
}


/**
* Global Exception Handler.
*/
Expand Down
1 change: 0 additions & 1 deletion init/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<meta-data
android:name="city.zouitel.init.SQLCipherDBInitializer"
android:value="androidx.startup" />

</provider>

</application>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package city.zouitel.links.di

import androidx.work.WorkerFactory
import org.koin.androidx.viewmodel.dsl.viewModelOf
import org.koin.dsl.module
import city.zouitel.links.ui.*
import city.zouitel.links.mapper.*
import city.zouitel.links.worker.LinkWorker
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.workmanager.dsl.worker
import org.koin.androidx.workmanager.dsl.workerOf
import org.koin.core.module.dsl.factoryOf

Expand All @@ -14,5 +17,8 @@ val linksKoinModule = module {

viewModelOf(::LinkVM)
viewModelOf(::NoteAndLinkVM)
workerOf(::LinkWorker)

worker {
LinkWorker(androidContext(), get(), get(), get(), get(), get(), get())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun CacheLinks(

//
linkVM.urlPreview(
url, title, host, img
ctx, url, title, host, img
)

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package city.zouitel.links.ui
import android.app.Application
import android.content.Context
import android.graphics.BitmapFactory
import android.widget.Toast
import androidx.compose.runtime.MutableState
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
Expand All @@ -23,8 +24,7 @@ import kotlinx.coroutines.launch
import java.io.File
import java.net.URL

//@HiltViewModel
class LinkVM /*@Inject*/ constructor(
class LinkVM(
application: Application,
getAll: LinkUseCase.GetAllLinks,
private val delete: LinkUseCase.DeleteLink,
Expand All @@ -40,7 +40,6 @@ class LinkVM /*@Inject*/ constructor(
listOf()
)

//
private var workManager = WorkManager.getInstance(application)

init {
Expand All @@ -58,6 +57,7 @@ class LinkVM /*@Inject*/ constructor(
}

fun urlPreview(
ctx: Context,
res: String?,
title: MutableState<String>?,
host: MutableState<String>?,
Expand All @@ -76,7 +76,7 @@ class LinkVM /*@Inject*/ constructor(
}

override fun onFailed(throwable: Throwable) {
// Toast.makeText(ctx, "Can't load link", Toast.LENGTH_SHORT).show()
Toast.makeText(ctx, "Can't load link", Toast.LENGTH_SHORT).show()
}
}).fetchUrlPreview()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ import city.zouitel.systemDesign.Cons
import city.zouitel.links.model.Link as InLink
import city.zouitel.links.model.NoteAndLink as InNoteAndLink
import kotlinx.coroutines.*
import org.koin.core.component.KoinComponent
import java.io.File
import java.io.FileOutputStream
import java.util.*

@OptIn(DelicateCoroutinesApi::class)
//@HiltWorker
class LinkWorker /*@AssistedInject*/ constructor(
/*@Assisted*/ private val context: Context,
/*@Assisted*/ workerParameters: WorkerParameters,
class LinkWorker(
private val context: Context,
workerParameters: WorkerParameters,
private val ioDeprecated: CoroutineDispatcher,
private val addLink: LinkUseCase.AddLink,
private val addNoteAndLink: NoteAndLinkUseCase.AddNoteAndLink,
private val linkMapper: LinkMapper,
private val noteAndLinkMapper: NoteAndLinkMapper,
): CoroutineWorker(context, workerParameters) {

): CoroutineWorker(context, workerParameters), KoinComponent {
private val linkImgPath = context.filesDir.path + "/" + "links_img"

override suspend fun doWork(): Result = withContext(ioDeprecated) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ fun NoteAdd(

// The Title.
item {

OutlinedTextField(
value = titleState.value ?: "",
onValueChange = { titleState.value = it },
Expand Down Expand Up @@ -331,7 +330,6 @@ fun NoteAdd(

// The Description.
item {

OutlinedTextField(
value = descriptionState.value ?: "",
onValueChange = {
Expand Down Expand Up @@ -398,7 +396,7 @@ fun NoteAdd(
}
}

// display all added tagEntities.
// display all added tags.
item {
FlowRow {
observeLabels.filter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package city.zouitel.navigation.home_screen

import android.annotation.SuppressLint
import android.view.View
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.LocalOverscrollConfiguration
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBarsPadding
Expand Down Expand Up @@ -103,7 +105,8 @@ fun NoteHome(
val drawerState = rememberDrawerState(DrawerValue.Closed)
//
val scaffoldState = rememberScaffoldState()
// to observer notes while changing immediately.

// to observer notes while changing immediately.
val observerLocalNotes: State<List<Note>> = when (
remember(dataStoreVM, dataStoreVM::getOrdination).collectAsState().value
) {
Expand Down Expand Up @@ -228,9 +231,12 @@ fun NoteHome(
.fillMaxSize(),
) {
items(
observerLocalNotes.value.filter {
items = observerLocalNotes.value.filter {
it.dataEntity.title?.contains(searchTitleState.value, true) ?: true ||
it.tagEntities.contains(searchTagEntityState.value)
},
key = {
it.dataEntity.uid
}
) { entity ->
NoteCard(
Expand Down Expand Up @@ -261,6 +267,7 @@ fun NoteHome(
state = lazyListState,
modifier = Modifier.fillMaxSize()
) {

item {
VerticalGrid(
maxColumnWidth = 220.dp
Expand All @@ -269,6 +276,7 @@ fun NoteHome(
it.dataEntity.title?.contains(searchTitleState.value, true) ?: true ||
it.tagEntities.contains(searchTagEntityState.value)
}.forEach { entity ->

NoteCard(
screen = Screens.HOME_SCREEN,
noteEntity = entity,
Expand Down

0 comments on commit deaff87

Please sign in to comment.