├── .gitignore ├── .idea ├── .gitignore ├── .name ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml ├── render.experimental.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── release │ ├── app-release.apk │ └── output-metadata.json └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── kotlinproject │ │ └── ExampleInstrumentedTest.kt │ ├── debug │ └── res │ │ └── values │ │ └── google_maps_api.xml │ ├── main │ ├── AndroidManifest.xml │ ├── icon_notification-playstore.png │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── kotlinproject │ │ │ ├── dataLayer │ │ │ ├── DataSourceViewModel.kt │ │ │ ├── entity │ │ │ │ ├── AlertTable.kt │ │ │ │ ├── Converter.kt │ │ │ │ ├── favtable │ │ │ │ │ ├── Alert.kt │ │ │ │ │ ├── Current.kt │ │ │ │ │ ├── Daily.kt │ │ │ │ │ ├── FavData.kt │ │ │ │ │ ├── FeelsLike.kt │ │ │ │ │ ├── Hourly.kt │ │ │ │ │ ├── Rain.kt │ │ │ │ │ ├── Temp.kt │ │ │ │ │ ├── Weather.kt │ │ │ │ │ ├── WeatherX.kt │ │ │ │ │ └── WeatherXX.kt │ │ │ │ └── oneCallEntity │ │ │ │ │ ├── Alert.kt │ │ │ │ │ ├── AllData.kt │ │ │ │ │ ├── Current.kt │ │ │ │ │ ├── Daily.kt │ │ │ │ │ ├── FeelsLike.kt │ │ │ │ │ ├── Hourly.kt │ │ │ │ │ ├── Rain.kt │ │ │ │ │ ├── Temp.kt │ │ │ │ │ ├── Weather.kt │ │ │ │ │ ├── WeatherX.kt │ │ │ │ │ └── WeatherXX.kt │ │ │ ├── local │ │ │ │ ├── room │ │ │ │ │ ├── DataBaseWeather.kt │ │ │ │ │ ├── RoomRepositry.kt │ │ │ │ │ └── WeatherDao.kt │ │ │ │ └── sharedprefrence │ │ │ │ │ ├── SettingModel.kt │ │ │ │ │ ├── SettingSB.kt │ │ │ │ │ └── SharedPrefrencesReopsitory.kt │ │ │ └── online │ │ │ │ ├── ApiClient.kt │ │ │ │ ├── ApiInterface.kt │ │ │ │ └── Repository.kt │ │ │ └── ui │ │ │ ├── GeneralFunctions.kt │ │ │ ├── NotificationHelper.kt │ │ │ ├── alert │ │ │ ├── Alert.kt │ │ │ ├── AlertViewModel.kt │ │ │ └── CurrentAlertAdaapter.kt │ │ │ ├── baseHome │ │ │ ├── MainActivity.kt │ │ │ └── MainViewModel.kt │ │ │ ├── createAlerm │ │ │ ├── AlermRecever.kt │ │ │ ├── CreateAlerm.kt │ │ │ └── CreateAlermViewModel.kt │ │ │ ├── favourit │ │ │ ├── Favourit.kt │ │ │ ├── FavouriteAdapter.kt │ │ │ └── FavouriteViewModel.kt │ │ │ ├── favouriteDetails │ │ │ ├── DailyAdapter.kt │ │ │ ├── DetailsViewModel.kt │ │ │ ├── FavouriteDetails.kt │ │ │ └── HourlyAdabter.kt │ │ │ ├── home │ │ │ ├── DailyAdapter.kt │ │ │ ├── Home.kt │ │ │ ├── HomeViewModel.kt │ │ │ ├── HourlyAdabter.kt │ │ │ └── LocationHanding.kt │ │ │ ├── map │ │ │ ├── MapActivity.kt │ │ │ └── MapActivityViewMode.kt │ │ │ ├── setting │ │ │ ├── Setting.kt │ │ │ └── SettingViewModel.kt │ │ │ ├── splash │ │ │ ├── Splash.kt │ │ │ └── SplashViewModel.kt │ │ │ └── widget │ │ │ └── WeatherWidget.kt │ └── res │ │ ├── anim │ │ └── wave.xml │ │ ├── animator │ │ └── move_down.xml │ │ ├── drawable-nodpi │ │ └── example_appwidget_preview.png │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── current_cloud.xml │ │ ├── current_humidity.xml │ │ ├── current_pressure.xml │ │ ├── current_sunrise.xml │ │ ├── current_sunsit.xml │ │ ├── current_wind.xml │ │ ├── frost.png │ │ ├── home_background.xml │ │ ├── ic__time_24.xml │ │ ├── ic_add_24.xml │ │ ├── ic_alert_24.xml │ │ ├── ic_arrow_24.xml │ │ ├── ic_arrow_down_24.xml │ │ ├── ic_avorite_24.xml │ │ ├── ic_baseline_add_alarm_24.xml │ │ ├── ic_baseline_check_box_outline_blank_24.xml │ │ ├── ic_baseline_close_24.xml │ │ ├── ic_check_24.xml │ │ ├── ic_cloud.xml │ │ ├── ic_date_24.xml │ │ ├── ic_description_24.xml │ │ ├── ic_event_24.xml │ │ ├── ic_gps_24.xml │ │ ├── ic_home_24.xml │ │ ├── ic_humidity.xml │ │ ├── ic_language_24.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_location_on_24.xml │ │ ├── ic_pressure.xml │ │ ├── ic_reload_24.xml │ │ ├── ic_settings_24.xml │ │ ├── ic_sunrise.xml │ │ ├── ic_sunset.xml │ │ ├── ic_toggle_off_24.xml │ │ ├── ic_toggle_on_24.xml │ │ ├── ic_units_24.xml │ │ ├── ic_wind.xml │ │ ├── logo.png │ │ ├── offline.xml │ │ ├── sky.png │ │ ├── snow.png │ │ ├── snow1.png │ │ └── toggle_selector.xml │ │ ├── layout │ │ ├── activity_create_alerm.xml │ │ ├── activity_favourite_details.xml │ │ ├── activity_main.xml │ │ ├── activity_map.xml │ │ ├── activity_splash.xml │ │ ├── alarm_item.xml │ │ ├── favourite_item.xml │ │ ├── fragment_alert.xml │ │ ├── fragment_favourit.xml │ │ ├── fragment_home.xml │ │ ├── fragment_setting.xml │ │ ├── hourly_item.xml │ │ └── weather_widget.xml │ │ ├── menu │ │ └── navigation_menu.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── icon_notification.xml │ │ └── icon_notification_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── icon_notification.png │ │ ├── icon_notification_foreground.png │ │ └── icon_notification_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── icon_notification.png │ │ ├── icon_notification_foreground.png │ │ └── icon_notification_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── icon_notification.png │ │ ├── icon_notification_foreground.png │ │ └── icon_notification_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── icon_notification.png │ │ ├── icon_notification_foreground.png │ │ └── icon_notification_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── icon_notification.png │ │ ├── icon_notification_foreground.png │ │ └── icon_notification_round.png │ │ ├── raw │ │ └── rang.mp3 │ │ ├── values-ar │ │ └── strings.xml │ │ ├── values-night │ │ ├── colors.xml │ │ └── themes.xml │ │ ├── values-round │ │ └── strings.xml │ │ ├── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── icon_notification_background.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ └── weather_widget_info.xml │ ├── release │ └── res │ │ └── values │ │ └── google_maps_api.xml │ └── test │ └── java │ └── com │ └── example │ └── kotlinproject │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 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 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | KotlinProject -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 20 | 22 | 23 | 135 | 136 | 138 | 139 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/render.experimental.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Weather-Viewer-Android-by-Kotlin 2 | 3 | ## ***Table of Contents***

