Skip to content

Commit 8252d1d

Browse files
committed
Initial commit
0 parents  commit 8252d1d

File tree

78 files changed

+2277
-0
lines changed

Some content is hidden

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

78 files changed

+2277
-0
lines changed

app/build.gradle

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
id 'kotlin-kapt'
5+
id 'kotlin-parcelize'
6+
}
7+
8+
android {
9+
namespace 'com.mihir.jumpingmindtask'
10+
compileSdk 33
11+
12+
defaultConfig {
13+
applicationId "com.mihir.jumpingmindtask"
14+
minSdk 21
15+
targetSdk 33
16+
versionCode 1
17+
versionName "1.0"
18+
19+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
20+
}
21+
22+
buildTypes {
23+
release {
24+
minifyEnabled true
25+
shrinkResources true
26+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27+
}
28+
debug{
29+
minifyEnabled true
30+
shrinkResources true
31+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
32+
}
33+
}
34+
compileOptions {
35+
sourceCompatibility JavaVersion.VERSION_1_8
36+
targetCompatibility JavaVersion.VERSION_1_8
37+
}
38+
kotlinOptions {
39+
jvmTarget = '1.8'
40+
}
41+
buildFeatures{
42+
viewBinding true
43+
dataBinding true
44+
}
45+
}
46+
47+
dependencies {
48+
49+
implementation 'androidx.core:core-ktx:1.9.0'
50+
implementation 'androidx.appcompat:appcompat:1.6.0'
51+
implementation 'com.google.android.material:material:1.7.0'
52+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
53+
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
54+
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
55+
testImplementation 'junit:junit:4.13.2'
56+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
57+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
58+
59+
// retrofit
60+
implementation "com.squareup.retrofit2:retrofit:2.9.0"
61+
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
62+
63+
// coroutines
64+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
65+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
66+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
67+
68+
// Intuit ssp & sdp
69+
implementation "com.intuit.sdp:sdp-android:1.0.6"
70+
implementation "com.intuit.ssp:ssp-android:1.0.6"
71+
72+
//shared prefs
73+
implementation "androidx.preference:preference-ktx:1.2.0"
74+
75+
//room database
76+
implementation "androidx.room:room-runtime:2.5.0"
77+
kapt "androidx.room:room-compiler:2.5.0"
78+
implementation "androidx.room:room-ktx:2.5.0"
79+
androidTestImplementation "androidx.room:room-testing:2.5.0"
80+
81+
// splashscreen
82+
implementation "androidx.core:core-splashscreen:1.0.0"
83+
84+
// paging
85+
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
86+
87+
// Glide
88+
implementation 'com.github.bumptech.glide:glide:4.14.2'
89+
90+
// Shimmer view
91+
implementation 'com.facebook.shimmer:shimmer:0.5.0'
92+
93+
// Prompt demo
94+
implementation 'uk.co.samuelwall:material-tap-target-prompt:3.3.0'
95+
}

