Skip to content

Commit

Permalink
Version 2.1 : bump SDK, Kotlin...
Browse files Browse the repository at this point in the history
  • Loading branch information
corenting committed Jul 15, 2019
1 parent df05218 commit a82ad49
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 49 deletions.
31 changes: 11 additions & 20 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,36 @@ 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'
}
}
}

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"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -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)
Expand All @@ -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) {
Expand Down Expand Up @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
}

Expand Down
13 changes: 7 additions & 6 deletions app/src/main/res/layout/activity_converter.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
>

<RelativeLayout
android:layout_width="wrap_content"
Expand All @@ -16,7 +17,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/currency"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" />

<Spinner
android:id="@+id/currencySpinner"
Expand All @@ -38,7 +39,7 @@
android:layout_below="@+id/currencyTextView"
android:layout_marginTop="12dp"
android:text="@string/sumToConvert"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

<EditText
android:id="@+id/amountEditText"
Expand Down Expand Up @@ -68,7 +69,7 @@
android:layout_below="@id/currencyOriginTextView"
android:layout_alignBaseline="@+id/yearOfOriginSpinner"
android:text="@string/yearOfOrigin"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

<Spinner
android:id="@+id/yearOfOriginSpinner"
Expand All @@ -90,7 +91,7 @@
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="@string/yearOfResult"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

<Spinner
android:id="@+id/yearOfResultSpinner"
Expand Down Expand Up @@ -121,7 +122,7 @@
android:layout_alignParentLeft="true"
android:layout_marginTop="24dp"
android:text="@string/resultText"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

<EditText
android:id="@+id/resultEditText"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
<item name="colorPrimary" type="color">#03a9f4</item>
<item name="colorPrimaryDark" type="color">#0288d1</item>
<item name="colorAccent" type="color">#448AFF</item>

<color name="darkPrimary">#ff607d8b</color>
<color name="darkPrimaryDark">#ff455a64</color>
<color name="darkAccent">#ffff5252</color>

</resources>
14 changes: 13 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
<resources>
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppThemeDark" parent="Theme.MaterialComponents">
<item name="colorPrimary">@color/darkPrimary</item>
<item name="colorPrimaryDark">@color/darkPrimaryDark</item>
<item name="colorAccent">@color/darkAccent</item>
<item name="actionBarTheme">@style/AppThemeDarkActionBar</item>
</style>

<style name="AppThemeDarkActionBar" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
</style>
</resources>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a82ad49

Please sign in to comment.