Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rajaumair7890 committed Jun 5, 2023
0 parents commit 2243157
Show file tree
Hide file tree
Showing 88 changed files with 3,605 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
83 changes: 83 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.devtools.ksp' version "1.8.0-1.0.9"
id "kotlin-kapt"
}

android {
namespace 'com.codingWithUmair.app.notify'
compileSdk 33

defaultConfig {
applicationId "com.codingWithUmair.app.notify"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.4.0'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}

kapt{
correctErrorTypes true
}

dependencies {
def room_version = '2.5.1'

implementation "androidx.room:room-runtime:$room_version"
ksp "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"

implementation platform('androidx.compose:compose-bom:2023.05.01')

implementation "com.google.code.gson:gson:2.10.1"
implementation "io.coil-kt:coil-compose:2.4.0"
implementation "io.getstream:sketchbook:1.0.4"
implementation "com.github.skydoves:orchestra-colorpicker:1.2.0"
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.1"
implementation "androidx.navigation:navigation-compose:2.5.3"
implementation 'androidx.activity:activity-compose:1.7.2'
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation 'androidx.compose.material3:material3:1.2.0-alpha02'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4"
debugImplementation "androidx.compose.ui:ui-tooling"
debugImplementation "androidx.compose.ui:ui-test-manifest"
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Binary file added app/release/app-release.apk
Binary file not shown.
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.codingWithUmair.app.notify",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.codingWithUmair.app.notify

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

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.codingWithUmair.app.notify", appContext.packageName)
}
}
38 changes: 38 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:name=".NotifyApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Notify"
tools:targetApi="31">
<provider
android:authorities="${applicationId}.fileProvider"
android:name=".fileSystem.NotifyFileProvider"
android:grantUriPermissions="true"
android:exported="false" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"
/>
</provider>
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Notify">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions app/src/main/java/com/codingWithUmair/app/notify/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.codingWithUmair.app.notify

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.view.WindowCompat
import com.codingWithUmair.app.notify.ui.screens.NotifyApp
import com.codingWithUmair.app.notify.ui.theme.NotifyTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContent {
NotifyTheme {
NotifyApp()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.codingWithUmair.app.notify

import android.app.Application
import com.codingWithUmair.app.notify.data.AppContainer
import com.codingWithUmair.app.notify.data.DefaultAppContainer

class NotifyApplication: Application(){
lateinit var container: AppContainer

override fun onCreate() {
super.onCreate()
container = DefaultAppContainer(this)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.codingWithUmair.app.notify.data

import android.content.Context
import com.codingWithUmair.app.notify.data.dataBase.NotifyDataBase
import com.codingWithUmair.app.notify.fileSystem.DefaultNotifyFileProviderRepository
import com.codingWithUmair.app.notify.fileSystem.LocalFileStorageRepository
import com.codingWithUmair.app.notify.fileSystem.NotifyFileProviderRepository

interface AppContainer {
val localFileStorageRepository: LocalFileStorageRepository
val notifyRepository: NotifyRepository
val notifyFileProviderRepository: NotifyFileProviderRepository
}

class DefaultAppContainer(private val context: Context): AppContainer{

override val localFileStorageRepository: LocalFileStorageRepository by lazy {
LocalFileStorageRepository(context)
}
override val notifyRepository: NotifyRepository by lazy {
OfflineNotifyRepository(NotifyDataBase.getDataBase(context).noteDao())
}
override val notifyFileProviderRepository: NotifyFileProviderRepository by lazy{
DefaultNotifyFileProviderRepository(context)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.codingWithUmair.app.notify.data

import com.codingWithUmair.app.notify.data.dataBase.NoteDao
import com.codingWithUmair.app.notify.model.Note
import kotlinx.coroutines.flow.Flow

interface NotifyRepository {

fun getAllNotes(): Flow<List<Note>>

fun getNotesByQuery(query: String): Flow<List<Note>>

suspend fun addNoteToDataBase(note: Note)

suspend fun updateNote(note: Note)

suspend fun deleteNote(note: Note)

suspend fun deleteAllNotes(notes: List<Note>)

}

class OfflineNotifyRepository(private val noteDao: NoteDao): NotifyRepository {

override fun getAllNotes(): Flow<List<Note>> = noteDao.getAllNotes()

override fun getNotesByQuery(query: String): Flow<List<Note>> = noteDao.getNotesByQuery(query)

override suspend fun addNoteToDataBase(note: Note) = noteDao.addNoteToDataBase(note)

override suspend fun updateNote(note: Note) = noteDao.updateNote(note)

override suspend fun deleteNote(note: Note) = noteDao.deleteNote(note)

override suspend fun deleteAllNotes(notes: List<Note>) = noteDao.deleteAllNotes(notes)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.codingWithUmair.app.notify.data.dataBase

import androidx.room.*
import com.codingWithUmair.app.notify.model.Note
import kotlinx.coroutines.flow.Flow

@Dao
interface NoteDao {

@Query("SELECT * FROM note")
fun getAllNotes(): Flow<List<Note>>

@Query("SELECT * FROM note WHERE title LIKE '%' || :query || '%' OR description LIKE '%' || :query || '%' ")
fun getNotesByQuery(query: String): Flow<List<Note>>

@Insert(Note::class)
suspend fun addNoteToDataBase(note: Note)

@Update(Note::class)
suspend fun updateNote(note: Note)

@Delete(Note::class)
suspend fun deleteNote(note: Note)

@Delete(Note::class)
suspend fun deleteAllNotes(notes: List<Note>)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.codingWithUmair.app.notify.data.dataBase

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.codingWithUmair.app.notify.model.Note

@Database(entities = [Note::class], version = 1, exportSchema = false)
@TypeConverters(RoomTypeConverter::class)
abstract class NotifyDataBase: RoomDatabase(){

abstract fun noteDao(): NoteDao

companion object{

@Volatile
private var INSTANCE: NotifyDataBase? = null

fun getDataBase(context: Context): NotifyDataBase {

return INSTANCE ?: synchronized(this){
Room.databaseBuilder(
context = context,
klass = NotifyDataBase::class.java,
name = "notify_database"
)
.fallbackToDestructiveMigration()
.build()
.also { INSTANCE = it }

}
}
}

}
Loading

0 comments on commit 2243157

Please sign in to comment.