Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6f05260
Test PR (#51)
hadiyarajesh Sep 9, 2022
e7cde59
Revert "Test PR (#51)" (#53)
hadiyarajesh Sep 9, 2022
7934291
Merge remote-tracking branch 'origin/dev' into dev
hadiyarajesh Sep 10, 2022
2017fe1
Revert "Test PR (#51)" (#53) (#54)
sumanabhi Sep 10, 2022
f0e708c
Merge remote-tracking branch 'origin/dev' into dev
hadiyarajesh Sep 10, 2022
7d3e5fd
Branch hadiyarajesh (#55)
hadiyarajesh Sep 10, 2022
33c4fe0
Base Integration of Detekt Analytics tool done.
sumanabhi Oct 1, 2022
d9008c9
added the detekt as pre-push git-hooks.
sumanabhi Oct 4, 2022
9ebb635
Enabled the ktlint and also added it into the pre-push git-hooks.
sumanabhi Oct 5, 2022
2a307a0
change order and define the taks to generate output in some dir
sumanabhi Oct 5, 2022
0c04e39
change some files and tasks and testing that pre-push is working or not
sumanabhi Oct 5, 2022
9a8b920
manually it is running but while push it is not working
sumanabhi Oct 5, 2022
229668c
code cleanup.
sumanabhi Oct 5, 2022
4209182
tried once more that scripts is working or not
sumanabhi Oct 6, 2022
d6e00e8
fixed detekt and lint errors.
sumanabhi Oct 6, 2022
877b81e
fixed detekt errors.
sumanabhi Oct 6, 2022
5581f3c
Merge pull request #63 from NoteXCommunity/sumanabhi/feature/detekt_k…
geetgobindsingh Oct 16, 2022
2423f28
Working on Notification and WorkManager
Arunshaik2001 Sep 17, 2022
0019c3c
Working on Notification and WorkManager
Arunshaik2001 Sep 19, 2022
5b27f0a
Working on Notification and WorkManager
Arunshaik2001 Sep 19, 2022
92202bd
n
Arunshaik2001 Sep 19, 2022
8cd0456
modified
Arunshaik2001 Sep 19, 2022
fed8b94
changed gitignore
Arunshaik2001 Sep 20, 2022
6c2bb88
refactoring
Arunshaik2001 Sep 22, 2022
9aded1a
refactoring
Arunshaik2001 Sep 22, 2022
f6ed73f
Update misc.xml
Arunshaik2001 Sep 22, 2022
bf413bb
Update gradle.xml
Arunshaik2001 Sep 22, 2022
fedd0cc
Update gradle.xml
Arunshaik2001 Sep 22, 2022
d75bb8e
Update gradle.xml
Arunshaik2001 Sep 22, 2022
346278e
Update misc.xml
Arunshaik2001 Sep 22, 2022
e96a86d
Delete misc.xml
Arunshaik2001 Sep 22, 2022
73da5c6
Delete gradle.xml
Arunshaik2001 Sep 22, 2022
d7086df
Update gradle.xml
Arunshaik2001 Sep 22, 2022
ad29d43
Update gradle.xml
Arunshaik2001 Sep 22, 2022
d86ee46
Update misc.xml
Arunshaik2001 Sep 22, 2022
cc58c5f
changed NoteXApp to myContent
Arunshaik2001 Sep 22, 2022
3ca9534
added NotificationDTO.kt
Arunshaik2001 Sep 24, 2022
dd985f9
Update misc.xml
Arunshaik2001 Sep 22, 2022
9caee95
Update gradle.xml
Arunshaik2001 Sep 22, 2022
a03316f
Update gradle.xml
Arunshaik2001 Sep 22, 2022
08e0278
Update gradle.xml
Arunshaik2001 Sep 22, 2022
fbe2109
Update misc.xml
Arunshaik2001 Sep 22, 2022
6fe9454
Update gradle.xml
Arunshaik2001 Sep 22, 2022
e2097f6
Update gradle.xml
Arunshaik2001 Sep 22, 2022
28d5c57
Update misc.xml
Arunshaik2001 Sep 22, 2022
4088be4
detekt requested changes applied
geetgobindsingh Oct 16, 2022
93795fa
ktlint changes applied
geetgobindsingh Oct 16, 2022
51c316e
ktlint changes applied
geetgobindsingh Oct 16, 2022
a6aff37
Merge pull request #59 from NoteXCommunity/branch_arun
geetgobindsingh Oct 16, 2022
df228f4
project gradle changes
geetgobindsingh Dec 17, 2022
d15a0d3
project gradle changes
geetgobindsingh Dec 17, 2022
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local.properties

# Android Studio / IntelliJ IDEA
*.iws
/.idea
/.idea/libraries
/.idea/tasks.xml
/.idea/caches
Expand All @@ -24,6 +25,7 @@ local.properties
/.idea/modules.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/misc.xml
/out/

.DS_Store
Expand Down
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

2 changes: 2 additions & 0 deletions .idea/gradle.xml

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

19 changes: 2 additions & 17 deletions .idea/misc.xml

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

4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ dependencies {
implementation("androidx.navigation:navigation-compose:${LibVersion.navigationComposeVersion}")
implementation("androidx.datastore:datastore-preferences:${LibVersion.dataStoreVersion}")
implementation("androidx.paging:paging-compose:1.0.0-alpha16")
implementation("androidx.work:work-runtime-ktx:2.7.1")
// DO NOT upgrade desugar_jdk_libs to 1.2.0
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.6")

Expand Down Expand Up @@ -133,4 +134,7 @@ dependencies {
androidTestImplementation("androidx.compose.ui:ui-test-junit4:${LibVersion.composeVersion}")
debugImplementation("androidx.compose.ui:ui-tooling:${LibVersion.composeVersion}")
debugImplementation("androidx.compose.ui:ui-test-manifest:${LibVersion.composeVersion}")

implementation("androidx.hilt:hilt-work:1.0.0")
kapt("androidx.hilt:hilt-compiler:1.0.0")
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.hadiyarajesh.notex

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand All @@ -21,4 +19,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.hadiyarajesh.notex", appContext.packageName)
}
}
}
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove">
</provider>

<receiver android:name=".reminder.notification.NotificationBroadCastReceiver"/>
</application>

</manifest>
4 changes: 2 additions & 2 deletions app/src/main/java/com/hadiyarajesh/notex/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.hadiyarajesh.notex.ui.NoteXApp
import com.hadiyarajesh.notex.ui.reminders.myContent
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
NoteXApp()
myContent()
}

createNotificationChannel()
Expand Down
15 changes: 14 additions & 1 deletion app/src/main/java/com/hadiyarajesh/notex/MyApplication.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
package com.hadiyarajesh.notex

import android.app.Application
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import dagger.hilt.android.HiltAndroidApp
import javax.inject.Inject

@HiltAndroidApp
class MyApplication: Application()
class MyApplication : Application(), Configuration.Provider {

@Inject
lateinit var workerFactory: HiltWorkerFactory

override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder()
.setWorkerFactory(workerFactory)
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package com.hadiyarajesh.notex.database.converter

import androidx.room.TypeConverter
import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter

object InstantConverter {
@JvmStatic
Expand All @@ -11,4 +15,13 @@ object InstantConverter {
@JvmStatic
@TypeConverter
fun toInstant(value: String?): Instant? = value?.let { Instant.parse(value) }

@JvmStatic
@TypeConverter
fun getLocalDate(instant: Instant): LocalDate {
val localDateTime: LocalDateTime =
LocalDateTime.ofInstant(instant, ZoneOffset.systemDefault())
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd")
return LocalDate.parse(localDateTime.format(formatter), formatter)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.time.Instant
@Dao
interface ReminderDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertOrUpdate(reminder: Reminder)
suspend fun insertOrUpdate(reminder: Reminder): Long

/**
* This method will add reminder to folder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class Folder(
val title: String,
val description: String?,
val folderType: FolderType,
//HexCode of a color
// HexCode of a color
val color: String? = null,
val createdOn: Instant,
val updatedOn: Instant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class Note(
val content: String?,
val archived: Boolean,
val archivedOn: Instant? = null,
//HexCode of a color
// HexCode of a color
val color: String? = null,
val createdOn: Instant,
val updatedOn: Instant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class Reminder(
val cancelledOn: Instant? = null,
val completed: Boolean,
val completedOn: Instant?,
//HexCode of a color
// HexCode of a color
val color: String? = null,
val createdOn: Instant,
val updatedOn: Instant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/com/hadiyarajesh/notex/di/ScopeModule.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.hadiyarajesh.notex.di

import com.hadiyarajesh.notex.reminder.notification.NotificationHelper
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import javax.inject.Singleton

@InstallIn(SingletonComponent::class)
@Module
Expand All @@ -18,4 +19,10 @@ class ScopeModule {
fun provideCoroutineScope(): CoroutineScope {
return CoroutineScope(SupervisorJob() + Dispatchers.IO)
}

@Singleton
@Provides
fun provideNotificationHelper(): NotificationHelper {
return NotificationHelper()
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package com.hadiyarajesh.notex.network.api

interface NoteApi {
}
interface NoteApi
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.hadiyarajesh.notex.reminder.notification

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import androidx.annotation.CallSuper
import androidx.core.app.NotificationManagerCompat
import com.hadiyarajesh.notex.R
import com.hadiyarajesh.notex.reminder.worker.ReminderWorkManager
import dagger.hilt.android.AndroidEntryPoint
import java.time.Instant
import java.time.temporal.ChronoUnit
import javax.inject.Inject

@AndroidEntryPoint
class NotificationBroadCastReceiver : HiltBroadcastReceiver() {

companion object {
const val TAG = "NotificationBroadCast"
}

@Inject
lateinit var reminderWorkManager: ReminderWorkManager

override fun onReceive(context: Context, intent: Intent) {
super.onReceive(context, intent)
when (intent.action) {
context.resources.getString(R.string.done_action) ->
reminderWorkManager.cancelWorkRequest(
context,
intent.getStringExtra(context.resources.getString(R.string.worker_tag)) ?: ""
)
context.resources.getString(R.string.postpone_action) -> {
reminderWorkManager.cancelWorkRequest(
context,
intent.getStringExtra(context.resources.getString(R.string.worker_tag)) ?: ""
)

reminderWorkManager.createWorkRequestAndEnqueue(
context,
time = Instant.now().plus(1, ChronoUnit.HOURS),
isFirstTime = false,
reminderId = intent.getLongExtra(
context.resources.getString(R.string.reminder_id),
-1
)
)
}
else -> Log.i(TAG, "Nothing to Perform this Action ${intent.action}")
}

with(NotificationManagerCompat.from(context)) {
cancel(intent.getIntExtra(context.resources.getString(R.string.notification_id), -1))
}
}
}

abstract class HiltBroadcastReceiver : BroadcastReceiver() {
@SuppressWarnings("EmptyFunctionBlock")
@CallSuper
override fun onReceive(context: Context, intent: Intent) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.hadiyarajesh.notex.reminder.notification

data class NotificationDTO(
val title: String,
val subTitle: String,
val reminderId: Long,
val workerTag: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.hadiyarajesh.notex.reminder.notification

import android.app.PendingIntent
import android.app.PendingIntent.FLAG_IMMUTABLE
import android.content.Context
import android.content.Intent
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.hadiyarajesh.notex.MainActivity
import com.hadiyarajesh.notex.R
import kotlin.random.Random

class NotificationHelper {

fun createNotification(
context: Context,
notificationDTO: NotificationDTO
) {
val actionIntent = Intent(context, MainActivity::class.java)
val actionPendingIntent = PendingIntent.getActivity(
context, 0,
actionIntent, PendingIntent.FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE
)

@SuppressWarnings("MagicNumber")
val notificationId = Random(121).nextInt(10000)

val postponeIntent = Intent(context, NotificationBroadCastReceiver::class.java).apply {
action = context.resources.getString(R.string.postpone_action)
putExtra(context.resources.getString(R.string.worker_tag), notificationDTO.workerTag)
putExtra(context.resources.getString(R.string.reminder_id), notificationDTO.reminderId)
putExtra(context.resources.getString(R.string.notification_id), notificationId)
}

val postponePendingIntent = PendingIntent.getBroadcast(
context, 0,
postponeIntent, PendingIntent.FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE
)

val cancelIntent = Intent(context, NotificationBroadCastReceiver::class.java).apply {
action = context.resources.getString(R.string.done_action)
putExtra(context.resources.getString(R.string.worker_tag), notificationDTO.workerTag)
putExtra(context.resources.getString(R.string.notification_id), notificationId)
}

val cancelPendingIntent = PendingIntent.getBroadcast(
context, 0,
cancelIntent, PendingIntent.FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE
)

val builder =
NotificationCompat.Builder(context, context.getString(R.string.notification_channel_id))
.setSmallIcon(R.drawable.ic_note_filled)
.setContentTitle(notificationDTO.title)
.setContentText(notificationDTO.subTitle)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(actionPendingIntent)
.addAction(R.drawable.ic_note_filled, context.getString(R.string.one_hour), postponePendingIntent)
.addAction(R.drawable.ic_note_filled, context.getString(R.string.done), cancelPendingIntent)
.setAutoCancel(true)

with(NotificationManagerCompat.from(context)) {
// notificationId is a unique int for each notification that you must define
notify(notificationId, builder.build())
}
}
}
Loading