Skip to content

Commit 1b8938c

Browse files
committed
Add inventory module
1 parent 84d9e98 commit 1b8938c

64 files changed

Lines changed: 1586 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ Within each module, you will find detailed TODO comments that guide you through
66

77
Currently it contains codebases for:
88

9+
- [App](https://github.com/AsemLab/Samples/tree/main/app): a general module contains and covers the various topics.
910
- [Activity Recognition](https://developer.android.com/develop/sensors-and-location/location/transitions): Detects changes in the user's activity( such as walking, running, or driving). By subscribes to a transition in activities of interest and the API notifies the app only when needed.
1011
- [App Shortcuts](https://developer.android.com/develop/ui/views/launch/shortcuts): Shortcuts can be displayed in a supported launcher. They help users quickly start common or recommended tasks within apps.
1112
- [Autofill](https://developers.google.com/identity/sms-retriever/request): Retrieve otp from SMS automatically using Google SMS Retriever API.
1213
- [Broadcast Receiver](https://github.com/AsemLab/Samples/tree/main/broadcast_receiver): Create a custom broadcast receiver.
1314
- [Chuncker](https://github.com/ChuckerTeam/chucker): an HTTP inspector for Android & OkHTTP. Apps using Chucker will display a notification showing a summary of ongoing HTTP activity.
1415
- [Firebase](https://firebase.google.com/):
15-
- [App Distribution](https://firebase.google.com/docs/app-distribution): makes distributing your apps to trusted testers painless. By getting your apps onto testers' devices quickly, you can get feedback early and often.
16+
- [App Distribution](https://firebase.google.com/docs/app-distribution): makes distributing your apps to trusted testers painless. By getting your apps onto testers' devices quickly, you can get feedback early and often.
1617
- [Firestore](https://firebase.google.com/docs/firestore): a flexible, scalable NoSQL cloud database, built on Google Cloud infrastructure, to store and sync data for client- and server-side development.
1718
- [GraphQL](https://graphql.com/learn/what-is-graphql/): is a query language for APIs. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more.
19+
- [Inventory](https://github.com/AsemLab/Samples/tree/main/inventory): a simple app demonstrates how to implement offline-first app
1820
- [Koin](https://insert-koin.io/): a lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
1921
- [Ktor](https://ktor.io/): a framework for quickly creating connected applications in Kotlin with minimal effort.
2022
- [Leak](https://square.github.io/leakcanary/): using LeakCanary that is a memory leak detection library for Android.

figures/inventory-app.png

1.33 MB
Loading

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ apollo = "4.0.0"
5757
firebase-distribution = "16.0.0-beta13"
5858
play-services-location = "21.3.0"
5959
datastore = "1.1.7"
60+
swiperefreshlayout = "1.1.0"
6061

6162
[libraries]
6263
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
@@ -131,6 +132,7 @@ firebase-appdistribution = { module = "com.google.firebase:firebase-appdistribut
131132
firebase-appdistribution-api-ktx = { module = "com.google.firebase:firebase-appdistribution-api-ktx" , version.ref="firebase-distribution"}
132133
play-services-location = { module = "com.google.android.gms:play-services-location", version.ref = "play-services-location" }
133134
datastore = { module = "androidx.datastore:datastore-preferences", version.ref = "datastore" }
135+
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swiperefreshlayout" }
134136

135137
[plugins]
136138
android-application = { id = "com.android.application", version.ref = "android-application" }

inventory/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

inventory/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## App objective:
2+
3+
This simple app demonstrates how to implement offline-first app using Retrofit & Room Database by adhering to MVVM and clean architecture.
4+
5+
</br></br>
6+
7+
## App overview:
8+
9+
Display simple inventory dashboard (products & their quantities in warehouses) with the ability to search
10+
11+
</br></br>
12+
13+
<img src="./figures/inventory-app.png"/>

inventory/build.gradle.kts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin)
4+
alias(libs.plugins.hilt.plugin)
5+
alias(libs.plugins.kotlin.kapt)
6+
}
7+
8+
android {
9+
namespace = "com.asemlab.inventory"
10+
compileSdk = com.asemlab.samples.Configuration.compileSdk
11+
12+
defaultConfig {
13+
minSdk = com.asemlab.samples.Configuration.minSdk
14+
targetSdk = com.asemlab.samples.Configuration.targetSdk
15+
versionCode = com.asemlab.samples.Configuration.versionCode
16+
versionName = com.asemlab.samples.Configuration.versionName
17+
18+
19+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
20+
}
21+
22+
buildTypes {
23+
24+
debug {
25+
buildConfigField("String", "API_KEY", "\"c29039e0\"")
26+
}
27+
28+
release {
29+
isMinifyEnabled = false
30+
proguardFiles(
31+
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
32+
)
33+
}
34+
}
35+
compileOptions {
36+
sourceCompatibility = JavaVersion.VERSION_17
37+
targetCompatibility = JavaVersion.VERSION_17
38+
}
39+
kotlinOptions {
40+
jvmTarget = "17"
41+
}
42+
43+
buildFeatures {
44+
dataBinding = true
45+
buildConfig = true
46+
}
47+
48+
}
49+
50+
dependencies {
51+
52+
implementation(libs.androidx.core.ktx)
53+
implementation(libs.androidx.appcompat)
54+
implementation(libs.material)
55+
implementation(libs.androidx.activity)
56+
implementation(libs.activity)
57+
implementation(libs.androidx.constraintlayout)
58+
testImplementation(libs.junit)
59+
androidTestImplementation(libs.androidx.junit)
60+
androidTestImplementation(libs.androidx.espresso.core)
61+
implementation(libs.androidx.navigation.fragment.ktx)
62+
implementation(libs.androidx.navigation.ui.ktx)
63+
implementation(libs.androidx.viewmodel)
64+
implementation(libs.androidx.swiperefreshlayout)
65+
66+
// Retrofit
67+
implementation(libs.retrofit)
68+
implementation(libs.converter.gson)
69+
implementation(libs.gson)
70+
implementation(platform(libs.okhttp.bom))
71+
implementation(libs.okhttp)
72+
implementation(libs.okhttp.interceptor)
73+
74+
// Hilt
75+
implementation(libs.hilt.android)
76+
kapt(libs.hilt.compiler)
77+
78+
// Room
79+
implementation(libs.androidx.room.runtime)
80+
implementation(libs.androidx.room.ktx)
81+
kapt(libs.androidx.room.compiler)
82+
83+
// Glide
84+
implementation(libs.glide)
85+
kapt(libs.glide.compiler)
86+
}

inventory/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.asemlab.inventory
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.asemlab.dashboard", appContext.packageName)
23+
}
24+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
7+
8+
<application
9+
android:name=".base.DashboardApp"
10+
android:allowBackup="true"
11+
android:dataExtractionRules="@xml/data_extraction_rules"
12+
android:fullBackupContent="@xml/backup_rules"
13+
android:icon="@mipmap/ic_launcher"
14+
android:label="@string/app_name"
15+
android:usesCleartextTraffic="true"
16+
android:roundIcon="@mipmap/ic_launcher_round"
17+
android:supportsRtl="true"
18+
android:theme="@style/Theme.Dashboard">
19+
<activity
20+
android:name=".ui.MainActivity"
21+
android:screenOrientation="portrait"
22+
android:exported="true">
23+
<intent-filter>
24+
<action android:name="android.intent.action.MAIN" />
25+
26+
<category android:name="android.intent.category.LAUNCHER" />
27+
</intent-filter>
28+
</activity>
29+
</application>
30+
31+
</manifest>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.asemlab.inventory.base
2+
3+
import android.app.Application
4+
import dagger.hilt.android.HiltAndroidApp
5+
6+
@HiltAndroidApp
7+
class DashboardApp: Application() {
8+
}

0 commit comments

Comments
 (0)