commit 5ac347336f8c0b1c23eb2c549087814435f3c613 Author: aminecmi Date: Sat Aug 3 23:26:08 2019 +0200 Initial commit with gitignore. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf934d2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,278 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild + + + + +# Created by https://www.gitignore.io/api/osx,gradle,kotlin,android,androidstudio +# Edit at https://www.gitignore.io/?templates=osx,gradle,kotlin,android,androidstudio + +### Android ### +# Built application files +*.apk +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +### Android Patch ### +gen-external-apklibs +output.json + +### Kotlin ### +# Compiled class file + +# Log file + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### OSX ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Gradle ### +.gradle + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +### Gradle Patch ### +**/build/ + +### AndroidStudio ### +# Covers files to be ignored for android development using Android Studio. + +# Built application files + +# Files for the ART/Dalvik VM + +# Java class files + +# Generated files + +# Gradle files + +# Signing files +.signing/ + +# Local configuration file (sdk path, etc) + +# Proguard folder generated by Eclipse + +# Log Files + +# Android Studio +/*/build/ +/*/local.properties +/*/out +/*/*/build +/*/*/production +*.ipr +*~ +*.swp + +# Android Patch + +# External native build folder generated in Android Studio 2.2 and later + +# NDK +obj/ + +# IntelliJ IDEA +*.iws +/out/ + +# User-specific configurations +.idea/caches/ +.idea/libraries/ +.idea/shelf/ +.idea/.name +.idea/compiler.xml +.idea/copyright/profiles_settings.xml +.idea/encodings.xml +.idea/misc.xml +.idea/scopes/scope_settings.xml +.idea/vcs.xml +.idea/jsLibraryMappings.xml +.idea/datasources.xml +.idea/dataSources.ids +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# OS-specific files +.DS_Store? +ehthumbs.db +Thumbs.db + +# Legacy Eclipse project files +.classpath +.project +.cproject +.settings/ + +# Mobile Tools for Java (J2ME) + +# Package Files # + +# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) + +## Plugin-specific files: + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Mongo Explorer plugin +.idea/mongoSettings.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### AndroidStudio Patch ### + +!/gradle/wrapper/gradle-wrapper.jar + +# End of https://www.gitignore.io/api/osx,gradle,kotlin,android,androidstudio + diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..1bec35e --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..d4e4a2f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,99 @@ +apply plugin: 'kotlin-kapt' + +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 28 + buildToolsVersion '28.0.3' + defaultConfig { + applicationId "bou.amine.apps.mteo" + minSdkVersion 22 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + + // Enabling multidex support. + multiDexEnabled true + lintOptions { + abortOnError true + disable 'InvalidPackage' + } + vectorDrawables.useSupportLibrary = true + + javaCompileOptions { + annotationProcessorOptions { + arguments = ["room.schemaLocation": + "$projectDir/schemas".toString()] + } + } + } + buildTypes { + all { + buildConfigField "String", "DARK_SKY_API_KEY", darkSkyApiKey + } + release { + minifyEnabled false + shrinkResources false + proguardFiles getDefaultProguardFile('proguard-android.txt'), + 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility = '1.8' + targetCompatibility = '1.8' + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + testImplementation 'junit:junit:4.13-beta-3' + androidTestImplementation 'androidx.test:runner:1.3.0-alpha02' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02' + + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + + implementation 'androidx.appcompat:appcompat:1.1.0-rc01' + implementation 'androidx.core:core-ktx:1.2.0-alpha02' + implementation "com.google.android.material:material:1.1.0-alpha09" + implementation "androidx.recyclerview:recyclerview:1.1.0-beta01" + implementation "androidx.legacy:legacy-support-v4:1.0.0" + implementation "androidx.vectordrawable:vectordrawable:1.1.0-rc01" + implementation "androidx.cardview:cardview:1.0.0" + implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' + + // Retrofit + http logging + okhttp + implementation 'com.squareup.retrofit2:retrofit:2.6.1' + implementation 'com.squareup.retrofit2:converter-gson:2.6.1' + + // glide + implementation 'com.github.bumptech.glide:glide:4.1.1' + implementation 'com.github.bumptech.glide:okhttp3-integration:4.1.1' + + implementation "androidx.lifecycle:lifecycle-livedata:2.2.0-alpha02" + implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0-alpha02" + + implementation "androidx.room:room-runtime:2.2.0-alpha01" + kapt "androidx.room:room-compiler:2.2.0-alpha01" + + implementation "android.arch.work:work-runtime-ktx:1.0.1" +} + + +afterEvaluate { + initApiPropertiesIfNeeded() +} + +def initApiPropertiesIfNeeded() { + def propertiesFile = file(System.getProperty("user.home") + '/.gradle/gradle.properties') + if (!propertiesFile.exists()) { + def commentMessage = "This is autogenerated local property from system environment to prevent key to be committed to source control." + ant.propertyfile(file: System.getProperty("user.home") + "/.gradle/gradle.properties", comment: commentMessage) { + entry(key: "darkSkyApiKey", value: System.getProperty("darkSkyApiKey")) + } + } +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..0b3ee7b --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,65 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/amine/apps/android-sdk-linux/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile + +#About libraries +-keep class .R +-keep class **.R$* { + ; +} + +-dontwarn okio.** +-dontwarn retrofit2.Platform$Java8 +-keep class retrofit.** { *; } +-keepclasseswithmembers class * { + @retrofit.http.* ; +} +-keepattributes *Annotation*,Signature +-keepattributes Exceptions +-dontwarn okio.** +-dontwarn javax.annotation.Nullable +-dontwarn javax.annotation.ParametersAreNonnullByDefault + + +#Bottom bar lib +-dontwarn com.roughike.bottombar.** + + +# self signed glidemodule +-keep public class * implements com.bumptech.glide.module.GlideModule +-keep public class * extends com.bumptech.glide.AppGlideModule +-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** { + **[] $VALUES; + public *; +} + +-dontwarn com.anupcowkur.reservoir.** + +-dontwarn javax.annotation.** + +-keep class android.support.v7.widget.SearchView { *; } + +# maybe remove later ? +-keep class * extends androidx.fragment.app.Fragment diff --git a/app/schemas/bou.amine.apps.mteo.persistence.database.AppDatabase/1.json b/app/schemas/bou.amine.apps.mteo.persistence.database.AppDatabase/1.json new file mode 100644 index 0000000..cd52735 --- /dev/null +++ b/app/schemas/bou.amine.apps.mteo.persistence.database.AppDatabase/1.json @@ -0,0 +1,46 @@ +{ + "formatVersion": 1, + "database": { + "version": 1, + "identityHash": "69f863b8cb6ddde56af1b6bd00a9bb36", + "entities": [ + { + "tableName": "locations", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `lat` REAL NOT NULL, `lng` REAL NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "lng", + "columnName": "lng", + "affinity": "REAL", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '69f863b8cb6ddde56af1b6bd00a9bb36')" + ] + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/bou/amine/apps/mteo/ExampleInstrumentedTest.kt b/app/src/androidTest/java/bou/amine/apps/mteo/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..657737c --- /dev/null +++ b/app/src/androidTest/java/bou/amine/apps/mteo/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package bou.amine.apps.mteo + +import androidx.test.InstrumentationRegistry +import androidx.test.runner.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getTargetContext() + assertEquals("bou.amine.apps.mteo", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f7cee6a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/bou/amine/apps/mteo/MainActivity.kt b/app/src/main/java/bou/amine/apps/mteo/MainActivity.kt new file mode 100644 index 0000000..8f12938 --- /dev/null +++ b/app/src/main/java/bou/amine/apps/mteo/MainActivity.kt @@ -0,0 +1,143 @@ +package bou.amine.apps.mteo + +import android.Manifest +import android.content.pm.PackageManager +import android.location.Location +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.location.LocationListener +import android.location.LocationManager +import android.widget.Toast +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat +import androidx.room.Room +import bou.amine.apps.mteo.api.DarkSkyApi +import bou.amine.apps.mteo.api.ForecastResponse +import bou.amine.apps.mteo.persistence.database.AppDatabase +import bou.amine.apps.mteo.persistence.entities.LocationView +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import kotlin.concurrent.thread + + +class MainActivity : AppCompatActivity() { + private val PERM_LOCATION = 101 + private lateinit var db: AppDatabase + private lateinit var api: DarkSkyApi + + private lateinit var currentLocation: LocationView + + override fun onCreate(savedInstanceState: Bundle?) { + + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + api = DarkSkyApi(this@MainActivity) + + db = Room.databaseBuilder( + applicationContext, + AppDatabase::class.java, "mteo-database" + ).build() + + thread { + val locations = db.locationDao().locations() + runOnUiThread { + if (locations.isEmpty()) { + checkPermission() + } else { + currentLocation = locations[0] + fetchForecastData() + } + } + } + } + + private fun fetchForecastData() { + thread { + api.forecast(currentLocation.lat.toString(), currentLocation.lng.toString()).enqueue(object : + Callback { + override fun onFailure(call: Call, t: Throwable) { + Toast.makeText(this@MainActivity, "Can't fetch forecast data !", Toast.LENGTH_LONG).show() + } + + override fun onResponse(call: Call, response: Response) { + Toast.makeText(this@MainActivity, "Ok", Toast.LENGTH_LONG).show() + } + + }) + } + } + + private fun checkPermission() { + if (ContextCompat.checkSelfPermission( + this@MainActivity, + Manifest.permission.ACCESS_FINE_LOCATION + ) + != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission( + this@MainActivity, + Manifest.permission.ACCESS_COARSE_LOCATION + ) + != PackageManager.PERMISSION_GRANTED + ) { + ActivityCompat.requestPermissions( + this@MainActivity, + arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION), + PERM_LOCATION + ) + } else { + handleLocationChange() + } + } + + private fun handleLocationChange() { + val mLocationManager = getSystemService(LOCATION_SERVICE) as LocationManager + + val mLocationListener = object : LocationListener { + override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) { + Toast.makeText(this@MainActivity, "status", Toast.LENGTH_SHORT).show() + } + + override fun onProviderEnabled(provider: String?) { + Toast.makeText(this@MainActivity, "enabled", Toast.LENGTH_SHORT).show() + } + + override fun onProviderDisabled(provider: String?) { + Toast.makeText(this@MainActivity, "disabled", Toast.LENGTH_SHORT).show() + } + + override fun onLocationChanged(location: Location) { + Toast.makeText(this@MainActivity, "location", Toast.LENGTH_SHORT).show() + mLocationManager.removeUpdates(this) + currentLocation = LocationView(location.latitude, location.longitude) + fetchForecastData() + thread { + db.locationDao().insertLocation(currentLocation) + } + } + } + + mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 10F, mLocationListener) + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, grantResults: IntArray + ) { + when (requestCode) { + PERM_LOCATION -> { + // If request is cancelled, the result arrays are empty. + if ((grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)) { + handleLocationChange() + } + return + } + + // Add other 'when' lines to check for other + // permissions this app might request. + else -> { + // Ignore all other requests. + } + } + } +} diff --git a/app/src/main/java/bou/amine/apps/mteo/api/DarkSkyApi.kt b/app/src/main/java/bou/amine/apps/mteo/api/DarkSkyApi.kt new file mode 100644 index 0000000..ad1405c --- /dev/null +++ b/app/src/main/java/bou/amine/apps/mteo/api/DarkSkyApi.kt @@ -0,0 +1,78 @@ +package bou.amine.apps.mteo.api + +import android.content.Context +import android.net.ConnectivityManager +import android.net.NetworkInfo +import bou.amine.apps.mteo.BuildConfig +import com.google.gson.GsonBuilder +import okhttp3.Cache +import retrofit2.Call +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import okhttp3.OkHttpClient + + +class DarkSkyApi(private val c: Context) { + + private var service: DarkSkyService + + + init { + val cacheSize = (5 * 1024 * 1024).toLong() + val cache = Cache(c.cacheDir, cacheSize) + + val okHttpClient = OkHttpClient.Builder() + .cache(cache) + .addInterceptor { chain -> + var request = chain.request() + request = if (hasNetwork(c)!!) { + /* + * If there is Internet, get the cache that was stored 2 minutes ago. + * If the cache is older than 2 minutes, then discard it, + * and indicate an error in fetching the response. + * The 'max-age' attribute is responsible for this behavior. + */ + request.newBuilder().header("Cache-Control", "public, max-age=" + (2 * 60)).build() + } else { + /* + * If there is no Internet, get the cache that was stored 7 days ago. + * If the cache is older than 7 days, then discard it, + * and indicate an error in fetching the response. + * The 'max-stale' attribute is responsible for this behavior. + * The 'only-if-cached' attribute indicates to not retrieve new data; fetch the cache only instead. + */ + request.newBuilder() + .header("Cache-Control", "public, only-if-cached, max-stale=" + (60 * 60 * 24 * 7)).build() + } + chain.proceed(request) + } + .build() + + val gson = + GsonBuilder() + .setLenient() + .create() + + + val retrofit = + Retrofit + .Builder() + .baseUrl("https://api.darksky.net/") + .client(okHttpClient) + .addConverterFactory(GsonConverterFactory.create(gson)) + .build() + service = retrofit.create(DarkSkyService::class.java) + } + + fun forecast(lat: String, lng: String): Call = + service.forecast(BuildConfig.DARK_SKY_API_KEY, lat, lng, "fr", listOf("ca")) + + private fun hasNetwork(context: Context): Boolean? { + var isConnected: Boolean? = false // Initial Value + val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + val activeNetwork: NetworkInfo? = connectivityManager.activeNetworkInfo + if (activeNetwork != null && activeNetwork.isConnected) + isConnected = true + return isConnected + } +} \ No newline at end of file diff --git a/app/src/main/java/bou/amine/apps/mteo/api/DarkSkyModels.kt b/app/src/main/java/bou/amine/apps/mteo/api/DarkSkyModels.kt new file mode 100644 index 0000000..86e21a6 --- /dev/null +++ b/app/src/main/java/bou/amine/apps/mteo/api/DarkSkyModels.kt @@ -0,0 +1,90 @@ +package bou.amine.apps.mteo.api + +import com.google.gson.annotations.SerializedName + +data class ForecastResponse( + @SerializedName("latitude") val latitude: Double, + @SerializedName("longitude") val longitude: Double, + @SerializedName("timezone") val timezone: String, + @SerializedName("currently") val currently: Datapoint?, + @SerializedName("minutely") val minutely: Datablock?, + @SerializedName("hourly") val hourly: Datablock?, + @SerializedName("daily") val daily: Datablock?, + @SerializedName("flags") val flags: Flags?, + @SerializedName("alerts") val alerts: List?, + @SerializedName("offset") val offset: Int? +) + + +data class Flags( + @SerializedName("sources") val sources: List, + @SerializedName("nearest-station") val nearestStation: Double, + @SerializedName("units") val units: String, + @SerializedName("darksky-unavailable") val darkskyUnavailable: String? +) + +data class Datablock( + @SerializedName("icon") val icon: String?, + @SerializedName("summary") val summary: String?, + @SerializedName("data") val data: List +) + + + +data class Datapoint( + @SerializedName("time") val time: Double, + @SerializedName("summary") val summary: String?, + @SerializedName("icon") val icon: String?, + @SerializedName("apparentTemperature") val apparentTemperature: Double?, // hourly + @SerializedName("apparentTemperatureHigh") val apparentTemperatureHigh: Double?, // daily + @SerializedName("apparentTemperatureHighTime") val apparentTemperatureHighTime: Double?, // daily + @SerializedName("apparentTemperatureLow") val apparentTemperatureLow: Double?, // daily + @SerializedName("apparentTemperatureLowTime") val apparentTemperatureLowTime: Double?, // daily + @SerializedName("apparentTemperatureMax") val apparentTemperatureMax: Double?, // daily + @SerializedName("apparentTemperatureMaxTime") val apparentTemperatureMaxTime: Double?, // daily + @SerializedName("apparentTemperatureMin") val apparentTemperatureMin: Double?, // daily + @SerializedName("apparentTemperatureMinTime") val apparentTemperatureMinTime: Double?, // daily + @SerializedName("cloudCover") val cloudCover: Double?, + @SerializedName("dewPoint") val dewPoint: Double?, + @SerializedName("humidity") val humidity: Double?, + @SerializedName("moonPhase") val moonPhase: Double?, // daily + @SerializedName("nearestStormBearing") val nearestStormBearing: Double?, // currently + @SerializedName("nearestStormDistance") val nearestStormDistance: Double?, // currently + @SerializedName("ozone") val ozone: Double?, + @SerializedName("precipAccumulation") val precipAccumulation: Double?, // hourly + daily + @SerializedName("precipIntensity") val precipIntensity: Double?, + @SerializedName("precipIntensityError") val precipIntensityError: Double?, + @SerializedName("precipIntensityMax") val precipIntensityMax: Double?, // daily + @SerializedName("precipIntensityMaxTime") val precipIntensityMaxTime: Double?, // daily + @SerializedName("precipProbability") val precipProbability: Double?, + @SerializedName("precipType") val precipType: String?, + @SerializedName("pressure") val pressure: String?, + @SerializedName("sunriseTime") val sunriseTime: Double?, // daily + @SerializedName("sunsetTime") val sunsetTime: Double?, // daily + @SerializedName("temperature") val temperature: Double?, // hourly + @SerializedName("temperatureHigh") val temperatureHigh: Double?, // daily + @SerializedName("temperatureHighTime") val temperatureHighTime: Double?, // daily + @SerializedName("temperatureLow") val temperatureLow: Double?, // daily + @SerializedName("temperatureLowTime") val temperatureLowTime: Double?, // daily + @SerializedName("temperatureMax") val temperatureMax: Double?, // daily + @SerializedName("temperatureMaxTime") val temperatureMaxTime: Double?, // daily + @SerializedName("temperatureMin") val temperatureMin: Double?, // daily + @SerializedName("temperatureMinTime") val temperatureMinTime: Double?, // daily + @SerializedName("uvIndex") val uvIndex: Int?, + @SerializedName("uvIndexTime") val uvIndexTime: Double?, // daily + @SerializedName("visibility") val visibility: Double?, + @SerializedName("windBearing") val windBearing: Double?, + @SerializedName("windGust") val windGust: Double?, + @SerializedName("windGustTime") val windGustTime: Double?, // daily + @SerializedName("windSpeed") val windSpeed: Double? +) + +data class Alert( + @SerializedName("description") val description: String, + @SerializedName("expired") val expired: Double, + @SerializedName("regions") val regions: List, + @SerializedName("severity") val severity: String, + @SerializedName("time") val time: Double, + @SerializedName("title") val title: String, + @SerializedName("uri") val uri: String +) \ No newline at end of file diff --git a/app/src/main/java/bou/amine/apps/mteo/api/DarkSkyService.kt b/app/src/main/java/bou/amine/apps/mteo/api/DarkSkyService.kt new file mode 100644 index 0000000..47d6da0 --- /dev/null +++ b/app/src/main/java/bou/amine/apps/mteo/api/DarkSkyService.kt @@ -0,0 +1,19 @@ +package bou.amine.apps.mteo.api + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Path +import retrofit2.http.Query + +internal interface DarkSkyService { + + // https://api.darksky.net/forecast/[key]/[latitude],[longitude] + @GET("forecast/{apiKey}/{lat},{lng}") + fun forecast( + @Path("apiKey") apiKey: String, + @Path("lat") lat: String, + @Path("lng") lng: String, + @Query("lang") lang: String, + @Query("units") units: List + ): Call +} \ No newline at end of file diff --git a/app/src/main/java/bou/amine/apps/mteo/persistence/dao/LocationsDao.kt b/app/src/main/java/bou/amine/apps/mteo/persistence/dao/LocationsDao.kt new file mode 100644 index 0000000..2b28c57 --- /dev/null +++ b/app/src/main/java/bou/amine/apps/mteo/persistence/dao/LocationsDao.kt @@ -0,0 +1,16 @@ +package bou.amine.apps.mteo.persistence.dao + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import bou.amine.apps.mteo.persistence.entities.LocationView + +@Dao +interface LocationsDao { + @Query("SELECT * FROM locations order by id asc") + fun locations(): List + + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insertLocation(vararg location: LocationView) +} \ No newline at end of file diff --git a/app/src/main/java/bou/amine/apps/mteo/persistence/database/AppDatabase.kt b/app/src/main/java/bou/amine/apps/mteo/persistence/database/AppDatabase.kt new file mode 100644 index 0000000..6244ed6 --- /dev/null +++ b/app/src/main/java/bou/amine/apps/mteo/persistence/database/AppDatabase.kt @@ -0,0 +1,11 @@ +package bou.amine.apps.mteo.persistence.database + +import androidx.room.Database +import androidx.room.RoomDatabase +import bou.amine.apps.mteo.persistence.dao.LocationsDao +import bou.amine.apps.mteo.persistence.entities.LocationView + +@Database(entities = [LocationView::class], version = 1) +abstract class AppDatabase : RoomDatabase() { + abstract fun locationDao(): LocationsDao +} \ No newline at end of file diff --git a/app/src/main/java/bou/amine/apps/mteo/persistence/entities/LocationView.kt b/app/src/main/java/bou/amine/apps/mteo/persistence/entities/LocationView.kt new file mode 100644 index 0000000..094895b --- /dev/null +++ b/app/src/main/java/bou/amine/apps/mteo/persistence/entities/LocationView.kt @@ -0,0 +1,16 @@ +package bou.amine.apps.mteo.persistence.entities + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey + +@Entity(tableName = "locations") +data class LocationView( + @ColumnInfo(name = "lat") + val lat: Double, + @ColumnInfo(name = "lng") + val lng: Double +) { + @PrimaryKey(autoGenerate = true) + var id: Int = 0 +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..6348baa --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_cloud.xml b/app/src/main/res/drawable/ic_cloud.xml new file mode 100644 index 0000000..7827443 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_download.xml b/app/src/main/res/drawable/ic_cloud_download.xml new file mode 100644 index 0000000..accb221 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_download.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_drizzle.xml b/app/src/main/res/drawable/ic_cloud_drizzle.xml new file mode 100644 index 0000000..77362e0 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_drizzle.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_drizzle_alt.xml b/app/src/main/res/drawable/ic_cloud_drizzle_alt.xml new file mode 100644 index 0000000..a8f0b2d --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_drizzle_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_drizzle_moon.xml b/app/src/main/res/drawable/ic_cloud_drizzle_moon.xml new file mode 100644 index 0000000..e1c5227 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_drizzle_moon.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_drizzle_moon_alt.xml b/app/src/main/res/drawable/ic_cloud_drizzle_moon_alt.xml new file mode 100644 index 0000000..5b00e84 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_drizzle_moon_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_drizzle_sun.xml b/app/src/main/res/drawable/ic_cloud_drizzle_sun.xml new file mode 100644 index 0000000..47ed013 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_drizzle_sun.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_drizzle_sun_alt.xml b/app/src/main/res/drawable/ic_cloud_drizzle_sun_alt.xml new file mode 100644 index 0000000..8a324a5 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_drizzle_sun_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_fog.xml b/app/src/main/res/drawable/ic_cloud_fog.xml new file mode 100644 index 0000000..a128c4b --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_fog.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_fog_alt.xml b/app/src/main/res/drawable/ic_cloud_fog_alt.xml new file mode 100644 index 0000000..64a3a19 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_fog_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_fog_moon.xml b/app/src/main/res/drawable/ic_cloud_fog_moon.xml new file mode 100644 index 0000000..5c45903 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_fog_moon.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_fog_moon_alt.xml b/app/src/main/res/drawable/ic_cloud_fog_moon_alt.xml new file mode 100644 index 0000000..4844ecc --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_fog_moon_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_fog_sun.xml b/app/src/main/res/drawable/ic_cloud_fog_sun.xml new file mode 100644 index 0000000..c6f431b --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_fog_sun.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_fog_sun_alt.xml b/app/src/main/res/drawable/ic_cloud_fog_sun_alt.xml new file mode 100644 index 0000000..6578670 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_fog_sun_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_hail.xml b/app/src/main/res/drawable/ic_cloud_hail.xml new file mode 100644 index 0000000..e2e19a4 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_hail.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_hail_alt.xml b/app/src/main/res/drawable/ic_cloud_hail_alt.xml new file mode 100644 index 0000000..55b8aff --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_hail_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_hail_moon.xml b/app/src/main/res/drawable/ic_cloud_hail_moon.xml new file mode 100644 index 0000000..93b9aa9 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_hail_moon.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_hail_moon_alt.xml b/app/src/main/res/drawable/ic_cloud_hail_moon_alt.xml new file mode 100644 index 0000000..9c234bf --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_hail_moon_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_hail_sun.xml b/app/src/main/res/drawable/ic_cloud_hail_sun.xml new file mode 100644 index 0000000..c88ad13 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_hail_sun.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_hail_sun_alt.xml b/app/src/main/res/drawable/ic_cloud_hail_sun_alt.xml new file mode 100644 index 0000000..ae72ef6 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_hail_sun_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_lightning.xml b/app/src/main/res/drawable/ic_cloud_lightning.xml new file mode 100644 index 0000000..764511b --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_lightning.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_lightning_moon.xml b/app/src/main/res/drawable/ic_cloud_lightning_moon.xml new file mode 100644 index 0000000..421edaa --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_lightning_moon.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_lightning_sun.xml b/app/src/main/res/drawable/ic_cloud_lightning_sun.xml new file mode 100644 index 0000000..62936ab --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_lightning_sun.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_moon.xml b/app/src/main/res/drawable/ic_cloud_moon.xml new file mode 100644 index 0000000..9b8992f --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_moon.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_rain.xml b/app/src/main/res/drawable/ic_cloud_rain.xml new file mode 100644 index 0000000..3bb3cbb --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_rain.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_rain_alt.xml b/app/src/main/res/drawable/ic_cloud_rain_alt.xml new file mode 100644 index 0000000..3606b92 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_rain_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_rain_moon.xml b/app/src/main/res/drawable/ic_cloud_rain_moon.xml new file mode 100644 index 0000000..1b51737 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_rain_moon.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_rain_moon_alt.xml b/app/src/main/res/drawable/ic_cloud_rain_moon_alt.xml new file mode 100644 index 0000000..ff7e86d --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_rain_moon_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_rain_sun.xml b/app/src/main/res/drawable/ic_cloud_rain_sun.xml new file mode 100644 index 0000000..0e9b7a2 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_rain_sun.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_rain_sun_alt.xml b/app/src/main/res/drawable/ic_cloud_rain_sun_alt.xml new file mode 100644 index 0000000..65951ec --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_rain_sun_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_refresh.xml b/app/src/main/res/drawable/ic_cloud_refresh.xml new file mode 100644 index 0000000..c7406ea --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_refresh.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_snow.xml b/app/src/main/res/drawable/ic_cloud_snow.xml new file mode 100644 index 0000000..24c69a4 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_snow.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_snow_alt.xml b/app/src/main/res/drawable/ic_cloud_snow_alt.xml new file mode 100644 index 0000000..7d64d5b --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_snow_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_snow_moon.xml b/app/src/main/res/drawable/ic_cloud_snow_moon.xml new file mode 100644 index 0000000..a4c28ec --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_snow_moon.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_snow_moon_alt.xml b/app/src/main/res/drawable/ic_cloud_snow_moon_alt.xml new file mode 100644 index 0000000..736335a --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_snow_moon_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_snow_sun.xml b/app/src/main/res/drawable/ic_cloud_snow_sun.xml new file mode 100644 index 0000000..a5d0cea --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_snow_sun.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_snow_sun_alt.xml b/app/src/main/res/drawable/ic_cloud_snow_sun_alt.xml new file mode 100644 index 0000000..63e4277 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_snow_sun_alt.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_upload.xml b/app/src/main/res/drawable/ic_cloud_upload.xml new file mode 100644 index 0000000..c76baae --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_upload.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_wind.xml b/app/src/main/res/drawable/ic_cloud_wind.xml new file mode 100644 index 0000000..dc0a20d --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_wind.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_wind_moon.xml b/app/src/main/res/drawable/ic_cloud_wind_moon.xml new file mode 100644 index 0000000..11e85e5 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_wind_moon.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud_wind_sun.xml b/app/src/main/res/drawable/ic_cloud_wind_sun.xml new file mode 100644 index 0000000..e1a9a5d --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_wind_sun.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_compass.xml b/app/src/main/res/drawable/ic_compass.xml new file mode 100644 index 0000000..c35ebbe --- /dev/null +++ b/app/src/main/res/drawable/ic_compass.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_compass_east.xml b/app/src/main/res/drawable/ic_compass_east.xml new file mode 100644 index 0000000..e7d8566 --- /dev/null +++ b/app/src/main/res/drawable/ic_compass_east.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_compass_north.xml b/app/src/main/res/drawable/ic_compass_north.xml new file mode 100644 index 0000000..04e89a0 --- /dev/null +++ b/app/src/main/res/drawable/ic_compass_north.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_compass_south.xml b/app/src/main/res/drawable/ic_compass_south.xml new file mode 100644 index 0000000..947e0c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_compass_south.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_compass_west.xml b/app/src/main/res/drawable/ic_compass_west.xml new file mode 100644 index 0000000..f645992 --- /dev/null +++ b/app/src/main/res/drawable/ic_compass_west.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_degrees_celcius.xml b/app/src/main/res/drawable/ic_degrees_celcius.xml new file mode 100644 index 0000000..8b62636 --- /dev/null +++ b/app/src/main/res/drawable/ic_degrees_celcius.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_degrees_fahrenheit.xml b/app/src/main/res/drawable/ic_degrees_fahrenheit.xml new file mode 100644 index 0000000..bd8a091 --- /dev/null +++ b/app/src/main/res/drawable/ic_degrees_fahrenheit.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..a0ad202 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_moon.xml b/app/src/main/res/drawable/ic_moon.xml new file mode 100644 index 0000000..769cb86 --- /dev/null +++ b/app/src/main/res/drawable/ic_moon.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_moon_first_quarter.xml b/app/src/main/res/drawable/ic_moon_first_quarter.xml new file mode 100644 index 0000000..cf295db --- /dev/null +++ b/app/src/main/res/drawable/ic_moon_first_quarter.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_moon_full.xml b/app/src/main/res/drawable/ic_moon_full.xml new file mode 100644 index 0000000..616b3bc --- /dev/null +++ b/app/src/main/res/drawable/ic_moon_full.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_moon_last_quarter.xml b/app/src/main/res/drawable/ic_moon_last_quarter.xml new file mode 100644 index 0000000..90dccfe --- /dev/null +++ b/app/src/main/res/drawable/ic_moon_last_quarter.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_moon_new.xml b/app/src/main/res/drawable/ic_moon_new.xml new file mode 100644 index 0000000..8258e86 --- /dev/null +++ b/app/src/main/res/drawable/ic_moon_new.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_moon_waning_crescent.xml b/app/src/main/res/drawable/ic_moon_waning_crescent.xml new file mode 100644 index 0000000..106e67f --- /dev/null +++ b/app/src/main/res/drawable/ic_moon_waning_crescent.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_moon_waning_gibbous.xml b/app/src/main/res/drawable/ic_moon_waning_gibbous.xml new file mode 100644 index 0000000..2924183 --- /dev/null +++ b/app/src/main/res/drawable/ic_moon_waning_gibbous.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_moon_waxing_crescent.xml b/app/src/main/res/drawable/ic_moon_waxing_crescent.xml new file mode 100644 index 0000000..d1bfefe --- /dev/null +++ b/app/src/main/res/drawable/ic_moon_waxing_crescent.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_moon_waxing_gibbous.xml b/app/src/main/res/drawable/ic_moon_waxing_gibbous.xml new file mode 100644 index 0000000..3a6ae9f --- /dev/null +++ b/app/src/main/res/drawable/ic_moon_waxing_gibbous.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_shades.xml b/app/src/main/res/drawable/ic_shades.xml new file mode 100644 index 0000000..4d1bac9 --- /dev/null +++ b/app/src/main/res/drawable/ic_shades.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_snowflake.xml b/app/src/main/res/drawable/ic_snowflake.xml new file mode 100644 index 0000000..30c8570 --- /dev/null +++ b/app/src/main/res/drawable/ic_snowflake.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_sun.xml b/app/src/main/res/drawable/ic_sun.xml new file mode 100644 index 0000000..b332a4b --- /dev/null +++ b/app/src/main/res/drawable/ic_sun.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_sun_low.xml b/app/src/main/res/drawable/ic_sun_low.xml new file mode 100644 index 0000000..1905acc --- /dev/null +++ b/app/src/main/res/drawable/ic_sun_low.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_sun_lower.xml b/app/src/main/res/drawable/ic_sun_lower.xml new file mode 100644 index 0000000..35aa94d --- /dev/null +++ b/app/src/main/res/drawable/ic_sun_lower.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_sunrise.xml b/app/src/main/res/drawable/ic_sunrise.xml new file mode 100644 index 0000000..7d1528d --- /dev/null +++ b/app/src/main/res/drawable/ic_sunrise.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_sunset.xml b/app/src/main/res/drawable/ic_sunset.xml new file mode 100644 index 0000000..491237c --- /dev/null +++ b/app/src/main/res/drawable/ic_sunset.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_thermometer.xml b/app/src/main/res/drawable/ic_thermometer.xml new file mode 100644 index 0000000..b9e42c4 --- /dev/null +++ b/app/src/main/res/drawable/ic_thermometer.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_thermometer_100.xml b/app/src/main/res/drawable/ic_thermometer_100.xml new file mode 100644 index 0000000..aed1508 --- /dev/null +++ b/app/src/main/res/drawable/ic_thermometer_100.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_thermometer_25.xml b/app/src/main/res/drawable/ic_thermometer_25.xml new file mode 100644 index 0000000..44c6792 --- /dev/null +++ b/app/src/main/res/drawable/ic_thermometer_25.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_thermometer_50.xml b/app/src/main/res/drawable/ic_thermometer_50.xml new file mode 100644 index 0000000..042aa32 --- /dev/null +++ b/app/src/main/res/drawable/ic_thermometer_50.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_thermometer_75.xml b/app/src/main/res/drawable/ic_thermometer_75.xml new file mode 100644 index 0000000..a86c8e9 --- /dev/null +++ b/app/src/main/res/drawable/ic_thermometer_75.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_thermometer_zero.xml b/app/src/main/res/drawable/ic_thermometer_zero.xml new file mode 100644 index 0000000..76c2327 --- /dev/null +++ b/app/src/main/res/drawable/ic_thermometer_zero.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_tornado.xml b/app/src/main/res/drawable/ic_tornado.xml new file mode 100644 index 0000000..50b7434 --- /dev/null +++ b/app/src/main/res/drawable/ic_tornado.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_umbrella.xml b/app/src/main/res/drawable/ic_umbrella.xml new file mode 100644 index 0000000..d1cbc4f --- /dev/null +++ b/app/src/main/res/drawable/ic_umbrella.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_wind.xml b/app/src/main/res/drawable/ic_wind.xml new file mode 100644 index 0000000..d05e42e --- /dev/null +++ b/app/src/main/res/drawable/ic_wind.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..716af5a --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..bbd3e02 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..bbd3e02 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..898f3ed Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..dffca36 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..64ba76f Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..dae5e08 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..e5ed465 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..14ed0af Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b0907ca Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..d8ae031 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..2c18de9 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..beed3cd Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..69b2233 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #008577 + #00574B + #D81B60 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..0e641c5 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Mteo + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..5885930 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/app/src/test/java/bou/amine/apps/mteo/ExampleUnitTest.kt b/app/src/test/java/bou/amine/apps/mteo/ExampleUnitTest.kt new file mode 100644 index 0000000..b4f8cb0 --- /dev/null +++ b/app/src/test/java/bou/amine/apps/mteo/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package bou.amine.apps.mteo + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..1fb910c --- /dev/null +++ b/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.41' + repositories { + google() + jcenter() + + } + dependencies { + classpath 'com.android.tools.build:gradle:3.4.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} + +project.ext.preDexLibs = !project.hasProperty('disablePreDex') diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..68f2754 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,23 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +org.gradle.caching=true +android.enableD8=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..8969e12 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Aug 03 13:12:38 CEST 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..e95643d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app'