Skip to content

Commit

Permalink
initial commit on compose branch
Browse files Browse the repository at this point in the history
  • Loading branch information
MahmoudRH committed Sep 3, 2022
0 parents commit 4a46a0d
Show file tree
Hide file tree
Showing 86 changed files with 2,355 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
/app/release
3 changes: 3 additions & 0 deletions .idea/.gitignore

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

1 change: 1 addition & 0 deletions .idea/.name

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

6 changes: 6 additions & 0 deletions .idea/compiler.xml

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

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

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

23 changes: 23 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

18 changes: 18 additions & 0 deletions .idea/misc.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
107 changes: 107 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'com.google.devtools.ksp' version '1.7.10-1.0.6'
}

android {
compileSdk 33

defaultConfig {
applicationId "com.mahmoudrh.roomxml"
minSdk 22
targetSdk 33
versionCode 4
versionName "2.0.0"

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

buildTypes {
release {
minifyEnabled true
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 compose_version
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}

applicationVariants.all { variant ->
kotlin.sourceSets {
getByName(variant.name) {
kotlin.srcDir("build/generated/ksp/${variant.name}/kotlin")
}
}
}
}

dependencies {



//-> Material Icons
implementation "androidx.compose.material:material-icons-extended:$compose_version"


//-> Compose Destinations Library
implementation "io.github.raamcosta.compose-destinations:core:$nav_destinations_version"
ksp "io.github.raamcosta.compose-destinations:ksp:$nav_destinations_version"

//-> RoomDB
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"

// ViewModel utilities for Compose
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.0-alpha01"

//-> Hilt DI
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'


// ACRA crash report library
implementation "ch.acra:acra-mail:5.9.5"
implementation "ch.acra:acra-dialog:5.9.5"



implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-util:$compose_version"
implementation 'androidx.compose.material3:material3:1.0.0-beta01'

implementation 'androidx.appcompat:appcompat:1.5.0'
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.5.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mahmoudrh.roomxml

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.mahmoudrh.roomxml", appContext.packageName)
}
}
30 changes: 30 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mahmoudrh.roomxml">

<application
android:name=".application.NotesApplication"
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:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.DNote"
tools:targetApi="31">
<activity
android:name=".presentation.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.DNote">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.mahmoudrh.roomxml.application

import android.app.Application
import android.content.Context
import com.mahmoudrh.roomxml.BuildConfig
import com.mahmoudrh.roomxml.R
import dagger.hilt.android.HiltAndroidApp
import org.acra.config.dialog
import org.acra.config.mailSender
import org.acra.data.StringFormat
import org.acra.ktx.initAcra

@HiltAndroidApp
class NotesApplication: Application() {

override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)

initAcra {
buildConfigClass = BuildConfig::class.java
reportFormat = StringFormat.JSON

dialog {
text = getString(R.string.dialog_text)
title = getString(R.string.dialog_title)
positiveButtonText = getString(R.string.dialog_positive)
negativeButtonText = getString(R.string.dialog_negative)
commentPrompt = getString(R.string.dialog_comment)
resIcon = R.drawable.ic_dialog_icon
resTheme = R.style.Theme_DNote
}

mailSender {
mailTo = "[email protected]"
subject = "D-Note Crash Report"
reportFileName = "Crash.txt"
}
}
}
}
30 changes: 30 additions & 0 deletions app/src/main/java/com/mahmoudrh/roomxml/data/local/NoteDAO.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.mahmoudrh.roomxml.data.local

import androidx.room.*
import com.mahmoudrh.roomxml.domain.models.Note
import kotlinx.coroutines.flow.Flow

@Dao
interface NoteDAO {

@Insert
suspend fun insertNote(note: Note)

@Update
suspend fun updateNote(note: Note)

@Delete
suspend fun deleteNote(note: Note)

@Query("DELETE FROM notes")
suspend fun deleteAll()

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

@Query("SELECT * FROM notes WHERE title LIKE '%' || :searchWord || '%'")
fun searchNotes(searchWord: String? = null): Flow<List<Note>>



}
14 changes: 14 additions & 0 deletions app/src/main/java/com/mahmoudrh/roomxml/data/local/NotesDB.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mahmoudrh.roomxml.data.local

import androidx.room.Database
import androidx.room.RoomDatabase
import com.mahmoudrh.roomxml.domain.models.Note

@Database(entities = [Note::class], version = 1, exportSchema = false)
abstract class NotesDB : RoomDatabase() {
abstract val noteDAO: NoteDAO

companion object{
const val DATABASE_NAME = "NotesDB"
}
}
Loading

0 comments on commit 4a46a0d

Please sign in to comment.