Skip to content

Commit 5683ab0

Browse files
Initial commit
0 parents  commit 5683ab0

Some content is hidden

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

58 files changed

+1864
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
id 'kotlin-kapt'
5+
id 'dagger.hilt.android.plugin'
6+
}
7+
8+
android {
9+
compileSdk 32
10+
11+
defaultConfig {
12+
applicationId "com.plcoding.weatherapp"
13+
minSdk 21
14+
targetSdk 32
15+
versionCode 1
16+
versionName "1.0"
17+
18+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19+
vectorDrawables {
20+
useSupportLibrary true
21+
}
22+
}
23+
24+
buildTypes {
25+
release {
26+
minifyEnabled false
27+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
28+
}
29+
}
30+
compileOptions {
31+
coreLibraryDesugaringEnabled true
32+
sourceCompatibility JavaVersion.VERSION_1_8
33+
targetCompatibility JavaVersion.VERSION_1_8
34+
}
35+
kotlinOptions {
36+
jvmTarget = '1.8'
37+
}
38+
buildFeatures {
39+
compose true
40+
}
41+
composeOptions {
42+
kotlinCompilerExtensionVersion compose_version
43+
}
44+
packagingOptions {
45+
resources {
46+
excludes += '/META-INF/{AL2.0,LGPL2.1}'
47+
}
48+
}
49+
}
50+
51+
dependencies {
52+
53+
implementation 'androidx.core:core-ktx:1.7.0'
54+
implementation "androidx.compose.ui:ui:$compose_version"
55+
implementation "androidx.compose.material:material:$compose_version"
56+
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
57+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
58+
implementation 'androidx.activity:activity-compose:1.3.1'
59+
testImplementation 'junit:junit:4.13.2'
60+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
61+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
62+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
63+
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
64+
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
65+
66+
//Dagger - Hilt
67+
implementation "com.google.dagger:hilt-android:2.40.5"
68+
kapt "com.google.dagger:hilt-android-compiler:2.40.5"
69+
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
70+
kapt "androidx.hilt:hilt-compiler:1.0.0"
71+
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
72+
73+
// Location Services
74+
implementation 'com.google.android.gms:play-services-location:20.0.0'
75+
76+
// Retrofit
77+
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
78+
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
79+
implementation "com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.3"
80+
81+
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.4.1"
82+
}

app/proguard-rules.pro

