diff --git a/app/build.gradle b/app/build.gradle index 1c5fabd..3da3cf6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,36 +3,26 @@ apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android' android { - compileSdkVersion 28 - buildToolsVersion "28.0.3" + compileSdkVersion 29 + buildToolsVersion "29.0.1" defaultConfig { applicationId "fr.corenting.convertisseureurofranc" minSdkVersion 14 - targetSdkVersion 28 - versionCode 9 - versionName "2.0" + targetSdkVersion 29 + versionCode 10 + versionName "2.1" } - signingConfigs { - release { - try { - storeFile file(KEYSTORE_FILE) - storePassword KEYSTORE_PASSWORD - keyAlias KEY_ALIAS - keyPassword KEY_PASSWORD - } - catch (ex) { - throw ex - } - } + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 } buildTypes { release { minifyEnabled true shrinkResources true - signingConfig signingConfigs.release proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } @@ -40,8 +30,9 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.0.2' - implementation 'com.google.android.material:material:1.1.0-alpha03' + implementation 'androidx.core:core:1.0.2' + implementation 'androidx.preference:preference:1.0.0' + implementation 'com.google.android.material:material:1.0.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } diff --git a/app/src/main/java/fr/corenting/convertisseureurofranc/ConverterActivity.kt b/app/src/main/java/fr/corenting/convertisseureurofranc/ConverterActivity.kt index 352548d..8ce9d46 100644 --- a/app/src/main/java/fr/corenting/convertisseureurofranc/ConverterActivity.kt +++ b/app/src/main/java/fr/corenting/convertisseureurofranc/ConverterActivity.kt @@ -2,20 +2,18 @@ package fr.corenting.convertisseureurofranc import android.content.SharedPreferences import android.os.Bundle -import android.preference.PreferenceManager import android.view.KeyEvent import android.view.Menu import android.view.MenuItem import android.view.View import android.widget.* import androidx.appcompat.app.AppCompatActivity -import androidx.appcompat.app.AppCompatDelegate +import androidx.preference.PreferenceManager import fr.corenting.convertisseureurofranc.convert.ConvertAbstract import fr.corenting.convertisseureurofranc.convert.France import fr.corenting.convertisseureurofranc.convert.USA import fr.corenting.convertisseureurofranc.utils.Utils import kotlinx.android.synthetic.main.activity_converter.* -import java.util.* class ConverterActivity : AppCompatActivity() { @@ -25,10 +23,9 @@ class ConverterActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { // Dark theme prefs = PreferenceManager.getDefaultSharedPreferences(this) - if (prefs.getBoolean(getString(R.string.preferenceDarkThemeKey), false)) { - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) - } else { - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) + when { + prefs.getBoolean(getString(R.string.preferenceDarkThemeKey), false) -> setTheme(R.style.AppThemeDark) + else -> setTheme(R.style.AppTheme) } super.onCreate(savedInstanceState) setContentView(R.layout.activity_converter) @@ -41,8 +38,8 @@ class ConverterActivity : AppCompatActivity() { initButtons() //Set currency spinner content - val currenciesList = Arrays - .asList(getString(R.string.france_currencies), getString(R.string.usa_currencies)) + val currenciesList = listOf(getString(R.string.france_currencies), + getString(R.string.usa_currencies)) setSpinnerAdapter(currencySpinner, currenciesList) currencySpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>?, view: View?, pos: Int, id: Long) { @@ -82,14 +79,15 @@ class ConverterActivity : AppCompatActivity() { private fun initSpinners() { //Populate the spinners with a list of years - val yearsList = (converter.latestYear downTo converter.firstYear) - .mapTo(LinkedList()) { it.toString() } - setSpinnerAdapter(yearOfOriginSpinner!!, yearsList) - setSpinnerAdapter(yearOfResultSpinner!!, yearsList) + val yearsList = (converter.latestYear downTo converter.firstYear).toList().map { + it.toString() + } + setSpinnerAdapter(yearOfOriginSpinner, yearsList) + setSpinnerAdapter(yearOfResultSpinner, yearsList) //Add an onItemSelected listener to change the currency text according to the year - setSpinnerListener(yearOfOriginSpinner!!, currencyOriginTextView) - setSpinnerListener(yearOfResultSpinner!!, currencyResultTextView) + setSpinnerListener(yearOfOriginSpinner, currencyOriginTextView) + setSpinnerListener(yearOfResultSpinner, currencyResultTextView) } private fun initButtons() { @@ -100,7 +98,7 @@ class ConverterActivity : AppCompatActivity() { //Click button when using enter on the keyboard amountEditText.setOnKeyListener(View.OnKeyListener { _, _, event -> if (event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER) { - convertButton!!.performClick() + convertButton.performClick() return@OnKeyListener false } false @@ -131,12 +129,12 @@ class ConverterActivity : AppCompatActivity() { s.adapter = adapter } - private fun setSpinnerListener(spinner: Spinner, textView: TextView?) { + private fun setSpinnerListener(spinner: Spinner, textView: TextView) { spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>?, view: View?, pos: Int, id: Long) { if (parent != null) { val year = Integer.parseInt(parent.getItemAtPosition(pos).toString()) - textView!!.text = converter.getCurrencyFromYear(year) + textView.text = converter.getCurrencyFromYear(year) } } diff --git a/app/src/main/res/layout/activity_converter.xml b/app/src/main/res/layout/activity_converter.xml index aba7c5d..e5d4f77 100644 --- a/app/src/main/res/layout/activity_converter.xml +++ b/app/src/main/res/layout/activity_converter.xml @@ -1,7 +1,8 @@ + android:layout_height="wrap_content" + > + android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" /> + android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> + android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> + android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> + android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> #03a9f4 #0288d1 #448AFF + + #ff607d8b + #ff455a64 + #ffff5252 + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 00aa3e6..f50bfb3 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,7 +1,19 @@ - + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3ca9435..6834921 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.21' + ext.kotlin_version = '1.3.31' repositories { jcenter() google() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.1' + 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 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92f8868..096f492 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Feb 12 17:32:37 CET 2019 +#Mon Jul 15 22:20:38 CEST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip