Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
MouradGaa committed Jun 7, 2023
0 parents commit 4de9ab7
Show file tree
Hide file tree
Showing 87 changed files with 1,891 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.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
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.

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.

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

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

22 changes: 22 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
79 changes: 79 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-android-extensions'
}

android {
compileSdkVersion 29
defaultConfig {
applicationId "com.androiddevs.grocerylist"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}


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'
}
namespace 'com.example.shoppinglist'
}

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

def room_version = "2.2.1"
def kodein_version = "6.4.0"
def lifecycle_version = "2.0.0"

// Room and Architectural Components
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0'
implementation "androidx.room:room-ktx:2.2.1"
kapt "androidx.room:room-compiler:$room_version"

// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0"

// New Material Design
implementation "com.google.android.material:material:1.4.0"

// ViewModel
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"

// Kodein
implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version"
implementation "org.kodein.di:kodein-di-framework-android-x:$kodein_version"

//Retrofit
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
//Gson
implementation 'com.google.code.gson:gson:2.8.5'
}
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.example.shoppinglist

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.example.shoppinglist", appContext.packageName)
}
}
26 changes: 26 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ShoppingList">
<activity
android:name=".DetailsActivity"
android:exported="false" />
<activity
android:name=".ShoppingListActivity"
android:exported="false" />
<activity android:name=".SplashActivity">
<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_add-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.shoppinglist

import com.example.shoppinglist.Data.ShoppingItem

interface AddDialogListener {
fun onAddButtomClicked(item:ShoppingItem){

}
}
13 changes: 13 additions & 0 deletions app/src/main/java/com/example/shoppinglist/ApiInterface.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.shoppinglist


import com.example.shoppinglist.Data.MoneyRate
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Query

interface ApiInterface {

@GET("/latest")
fun getMoney() : Call<MoneyRate>
}
8 changes: 8 additions & 0 deletions app/src/main/java/com/example/shoppinglist/Data/MoneyRate.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.example.shoppinglist.Data

data class MoneyRate(
val amount: Double,
val base: String,
val date: String,
val rates: Rates
)
36 changes: 36 additions & 0 deletions app/src/main/java/com/example/shoppinglist/Data/Rates.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.example.shoppinglist.Data

data class Rates(
val AUD: Double,
val BGN: Double,
val BRL: Double,
val CAD: Double,
val CHF: Double,
val CNY: Double,
val CZK: Double,
val DKK: Double,
val GBP: Double,
val HKD: Double,
val HRK: Double,
val HUF: Double,
val IDR: Int,
val ILS: Double,
val INR: Double,
val ISK: Double,
val JPY: Double,
val KRW: Double,
val MXN: Double,
val MYR: Double,
val NOK: Double,
val NZD: Double,
val PHP: Double,
val PLN: Double,
val RON: Double,
val RUB: Double,
val SEK: Double,
val SGD: Double,
val THB: Double,
val TRY: Double,
val USD: Double,
val ZAR: Double
)
21 changes: 21 additions & 0 deletions app/src/main/java/com/example/shoppinglist/Data/ShoppingDAO.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.shoppinglist.Data

import androidx.lifecycle.LiveData
import androidx.room.*


@Dao
interface ShoppingDAO {

@Insert(onConflict = OnConflictStrategy.REPLACE) // insert and update
fun upsert(item:ShoppingItem)

@Delete
fun delete(item: ShoppingItem)

@Query("SELECT * FROM shopping_items")
fun getAllItems(): LiveData<List<ShoppingItem>>

@Query("DELETE FROM shopping_items")
fun deleteAll()
}
19 changes: 19 additions & 0 deletions app/src/main/java/com/example/shoppinglist/Data/ShoppingItem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.shoppinglist.Data

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import java.io.Serializable


@Entity(tableName = "shopping_items")
data class ShoppingItem(
@ColumnInfo(name = "category") var category: String,
@ColumnInfo(name = "name") var name: String,
@ColumnInfo(name = "description") var description: String,
@ColumnInfo(name = "price") var price: Float,
@ColumnInfo(name = "status") var status: Boolean,
){
@PrimaryKey(autoGenerate = true) var itemId : Long?=null
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.shoppinglist.Data

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import java.security.AccessControlContext

@Database(entities = arrayOf(ShoppingItem::class),version = 1)
abstract class ShoppingListDataBase: RoomDatabase () {

abstract fun ShoppingDao(): ShoppingDAO

companion object{
@Volatile
private var instance: ShoppingListDataBase? = null
private var lock = Any()

operator fun invoke(context: Context) = instance ?: synchronized(lock){ // check if the instance is null, if it is null
instance?: createDatabase(context).also { instance = it} // create a database.
}


private fun createDatabase(context: Context) =
Room.databaseBuilder(context.applicationContext,
ShoppingListDataBase::class.java,"ShoppingList.db").build()
}
}
Loading

0 comments on commit 4de9ab7

Please sign in to comment.