+21
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.plcoding.weatherapp
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.plcoding.weatherapp", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.plcoding.weatherapp">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
7+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
8+
9+
<application
10+
android:allowBackup="true"
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.WeatherApp">
16+
<activity
17+
android:name=".presentation.MainActivity"
18+
android:exported="true"
19+
android:label="@string/app_name"
20+
android:theme="@style/Theme.WeatherApp">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
</activity>
27+
</application>
28+
29+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.plcoding.weatherapp.domain.util
2+
3+
sealed class Resource<T>(val data: T? = null, val message: String? = null) {
4+
class Success<T>(data: T?): Resource<T>(data)
5+
class Error<T>(message: String, data: T? = null): Resource<T>(data, message)
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
package com.plcoding.weatherapp.domain.weather
2+
3+
import androidx.annotation.DrawableRes
4+
import com.plcoding.weatherapp.R
5+
6+
sealed class WeatherType(
7+
val weatherDesc: String,
8+
@DrawableRes val iconRes: Int
9+
) {
10+
object ClearSky : WeatherType(
11+
weatherDesc = "Clear sky",
12+
iconRes = R.drawable.ic_sunny
13+
)
14+
object MainlyClear : WeatherType(
15+
weatherDesc = "Mainly clear",
16+
iconRes = R.drawable.ic_cloudy
17+
)
18+
object PartlyCloudy : WeatherType(
19+
weatherDesc = "Partly cloudy",
20+
iconRes = R.drawable.ic_cloudy
21+
)
22+
object Overcast : WeatherType(
23+
weatherDesc = "Overcast",
24+
iconRes = R.drawable.ic_cloudy
25+
)
26+
object Foggy : WeatherType(
27+
weatherDesc = "Foggy",
28+
iconRes = R.drawable.ic_very_cloudy
29+
)
30+
object DepositingRimeFog : WeatherType(
31+
weatherDesc = "Depositing rime fog",
32+
iconRes = R.drawable.ic_very_cloudy
33+
)
34+
object LightDrizzle : WeatherType(
35+
weatherDesc = "Light drizzle",
36+
iconRes = R.drawable.ic_rainshower
37+
)
38+
object ModerateDrizzle : WeatherType(
39+
weatherDesc = "Moderate drizzle",
40+
iconRes = R.drawable.ic_rainshower
41+
)
42+
object DenseDrizzle : WeatherType(
43+
weatherDesc = "Dense drizzle",
44+
iconRes = R.drawable.ic_rainshower
45+
)
46+
object LightFreezingDrizzle : WeatherType(
47+
weatherDesc = "Slight freezing drizzle",
48+
iconRes = R.drawable.ic_snowyrainy
49+
)
50+
object DenseFreezingDrizzle : WeatherType(
51+
weatherDesc = "Dense freezing drizzle",
52+
iconRes = R.drawable.ic_snowyrainy
53+
)
54+
object SlightRain : WeatherType(
55+
weatherDesc = "Slight rain",
56+
iconRes = R.drawable.ic_rainy
57+
)
58+
object ModerateRain : WeatherType(
59+
weatherDesc = "Rainy",
60+
iconRes = R.drawable.ic_rainy
61+
)
62+
object HeavyRain : WeatherType(
63+
weatherDesc = "Heavy rain",
64+
iconRes = R.drawable.ic_rainy
65+
)
66+
object HeavyFreezingRain: WeatherType(
67+
weatherDesc = "Heavy freezing rain",
68+
iconRes = R.drawable.ic_snowyrainy
69+
)
70+
object SlightSnowFall: WeatherType(
71+
weatherDesc = "Slight snow fall",
72+
iconRes = R.drawable.ic_snowy
73+
)
74+
object ModerateSnowFall: WeatherType(
75+
weatherDesc = "Moderate snow fall",
76+
iconRes = R.drawable.ic_heavysnow
77+
)
78+
object HeavySnowFall: WeatherType(
79+
weatherDesc = "Heavy snow fall",
80+
iconRes = R.drawable.ic_heavysnow
81+
)
82+
object SnowGrains: WeatherType(
83+
weatherDesc = "Snow grains",
84+
iconRes = R.drawable.ic_heavysnow
85+
)
86+
object SlightRainShowers: WeatherType(
87+
weatherDesc = "Slight rain showers",
88+
iconRes = R.drawable.ic_rainshower
89+
)
90+
object ModerateRainShowers: WeatherType(
91+
weatherDesc = "Moderate rain showers",
92+
iconRes = R.drawable.ic_rainshower
93+
)
94+
object ViolentRainShowers: WeatherType(
95+
weatherDesc = "Violent rain showers",
96+
iconRes = R.drawable.ic_rainshower
97+
)
98+
object SlightSnowShowers: WeatherType(
99+
weatherDesc = "Light snow showers",
100+
iconRes = R.drawable.ic_snowy
101+
)
102+
object HeavySnowShowers: WeatherType(
103+
weatherDesc = "Heavy snow showers",
104+
iconRes = R.drawable.ic_snowy
105+
)
106+
object ModerateThunderstorm: WeatherType(
107+
weatherDesc = "Moderate thunderstorm",
108+
iconRes = R.drawable.ic_thunder
109+
)
110+
object SlightHailThunderstorm: WeatherType(
111+
weatherDesc = "Thunderstorm with slight hail",
112+
iconRes = R.drawable.ic_rainythunder
113+
)
114+
object HeavyHailThunderstorm: WeatherType(
115+
weatherDesc = "Thunderstorm with heavy hail",
116+
iconRes = R.drawable.ic_rainythunder
117+
)
118+
119+
companion object {
120+
fun fromWMO(code: Int): WeatherType {
121+
return when(code) {
122+
0 -> ClearSky
123+
1 -> MainlyClear
124+
2 -> PartlyCloudy
125+
3 -> Overcast
126+
45 -> Foggy
127+
48 -> DepositingRimeFog
128+
51 -> LightDrizzle
129+
53 -> ModerateDrizzle
130+
55 -> DenseDrizzle
131+
56 -> LightFreezingDrizzle
132+
57 -> DenseFreezingDrizzle
133+
61 -> SlightRain
134+
63 -> ModerateRain
135+
65 -> HeavyRain
136+
66 -> LightFreezingDrizzle
137+
67 -> HeavyFreezingRain
138+
71 -> SlightSnowFall
139+
73 -> ModerateSnowFall
140+
75 -> HeavySnowFall
141+
77 -> SnowGrains
142+
80 -> SlightRainShowers
143+
81 -> ModerateRainShowers
144+
82 -> ViolentRainShowers
145+
85 -> SlightSnowShowers
146+
86 -> HeavySnowShowers
147+
95 -> ModerateThunderstorm
148+
96 -> SlightHailThunderstorm
149+
99 -> HeavyHailThunderstorm
150+
else -> ClearSky
151+
}
152+
}
153+
}
154+
}

0 commit comments

Comments
 (0)