Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Android CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
5 changes: 5 additions & 0 deletions .idea/discord.xml

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

3 changes: 2 additions & 1 deletion .idea/gradle.xml

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

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

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

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Yuriy Yangel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- MVVM

## 📱 Screenshots
### ⬜ Light Theme
⬜ Light Theme
<h3 align="center"> Issue Screen | Main Screen | Detail Section | Forecast Section </h3>
<p align="center">
<img src="screenshot/LightTheme/7.png" width="200">
Expand All @@ -32,7 +32,7 @@
<img src="screenshot/LightTheme/6.png" width="200">
</p>

### ⬛ Dark Theme
⬛ Dark Theme
<h3 align="center"> Issue Screen | Main Screen | Detail Section | Forecast Section </h3>
<p align="center">
<img src="screenshot/DarkTheme/7.png" width="200">
Expand All @@ -46,4 +46,29 @@
<img src="screenshot/DarkTheme/4.png" width="200">
<img src="screenshot/DarkTheme/5.png" width="200" >
<img src="screenshot/DarkTheme/6.png" width="200">
</p>
</p>

## 🧑‍⚖️ License
```
MIT License

Copyright (c) 2023 Yuriy Yangel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
43 changes: 26 additions & 17 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.devtools.ksp'
id 'com.google.dagger.hilt.android'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.0'
id 'kotlin-kapt'
id 'com.google.gms.google-services'

}


Expand All @@ -18,7 +18,7 @@ android {
defaultConfig {
applicationId "com.example.diapplication"
minSdk 26
targetSdk 33
targetSdk 34
versionCode 1
versionName "1.0"

Expand All @@ -45,7 +45,7 @@ android {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.3.2'
kotlinCompilerExtensionVersion '1.5.2'
}
packagingOptions {
resources {
Expand All @@ -56,42 +56,50 @@ android {

dependencies {

def nav_version = "2.6.0"
def hiltVersion = "2.44"
def nav_version = "2.7.6"
def hiltVersion = "2.50"
def retrofitVersion = "2.9.0"
def okHttpVersion = "4.9.1"
def okHttpVersion = "4.12.0"
def kotlinSerializationVersion = "1.5.1"
def kotlinSerialization = "1.0.0"
def espressoVersion = "3.5.1"
def coilVersion = "2.4.0"
def lifeCycleVersion = "2.6.1"
def hiltNavCompose = "1.0.0"
def securityCryptoVersion = "1.1.0-alpha06"
def lifeCycleVersion = "2.7.0"
def hiltNavCompose = "1.1.0"
def accompanistUi = "0.27.0"
def placesVersion = "3.2.0"
def placesVersion = "3.3.0"
def room_version = "2.6.1"




implementation("androidx.room:room-runtime:$room_version")
annotationProcessor("androidx.room:room-compiler:$room_version")
implementation "androidx.navigation:navigation-compose:$nav_version"
implementation("io.coil-kt:coil-compose:$coilVersion")
implementation "androidx.hilt:hilt-navigation-compose:$hiltNavCompose"
implementation("com.google.android.gms:play-services-location:21.0.1")
implementation 'com.google.accompanist:accompanist-permissions:0.31.5-beta'
implementation("com.google.android.gms:play-services-location:21.1.0")
implementation 'com.google.accompanist:accompanist-permissions:0.34.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation("androidx.security:security-crypto:$securityCryptoVersion")
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanistUi"
implementation "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:$kotlinSerialization"
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.google.android.libraries.places:places:$placesVersion"
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
implementation "com.google.dagger:hilt-android:$hiltVersion"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializationVersion"
implementation 'androidx.core:core-ktx:1.10.1'
implementation ("androidx.work:work-runtime-ktx:2.8.1")
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.core:core-ktx:1.12.0'
implementation ("androidx.work:work-runtime-ktx:2.9.0")
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifeCycleVersion"
implementation 'androidx.activity:activity-compose:1.7.2'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation 'androidx.compose.ui:ui'
implementation 'com.google.firebase:firebase-database-ktx:20.2.2'
implementation 'com.google.firebase:firebase-database-ktx:20.3.0'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation("androidx.compose.material3:material3-android:1.2.0-rc01")

implementation platform('androidx.compose:compose-bom:2022.10.00')
implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
Expand All @@ -100,6 +108,7 @@ dependencies {
implementation("com.google.firebase:firebase-database-ktx")

kapt "com.google.dagger:hilt-compiler:$hiltVersion"
ksp "androidx.room:room-compiler:$room_version"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:allowBackup="true"
android:name = ".data.WeatherApp"
android:name = "WeatherApp"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
Expand Down
60 changes: 13 additions & 47 deletions app/src/main/java/com/example/diapplication/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,69 +1,35 @@
@file:OptIn(ExperimentalPermissionsApi::class)

package com.example.diapplication

import android.content.Context
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.platform.LocalContext
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.example.diapplication.presentation.CityPredictViewModel
import com.example.diapplication.presentation.UserViewModel
import com.example.diapplication.presentation.WeatherViewModel
import com.example.diapplication.ui.theme.DIapplicationTheme
import com.example.diapplication.view.navigation.WeatherNavHost
import androidx.hilt.navigation.compose.hiltViewModel
import com.example.diapplication.presentation.ui.navigation.WeatherNavHost
import com.example.diapplication.presentation.ui.theme.DIapplicationTheme
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.rememberPermissionState
import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.LocationServices
import com.google.firebase.FirebaseApp
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private val weatherViewModel: WeatherViewModel by viewModels()
private val userViewModel: UserViewModel by viewModels()
private val cityPredictViewModel: CityPredictViewModel by viewModels()
private lateinit var fusedLocationProviderClient: FusedLocationProviderClient


@OptIn(ExperimentalPermissionsApi::class)
private lateinit var fusedLocationProviderClient: FusedLocationProviderClient
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this)
super.onCreate(savedInstanceState)
setContent {
val darkTheme by userViewModel.darkTheme.collectAsStateWithLifecycle()

val context: Context = LocalContext.current
val permissionDenied = rememberSaveable { mutableStateOf(false) }
val locationPermissionState =
rememberPermissionState(permission = android.Manifest.permission.ACCESS_FINE_LOCATION)

LaunchedEffect(Unit) {
userViewModel.getUserTheme()
weatherViewModel.updateUserGeolocation(
context = context,
fusedLocationProviderClient = fusedLocationProviderClient,
locationPermissionState = locationPermissionState,
permissionDenied = permissionDenied,
)
weatherViewModel.getCities()
}

FirebaseApp.initializeApp(this)

DIapplicationTheme(darkTheme = darkTheme) {
DIapplicationTheme(darkTheme = false) {
WeatherNavHost(
weatherViewModel = weatherViewModel,
userViewModel = userViewModel,
cityPredictViewModel = cityPredictViewModel,
darkTheme = darkTheme,
weatherViewModel = hiltViewModel(),
cityPredictViewModel = hiltViewModel(),
darkTheme = true,
fusedLocationProviderClient = fusedLocationProviderClient
)


}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.diapplication.data
package com.example.diapplication

import android.app.Application
import dagger.hilt.android.HiltAndroidApp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.example.diapplication.domain.utils
package com.example.diapplication.common

object Constants {
const val API_TOKEN = "ee6dfd6f5e224f0a8ed134208230407"
const val BASE_URL = "http://api.weatherapi.com/v1/"
const val CONNECT_TIMEOUT = 10L
const val READ_TIMEOUT = 10L
const val WRITE_TIMEOUT = 10L
const val EMPTY_STRING = ""
const val PRIORITY = 100
const val SHORT_SPACE = " "
const val PREDICT_DELAY = 300L
const val TOKEN_REFERENCES = "secret_shared_prefs"
const val GIT_HUB_KEY = "gitHub"
const val ISSUE_KEY = "form"
const val GIT_HUB_URL = "https://github.com/rendivy/ShiftAndroid2023"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.diapplication.common

object NetworkConstants {
const val API_TOKEN = "ee6dfd6f5e224f0a8ed134208230407"
const val BASE_URL = "http://api.weatherapi.com/v1/"
const val CONNECT_TIMEOUT = 10L
const val READ_TIMEOUT = 10L
const val WRITE_TIMEOUT = 10L
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.diapplication.domain.utils
package com.example.diapplication.common

enum class UiError(val message: String) {
CITY_ALREADY_EXISTS("City already added"),
Expand Down
Loading