4 | 5 | * What is Weather-Viewer? 6 | * How to use it? 7 | * Futures. 8 | * Tecgnologes uses in it. 9 | * Tools and IDEs uses. 10 | * Links. 11 | 12 | 13 | 14 | _________________________________________________________________________________________________________________________________________________ 15 | ###### **What is Weather-Viewer?** 16 | 17 | Weather Viewer App is a forcasting Mobile Application based on kotlin language that is enabel you to featch weather and observe it with alot of future, and add as mutch as you 18 | want of places to your favourite to observe them. 19 | 20 | you can know the current forcastion, daily and weekly, and you kan set alert to in a time to reminds you when ever you want with the weather statios, and if the weather have a 21 | dangerose statios you can enaabel it to tell you 22 | 23 | 24 | 25 | ###### **How to use it?** 26 | Just install it and set your favourite setting or set them as defult. 27 | 28 | 29 | ###### **Futures?** 30 | * Cashing 31 | * Add Custom Location, or va gps 32 | * Work Offline &Online 33 | * Suppurt Dark and Light Mood 34 | * Support English & Arabic Languages 35 | 36 | ###### **Tecgnologes uses in it.** 37 | * Kotlin. 38 | * xml 39 | * MVVM Design Pattern 40 | * Room DataBase 41 | * LiveData 42 | * widget 43 | 44 | 45 | ###### **Tools and IDEs uses.** 46 | * Android Studio 47 | * photoshop 48 | * Postman 49 | * Adobe XD 50 | 51 | 52 | ###### **Links** 53 | * [Dowenload APK from here](https://drive.google.com/file/d/1N_Dys-N-5FIZ4_jbA4PQeNMvv6wG4LiA/view?usp=sharing) 54 | 55 | * link to demo video click the image [![link to demo video from here](https://github.com/EsraaFathy/EsraaFathy/blob/main/images/weather.png)](https://youtu.be/-pRl67B1uQ0) 56 | 57 | 58 | 59 | By @EsraaFathy 60 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | } 5 | apply plugin: 'kotlin-kapt' 6 | 7 | android { 8 | compileSdkVersion 30 9 | buildToolsVersion "30.0.3" 10 | 11 | defaultConfig { 12 | applicationId "com.example.kotlinproject" 13 | minSdkVersion 23 14 | targetSdkVersion 30 15 | versionCode 1 16 | versionName "1.0" 17 | multiDexEnabled true 18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 19 | } 20 | 21 | buildTypes { 22 | release { 23 | minifyEnabled false 24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 25 | } 26 | } 27 | compileOptions { 28 | sourceCompatibility JavaVersion.VERSION_1_8 29 | targetCompatibility JavaVersion.VERSION_1_8 30 | } 31 | kotlinOptions { 32 | jvmTarget = '1.8' 33 | } 34 | 35 | buildFeatures { 36 | //noinspection DataBindingWithoutKapt 37 | dataBinding = true 38 | viewBinding = true 39 | } 40 | } 41 | 42 | dependencies { 43 | 44 | implementation 'com.google.android.gms:play-services-location:18.0.0' 45 | 46 | 47 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 48 | implementation 'androidx.core:core-ktx:1.3.2' 49 | implementation 'androidx.appcompat:appcompat:1.2.0' 50 | implementation 'com.google.android.material:material:1.3.0' 51 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 52 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1" 53 | 54 | 55 | implementation 'androidx.recyclerview:recyclerview:1.1.0' 56 | implementation 'com.github.bumptech.glide:glide:4.11.0' 57 | 58 | //LifeCycle 59 | implementation 'androidx.lifecycle:lifecycle-common:2.3.0' 60 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0' 61 | implementation 'android.arch.lifecycle:extensions:2.2.0' 62 | implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0' 63 | 64 | //Retrofit 65 | implementation 'com.squareup.retrofit2:retrofit:2.9.0' 66 | implementation 'com.google.code.gson:gson:2.8.6' 67 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' 68 | implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' 69 | 70 | 71 | //room 72 | def room_version = "2.2.6" 73 | implementation "androidx.room:room-runtime:$room_version" 74 | // annotationProcessor "androidx.room:room-compiler:$room_version" 75 | // optional - RxJava support for Room 76 | implementation "androidx.room:room-rxjava2:$room_version" 77 | // optional - Guava support for Room, including Optional and ListenableFuture 78 | implementation "androidx.room:room-guava:$room_version" 79 | // optional - Test helpers 80 | testImplementation "androidx.room:room-testing:$room_version" 81 | implementation 'androidx.room:room-ktx:2.2.6' 82 | //noinspection LifecycleAnnotationProcessorWithJava8 83 | kapt "android.arch.lifecycle:compiler:1.1.1" 84 | kapt "androidx.room:room-compiler:$room_version" 85 | 86 | kapt "android.arch.persistence.room:compiler:1.1.1" 87 | implementation 'com.squareup.okhttp3:logging-interceptor:3.12.0' 88 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 89 | implementation 'com.google.android.gms:play-services-maps:17.0.0' 90 | 91 | 92 | implementation "androidx.multidex:multidex:2.0.1" 93 | testImplementation 'junit:junit:4.13.2' 94 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 95 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 96 | 97 | 98 | 99 | def work_version = "2.5.0" 100 | // Kotlin + coroutines 101 | implementation "androidx.work:work-runtime-ktx:$work_version" 102 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /app/release/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/release/app-release.apk -------------------------------------------------------------------------------- /app/release/output-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "artifactType": { 4 | "type": "APK", 5 | "kind": "Directory" 6 | }, 7 | "applicationId": "com.example.kotlinproject", 8 | "variantName": "processReleaseResources", 9 | "elements": [ 10 | { 11 | "type": "SINGLE", 12 | "filters": [], 13 | "versionCode": 1, 14 | "versionName": "1.0", 15 | "outputFile": "app-release.apk" 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/kotlinproject/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject 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.example.kotlinproject", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/debug/res/values/google_maps_api.xml: -------------------------------------------------------------------------------- 1 | 2 | 23 | AIzaSyDgF3e8lPe84s1PZyleV7GDugnX72QamK8 24 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 13 | 14 | 15 | 16 | 27 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 42 | 45 | 53 | 56 | 57 | 61 | 64 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /app/src/main/icon_notification-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/icon_notification-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/AlertTable.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity 2 | 3 | import androidx.room.ColumnInfo 4 | import androidx.room.Entity 5 | import androidx.room.PrimaryKey 6 | 7 | @Entity 8 | data class AlertTable( 9 | @PrimaryKey(autoGenerate = true) 10 | val id : Int = 0, 11 | 12 | @ColumnInfo(defaultValue = "UnTitled", name = "title") 13 | val title: String, 14 | val type: String, 15 | val time :String, 16 | val reputation: Boolean, 17 | ) 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/Alert.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | data class Alert( 4 | val description: String?, 5 | val end: Int?, 6 | val event: String?, 7 | val sender_name: String?, 8 | val start: Int? 9 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/Current.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | data class Current( 4 | val clouds: Int, 5 | val dew_point: Double, 6 | val dt: Int, 7 | val feels_like: Double, 8 | val humidity: Int, 9 | val pressure: Int, 10 | val sunrise: Int, 11 | val sunset: Int, 12 | val temp: Double, 13 | val uvi: Double, 14 | val visibility: Int, 15 | val weather: List, 16 | val wind_deg: Int, 17 | val wind_speed: Double 18 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/Daily.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | 4 | data class Daily( 5 | val clouds: Double, 6 | val dew_point: Double, 7 | val dt: Int, 8 | val feels_like: FeelsLike, 9 | val humidity: Int, 10 | val pop: Double, 11 | val pressure: Int, 12 | val rain: Double, 13 | val sunrise: Int, 14 | val sunset: Int, 15 | val temp: Temp, 16 | val uvi: Double, 17 | val weather: List, 18 | val wind_deg: Int, 19 | val wind_speed: Double 20 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/FavData.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | import androidx.room.Entity 4 | 5 | @Entity(primaryKeys = arrayOf("lat","lon")) 6 | data class FavData( 7 | val lat: Double, 8 | val lon: Double, 9 | val timezone: String, 10 | val timezone_offset: Int, 11 | val current: Current, 12 | val hourly: List, 13 | val daily: List, 14 | val alerts: List?) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/FeelsLike.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | data class FeelsLike( 4 | val day: Double, 5 | val eve: Double, 6 | val morn: Double, 7 | val night: Double 8 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/Hourly.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | 4 | data class Hourly( 5 | val clouds: Int, 6 | val dew_point: Double, 7 | val dt: Int, 8 | val feels_like: Double, 9 | val humidity: Int, 10 | val pop: Double, 11 | val pressure: Int, 12 | val rain: Rain, 13 | val temp: Double, 14 | val uvi: Double, 15 | val visibility: Int, 16 | val weather: List, 17 | val wind_deg: Int, 18 | val wind_speed: Double 19 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/Rain.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | data class Rain( 4 | val `1h`: Double 5 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/Temp.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | data class Temp( 4 | val day: Double, 5 | val eve: Double, 6 | val max: Double, 7 | val min: Double, 8 | val morn: Double, 9 | val night: Double 10 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/Weather.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | data class Weather( 4 | val description: String, 5 | val icon: String, 6 | val id: Int, 7 | val main: String 8 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/WeatherX.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | 4 | data class WeatherX( 5 | val description: String, 6 | val icon: String, 7 | val id: Int, 8 | val main: String 9 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/favtable/WeatherXX.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.favtable 2 | 3 | import androidx.room.Entity 4 | 5 | data class WeatherXX( 6 | val description: String, 7 | val icon: String, 8 | val id: Int, 9 | val main: String 10 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/Alert.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | data class Alert( 4 | val description: String, 5 | val end: Int, 6 | val event: String, 7 | val sender_name: String, 8 | val start: Int 9 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/AllData.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | import com.google.gson.annotations.Expose 6 | import com.google.gson.annotations.SerializedName 7 | 8 | 9 | @Entity 10 | data class AllData( 11 | val alerts: List?, 12 | val current: Current, 13 | val daily: List, 14 | val hourly: List, 15 | val lat: Double, 16 | val lon: Double, 17 | @PrimaryKey 18 | val timezone: String, 19 | val timezone_offset: Int 20 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/Current.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | data class Current( 4 | val clouds: Int, 5 | val dew_point: Double, 6 | val dt: Int, 7 | val feels_like: Double, 8 | val humidity: Int, 9 | val pressure: Int, 10 | val sunrise: Int, 11 | val sunset: Int, 12 | val temp: Double, 13 | val uvi: Double, 14 | val visibility: Int, 15 | val weather: List, 16 | val wind_deg: Int, 17 | val wind_speed: Double 18 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/Daily.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | 4 | data class Daily( 5 | val clouds: Double, 6 | val dew_point: Double, 7 | val dt: Int, 8 | val feels_like: FeelsLike, 9 | val humidity: Int, 10 | val pop: Double, 11 | val pressure: Int, 12 | val rain: Double, 13 | val sunrise: Int, 14 | val sunset: Int, 15 | val temp: Temp, 16 | val uvi: Double, 17 | val weather: List, 18 | val wind_deg: Int, 19 | val wind_speed: Double 20 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/FeelsLike.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | data class FeelsLike( 4 | val day: Double, 5 | val eve: Double, 6 | val morn: Double, 7 | val night: Double 8 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/Hourly.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | 4 | data class Hourly( 5 | val clouds: Int, 6 | val dew_point: Double, 7 | val dt: Int, 8 | val feels_like: Double, 9 | val humidity: Int, 10 | val pop: Double, 11 | val pressure: Int, 12 | val rain: Rain, 13 | val temp: Double, 14 | val uvi: Double, 15 | val visibility: Int, 16 | val weather: List, 17 | val wind_deg: Int, 18 | val wind_speed: Double 19 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/Rain.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | data class Rain( 4 | val `1h`: Double 5 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/Temp.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | data class Temp( 4 | val day: Double, 5 | val eve: Double, 6 | val max: Double, 7 | val min: Double, 8 | val morn: Double, 9 | val night: Double 10 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/Weather.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | data class Weather( 4 | val description: String, 5 | val icon: String, 6 | val id: Int, 7 | val main: String 8 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/WeatherX.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | 4 | data class WeatherX( 5 | val description: String, 6 | val icon: String, 7 | val id: Int, 8 | val main: String 9 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/entity/oneCallEntity/WeatherXX.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.entity.oneCallEntity 2 | 3 | import androidx.room.Entity 4 | 5 | data class WeatherXX( 6 | val description: String, 7 | val icon: String, 8 | val id: Int, 9 | val main: String 10 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/local/room/DataBaseWeather.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.local.room 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import androidx.room.Database 6 | import androidx.room.Room 7 | import androidx.room.RoomDatabase 8 | import androidx.room.TypeConverters 9 | import com.example.kotlinproject.dataLayer.entity.AlertTable 10 | import com.example.kotlinproject.dataLayer.entity.Converter 11 | import com.example.kotlinproject.dataLayer.entity.favtable.FavData 12 | import com.example.kotlinproject.dataLayer.entity.oneCallEntity.AllData 13 | 14 | @TypeConverters(Converter::class) 15 | @Database(entities = [AllData::class, FavData::class,AlertTable::class], version = 1,exportSchema = false) 16 | abstract class DataBaseWeather : RoomDatabase() { 17 | companion object{ 18 | @Volatile 19 | private var db :DataBaseWeather? =null 20 | 21 | fun getInstance(application: Application): DataBaseWeather? { 22 | synchronized(this) { 23 | if (db == null) 24 | db = Room.databaseBuilder( 25 | application, DataBaseWeather::class.java, "Weather" 26 | ).allowMainThreadQueries().fallbackToDestructiveMigration().build() 27 | } 28 | return db 29 | } 30 | 31 | } 32 | 33 | 34 | abstract fun weatherDao(): WeatherDao 35 | 36 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/local/room/RoomRepositry.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.local.room 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import androidx.lifecycle.AndroidViewModel 6 | import androidx.lifecycle.LiveData 7 | import com.example.kotlinproject.dataLayer.entity.AlertTable 8 | import com.example.kotlinproject.dataLayer.entity.favtable.FavData 9 | import com.example.kotlinproject.dataLayer.entity.oneCallEntity.Alert 10 | import com.example.kotlinproject.dataLayer.entity.oneCallEntity.AllData 11 | 12 | 13 | class RoomRepositry(context: Application) : AndroidViewModel(context) { 14 | val database :DataBaseWeather?=DataBaseWeather.getInstance(context) 15 | val weatherDao :WeatherDao= database!!.weatherDao() 16 | 17 | suspend fun saveAllData(allData : AllData){ 18 | weatherDao.saveAllData(allData) 19 | } 20 | fun getAllData(): LiveData>{ 21 | return weatherDao.getAllData() 22 | } 23 | fun getData(): List{ 24 | return weatherDao.getData() 25 | } 26 | fun deleteAll(){ 27 | return weatherDao.deleteAll() 28 | } 29 | 30 | 31 | /////////////////fav\\\\\\\\\\\\\\\\\\\\\ 32 | suspend fun saveFavData(favData : FavData){ 33 | weatherDao.saveFaveData(favData) 34 | } 35 | fun getFavData(): LiveData>{ 36 | return weatherDao.getFavData() 37 | } 38 | fun getFavDataNotLiveData(): List{ 39 | return weatherDao.getFavDataNotLiveData() 40 | } 41 | fun deleteAllFav(){ 42 | return weatherDao.deleteAllFav() 43 | } 44 | 45 | fun getOneFav(lat: String,lon: String):LiveData{ 46 | return weatherDao.getOneFav(lat,lon) 47 | } 48 | fun deleteOneFav(lat: String,lon: String){ 49 | weatherDao.deleteOneFav(lat,lon) 50 | } 51 | 52 | fun saveAlert(alertTable: AlertTable):Long{ 53 | return weatherDao.saveAlert(alertTable) 54 | } 55 | fun getAllAlerts():LiveData>{ 56 | return weatherDao.getAllAlerts() 57 | } 58 | fun deleteAlert(id: Long)=weatherDao.deleteAlert(id) 59 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/local/room/WeatherDao.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.local.room 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.room.Dao 5 | import androidx.room.Insert 6 | import androidx.room.OnConflictStrategy 7 | import androidx.room.Query 8 | import com.example.kotlinproject.dataLayer.entity.AlertTable 9 | import com.example.kotlinproject.dataLayer.entity.favtable.FavData 10 | import com.example.kotlinproject.dataLayer.entity.favtable.Alert 11 | import com.example.kotlinproject.dataLayer.entity.oneCallEntity.AllData 12 | 13 | @Dao 14 | interface WeatherDao { 15 | 16 | @Query("SELECT * FROM AllData") 17 | fun getAllData(): LiveData> 18 | 19 | @Query("SELECT * FROM AllData") 20 | fun getData(): List 21 | 22 | @Insert(onConflict = OnConflictStrategy.REPLACE) 23 | suspend fun saveAllData(allData: AllData) 24 | 25 | @Query("DELETE FROM AllData") 26 | fun deleteAll() 27 | 28 | 29 | //////////////////////fav\\\\\\\\\\\\\\\\\\\\\ 30 | 31 | @Query("SELECT * FROM FavData ") 32 | fun getFavData(): LiveData> 33 | 34 | 35 | @Query("SELECT * FROM FavData ") 36 | fun getFavDataNotLiveData(): List 37 | 38 | @Insert(onConflict = OnConflictStrategy.REPLACE) 39 | suspend fun saveFaveData(favData: FavData) 40 | 41 | 42 | @Query("SELECT * FROM FavData WHERE lat LIKE:lat AND lon LIKE:lon LIMIT 1") 43 | fun getOneFav(lat: String, lon: String): LiveData 44 | 45 | @Query("DELETE FROM FavData WHERE lat LIKE:lat AND lon LIKE:lon") 46 | fun deleteOneFav(lat: String, lon: String) 47 | 48 | 49 | @Query("DELETE FROM FavData") 50 | fun deleteAllFav() 51 | 52 | @Query("SELECT timezone FROM FavData") 53 | fun getTimezones(): LiveData> 54 | 55 | @Query("SELECT * FROM FavData WHERE timezone LIKE:timezone LIMIT 1") 56 | fun getOAlerts(timezone : String): LiveData? 57 | 58 | 59 | //////////////////////alert\\\\\\\\\\\\\\\\\\\\\ 60 | @Insert(onConflict = OnConflictStrategy.REPLACE) 61 | fun saveAlert(alertTable: AlertTable):Long 62 | 63 | @Query("SELECT * FROM AlertTable") 64 | fun getAllAlerts():LiveData> 65 | 66 | @Query("DELETE FROM AlertTable WHERE id Like:id") 67 | fun deleteAlert(id: Long) 68 | 69 | 70 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/local/sharedprefrence/SettingModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.local.sharedprefrence 2 | 3 | data class SettingModel(val units:String,val lang:String,val location:String) 4 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/local/sharedprefrence/SettingSB.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.local.sharedprefrence 2 | 3 | import android.content.Context 4 | import android.content.SharedPreferences 5 | import androidx.lifecycle.LiveData 6 | import androidx.lifecycle.MutableLiveData 7 | import com.google.android.gms.maps.model.LatLng 8 | import kotlinx.coroutines.CoroutineScope 9 | import kotlinx.coroutines.Dispatchers 10 | import kotlinx.coroutines.launch 11 | 12 | class SettingSB(val context: Context) { 13 | 14 | companion object { 15 | const val fileName = "Current" 16 | } 17 | private val SettingData: MutableLiveData = MutableLiveData() 18 | private val latlon: MutableLiveData = MutableLiveData() 19 | private val alert: MutableLiveData = MutableLiveData() 20 | private val sharedPreferences: SharedPreferences = context.getSharedPreferences(fileName,Context.MODE_PRIVATE) 21 | 22 | 23 | fun saveSetting(settingModel: SettingModel){ 24 | CoroutineScope(Dispatchers.IO).launch { 25 | val editor:SharedPreferences.Editor = sharedPreferences.edit() 26 | editor.putString("units",settingModel.units) 27 | editor.putString("lang",settingModel.lang) 28 | editor.putString("location",settingModel.location) 29 | editor.apply() 30 | editor.commit() 31 | } 32 | } 33 | 34 | fun loadSetting(){ 35 | CoroutineScope(Dispatchers.IO).launch { 36 | val units = sharedPreferences.getString("units","standard") 37 | val lang = sharedPreferences.getString("lang","ar") 38 | val location = sharedPreferences.getString("location","gps") 39 | SettingData.postValue(SettingModel(units!!, lang!!, location!!)) 40 | } 41 | } 42 | fun loadLocationSetting(){ 43 | CoroutineScope(Dispatchers.IO).launch { 44 | val lat = sharedPreferences.getFloat("lat", 0.0F) 45 | val lon = sharedPreferences.getFloat("lon", 0.0F) 46 | latlon.postValue(LatLng(lat.toDouble(), lon.toDouble())) 47 | } 48 | } 49 | fun loadAlertSetting(){ 50 | CoroutineScope(Dispatchers.IO).launch { 51 | val alertl = sharedPreferences.getString("alert", "OFF") 52 | alert.postValue(alertl!!) 53 | } 54 | } 55 | 56 | fun saveLocationSetting(latLng: LatLng){ 57 | CoroutineScope(Dispatchers.IO).launch { 58 | val editor:SharedPreferences.Editor = sharedPreferences.edit() 59 | editor.putFloat("lat", latLng.latitude.toFloat()) 60 | editor.putFloat("lon", latLng.longitude.toFloat()) 61 | editor.apply() 62 | editor.commit() 63 | } 64 | } 65 | fun saveAlertSetting(alert: String){ 66 | CoroutineScope(Dispatchers.IO).launch { 67 | val editor:SharedPreferences.Editor = sharedPreferences.edit() 68 | editor.putString("alert", alert) 69 | editor.apply() 70 | editor.commit() 71 | } 72 | } 73 | 74 | 75 | fun getSetting(): LiveData{ 76 | return SettingData 77 | } 78 | fun getLocationSetting(): LiveData{ 79 | return latlon 80 | } 81 | fun getAlertSetting(): LiveData{ 82 | return alert 83 | } 84 | 85 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/local/sharedprefrence/SharedPrefrencesReopsitory.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.local.sharedprefrence 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import androidx.lifecycle.AndroidViewModel 6 | import androidx.lifecycle.LiveData 7 | import com.google.android.gms.maps.model.LatLng 8 | 9 | class SharedPrefrencesReopsitory(context: Application) : AndroidViewModel(context) { 10 | private val setting : SettingSB = SettingSB(context) 11 | fun updateSetting(settingModel: SettingModel)=setting.saveSetting(settingModel) 12 | fun getSetting(): LiveData{ 13 | setting.loadSetting() 14 | return setting.getSetting() 15 | } 16 | 17 | 18 | fun saveLocationSetting(latLng: LatLng)=setting.saveLocationSetting(latLng) 19 | fun getLocationSetting(): LiveData{ 20 | setting.loadLocationSetting() 21 | return setting.getLocationSetting() 22 | } 23 | 24 | fun saveAlertSetting(alert: String)=setting.saveAlertSetting(alert) 25 | 26 | fun getAlertSetting(): LiveData{ 27 | setting.loadAlertSetting() 28 | return setting.getAlertSetting() 29 | } 30 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/online/ApiClient.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.online 2 | 3 | import com.google.gson.GsonBuilder 4 | import retrofit2.Retrofit 5 | import retrofit2.converter.gson.GsonConverterFactory 6 | import retrofit2.converter.scalars.ScalarsConverterFactory 7 | 8 | 9 | object ApiClient { 10 | private const val BASE_URL = "https://api.openweathermap.org/" 11 | var gson = GsonBuilder() 12 | .setLenient() 13 | .create() 14 | private fun getRetrofit(): Retrofit { 15 | return Retrofit.Builder() 16 | .baseUrl(BASE_URL) 17 | .addConverterFactory(ScalarsConverterFactory.create()) //important 18 | .addConverterFactory(GsonConverterFactory.create(gson)) 19 | .build() 20 | } 21 | 22 | val apiService: ApiInterface = getRetrofit().create(ApiInterface::class.java) 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/online/ApiInterface.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.online 2 | 3 | import com.example.kotlinproject.dataLayer.entity.favtable.FavData 4 | import com.example.kotlinproject.dataLayer.entity.oneCallEntity.AllData 5 | import retrofit2.Call 6 | import retrofit2.http.GET 7 | import retrofit2.http.Query 8 | interface ApiInterface { 9 | 10 | @GET("/data/2.5/onecall?") 11 | fun getOneCall(@Query("lat") lat: String, 12 | @Query("lon") lon: String, 13 | @Query("lang") lang: String, 14 | @Query("appid") appid: String, 15 | @Query("exclude") exclude :String, 16 | @Query("units") units :String) :Call 17 | 18 | @GET("/data/2.5/onecall?") 19 | fun getFavCall(@Query("lat") lat: String, 20 | @Query("lon") lon: String, 21 | @Query("lang") lang: String, 22 | @Query("appid") appid: String, 23 | @Query("exclude") exclude :String, 24 | @Query("units") units :String) :Call 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/dataLayer/online/Repository.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.dataLayer.online 2 | 3 | import android.util.Log 4 | import androidx.lifecycle.LiveData 5 | import androidx.lifecycle.MutableLiveData 6 | import com.example.kotlinproject.dataLayer.entity.oneCallEntity.AllData 7 | import kotlinx.coroutines.CoroutineScope 8 | import kotlinx.coroutines.Dispatchers 9 | import kotlinx.coroutines.launch 10 | import retrofit2.Call 11 | import retrofit2.Callback 12 | import retrofit2.Response 13 | 14 | class Repository(private val apiInterface : ApiInterface) { 15 | fun getOneCall(lat: String,lon: String,lang: String, appid: String,exclude :String,units :String) = 16 | apiInterface.getOneCall(lat,lon,lang,appid,exclude,units) 17 | fun getFavCall(lat: String,lon: String,lang: String, appid: String,exclude :String,units :String) = 18 | apiInterface.getFavCall(lat,lon,lang,appid,exclude,units) 19 | 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/GeneralFunctions.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui 2 | 3 | import android.annotation.SuppressLint 4 | import android.app.Activity 5 | import android.content.Context 6 | import android.content.res.Configuration 7 | import android.content.res.Resources 8 | import android.net.ConnectivityManager 9 | import android.net.NetworkCapabilities 10 | import android.os.Build 11 | import android.util.Log 12 | import android.widget.ImageView 13 | import androidx.annotation.RequiresApi 14 | import com.bumptech.glide.Glide 15 | import java.text.SimpleDateFormat 16 | import java.util.* 17 | 18 | 19 | class GeneralFunctions { 20 | @SuppressLint("ServiceCast") 21 | fun isOnline(context: Context): Boolean { 22 | val connectivityManager = 23 | context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager 24 | val capabilities = 25 | connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork) 26 | if (capabilities != null) { 27 | when { 28 | capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> { 29 | Log.i("Internet", "NetworkCapabilities.TRANSPORT_CELLULAR") 30 | return true 31 | } 32 | capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> { 33 | Log.i("Internet", "NetworkCapabilities.TRANSPORT_WIFI") 34 | return true 35 | } 36 | capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> { 37 | Log.i("Internet", "NetworkCapabilities.TRANSPORT_ETHERNET") 38 | return true 39 | } 40 | } 41 | } 42 | return false 43 | } 44 | 45 | 46 | @RequiresApi(Build.VERSION_CODES.O) 47 | fun loadImage(imageView: ImageView, string: String) { 48 | Glide.with(imageView) //2http://openweathermap.org/img/w/10n.png 49 | .load("https://openweathermap.org/img/w/$string.png") //3 50 | .fitCenter() //4 51 | .into(imageView) 52 | } 53 | 54 | 55 | @SuppressLint("SimpleDateFormat") 56 | fun formateDate(format: Int): String { 57 | val sdf = SimpleDateFormat("MM/dd/yyyy") 58 | val netDate = Date(format.toLong() * 1000) 59 | return sdf.format(netDate) 60 | } 61 | 62 | @SuppressLint("SimpleDateFormat") 63 | fun formateTime(format: Int): String { 64 | val dateFormat = SimpleDateFormat("HH:mm a") 65 | val date = Date() 66 | date.time = format.toLong() * 1000 67 | return dateFormat.format(date) 68 | } 69 | 70 | fun getUnites(units: String): String { 71 | return when (units) { 72 | "standard" -> { 73 | "K" 74 | } 75 | "imperial" -> { 76 | "F" 77 | } 78 | else -> { 79 | "C" 80 | } 81 | } 82 | } 83 | 84 | @Suppress("DEPRECATION", "NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") 85 | fun setLocale(activity: Activity, languageCode: String?) { 86 | val locale = Locale(languageCode) 87 | Locale.setDefault(locale) 88 | val resources: Resources = activity.resources 89 | val config: Configuration = resources.configuration 90 | config.setLocale(locale) 91 | resources.updateConfiguration(config, resources.displayMetrics) 92 | } 93 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/NotificationHelper.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui 2 | 3 | import android.app.Notification 4 | import android.app.NotificationChannel 5 | import android.app.NotificationManager 6 | import android.content.Context 7 | import android.content.ContextWrapper 8 | import android.media.AudioAttributes 9 | import android.media.AudioManager 10 | import android.net.Uri 11 | import androidx.core.app.NotificationCompat 12 | import com.example.kotlinproject.R 13 | 14 | 15 | class NotificationHelper(context: Context) : ContextWrapper(context){ 16 | private val channelID: String = "channelID" 17 | private val channelName: String = "channelName" 18 | private var notificationManager: NotificationManager? = null 19 | 20 | init { 21 | createChanel() 22 | } 23 | 24 | private fun createChanel() { 25 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { 26 | 27 | val audioAttributes = AudioAttributes.Builder() 28 | .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) 29 | .setUsage(AudioAttributes.USAGE_ALARM) 30 | .build() 31 | 32 | val soundUri = Uri.parse( 33 | "android.resource://" + 34 | applicationContext.packageName + 35 | "/" + 36 | R.raw.rang 37 | ) 38 | 39 | val notificationChannel = NotificationChannel( 40 | channelID, 41 | channelName, 42 | NotificationManager.IMPORTANCE_DEFAULT 43 | ) 44 | notificationChannel.enableLights(true) 45 | notificationChannel.enableVibration(true) 46 | notificationChannel.setSound(soundUri, audioAttributes) 47 | notificationChannel.lightColor = R.color.text_color 48 | notificationChannel.lockscreenVisibility = Notification.VISIBILITY_PRIVATE 49 | getManger()!!.createNotificationChannel(notificationChannel) 50 | } else { 51 | TODO("VERSION.SDK_INT < O") 52 | } 53 | } 54 | 55 | fun getManger(): NotificationManager? { 56 | if (notificationManager == null) { 57 | notificationManager = 58 | getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager? 59 | } 60 | return notificationManager 61 | } 62 | 63 | fun getChanelNotification(title: String, message: String): NotificationCompat.Builder { 64 | return NotificationCompat.Builder(applicationContext, channelID).setContentTitle(title) 65 | .setCategory(NotificationCompat.CATEGORY_MESSAGE) 66 | .setSound(Uri.parse( 67 | "android.resource://" + 68 | applicationContext.packageName + 69 | "/" + 70 | R.raw.rang 71 | ), AudioManager.STREAM_NOTIFICATION) 72 | .setContentText(message).setSmallIcon(R.mipmap.icon_notification) 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/alert/Alert.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.alert 2 | 3 | 4 | import android.content.Intent 5 | import android.os.Bundle 6 | import android.util.Log 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import android.view.ViewGroup 10 | import androidx.fragment.app.Fragment 11 | import androidx.lifecycle.ViewModelProvider 12 | import androidx.recyclerview.widget.LinearLayoutManager 13 | import androidx.recyclerview.widget.RecyclerView 14 | import com.example.kotlinproject.dataLayer.entity.AlertTable 15 | import com.example.kotlinproject.databinding.FragmentAlertBinding 16 | import com.example.kotlinproject.ui.createAlerm.CreateAlerm 17 | 18 | 19 | class Alert : Fragment() { 20 | 21 | private lateinit var fragmentAlertBinding: FragmentAlertBinding 22 | private lateinit var alertViewModel: AlertViewModel 23 | private lateinit var currentAlertAdaapter: CurrentAlertAdaapter 24 | 25 | 26 | override fun onCreateView( 27 | inflater: LayoutInflater, container: ViewGroup?, 28 | savedInstanceState: Bundle? 29 | ): View { 30 | fragmentAlertBinding = FragmentAlertBinding.inflate(inflater, container, false) 31 | alertViewModel = ViewModelProvider( 32 | this, 33 | ViewModelProvider.AndroidViewModelFactory.getInstance(requireActivity().application) 34 | )[AlertViewModel::class.java] 35 | fragmentAlertBinding.empty.visibility=View.VISIBLE 36 | 37 | currentAlertAdaapter = CurrentAlertAdaapter(alertViewModel) 38 | val lay: RecyclerView.LayoutManager = LinearLayoutManager(activity) 39 | fragmentAlertBinding.listCurrent.layoutManager = lay 40 | fragmentAlertBinding.listCurrent.adapter=currentAlertAdaapter 41 | 42 | fragmentAlertBinding.addAlertButton.setOnClickListener { 43 | val intent =Intent(activity,CreateAlerm::class.java) 44 | startActivity(intent) 45 | } 46 | 47 | alertViewModel.gerAlertTable().observe(this,{ 48 | if (it!=null) 49 | showRecyclel(it) 50 | }) 51 | 52 | alertViewModel.getAlertSetting().observe(this,{ 53 | if (it == "OFF"){ 54 | fragmentAlertBinding.enableOrNot.isChecked=false 55 | Log.d("TAG", "offff $it") 56 | }else{ 57 | fragmentAlertBinding.enableOrNot.isChecked=true 58 | Log.d("TAG","onnnn $it") 59 | } 60 | }) 61 | 62 | 63 | fragmentAlertBinding.enableOrNot.setOnClickListener { 64 | alertViewModel.saveAlertSetting(fragmentAlertBinding.enableOrNot.text.toString()) 65 | Log.d("TAG",fragmentAlertBinding.enableOrNot.text.toString()) 66 | } 67 | 68 | alertViewModel.cancelAlert.observe(this,{ 69 | alertViewModel.cancelAlert(activity!!,it) 70 | }) 71 | 72 | return fragmentAlertBinding.root 73 | } 74 | 75 | 76 | private fun showRecyclel(alerts: List?) { 77 | if (alerts!!.isNotEmpty()){ 78 | fragmentAlertBinding.empty.visibility=View.INVISIBLE 79 | fragmentAlertBinding.listCurrent.visibility=View.VISIBLE 80 | currentAlertAdaapter.models = alerts 81 | currentAlertAdaapter.notifyDataSetChanged() 82 | }else{ 83 | fragmentAlertBinding.empty.visibility=View.VISIBLE 84 | fragmentAlertBinding.listCurrent.visibility=View.INVISIBLE 85 | } 86 | 87 | } 88 | 89 | // fun startAlert() { 90 | // 91 | // val myIntent = Intent(activity, AlermRecever::class.java) 92 | // val pendingIntent = PendingIntent.getBroadcast(activity, 1, myIntent, 0) 93 | // val alarmManager: AlarmManager = 94 | // activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager 95 | // val calendar: Calendar = Calendar.getInstance() 96 | // calendar.timeInMillis = System.currentTimeMillis() 97 | // calendar.add(Calendar.SECOND, 400) 98 | // 99 | // alarmManager.setExact(AlarmManager.RTC_WAKEUP, 1000, pendingIntent) 100 | // 101 | // } 102 | // 103 | // fun cancelAlarm() { 104 | // val myIntent = Intent(activity, AlermRecever::class.java) 105 | // val pendingIntent = PendingIntent.getBroadcast(activity, 1, myIntent, 0) 106 | // val alarmManager: AlarmManager = 107 | // activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager 108 | // alarmManager.cancel(pendingIntent) 109 | // 110 | // } 111 | 112 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/alert/AlertViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.alert 2 | 3 | import android.app.Activity 4 | import android.app.AlarmManager 5 | import android.app.Application 6 | import android.app.PendingIntent 7 | import android.content.Context 8 | import android.content.Intent 9 | import androidx.lifecycle.AndroidViewModel 10 | import androidx.lifecycle.LiveData 11 | import androidx.lifecycle.MutableLiveData 12 | import androidx.lifecycle.ViewModel 13 | import com.example.kotlinproject.dataLayer.DataSourceViewModel 14 | import com.example.kotlinproject.dataLayer.entity.AlertTable 15 | import com.example.kotlinproject.dataLayer.entity.favtable.FavData 16 | import com.example.kotlinproject.dataLayer.entity.oneCallEntity.AllData 17 | import com.example.kotlinproject.ui.createAlerm.AlermRecever 18 | 19 | class AlertViewModel(application: Application) : AndroidViewModel(application) { 20 | private val dataSourceViewModel: DataSourceViewModel = DataSourceViewModel(application) 21 | val cancelAlert :MutableLiveData = MutableLiveData() 22 | 23 | 24 | 25 | fun saveAlertSetting(alert: String)=dataSourceViewModel.saveAlertSetting(alert) 26 | 27 | fun getAlertSetting(): LiveData{ 28 | return dataSourceViewModel.getAlertSetting() 29 | } 30 | fun gerAlertTable():LiveData>{ 31 | return dataSourceViewModel.getAllAlerts() 32 | } 33 | 34 | fun cancelAlert(activity: Activity, id: Int){ 35 | deleteAlert(id.toLong()) 36 | val alarmManager = activity.getSystemService(Context.ALARM_SERVICE) as AlarmManager? 37 | val myIntent = Intent(activity, AlermRecever::class.java) 38 | val pendingIntent = PendingIntent.getBroadcast(activity, id, myIntent, PendingIntent.FLAG_UPDATE_CURRENT) 39 | alarmManager!!.cancel(pendingIntent) 40 | } 41 | private fun deleteAlert(id: Long)=dataSourceViewModel.deleteAlert(id) 42 | 43 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/alert/CurrentAlertAdaapter.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.alert 2 | 3 | import android.annotation.SuppressLint 4 | import android.os.Build 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import android.widget.ImageView 9 | import android.widget.TextView 10 | import androidx.annotation.RequiresApi 11 | import androidx.recyclerview.widget.RecyclerView 12 | import com.example.kotlinproject.R 13 | import com.example.kotlinproject.dataLayer.entity.AlertTable 14 | 15 | class CurrentAlertAdaapter(var favViewModel: AlertViewModel) : RecyclerView.Adapter() { 16 | var models: List = emptyList() 17 | 18 | inner class MyViewHolder( itemView: View) : RecyclerView.ViewHolder(itemView) { 19 | private val event : TextView = itemView.findViewById(R.id.event_Data) 20 | private val start : TextView = itemView.findViewById(R.id.start_data) 21 | private val description : TextView = itemView.findViewById(R.id.description_data) 22 | private val close : ImageView=itemView.findViewById(R.id.close_alert) 23 | private val reputation : ImageView=itemView.findViewById(R.id.repetedDaialyPic) 24 | 25 | 26 | @SuppressLint("SetTextI18n") 27 | @RequiresApi(Build.VERSION_CODES.O) 28 | fun binding(allData: AlertTable) { 29 | event.text=allData.title 30 | description.text=allData.type 31 | start.text=allData.time 32 | if (allData.reputation){ 33 | reputation.setImageResource(R.drawable.ic_check_24) 34 | }else{ 35 | reputation.setImageResource(R.drawable.ic_baseline_check_box_outline_blank_24) 36 | } 37 | close.setOnClickListener { 38 | favViewModel.cancelAlert.value=allData.id 39 | } 40 | } 41 | } 42 | 43 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { 44 | val inflater = LayoutInflater.from(parent.context) 45 | val binding = inflater.inflate(R.layout.alarm_item, parent, false) 46 | return MyViewHolder(binding) 47 | } 48 | 49 | @RequiresApi(Build.VERSION_CODES.O) 50 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) { 51 | holder.binding(models[position]) 52 | } 53 | 54 | override fun getItemCount(): Int { 55 | return models.size 56 | } 57 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/baseHome/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.baseHome 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import androidx.databinding.DataBindingUtil 6 | import androidx.fragment.app.Fragment 7 | import com.example.kotlinproject.R 8 | import com.example.kotlinproject.dataLayer.entity.favtable.FavData 9 | import com.example.kotlinproject.dataLayer.local.sharedprefrence.SettingModel 10 | import com.example.kotlinproject.databinding.ActivityMainBinding 11 | import com.example.kotlinproject.ui.alert.Alert 12 | import com.example.kotlinproject.ui.favourit.Favourit 13 | import com.example.kotlinproject.ui.home.Home 14 | import com.example.kotlinproject.ui.setting.Setting 15 | import kotlinx.coroutines.CoroutineScope 16 | import kotlinx.coroutines.Dispatchers 17 | import kotlinx.coroutines.launch 18 | import java.util.* 19 | 20 | 21 | class MainActivity : AppCompatActivity() { 22 | private lateinit var binding: ActivityMainBinding 23 | private lateinit var fragment: Fragment 24 | private lateinit var mainViewModel: MainViewModel 25 | private lateinit var list: List 26 | private lateinit var setting: SettingModel 27 | 28 | companion object { 29 | var units: String = "standard" 30 | var readFromDatabase:Boolean=false 31 | } 32 | 33 | // override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { 34 | // super.onActivityResult(requestCode, resultCode, data) 35 | // if (resultCode != RESULT_CANCELED && data != null) { 36 | // Log.d("TAG", "LOCATION_PERMISSION_REQUEST_CODE111111 $requestCode") 37 | // val fragment = supportFragmentManager.findFragmentByTag("HOME") 38 | // fragment!!.onActivityResult(requestCode, resultCode, data) 39 | // } 40 | // } 41 | 42 | // override fun onRequestPermissionsResult( 43 | // requestCode: Int, 44 | // permissions: Array, 45 | // grantResults: IntArray 46 | // ) { 47 | // super.onRequestPermissionsResult(requestCode, permissions, grantResults) 48 | // if (requestCode != RESULT_CANCELED) { 49 | // Log.d("TAG", "onRequestPermissionsResult main $requestCode") 50 | // val fragment = supportFragmentManager.findFragmentByTag("HOME") 51 | // fragment!!.onRequestPermissionsResult(requestCode, permissions, grantResults) 52 | // } 53 | // } 54 | 55 | override fun onCreate(savedInstanceState: Bundle?) { 56 | super.onCreate(savedInstanceState) 57 | binding = DataBindingUtil.setContentView(this, R.layout.activity_main) 58 | mainViewModel = MainViewModel(application) 59 | updateFavourite() 60 | // fragment = Home() 61 | // supportFragmentManager.beginTransaction().add(R.id.fragment, fragment, "HOME").commit() 62 | 63 | binding.bottomNavigationView.setOnNavigationItemSelectedListener { 64 | when (it.itemId) { 65 | R.id.homeItem_menu -> { 66 | fragment = Home() 67 | supportFragmentManager.beginTransaction().replace(R.id.fragment, fragment) 68 | .commit() 69 | } 70 | R.id.favorite_menu -> { 71 | fragment = Favourit() 72 | supportFragmentManager.beginTransaction().replace(R.id.fragment, fragment) 73 | .commit() 74 | } 75 | R.id.alert_menu -> { 76 | fragment = Alert() 77 | supportFragmentManager.beginTransaction().replace(R.id.fragment, fragment) 78 | .commit() 79 | } 80 | else -> { 81 | fragment = Setting() 82 | supportFragmentManager.beginTransaction().replace(R.id.fragment, fragment) 83 | .commit() 84 | } 85 | } 86 | return@setOnNavigationItemSelectedListener true 87 | 88 | } 89 | 90 | } 91 | 92 | private fun updateFavourite() { 93 | list = mainViewModel.getFavDataNotLiveData() 94 | mainViewModel.getSettnig().observe(this@MainActivity, { 95 | setting = it 96 | reDowenloadData(list) 97 | }) 98 | } 99 | 100 | private fun reDowenloadData(list: List) { 101 | CoroutineScope(Dispatchers.IO).launch { 102 | // mainViewModel.deleteAllFav() 103 | for (i in list) { 104 | mainViewModel.saveFav( 105 | i.lat.toString(), 106 | i.lon.toString(), 107 | setting.lang, 108 | setting.units 109 | ) 110 | } 111 | } 112 | } 113 | override fun onDestroy() { 114 | super.onDestroy() 115 | readFromDatabase = false 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/baseHome/MainViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.baseHome 2 | 3 | import android.app.Application 4 | import androidx.lifecycle.AndroidViewModel 5 | import androidx.lifecycle.LiveData 6 | import com.example.kotlinproject.dataLayer.DataSourceViewModel 7 | import com.example.kotlinproject.dataLayer.entity.favtable.FavData 8 | import com.example.kotlinproject.dataLayer.local.sharedprefrence.SettingModel 9 | 10 | class MainViewModel(application: Application) : AndroidViewModel(application) { 11 | private val dataSourceViewModel: DataSourceViewModel = DataSourceViewModel(application) 12 | fun getFavDataNotLiveData(): List{ 13 | return dataSourceViewModel.getFavDataNotLiveData() 14 | } 15 | 16 | fun saveFav(lat: String,lon: String,lang: String,units :String){ 17 | dataSourceViewModel.saveFave(lat,lon,lang,units) 18 | } 19 | fun getSettnig():LiveData{ 20 | return dataSourceViewModel.getSetting() 21 | } 22 | fun deleteAllFav(){ 23 | return dataSourceViewModel.deleteAllFav() 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/createAlerm/AlermRecever.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.createAlerm 2 | 3 | import android.app.Application 4 | import android.content.BroadcastReceiver 5 | import android.content.Context 6 | import android.content.Intent 7 | import android.util.Log.d 8 | import com.example.kotlinproject.R 9 | import com.example.kotlinproject.dataLayer.local.room.RoomRepositry 10 | import com.example.kotlinproject.ui.NotificationHelper 11 | 12 | class AlermRecever() : BroadcastReceiver() { 13 | lateinit var notificationHelper: NotificationHelper 14 | 15 | 16 | override fun onReceive(context: Context?, intent: Intent?) { 17 | notificationHelper = NotificationHelper(context!!) 18 | val roomRepositry= RoomRepositry(context = context.applicationContext as Application) 19 | val current = roomRepositry.getData()[0].current 20 | val actualType = current.weather[0].description 21 | d("TAG", "Receved") 22 | if (intent != null) { 23 | 24 | val type = intent.getStringExtra("TYPE") 25 | if (actualType.contains(type!!) ) { 26 | val notificationBuilder = notificationHelper.getChanelNotification( 27 | context.getString(R.string.weather_alert), 28 | context.getString(R.string.take_care) + type 29 | ) 30 | notificationHelper.getManger()!!.notify(1, notificationBuilder.build()) 31 | } 32 | d("TAG", "Receved $type") 33 | 34 | } 35 | } 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/createAlerm/CreateAlermViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.createAlerm 2 | 3 | import android.app.Activity 4 | import android.app.AlarmManager 5 | import android.app.Application 6 | import android.app.PendingIntent 7 | import android.content.Context 8 | import android.content.Intent 9 | import android.content.IntentFilter 10 | import android.util.Log 11 | import android.widget.Toast 12 | import androidx.lifecycle.AndroidViewModel 13 | import androidx.lifecycle.LiveData 14 | import androidx.lifecycle.MutableLiveData 15 | import com.example.kotlinproject.R 16 | import com.example.kotlinproject.dataLayer.DataSourceViewModel 17 | import com.example.kotlinproject.dataLayer.entity.AlertTable 18 | import kotlinx.coroutines.CoroutineScope 19 | import kotlinx.coroutines.Dispatchers 20 | import kotlinx.coroutines.launch 21 | import java.util.* 22 | 23 | 24 | class CreateAlermViewModel(application: Application) : AndroidViewModel(application) { 25 | private val dataSourceViewModel = DataSourceViewModel(application) 26 | private val dataSavedOrNot = MutableLiveData() 27 | val idLiveData = MutableLiveData() 28 | private fun saveAlert(alertTable: AlertTable): Long { 29 | return dataSourceViewModel.saveAlert(alertTable) 30 | } 31 | 32 | // fun getdata(): LiveData> { 33 | // return dataSourceViewModel.getRoomDataBase() 34 | // } 35 | 36 | fun saveData( 37 | title: String?, 38 | type: String?, 39 | time: String, 40 | reputation: Boolean 41 | ) { 42 | if (title != null || type != null) { 43 | CoroutineScope(Dispatchers.IO).launch { 44 | val id = saveAlert( 45 | AlertTable( 46 | title = title!!, 47 | type = type!!, 48 | time = time, 49 | reputation = reputation 50 | ) 51 | ) 52 | Log.d("TAG", id.toString()) 53 | idLiveData.postValue(id.toInt()) 54 | } 55 | dataSavedOrNot.value = true 56 | } else { 57 | dataSavedOrNot.value = false 58 | } 59 | } 60 | 61 | fun getDataSavedOrNot(): LiveData { 62 | return dataSavedOrNot 63 | } 64 | 65 | fun setAlaram( 66 | activity: Activity, 67 | hour: Int, 68 | min: Int, 69 | month: Int, 70 | day: Int, 71 | year: Int, 72 | type: String?, 73 | reputation: Boolean, 74 | id: Int 75 | ) { 76 | val intentA = Intent(activity, AlermRecever::class.java) 77 | intentA.putExtra("TYPE", type) 78 | intentA.putExtra("REPUTATION", reputation) 79 | val pendingIntentA = PendingIntent.getBroadcast(activity, id, intentA, 0) 80 | val calendar = Calendar.getInstance() 81 | calendar.set(Calendar.HOUR_OF_DAY, hour) 82 | calendar.set(Calendar.MINUTE, min) 83 | calendar[Calendar.MONTH] = month - 1 84 | calendar[Calendar.DATE] = day 85 | calendar[Calendar.YEAR] = year 86 | calendar[Calendar.SECOND] = 0 87 | val datetime = Calendar.getInstance() 88 | if (calendar.timeInMillis >= datetime.timeInMillis) { 89 | val alarmtime: Long = calendar.timeInMillis 90 | Log.d("Tag", alarmtime.toString()) 91 | val alarmManager: AlarmManager = 92 | activity.getSystemService(Context.ALARM_SERVICE) as AlarmManager 93 | if (reputation){ 94 | alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, alarmtime,AlarmManager.INTERVAL_DAY, pendingIntentA) 95 | }else{ 96 | alarmManager.setExact(AlarmManager.RTC_WAKEUP, alarmtime, pendingIntentA) 97 | 98 | } 99 | activity.registerReceiver(AlermRecever(), IntentFilter()) 100 | } else { 101 | Toast.makeText( 102 | activity, 103 | activity.getString(R.string.cant_create_alert_at_this_time), 104 | Toast.LENGTH_SHORT 105 | ).show() 106 | CoroutineScope(Dispatchers.IO).launch { 107 | dataSourceViewModel.deleteAlert(id.toLong()) 108 | } 109 | } 110 | 111 | } 112 | 113 | 114 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/favourit/Favourit.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.favourit 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import androidx.fragment.app.Fragment 6 | import android.view.LayoutInflater 7 | import android.view.View 8 | import android.view.ViewGroup 9 | import android.widget.Toast 10 | import androidx.appcompat.app.AlertDialog 11 | import androidx.lifecycle.ViewModelProvider 12 | import androidx.recyclerview.widget.LinearLayoutManager 13 | import androidx.recyclerview.widget.RecyclerView 14 | import com.example.kotlinproject.R 15 | import com.example.kotlinproject.dataLayer.entity.favtable.FavData 16 | import com.example.kotlinproject.databinding.FragmentFavouritBinding 17 | import com.example.kotlinproject.ui.baseHome.MainActivity 18 | import com.example.kotlinproject.ui.favouriteDetails.FavouriteDetails 19 | import com.example.kotlinproject.ui.map.MapActivity 20 | import kotlinx.coroutines.CoroutineScope 21 | import kotlinx.coroutines.Dispatchers 22 | import kotlinx.coroutines.launch 23 | 24 | 25 | class Favourit : Fragment() { 26 | 27 | private lateinit var binding :FragmentFavouritBinding 28 | private lateinit var favouriteViewModel: FavouriteViewModel 29 | private lateinit var adapter: FavouriteAdapter 30 | private lateinit var dataList : List 31 | 32 | override fun onCreateView( 33 | inflater: LayoutInflater, container: ViewGroup?, 34 | savedInstanceState: Bundle? 35 | ): View { 36 | binding = FragmentFavouritBinding.inflate(inflater, container, false) 37 | favouriteViewModel= ViewModelProvider(this, ViewModelProvider.AndroidViewModelFactory.getInstance(requireActivity().application))[FavouriteViewModel::class.java] 38 | 39 | adapter= FavouriteAdapter(favouriteViewModel,MainActivity.units) 40 | binding.addButton.setOnClickListener{ 41 | if (favouriteViewModel.getOnline(activity!!)) { 42 | val intent = Intent(activity, MapActivity::class.java) 43 | startActivity(intent) 44 | }else{ 45 | Toast.makeText(requireActivity(),getString(R.string.you_are_offline),Toast.LENGTH_SHORT).show() 46 | } 47 | } 48 | 49 | favouriteViewModel.getFavDataBase().observe(this,{ 50 | if (it.isNotEmpty()){ 51 | binding.recyclerViewFav.visibility=View.VISIBLE 52 | binding.empty.visibility=View.GONE 53 | loadFavourite(it) 54 | dataList=it 55 | }else{ 56 | binding.empty.visibility=View.VISIBLE 57 | binding.recyclerViewFav.visibility=View.GONE 58 | } 59 | }) 60 | 61 | favouriteViewModel.getIntent().observe(this,{ 62 | val intent = Intent(activity, FavouriteDetails::class.java) 63 | intent.putExtra("lat", "${dataList[it].lat}") 64 | intent.putExtra("lon", "${dataList[it].lon}") 65 | intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK 66 | startActivity(intent) 67 | }) 68 | favouriteViewModel.getAlertDialogLiveData().observe(this,{ 69 | if (it!=null){ 70 | showAlarm(it.lat.toString(),it.lon.toString()) 71 | } 72 | }) 73 | 74 | return binding.root 75 | } 76 | 77 | private fun loadFavourite(it: List) { 78 | val lay : RecyclerView.LayoutManager= LinearLayoutManager(activity) 79 | binding.recyclerViewFav.layoutManager=lay 80 | adapter.models=it 81 | binding.recyclerViewFav.adapter=adapter 82 | } 83 | 84 | private fun showAlarm(lat : String,lon: String) { 85 | val alertDialogBuilder = AlertDialog.Builder(activity!!) 86 | alertDialogBuilder.setTitle("Are you Sure") 87 | alertDialogBuilder.setMessage("you want to delete this city") 88 | alertDialogBuilder.setPositiveButton("Yes") { _, _ -> 89 | CoroutineScope(Dispatchers.IO).launch { 90 | favouriteViewModel.deleteOneFav(lat,lon) 91 | } 92 | } 93 | alertDialogBuilder.setNegativeButton("No") { _, _ -> 94 | 95 | } 96 | alertDialogBuilder.show() 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/favourit/FavouriteAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.favourit 2 | 3 | import android.os.Build 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.ImageView 8 | import android.widget.TextView 9 | import androidx.annotation.RequiresApi 10 | import androidx.recyclerview.widget.RecyclerView 11 | import com.example.kotlinproject.R 12 | import com.example.kotlinproject.dataLayer.entity.favtable.FavData 13 | 14 | 15 | class FavouriteAdapter(var favViewModel: FavouriteViewModel,val units:String) : RecyclerView.Adapter() { 16 | lateinit var models: List 17 | // var homeViewModel: FavouriteViewModel = FavouriteViewModel(context) 18 | 19 | inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 20 | var temp = itemView.findViewById(R.id.currentTemp) 21 | var tempUnits = itemView.findViewById(R.id.tempUnit) 22 | var description = itemView.findViewById(R.id.description) 23 | var time_Zone = itemView.findViewById(R.id.time_zone) 24 | var icon = itemView.findViewById(R.id.currentModeImg) 25 | 26 | 27 | @RequiresApi(Build.VERSION_CODES.O) 28 | fun binding(favData: FavData,position: Int) { 29 | favViewModel.loadImage(icon, favData.current.weather[0].icon) 30 | description.text = favData.current.weather[0].description 31 | temp.text = favData.current.temp.toString() 32 | time_Zone.text=favData.timezone 33 | tempUnits.text=favViewModel.getUnites(units) 34 | 35 | itemView.setOnClickListener{ 36 | favViewModel.intentLiveData(position) 37 | } 38 | itemView.setOnLongClickListener{ 39 | favViewModel.setAlertDialogLiveData(favData) 40 | // favViewModel.showAlarm(favData.lat.toString(), favData.lon.toString()) 41 | true 42 | } 43 | 44 | } 45 | } 46 | 47 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { 48 | val inflater = LayoutInflater.from(parent.context) 49 | val binding = inflater.inflate(R.layout.favourite_item, parent, false) 50 | return MyViewHolder(binding) 51 | } 52 | 53 | @RequiresApi(Build.VERSION_CODES.O) 54 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) { 55 | holder.binding(models.get(position),position) 56 | } 57 | 58 | override fun getItemCount(): Int { 59 | return models.size 60 | } 61 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/favourit/FavouriteViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.favourit 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import android.os.Build 6 | import android.widget.ImageView 7 | import androidx.annotation.RequiresApi 8 | import androidx.lifecycle.AndroidViewModel 9 | import androidx.lifecycle.LiveData 10 | import androidx.lifecycle.MutableLiveData 11 | import com.bumptech.glide.Glide 12 | import com.example.kotlinproject.dataLayer.DataSourceViewModel 13 | import com.example.kotlinproject.dataLayer.entity.favtable.FavData 14 | import com.example.kotlinproject.ui.GeneralFunctions 15 | 16 | 17 | class FavouriteViewModel(application: Application) : AndroidViewModel(application) { 18 | private val dataSourceViewModel: DataSourceViewModel = DataSourceViewModel(application) 19 | private val intentLiveData: MutableLiveData = MutableLiveData() 20 | private val alertDialogLiveData: MutableLiveData = MutableLiveData() 21 | private val generalFunctions :GeneralFunctions= GeneralFunctions() 22 | fun deleteOneFav(lat: String, lon: String)= dataSourceViewModel.deleteOneFav(lat,lon) 23 | 24 | fun getFavDataBase(): LiveData> { 25 | return dataSourceViewModel.getFavDataBase() 26 | } 27 | 28 | @RequiresApi(Build.VERSION_CODES.O) 29 | fun loadImage(imageView: ImageView, string: String) { 30 | Glide.with(imageView) //2 31 | .load("https://openweathermap.org/img/wn/$string@2x.png") //3 32 | .centerCrop() //4 33 | .into(imageView) 34 | } 35 | 36 | 37 | fun intentLiveData(position : Int){ 38 | intentLiveData.value=position 39 | } 40 | 41 | fun getIntent():LiveData{ 42 | return intentLiveData 43 | } 44 | fun setAlertDialogLiveData(position : FavData){ 45 | alertDialogLiveData.value=position 46 | } 47 | 48 | fun getAlertDialogLiveData():LiveData{ 49 | return alertDialogLiveData 50 | } 51 | fun getOnline(context: Context) : Boolean{ 52 | return generalFunctions.isOnline(context) 53 | } 54 | fun getUnites(units: String): String { 55 | return generalFunctions.getUnites(units) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/favouriteDetails/DailyAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.favouriteDetails 2 | 3 | import android.os.Build 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.ImageView 8 | import android.widget.TextView 9 | import androidx.annotation.RequiresApi 10 | import androidx.recyclerview.widget.RecyclerView 11 | import com.example.kotlinproject.R 12 | import com.example.kotlinproject.dataLayer.entity.favtable.Daily 13 | import com.example.kotlinproject.ui.baseHome.MainActivity 14 | 15 | class DailyAdapter (var homeViewModel: DetailsViewModel) : RecyclerView.Adapter() { 16 | lateinit var models: List 17 | 18 | inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 19 | private var time = itemView.findViewById(R.id.currentTime) 20 | private var tempUnits = itemView.findViewById(R.id.tempUnit) 21 | private var temp = itemView.findViewById(R.id.currentTemp) 22 | private var description = itemView.findViewById(R.id.description) 23 | private var icon = itemView.findViewById(R.id.currentModeImg) 24 | 25 | @RequiresApi(Build.VERSION_CODES.O) 26 | fun binding(hourly: Daily) { 27 | homeViewModel.loadImage(icon,hourly.weather[0].icon) 28 | description.text = hourly.weather[0].description 29 | temp.text = hourly.temp.day.toString() 30 | time.text = homeViewModel.formatDate(hourly.dt) 31 | tempUnits.text=homeViewModel.getUnites(MainActivity.units) 32 | 33 | } 34 | } 35 | 36 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { 37 | val inflater = LayoutInflater.from(parent.context) 38 | val binding = inflater.inflate(R.layout.hourly_item, parent, false) 39 | return MyViewHolder(binding) 40 | } 41 | 42 | @RequiresApi(Build.VERSION_CODES.O) 43 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) { 44 | holder.binding(models[position]) 45 | } 46 | 47 | override fun getItemCount(): Int { 48 | return models.size 49 | } 50 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/favouriteDetails/DetailsViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.favouriteDetails 2 | 3 | import android.annotation.SuppressLint 4 | import android.app.Application 5 | import android.os.Build 6 | import android.widget.ImageView 7 | import androidx.annotation.RequiresApi 8 | import androidx.lifecycle.AndroidViewModel 9 | import com.example.kotlinproject.dataLayer.DataSourceViewModel 10 | import com.example.kotlinproject.ui.GeneralFunctions 11 | 12 | class DetailsViewModel(application: Application) : AndroidViewModel(application) { 13 | private val mApplication: Application=application 14 | private val dataSourceViewModel: DataSourceViewModel = DataSourceViewModel(mApplication) 15 | private val generalFunctions :GeneralFunctions= GeneralFunctions() 16 | fun getOneFav(lat: String,lon: String)= dataSourceViewModel.getOneFav(lat,lon) 17 | 18 | fun saveFave(lat: String,lon: String,lang: String,units :String){ 19 | dataSourceViewModel.saveFave(lat,lon,lang,units) 20 | } 21 | 22 | @RequiresApi(Build.VERSION_CODES.O) 23 | fun loadImage(imageView: ImageView, string: String) { 24 | generalFunctions.loadImage(imageView,string) 25 | } 26 | @SuppressLint("SimpleDateFormat") 27 | fun fermatTime(format: Int): String { 28 | return generalFunctions.formateTime(format) 29 | 30 | } 31 | @SuppressLint("SimpleDateFormat") 32 | fun formatDate(format: Int): String { 33 | return generalFunctions.formateDate(format) 34 | } 35 | fun getUnites(units: String): String { 36 | return generalFunctions.getUnites(units) 37 | } 38 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/favouriteDetails/HourlyAdabter.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.favouriteDetails 2 | 3 | 4 | import android.os.Build 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import android.widget.ImageView 9 | import android.widget.TextView 10 | import androidx.annotation.RequiresApi 11 | import androidx.recyclerview.widget.RecyclerView 12 | import com.example.kotlinproject.R 13 | import com.example.kotlinproject.dataLayer.entity.favtable.Hourly 14 | import com.example.kotlinproject.ui.baseHome.MainActivity 15 | 16 | 17 | class HourlyAdabter(var homeViewModel: DetailsViewModel) : RecyclerView.Adapter() { 18 | lateinit var models: List 19 | 20 | inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 21 | private var time = itemView.findViewById(R.id.currentTime) 22 | private var tempUnits = itemView.findViewById(R.id.tempUnit) 23 | private var temp = itemView.findViewById(R.id.currentTemp) 24 | private var description = itemView.findViewById(R.id.description) 25 | private var icon = itemView.findViewById(R.id.currentModeImg) 26 | 27 | @RequiresApi(Build.VERSION_CODES.O) 28 | fun binding(hourly: Hourly) { 29 | homeViewModel.loadImage(icon,hourly.weather[0].icon) 30 | description.text = hourly.weather[0].description 31 | temp.text = hourly.temp.toString() 32 | time.text = homeViewModel.fermatTime(hourly.dt) 33 | tempUnits.text=homeViewModel.getUnites(MainActivity.units) 34 | 35 | } 36 | } 37 | 38 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { 39 | val inflater = LayoutInflater.from(parent.context) 40 | val binding = inflater.inflate(R.layout.hourly_item, parent, false) 41 | return MyViewHolder(binding) 42 | } 43 | 44 | @RequiresApi(Build.VERSION_CODES.O) 45 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) { 46 | holder.binding(models[position]) 47 | } 48 | 49 | override fun getItemCount(): Int { 50 | return models.size 51 | } 52 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/home/DailyAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.home 2 | 3 | import android.os.Build 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.ImageView 8 | import android.widget.TextView 9 | import androidx.annotation.RequiresApi 10 | import androidx.recyclerview.widget.RecyclerView 11 | import com.example.kotlinproject.R 12 | import com.example.kotlinproject.dataLayer.entity.oneCallEntity.Daily 13 | import com.example.kotlinproject.ui.baseHome.MainActivity 14 | 15 | class DailyAdapter ( var homeViewModel: HomeViewModel) : RecyclerView.Adapter() { 16 | lateinit var models: List 17 | 18 | inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 19 | private var time = itemView.findViewById(R.id.currentTime) 20 | private var temp = itemView.findViewById(R.id.currentTemp) 21 | private var tempUInt = itemView.findViewById(R.id.tempUnit) 22 | private var description = itemView.findViewById(R.id.description) 23 | private var icon = itemView.findViewById(R.id.currentModeImg) 24 | 25 | @RequiresApi(Build.VERSION_CODES.O) 26 | fun binding(hourly: Daily) { 27 | homeViewModel.loadImage(icon,hourly.weather[0].icon) 28 | description.text = hourly.weather[0].description 29 | temp.text = hourly.temp.day.toString() 30 | time.text = homeViewModel.formateDate(hourly.dt) 31 | tempUInt.text=homeViewModel.getUnites(MainActivity.units) 32 | 33 | } 34 | } 35 | 36 | 37 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { 38 | val inflater = LayoutInflater.from(parent.context) 39 | val binding = inflater.inflate(R.layout.hourly_item, parent, false) 40 | return MyViewHolder(binding) 41 | } 42 | 43 | @RequiresApi(Build.VERSION_CODES.O) 44 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) { 45 | holder.binding(models[position]) 46 | } 47 | 48 | override fun getItemCount(): Int { 49 | return models.size 50 | } 51 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/home/HomeViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.home 2 | 3 | import android.annotation.SuppressLint 4 | import android.app.Activity 5 | import android.app.Application 6 | import android.content.Context 7 | import android.location.Location 8 | import android.os.Build 9 | import android.util.Log 10 | import android.widget.ImageView 11 | import android.widget.Toast 12 | import androidx.annotation.RequiresApi 13 | import androidx.lifecycle.AndroidViewModel 14 | import androidx.lifecycle.LiveData 15 | import com.example.kotlinproject.R 16 | import com.example.kotlinproject.dataLayer.DataSourceViewModel 17 | import com.example.kotlinproject.dataLayer.entity.oneCallEntity.AllData 18 | import com.example.kotlinproject.dataLayer.local.sharedprefrence.SettingModel 19 | import com.example.kotlinproject.ui.GeneralFunctions 20 | import com.google.android.gms.maps.model.LatLng 21 | 22 | 23 | class HomeViewModel(application: Application) : AndroidViewModel(application) { 24 | private val mApplication: Application=application 25 | private val locationHanding: LocationHanding = LocationHanding(mApplication.applicationContext) 26 | private val dataSourceViewModel: DataSourceViewModel = DataSourceViewModel(mApplication) 27 | private val generalFunctions : GeneralFunctions= GeneralFunctions() 28 | 29 | 30 | fun loadOnlineData(lat: String, lon: String, lang: String, units: String,context: Context) 31 | { 32 | if (generalFunctions.isOnline(context)) { 33 | Log.d("TAG", "loadOnlineData: ") 34 | dataSourceViewModel.loadOneCall(lat, lon, lang, units) 35 | }else{ 36 | Toast.makeText(context,context.getString(R.string.you_areoffline),Toast.LENGTH_SHORT).show() 37 | } 38 | } 39 | 40 | fun getUnites(units: String): String { 41 | return generalFunctions.getUnites(units) 42 | } 43 | 44 | fun gettingLocation(context: Context,activity: Activity) :LiveData{ 45 | locationHanding.loadLocation(context,activity) 46 | return locationHanding.getLocatin() 47 | } 48 | fun getLocationSettnig():LiveData{ 49 | return dataSourceViewModel.getLocationSetting() 50 | } 51 | 52 | fun getSetting():LiveData{ 53 | return dataSourceViewModel.getSetting() 54 | } 55 | 56 | 57 | fun getRoomData():LiveData>{ 58 | return dataSourceViewModel.getRoomDataBase() 59 | } 60 | 61 | @RequiresApi(Build.VERSION_CODES.O) 62 | fun loadImage(imageView: ImageView, string: String) { 63 | generalFunctions.loadImage(imageView,string) 64 | } 65 | 66 | 67 | @SuppressLint("SimpleDateFormat") 68 | fun formateDate(format: Int): String { 69 | return generalFunctions.formateDate(format) 70 | } 71 | 72 | @SuppressLint("SimpleDateFormat") 73 | fun formateTime(format: Int): String { 74 | return generalFunctions.formateTime(format) 75 | } 76 | 77 | fun getAlertFromSetting():LiveData{ 78 | return dataSourceViewModel.getAlertSetting() 79 | } 80 | 81 | 82 | 83 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/home/HourlyAdabter.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.home 2 | 3 | 4 | import android.os.Build 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import android.widget.ImageView 9 | import android.widget.TextView 10 | import androidx.annotation.RequiresApi 11 | import androidx.recyclerview.widget.RecyclerView 12 | import com.example.kotlinproject.R 13 | import com.example.kotlinproject.dataLayer.entity.oneCallEntity.Hourly 14 | import com.example.kotlinproject.ui.baseHome.MainActivity 15 | 16 | 17 | //class HourlyAdabter { 18 | //} 19 | class HourlyAdabter(var homeViewModel: HomeViewModel) : RecyclerView.Adapter() { 20 | lateinit var models: List 21 | 22 | inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 23 | private var time = itemView.findViewById(R.id.currentTime) 24 | private var tempUnits = itemView.findViewById(R.id.tempUnit) 25 | private var temp = itemView.findViewById(R.id.currentTemp) 26 | private var description = itemView.findViewById(R.id.description) 27 | private var icon = itemView.findViewById(R.id.currentModeImg) 28 | 29 | @RequiresApi(Build.VERSION_CODES.O) 30 | fun binding(hourly: Hourly) { 31 | homeViewModel.loadImage(icon,hourly.weather[0].icon) 32 | description.text = hourly.weather[0].description 33 | temp.text = hourly.temp.toString() 34 | time.text = homeViewModel.formateTime(hourly.dt) 35 | tempUnits.text=homeViewModel.getUnites(MainActivity.units) 36 | 37 | } 38 | } 39 | 40 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { 41 | val inflater = LayoutInflater.from(parent.context) 42 | val binding = inflater.inflate(R.layout.hourly_item, parent, false) 43 | return MyViewHolder(binding) 44 | } 45 | 46 | @RequiresApi(Build.VERSION_CODES.O) 47 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) { 48 | holder.binding(models[position]) 49 | } 50 | 51 | override fun getItemCount(): Int { 52 | return models.size 53 | } 54 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/home/LocationHanding.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.home 2 | 3 | import android.Manifest 4 | import android.annotation.SuppressLint 5 | import android.app.Activity 6 | import android.content.Context 7 | import android.content.Intent 8 | import android.content.pm.PackageManager 9 | import android.location.Location 10 | import android.location.LocationManager 11 | import android.os.Bundle 12 | import android.provider.Settings 13 | import android.util.Log 14 | import androidx.appcompat.app.AlertDialog 15 | import androidx.core.app.ActivityCompat 16 | import androidx.core.app.ActivityCompat.startActivityForResult 17 | import androidx.lifecycle.LiveData 18 | import androidx.lifecycle.MutableLiveData 19 | import com.example.kotlinproject.R 20 | import com.example.kotlinproject.ui.baseHome.MainActivity 21 | import com.google.android.gms.location.FusedLocationProviderClient 22 | import com.google.android.gms.location.LocationServices 23 | 24 | class LocationHanding(val context: Context) { 25 | companion object { 26 | const val LOCATION_PERMISSION_REQUEST_CODE = 1584 27 | } 28 | 29 | private var locationLiveData: MutableLiveData = MutableLiveData() 30 | private var loadLocal: MutableLiveData = MutableLiveData() 31 | private var fusedLocationClient: FusedLocationProviderClient = 32 | LocationServices.getFusedLocationProviderClient( 33 | context 34 | ) 35 | 36 | @SuppressLint("MissingPermission") 37 | fun loadLocation(context: Context, activity: Activity) { 38 | if (verifyLocationEnabled()) { 39 | if (chickPermition()) { 40 | 41 | fusedLocationClient.lastLocation 42 | .addOnSuccessListener { location: Location? -> 43 | if (location != null) 44 | locationLiveData.value = location 45 | } 46 | } else { 47 | requestPremition(activity) 48 | loadLocation(context, activity) 49 | } 50 | } else { 51 | enableLocationSitting(context, activity) 52 | } 53 | } 54 | 55 | @SuppressLint("MissingPermission") 56 | fun checkLocation(context: Context, activity: Activity) { 57 | if (verifyLocationEnabled()) { 58 | if (chickPermition()) { 59 | } else { 60 | requestPremition(activity) 61 | } 62 | } else { 63 | enableLocationSitting(context, activity) 64 | } 65 | } 66 | 67 | private fun enableLocationSitting(context: Context, activity: Activity) { 68 | Log.d("TAG","MainActivity.readFromDatabase " + MainActivity.readFromDatabase.toString()) 69 | if (!MainActivity.readFromDatabase) { 70 | val alertDialogBuilder = AlertDialog.Builder(context) 71 | alertDialogBuilder.setTitle(context.getString(R.string.location_not_enabel)) 72 | alertDialogBuilder.setMessage(context.getString(R.string.to_load_condetions)) 73 | alertDialogBuilder.setPositiveButton(context.getString(R.string.enabel)) { dialog, _ -> 74 | Log.d("TAG", "Enabel log") 75 | MainActivity.readFromDatabase = false 76 | dialog.dismiss() 77 | val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS) 78 | startActivityForResult(activity, intent, LOCATION_PERMISSION_REQUEST_CODE, Bundle()) 79 | 80 | } 81 | alertDialogBuilder.setNegativeButton(context.getString(R.string.load_from_last_known_data)) { _, _ -> 82 | loadLocal.value = true 83 | MainActivity.readFromDatabase = true 84 | } 85 | Log.d("TAG", "Enabel show") 86 | alertDialogBuilder.show() 87 | } 88 | } 89 | 90 | private fun chickPermition(): Boolean { 91 | return ActivityCompat.checkSelfPermission( 92 | context, 93 | Manifest.permission.ACCESS_FINE_LOCATION 94 | ) == PackageManager.PERMISSION_GRANTED && 95 | ActivityCompat.checkSelfPermission( 96 | context, 97 | Manifest.permission.ACCESS_COARSE_LOCATION 98 | ) == PackageManager.PERMISSION_GRANTED 99 | } 100 | 101 | fun verifyLocationEnabled(): Boolean { 102 | val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager 103 | return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) 104 | } 105 | 106 | private fun requestPremition(activity: Activity) { 107 | ActivityCompat.requestPermissions( 108 | activity, 109 | arrayOf( 110 | Manifest.permission.ACCESS_COARSE_LOCATION, 111 | Manifest.permission.ACCESS_FINE_LOCATION 112 | ), 113 | LOCATION_PERMISSION_REQUEST_CODE 114 | ) 115 | } 116 | 117 | fun getLocatin(): LiveData { 118 | return locationLiveData 119 | } 120 | 121 | 122 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/map/MapActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.map 2 | 3 | 4 | import android.net.ConnectivityManager 5 | import android.os.Bundle 6 | import android.util.Log 7 | import androidx.appcompat.app.AppCompatActivity 8 | import androidx.lifecycle.ViewModelProvider 9 | import com.example.kotlinproject.R 10 | import com.google.android.gms.maps.GoogleMap 11 | import com.google.android.gms.maps.OnMapReadyCallback 12 | import com.google.android.gms.maps.SupportMapFragment 13 | import com.google.android.gms.maps.model.LatLng 14 | import com.google.android.gms.maps.model.MarkerOptions 15 | 16 | 17 | class MapActivity : AppCompatActivity(), OnMapReadyCallback { 18 | 19 | private lateinit var mMap: GoogleMap 20 | private lateinit var mapActivityViewMode: MapActivityViewMode 21 | private lateinit var latLng: LatLng 22 | private lateinit var type: String 23 | 24 | override fun onCreate(savedInstanceState: Bundle?) { 25 | super.onCreate(savedInstanceState) 26 | setContentView(R.layout.activity_map) 27 | 28 | type=intent.getStringExtra("type").toString() 29 | 30 | val mapFragment = supportFragmentManager 31 | .findFragmentById(R.id.map) as SupportMapFragment 32 | mapFragment.getMapAsync(this) 33 | // mapActivityViewMode= MapActivityViewMode(this) 34 | mapActivityViewMode= ViewModelProvider( 35 | this, ViewModelProvider.AndroidViewModelFactory.getInstance( 36 | application 37 | ) 38 | )[MapActivityViewMode::class.java] 39 | 40 | 41 | mapActivityViewMode.saveLatLng.observe(this, { 42 | if (it) { 43 | mapActivityViewMode.saveLocationSetting(latLng) 44 | mapActivityViewMode.saveLatLng.value = false 45 | 46 | } 47 | }) 48 | 49 | mapActivityViewMode.saveFav.observe(this, { it -> 50 | if (it) { 51 | mapActivityViewMode.getSettnig().observe(this, { 52 | mapActivityViewMode.saveFav( 53 | latLng.latitude.toString(), 54 | latLng.longitude.toString(), 55 | it.lang, 56 | it.units 57 | ) 58 | }) 59 | mapActivityViewMode.saveFav.value = false 60 | 61 | } 62 | }) 63 | } 64 | 65 | 66 | override fun onMapReady(googleMap: GoogleMap) { 67 | mMap = googleMap 68 | mMap.mapType = GoogleMap.MAP_TYPE_HYBRID 69 | mMap.uiSettings.isZoomControlsEnabled = true 70 | 71 | mMap.setOnMapClickListener { 72 | mMap.clear() 73 | mMap.addMarker(MarkerOptions().position(it)) 74 | Log.d("TAG", "${it.latitude}.....${it.longitude}") 75 | latLng=it 76 | if (type=="setting"){ 77 | mapActivityViewMode.showLocationSavingAlarm(this) 78 | }else { 79 | mapActivityViewMode.showAlarm(this) 80 | } 81 | Log.d("TAG", "${latLng.latitude}.....${type}") 82 | Log.d("TAG type", "") 83 | } 84 | 85 | } 86 | 87 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/map/MapActivityViewMode.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.map 2 | 3 | import android.annotation.SuppressLint 4 | import android.app.Application 5 | import android.content.Context 6 | 7 | import androidx.appcompat.app.AlertDialog 8 | import androidx.lifecycle.AndroidViewModel 9 | import androidx.lifecycle.LiveData 10 | import androidx.lifecycle.MutableLiveData 11 | import com.example.kotlinproject.R 12 | import com.example.kotlinproject.dataLayer.DataSourceViewModel 13 | import com.example.kotlinproject.dataLayer.local.sharedprefrence.SettingModel 14 | import com.google.android.gms.maps.model.LatLng 15 | 16 | class MapActivityViewMode(application: Application) : AndroidViewModel(application) { 17 | private val mApplication: Application=application 18 | val saveFav :MutableLiveData =MutableLiveData() 19 | val saveLatLng :MutableLiveData =MutableLiveData() 20 | private val dataSourceViewModel: DataSourceViewModel = DataSourceViewModel(application) 21 | 22 | fun showAlarm(context: Context) { 23 | val alertDialogBuilder = AlertDialog.Builder(context) 24 | alertDialogBuilder.setTitle(context.getString(R.string.are_you_sure)) 25 | alertDialogBuilder.setMessage(context.getString(R.string.you_want_to_add)) 26 | alertDialogBuilder.setPositiveButton(context.getString(R.string.yes)) { _, _ -> 27 | saveFav.value=true 28 | } 29 | alertDialogBuilder.setNegativeButton(context.getString(R.string.no)) { _, _ -> 30 | saveFav.value=false 31 | } 32 | alertDialogBuilder.show() 33 | } 34 | fun showLocationSavingAlarm(context: Context) { 35 | val alertDialogBuilder = AlertDialog.Builder(context) 36 | alertDialogBuilder.setTitle(context.getString(R.string.are_you_sure)) 37 | alertDialogBuilder.setMessage(context.getString(R.string.are_you_sure_location)) 38 | alertDialogBuilder.setPositiveButton(context.getString(R.string.yes)) { _, _ -> 39 | saveLatLng.value=true 40 | } 41 | alertDialogBuilder.setNegativeButton(context.getString(R.string.no)) { _, _ -> 42 | saveLatLng.value=false 43 | } 44 | alertDialogBuilder.show() 45 | } 46 | 47 | fun saveFav(lat: String,lon: String,lang: String,units :String){ 48 | dataSourceViewModel.saveFave(lat,lon,lang,units) 49 | } 50 | 51 | fun getSettnig():LiveData{ 52 | return dataSourceViewModel.getSetting() 53 | } 54 | 55 | fun saveLocationSetting(latLng: LatLng)=dataSourceViewModel.saveLocationSetting(latLng) 56 | 57 | 58 | 59 | 60 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/setting/Setting.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.setting 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import android.util.Log 6 | import androidx.fragment.app.Fragment 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import android.view.ViewGroup 10 | import android.widget.Switch 11 | import android.widget.Toast 12 | import androidx.lifecycle.Observer 13 | import androidx.lifecycle.ViewModelProvider 14 | import com.example.kotlinproject.R 15 | import com.example.kotlinproject.dataLayer.local.sharedprefrence.SettingModel 16 | import com.example.kotlinproject.databinding.FragmentSettingBinding 17 | import com.example.kotlinproject.ui.baseHome.MainActivity 18 | import com.example.kotlinproject.ui.favouriteDetails.FavouriteDetails 19 | import com.example.kotlinproject.ui.map.MapActivity 20 | import com.example.kotlinproject.ui.map.MapActivityViewMode 21 | 22 | 23 | class Setting : Fragment() { 24 | lateinit var binding: FragmentSettingBinding 25 | lateinit var settingViewModel: SettingViewModel 26 | override fun onCreate(savedInstanceState: Bundle?) { 27 | super.onCreate(savedInstanceState) 28 | } 29 | 30 | override fun onCreateView( 31 | inflater: LayoutInflater, 32 | container: ViewGroup?, 33 | savedInstanceState: Bundle? 34 | ): View { 35 | binding = FragmentSettingBinding.inflate(inflater, container, false) 36 | settingViewModel = ViewModelProvider(this, ViewModelProvider.AndroidViewModelFactory.getInstance( 37 | requireActivity().application 38 | ))[SettingViewModel::class.java] 39 | 40 | 41 | binding.saveButton.setOnClickListener{ 42 | savedata() 43 | } 44 | 45 | binding.addLocationRadioButton.setOnClickListener{ 46 | val intent = Intent(activity, MapActivity::class.java) 47 | intent.putExtra("type","setting") 48 | startActivity(intent) 49 | } 50 | getSetting() 51 | 52 | return binding.root 53 | } 54 | 55 | fun getSetting() { 56 | settingViewModel.getSetting().observe(this, { 57 | val units: String = it.units 58 | val lang: String = it.lang 59 | val location: String = it.location 60 | Log.d("TAG",it.location) 61 | if (units == "standard") { 62 | binding.unitsRadioGroup.check(R.id.standardRadioButton) 63 | } else if (units == "imperial") { 64 | binding.unitsRadioGroup.check(R.id.imperialRadioButton) 65 | } else { 66 | binding.unitsRadioGroup.check(R.id.metricRadioButton) 67 | } 68 | 69 | if (lang == "en") { 70 | binding.langRadioGroup.check(R.id.EnglishRadioButton) 71 | } else { 72 | binding.langRadioGroup.check(R.id.ArabicRadioButton) 73 | } 74 | 75 | if (location == "add") { 76 | binding.locationRadioGroup.check(R.id.addLocationRadioButton) 77 | } else { 78 | binding.locationRadioGroup.check(R.id.gpsRadioButton) 79 | } 80 | }) 81 | } 82 | var langS:String="en" 83 | private fun savedata() { 84 | val units: String = when (binding.unitsRadioGroup.checkedRadioButtonId) { 85 | R.id.standardRadioButton -> { 86 | "standard" 87 | } 88 | R.id.imperialRadioButton -> { 89 | "imperial" 90 | } 91 | else -> { 92 | "metric" 93 | } 94 | } 95 | 96 | 97 | val lang: String = if (binding.langRadioGroup.checkedRadioButtonId == R.id.EnglishRadioButton) { 98 | "en" 99 | } else { 100 | "ar" 101 | } 102 | langS=lang 103 | 104 | 105 | 106 | val location: String = if (binding.locationRadioGroup.checkedRadioButtonId == R.id.gpsRadioButton) { 107 | "gps" 108 | } else { 109 | "add" 110 | } 111 | 112 | settingViewModel.setSetting(SettingModel(units, lang, location)) 113 | settingViewModel.setLocale(requireActivity(),langS) 114 | startActivity(Intent(requireContext(),MainActivity::class.java)) 115 | requireActivity().finish() 116 | } 117 | 118 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/setting/SettingViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.setting 2 | 3 | import android.app.Activity 4 | import android.app.Application 5 | import android.content.Context 6 | import android.location.Location 7 | import androidx.lifecycle.AndroidViewModel 8 | import androidx.lifecycle.LiveData 9 | import com.example.kotlinproject.dataLayer.DataSourceViewModel 10 | import com.example.kotlinproject.dataLayer.local.sharedprefrence.SettingModel 11 | import com.example.kotlinproject.ui.GeneralFunctions 12 | import com.example.kotlinproject.ui.home.LocationHanding 13 | 14 | 15 | class SettingViewModel(application: Application) : AndroidViewModel(application) { 16 | private val mApplication: Application = application 17 | val dataSourceViewModel: DataSourceViewModel = DataSourceViewModel(mApplication) 18 | 19 | private val generalFunctions = GeneralFunctions() 20 | 21 | fun setLocale(activity: Activity, languageCode: String?) { 22 | generalFunctions.setLocale(activity, languageCode) 23 | } 24 | 25 | fun getSetting(): LiveData { 26 | return dataSourceViewModel.getSetting() 27 | } 28 | 29 | fun setSetting(setttingModel: SettingModel) { 30 | dataSourceViewModel.setSetting(setttingModel) 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/splash/Splash.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.splash 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Intent 5 | import android.content.pm.PackageManager 6 | import android.os.Bundle 7 | import android.os.Handler 8 | import android.util.Log 9 | import android.view.animation.Animation 10 | import android.view.animation.AnimationUtils 11 | import android.widget.Toast 12 | import androidx.appcompat.app.AppCompatActivity 13 | import androidx.databinding.DataBindingUtil 14 | import androidx.lifecycle.ViewModelProvider 15 | import com.example.kotlinproject.R 16 | import com.example.kotlinproject.databinding.ActivitySplashBinding 17 | import com.example.kotlinproject.ui.baseHome.MainActivity 18 | import com.example.kotlinproject.ui.home.LocationHanding 19 | import java.util.* 20 | 21 | 22 | class Splash : AppCompatActivity() { 23 | lateinit var binding:ActivitySplashBinding 24 | private lateinit var splashViewModel: SplashViewModel 25 | @SuppressLint("ResourceType") 26 | override fun onCreate(savedInstanceState: Bundle?) { 27 | super.onCreate(savedInstanceState) 28 | binding = DataBindingUtil.setContentView(this, R.layout.activity_splash) 29 | splashViewModel= ViewModelProvider( 30 | this, 31 | ViewModelProvider.AndroidViewModelFactory.getInstance(this.application) 32 | )[SplashViewModel::class.java] 33 | val down=AnimationUtils.loadAnimation(this, R.animator.move_down) 34 | val animation :Animation=AnimationUtils.loadAnimation(this, R.anim.wave) 35 | binding.snow1.startAnimation(animation) 36 | binding.snow1.startAnimation(down) 37 | binding.snow2.startAnimation(animation) 38 | binding.snow2.startAnimation(down) 39 | binding.snow3.startAnimation(animation) 40 | binding.snow3.startAnimation(down) 41 | binding.snow4.startAnimation(animation) 42 | binding.snow4.startAnimation(down) 43 | binding.snow5.startAnimation(animation) 44 | binding.snow5.startAnimation(down) 45 | binding.snow6.startAnimation(animation) 46 | binding.snow6.startAnimation(down) 47 | binding.snow7.startAnimation(animation) 48 | binding.snow7.startAnimation(down) 49 | binding.snow8.startAnimation(animation) 50 | binding.snow8.startAnimation(down) 51 | binding.snow9.startAnimation(animation) 52 | binding.snow9.startAnimation(down) 53 | binding.snow10.startAnimation(animation) 54 | binding.snow10.startAnimation(down) 55 | binding.snow11.startAnimation(animation) 56 | binding.snow11.startAnimation(down) 57 | binding.snow12.startAnimation(animation) 58 | binding.snow12.startAnimation(down) 59 | 60 | 61 | // val locationHanding : LocationHanding= LocationHanding(this) 62 | splashViewModel.getSetting().observe(this, { 63 | // if (it.location == "gps") { 64 | // locationHanding.checkLocation(this, this) 65 | // } 66 | splashViewModel.enableLocalization(this, it.lang) 67 | }) 68 | @Suppress("DEPRECATION") val handler = Handler() 69 | 70 | handler.postDelayed({ 71 | val intent = Intent(this, MainActivity::class.java) 72 | startActivity(intent) 73 | finish() 74 | }, 4000) 75 | } 76 | 77 | // override fun onRequestPermissionsResult( 78 | // requestCode: Int, 79 | // permissions: Array, 80 | // grantResults: IntArray 81 | // ) { 82 | // super.onRequestPermissionsResult(requestCode, permissions, grantResults) 83 | // if (requestCode == LocationHanding.LOCATION_PERMISSION_REQUEST_CODE) { 84 | // if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { 85 | // Toast.makeText(this,"dhklsghlsghlfslj",Toast.LENGTH_SHORT).show() 86 | // Log.d("jgjgjb","knbkbkbj${LocationHanding.LOCATION_PERMISSION_REQUEST_CODE}") 87 | // } 88 | // } 89 | // } 90 | 91 | 92 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/kotlinproject/ui/splash/SplashViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject.ui.splash 2 | 3 | import android.app.Activity 4 | import android.app.Application 5 | import android.content.res.Configuration 6 | import android.content.res.Resources 7 | import androidx.lifecycle.AndroidViewModel 8 | import androidx.lifecycle.LiveData 9 | import com.example.kotlinproject.dataLayer.DataSourceViewModel 10 | import com.example.kotlinproject.dataLayer.local.sharedprefrence.SettingModel 11 | import com.example.kotlinproject.ui.GeneralFunctions 12 | import java.util.* 13 | 14 | class SplashViewModel(application: Application) : AndroidViewModel(application) { 15 | private val dataSourceViewModel: DataSourceViewModel = DataSourceViewModel(application) 16 | private val generalFunctions=GeneralFunctions() 17 | 18 | private fun setLocale(activity: Activity, languageCode: String?) { 19 | generalFunctions.setLocale(activity,languageCode) 20 | } 21 | fun getSetting():LiveData{ 22 | return dataSourceViewModel.getSetting() 23 | } 24 | fun enableLocalization(activity: Activity, languageCode: String?){ 25 | setLocale(activity,languageCode) 26 | 27 | } 28 | 29 | 30 | 31 | } -------------------------------------------------------------------------------- /app/src/main/res/anim/wave.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 14 | 15 | 16 | android:interpolator="@android:anim/accelerate_interpolator" 17 | android:startOffset="700"> 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/animator/move_down.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/example_appwidget_preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/drawable-nodpi/example_appwidget_preview.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/current_cloud.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/current_humidity.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/current_pressure.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/current_sunrise.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/current_sunsit.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/current_wind.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/frost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/drawable/frost.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/home_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic__time_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_alert_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_arrow_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_arrow_down_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_avorite_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_add_alarm_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_check_box_outline_blank_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_close_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_check_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_cloud.xml: -------------------------------------------------------------------------------- 1 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_date_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_description_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_event_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_gps_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_home_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_humidity.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_language_24.xml: -------------------------------------------------------------------------------- 1 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_location_on_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_reload_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_settings_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sunrise.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sunset.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_toggle_off_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_toggle_on_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_units_24.xml: -------------------------------------------------------------------------------- 1 | 10 | 14 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_wind.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/drawable/logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/drawable/sky.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/drawable/snow.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/snow1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/drawable/snow1.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/toggle_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 26 | 27 | 36 | 43 | 44 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_map.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/favourite_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 20 | 21 | 32 | 33 | 45 | 57 | 70 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_alert.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 24 | 25 | 32 | 33 | 40 | 41 | 42 | 49 | 50 | 55 | 56 | 62 | 63 | 64 | 72 | 73 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_favourit.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 18 | 19 | 20 | 31 | 32 | 41 | 42 | 43 | 44 | 51 | 56 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/res/layout/hourly_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 20 | 21 | 33 | 34 | 45 | 46 | 58 | 70 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /app/src/main/res/layout/weather_widget.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 24 | 33 | 34 | 42 | 55 | 56 | 67 | 78 | 79 | 91 | 92 | -------------------------------------------------------------------------------- /app/src/main/res/menu/navigation_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | 15 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/icon_notification.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/icon_notification_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/icon_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-hdpi/icon_notification.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/icon_notification_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-hdpi/icon_notification_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/icon_notification_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-hdpi/icon_notification_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/icon_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-mdpi/icon_notification.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/icon_notification_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-mdpi/icon_notification_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/icon_notification_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-mdpi/icon_notification_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/icon_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xhdpi/icon_notification.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/icon_notification_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xhdpi/icon_notification_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/icon_notification_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xhdpi/icon_notification_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/icon_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xxhdpi/icon_notification.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/icon_notification_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xxhdpi/icon_notification_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/icon_notification_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xxhdpi/icon_notification_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/icon_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xxxhdpi/icon_notification.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/icon_notification_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xxxhdpi/icon_notification_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/icon_notification_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/mipmap-xxxhdpi/icon_notification_round.png -------------------------------------------------------------------------------- /app/src/main/res/raw/rang.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/app/src/main/res/raw/rang.mp3 -------------------------------------------------------------------------------- /app/src/main/res/values-ar/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Weather viewer 4 | الرئيسية 5 | المفضلة 6 | الاعدادات 7 | الشكل 8 | المدينة الحالية 9 | 20 10 | 11:11 11 | الوضع الحالى 12 | ْ C 13 | Mostly Clear 14 | Hello blank fragment 15 | arrow 16 | الحالى 17 | يومى 18 | على مدار الساعة 19 | Humidity 20 | 40% 21 | سرعة الرياح 22 | الضغط 23 | السحب 24 | المزيد من التفاصيل 25 | اسفل 26 | خريطه 27 | 517a14f849e519bb4fa84cdbd4755f56 28 | minutely 29 | هنا يمكنك تغير وحدات القياس 30 | اساسي 31 | متري 32 | إمبراطوري 33 | درجة الحرارة بالكلفن وسرعة الرياح بالمتر / ثانية 34 | درجه الحرارة بمئوية وسرعة الرياح بالمتر / ثانية 35 | درجة الحرارة بالفهرنهايت وسرعة الرياح بالأميال / ساعة 36 | هنا يمكنك اختيار اللغة 37 | اللغه الانجليزية 38 | اللغه العربية 39 | حفظ 40 | غروب الشمس 41 | شروق الشمس 42 | صورة 43 | اعادة تحميل 44 | 1268 45 | اضافه مفضله 46 | top 47 | نظام تحديد المواقع 48 | إضافة موقع محدد 49 | هنا يمكنك اختيار إعداد الموقع الخاص بك 50 | انذار 51 | تفاصيل 52 | دفقة 53 | Hello Square World! 54 | الشاشة الرئيسية 55 | ثلج 56 | تفعيل الانذارات 57 | حدث 58 | البداية 59 | النهاية 60 | الوصف 61 | البيانات غير متوفرة 62 | شعار 63 | انت غير متصل بالانترنت 64 | هناك داتا مفقودة 65 | لتحميل بيانات الطقس الحالية ، يجب عليك تمكين الموقع 66 | انت غير متصل بالانترنت 67 | هل انت متاكد؟ 68 | تريد إضافة هذا الموقع إلى الأماكن المفضلة 69 | لا يمكنك انشاء تنبيه في وقت سابق 70 | اسم التنبيه 71 | غير مسمى 72 | التكرار 73 | من 74 | الى 75 | الغاء 76 | اضافة تنبية 77 | حفظ البيانات 78 | تنبيه الطقس 79 | تحميل من آخر البيانات المعروفة 80 | الموقع غير ممكن 81 | نعم 82 | لا 83 | تريد إضافة هذا الموقع لتخزينه كموقعك 84 | تفعيل 85 | \"انتبه الطقس الان \" 86 | تكرار يومى 87 | 88 | عاصفة 89 | رذاذ 90 | مطر 91 | ثلج 92 | غيوم 93 | 94 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #4d9fdc 9 | #FFFFFFFF 10 | #373737 11 | #832D26 12 | #E6BE9C 13 | #E6BE9C 14 | #96C6D9 15 | #C6C6C6 16 | #A66D97 17 | #8FA6BD 18 | #8F8F8F 19 | #A5A5A5 20 | #373737 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/values-round/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Weather viewer 4 | الرئيسية 5 | المفضلة 6 | الاعدادات 7 | الشكل 8 | المدينة الحالية 9 | 0 10 | 11:11 11 | الوضع الحالى 12 | ْ C 13 | Mostly Clear 14 | Hello blank fragment 15 | arrow 16 | الحالى 17 | يومى 18 | على مدار الساعة 19 | Humidity 20 | 40% 21 | سرعة الرياح 22 | الضغط 23 | السحب 24 | المزيد من التفاصيل 25 | اسفل 26 | خريطه 27 | 517a14f849e519bb4fa84cdbd4755f56 28 | minutely 29 | هنا يمكنك تغير وحدات القياس 30 | اساسي 31 | متري 32 | إمبراطوري 33 | درجة الحرارة بالكلفن وسرعة الرياح بالمتر / ثانية 34 | درجه الحرارة بمئوية وسرعة الرياح بالمتر / ثانية 35 | درجة الحرارة بالفهرنهايت وسرعة الرياح بالأميال / ساعة 36 | هنا يمكنك اختيار اللغة 37 | اللغه الانجليزية 38 | اللغه العربية 39 | حفظ 40 | غروب الشمس 41 | شروق الشمس 42 | صورة 43 | اعادة تحميل 44 | 1268 45 | اضافه مفضله 46 | top 47 | نظام تحديد المواقع 48 | إضافة موقع محدد 49 | هنا يمكنك اختيار إعداد الموقع الخاص بك 50 | انذار 51 | تفاصيل 52 | دفقة 53 | Hello Square World! 54 | الشاشة الرئيسية 55 | ثلج 56 | تفعيل الانذارات 57 | حدث 58 | البداية 59 | النهاية 60 | الوصف 61 | البيانات غير متوفرة 62 | شعار 63 | انت غير متصل بالانترنت 64 | هناك داتا مفقودة 65 | لتحميل بيانات الطقس الحالية ، يجب عليك تمكين الموقع 66 | انت غير متصل بالانترنت 67 | هل انت متاكد؟ 68 | تريد إضافة هذا الموقع إلى الأماكن المفضلة 69 | لا يمكنك انشاء تنبيه في وقت سابق 70 | اسم التنبيه 71 | غير مسمى 72 | التكرار 73 | من 74 | الى 75 | الغاء 76 | اضافة تنبية 77 | حفظ البيانات 78 | تنبيه الطقس 79 | تحميل من آخر البيانات المعروفة 80 | الموقع غير ممكن 81 | نعم 82 | لا 83 | تريد إضافة هذا الموقع لتخزينه كموقعك 84 | تفعيل 85 | \"انتبه الطقس الان \" 86 | تكرار يومى 87 | 88 | عاصفة 89 | رذاذ 90 | مطر 91 | ثلج 92 | غيوم 93 | 94 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #4d9fdc 9 | #FF000000 10 | #FFFFFFFF 11 | #832D26 12 | #832D26 13 | #E6BE9C 14 | #E6BE9C 15 | #96C6D9 16 | #A66D97 17 | #8FA6BD 18 | #8F8F8F 19 | #EDE2E2 20 | #832D26 21 | #FFE1F5FE 22 | #FF81D4FA 23 | #FF039BE5 24 | #FF01579B 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 0dp 8 | 9 | 14 | 5dp 15 | 16 | 20 | 10dp 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/icon_notification_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #F7FFF3 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Weather viewer 3 | Home 4 | Favorite 5 | Setting 6 | shape 7 | Current City 8 | 1 9 | 11:11 10 | current mode 11 | ْ C 12 | Mostly Clear 13 | Hello blank fragment 14 | arrow 15 | Current 16 | Daily 17 | Hourly 18 | Humidity 19 | 40% 20 | Wind speed 21 | Pressure 22 | Clouds 23 | More Details 24 | down 25 | Map 26 | 517a14f849e519bb4fa84cdbd4755f56 27 | minutely 28 | Here yoy can change units of measurement as you want 29 | standard 30 | Metric 31 | Imperial 32 | Temperature in Kelvin and wind speed in meter/sec 33 | Celsius and wind speed in meter/sec 34 | temperature in Fahrenheit and wind speed in miles/hour 35 | Here you can chose language 36 | English 37 | Arabic 38 | Save 39 | Sunset 40 | Sunrise 41 | image 42 | reload 43 | 1268 44 | add fav 45 | top 46 | Gps 47 | Add Custom Location 48 | Here you can choose your location setting 49 | Alert 50 | Details 51 | Splash 52 | 56 | Hello Square World! 57 | MainActivity 58 | snow 59 | Enable Alarm 60 | Event 61 | 62 | Description 63 | No Data Available 64 | logo 65 | You Are Offline 66 | There is Missed Data 67 | Start 68 | End 69 | Alert Name 70 | UnTitled 71 | Reputation 72 | From 73 | To 74 | Cancel 75 | Add Alert 76 | Data Saved 77 | Weather Alert 78 | Load From Last Known data 79 | Location Not enable 80 | Yes 81 | No 82 | you want to add this location to store as your location 83 | Enable 84 | To load the current weather data you have to enable location 85 | You are offline 86 | Are you Sure 87 | can\'t create alert at this time 88 | you want to add this location to favourite places 89 | \"Take care he Weather is \" 90 | Reputation daily 91 | 92 | 93 | thunderstorm 94 | drizzle 95 | rain 96 | snow 97 | clouds 98 | 99 | EXAMPLE 100 | Add widget 101 | Last Update 102 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 22 | 23 | 26 | 27 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/xml/weather_widget_info.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/release/res/values/google_maps_api.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | AIzaSyDgF3e8lPe84s1PZyleV7GDugnX72QamK8 20 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/kotlinproject/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.kotlinproject 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.30" 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "com.android.tools.build:gradle:4.1.2" 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EsraaFathy/Weather-Viewer-Android-Kotlin/794e732c5cc2655c6e07dcdc24a771d37071bd87/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Feb 22 21:49:54 EET 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | rootProject.name = "KotlinProject" --------------------------------------------------------------------------------