app/proguard-rules.pro

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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
22+
23+
-keep class com.mihir.jumpingmindtask.model*
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.mihir.jumpingmindtask
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.mihir.jumpingmindtask", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
<application
8+
android:allowBackup="true"
9+
android:dataExtractionRules="@xml/data_extraction_rules"
10+
android:fullBackupContent="@xml/backup_rules"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/Theme.JumpingMindTask"
16+
tools:targetApi="31">
17+
<activity
18+
android:theme="@style/Theme.Splash"
19+
android:name=".ui.screen.MainActivity"
20+
android:exported="true">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
27+
<meta-data
28+
android:name="android.app.lib_name"
29+
android:value="" />
30+
</activity>
31+
</application>
32+
33+
</manifest>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.mihir.jumpingmindtask
2+
3+
const val BASE_URL = "https://api.punkapi.com/v2/"
4+
const val API_FAILED = "API_FAILED"
5+
const val API_SUCCESS = "API_SUCCESS"
6+
7+
const val PER_PAGE_ITEMS = 25
8+
const val INITIAL_PAGE_INDEX = 1
9+
10+
const val DATA = "data"
11+
12+
const val HAS_SEEN_LIST_PROMPT = "HAS_SEEN_LIST_PROMPT"
13+
const val HAS_SEEN_DETAILS_PROMPT = "HAS_SEEN_DETAILS_PROMPT"
14+
const val HAS_SEEN_LIKED_PROMPT = "HAS_SEEN_LIKED_PROMPT"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.mihir.jumpingmindtask.database
2+
3+
import android.content.Context
4+
import androidx.room.Database
5+
import androidx.room.Room
6+
import androidx.room.RoomDatabase
7+
import androidx.room.TypeConverters
8+
import com.mihir.jumpingmindtask.model.BeerDataItem
9+
10+
@Database(entities = [BeerDataItem::class],version = 1,exportSchema = false)
11+
@TypeConverters(TypeConverter::class)
12+
abstract class FavDatabase: RoomDatabase() {
13+
14+
abstract fun favDao(): FavInterface
15+
16+
companion object{
17+
@Volatile
18+
private var INSTANCE: FavDatabase?=null
19+
20+
fun getDatabase(context: Context): FavDatabase {
21+
val tempInstance = INSTANCE
22+
if (tempInstance!= null){
23+
return tempInstance
24+
}
25+
synchronized(this){
26+
val instance = Room.databaseBuilder(
27+
context.applicationContext,
28+
FavDatabase::class.java,
29+
"fav_database"
30+
).build()
31+
32+
INSTANCE = instance
33+
return instance
34+
}
35+
}
36+
}
37+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.mihir.jumpingmindtask.database
2+
3+
import androidx.lifecycle.LiveData
4+
import androidx.room.*
5+
import com.mihir.jumpingmindtask.model.BeerDataItem
6+
7+
@Dao
8+
interface FavInterface {
9+
@Insert(onConflict = OnConflictStrategy.REPLACE)
10+
suspend fun addFav(beer:BeerDataItem)
11+
12+
@Query("SELECT * FROM fav_beer")
13+
fun getFavs():LiveData<List<BeerDataItem>>
14+
15+
@Delete
16+
suspend fun deleteFav(beer: BeerDataItem)
17+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package com.mihir.jumpingmindtask.database
2+
3+
import androidx.room.TypeConverter
4+
import com.google.gson.Gson
5+
import com.mihir.jumpingmindtask.model.*
6+
7+
class TypeConverter {
8+
@TypeConverter
9+
fun classToJsonAmount(source: Amount?):String{
10+
return Gson().toJson(source)
11+
}
12+
13+
@TypeConverter
14+
fun classFromJsonAmount(source: String?):Amount{
15+
return Gson().fromJson(source, Amount::class.java)
16+
}
17+
18+
@TypeConverter
19+
fun classToJsonBoil(source: BoilVolume?):String{
20+
return Gson().toJson(source)
21+
}
22+
23+
@TypeConverter
24+
fun classFromJsonBoil(source: String?):BoilVolume{
25+
return Gson().fromJson(source, BoilVolume::class.java)
26+
}
27+
28+
@TypeConverter
29+
fun classToJsonFer(source: Fermentation?):String{
30+
return Gson().toJson(source)
31+
}
32+
33+
@TypeConverter
34+
fun classFromJsonFer(source: String?):Fermentation{
35+
return Gson().fromJson(source, Fermentation::class.java)
36+
}
37+
38+
@TypeConverter
39+
fun classToJsonHop(source: Hop?):String{
40+
return Gson().toJson(source)
41+
}
42+
43+
@TypeConverter
44+
fun classFromJsonHop(source: String?):Hop{
45+
return Gson().fromJson(source, Hop::class.java)
46+
}
47+
48+
@TypeConverter
49+
fun classToJsonIngredients(source: Ingredients?):String{
50+
return Gson().toJson(source)
51+
}
52+
53+
@TypeConverter
54+
fun classFromJsonIngredients(source: String?):Ingredients{
55+
return Gson().fromJson(source, Ingredients::class.java)
56+
}
57+
58+
@TypeConverter
59+
fun classToJsonMalt(source: Malt?):String{
60+
return Gson().toJson(source)
61+
}
62+
63+
@TypeConverter
64+
fun classFromJsonMalt(source: String?):Malt{
65+
return Gson().fromJson(source, Malt::class.java)
66+
}
67+
68+
@TypeConverter
69+
fun classToJsonMashTemp(source: MashTemp?):String{
70+
return Gson().toJson(source)
71+
}
72+
73+
@TypeConverter
74+
fun classFromJsonMashTemp(source: String?):MashTemp{
75+
return Gson().fromJson(source, MashTemp::class.java)
76+
}
77+
78+
@TypeConverter
79+
fun classToJsonMashMethod(source: Method?):String{
80+
return Gson().toJson(source)
81+
}
82+
83+
@TypeConverter
84+
fun classFromJsonMethod(source: String?):Method{
85+
return Gson().fromJson(source, Method::class.java)
86+
}
87+
88+
@TypeConverter
89+
fun classToJsonMashTemp(source: Temp?):String{
90+
return Gson().toJson(source)
91+
}
92+
93+
@TypeConverter
94+
fun classFromJsonTemp(source: String?):Temp{
95+
return Gson().fromJson(source, Temp::class.java)
96+
}
97+
98+
@TypeConverter
99+
fun classToJsonMashVolume(source: Volume?):String{
100+
return Gson().toJson(source)
101+
}
102+
103+
@TypeConverter
104+
fun classFromJsonVolume(source: String?):Volume{
105+
return Gson().fromJson(source, Volume::class.java)
106+
}
107+
108+
@TypeConverter
109+
fun listToJsonString(value: List<String>?): String = Gson().toJson(value)
110+
111+
@TypeConverter
112+
fun jsonStringToList(value: String) = Gson().fromJson(value, Array<String>::class.java).toList()
113+
}
114+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.mihir.jumpingmindtask.model
2+
3+
import android.os.Parcelable
4+
import kotlinx.parcelize.Parcelize
5+
6+
@Parcelize
7+
data class Amount(
8+
val unit: String?,
9+
val value: Double
10+
):Parcelable
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package com.mihir.jumpingmindtask.model
2+
3+
class BeerData : ArrayList<BeerDataItem>()

0 commit comments

Comments
 (0)