diff --git a/app/build.gradle b/app/build.gradle index 28166e6..0443272 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "fr.corenting.convertisseureurofranc" minSdkVersion 17 targetSdkVersion 29 - versionCode 14 - versionName "2.5" + versionCode 15 + versionName "2.6" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/fr/corenting/convertisseureurofranc/AutoCompleteAdapter.kt b/app/src/main/java/fr/corenting/convertisseureurofranc/AutoCompleteAdapter.kt new file mode 100644 index 0000000..a3541b8 --- /dev/null +++ b/app/src/main/java/fr/corenting/convertisseureurofranc/AutoCompleteAdapter.kt @@ -0,0 +1,20 @@ +package fr.corenting.convertisseureurofranc + +import android.content.Context +import android.widget.ArrayAdapter +import android.widget.Filter + + +class AutocompleteAdapter(context: Context, resource: Int, objects: List) : + ArrayAdapter(context, resource, objects) { + + override fun getFilter(): Filter { + return object : Filter() { + override fun performFiltering(constraint: CharSequence): FilterResults { + return FilterResults() + } + + override fun publishResults(constraint: CharSequence, results: FilterResults) {} + } + } +} diff --git a/app/src/main/java/fr/corenting/convertisseureurofranc/ConverterActivity.kt b/app/src/main/java/fr/corenting/convertisseureurofranc/ConverterActivity.kt index 28e3c18..37fbce9 100644 --- a/app/src/main/java/fr/corenting/convertisseureurofranc/ConverterActivity.kt +++ b/app/src/main/java/fr/corenting/convertisseureurofranc/ConverterActivity.kt @@ -6,7 +6,6 @@ import android.view.KeyEvent import android.view.MenuItem import android.view.View import android.widget.AdapterView -import android.widget.ArrayAdapter import android.widget.AutoCompleteTextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity @@ -23,9 +22,16 @@ import java.util.* class ConverterActivity : AppCompatActivity() { + companion object { + private const val converterBundleKey = "converter" + } + lateinit var converter: ConverterAbstract private lateinit var prefs: SharedPreferences + // Save position for config change + private var currentConverter: Int = 0 + private fun handleDarkTheme() { // Dark theme prefs = PreferenceManager.getDefaultSharedPreferences(this) @@ -48,13 +54,6 @@ class ConverterActivity : AppCompatActivity() { setContentView(R.layout.activity_converter) topAppBar.setOnMenuItemClickListener(this::onMenuItemClickListener) - // Default converter - converter = USAConverter(applicationContext) - - //Initialize the years spinners and the buttons - initYearInputs() - initButtons() - //Set currency spinner content val currenciesList = listOf( getString(R.string.usa_currencies), @@ -67,18 +66,31 @@ class ConverterActivity : AppCompatActivity() { } // Set default currency - val currentLocale: Locale = ConfigurationCompat.getLocales(resources.configuration).get(0) - if (currentLocale == Locale.FRANCE) { - currencyAutoComplete.setText(getString(R.string.france_currencies), false) + if (savedInstanceState == null) { + val currentLocale: Locale = + ConfigurationCompat.getLocales(resources.configuration).get(0) + if (currentLocale == Locale.FRANCE) { + currencyAutoComplete.setText(getString(R.string.france_currencies), false) + onCurrencyItemClickListener(1) + } else { + currencyAutoComplete.setText(getString(R.string.usa_currencies), false) + onCurrencyItemClickListener(0) + } } else { - currencyAutoComplete.setText(getString(R.string.usa_currencies), false) + onCurrencyItemClickListener(savedInstanceState.getInt(converterBundleKey)) } + initButtons() if (prefs.getBoolean(getString(R.string.preferenceDarkThemeKey), false)) { topAppBar.menu.getItem(0).isChecked = true } + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + outState.putInt(converterBundleKey, currentConverter) } private fun onCurrencyItemClickListener(position: Int) { @@ -86,6 +98,7 @@ class ConverterActivity : AppCompatActivity() { 0 -> USAConverter(applicationContext) else -> FranceConverter(applicationContext) } + currentConverter = position initYearInputs() } @@ -178,7 +191,7 @@ class ConverterActivity : AppCompatActivity() { autoCompleteTextView: AutoCompleteTextView, items: List ) { - val adapter = ArrayAdapter(this, R.layout.list_item, items) + val adapter = AutocompleteAdapter(this, R.layout.list_item, items) autoCompleteTextView.setAdapter(adapter) } @@ -190,6 +203,7 @@ class ConverterActivity : AppCompatActivity() { autoCompleteTextView.onItemClickListener = AdapterView.OnItemClickListener { parent, _, position, _ -> if (parent != null) { + Utils.hideSoftKeyboard(parent) val year = Integer.parseInt(parent.getItemAtPosition(position).toString()) setCurrencyInputHint(textView, year, stringReference) } diff --git a/app/src/main/java/fr/corenting/convertisseureurofranc/utils/Utils.kt b/app/src/main/java/fr/corenting/convertisseureurofranc/utils/Utils.kt index 1bc6996..7db1a74 100644 --- a/app/src/main/java/fr/corenting/convertisseureurofranc/utils/Utils.kt +++ b/app/src/main/java/fr/corenting/convertisseureurofranc/utils/Utils.kt @@ -21,7 +21,7 @@ object Utils { fun hideSoftKeyboard(v: View): Boolean { val imm = v.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - return imm.hideSoftInputFromWindow(v.windowToken, 0) + return imm.hideSoftInputFromWindow(v.applicationWindowToken, 0) } fun showCredits(activity: Activity): AlertDialog { diff --git a/app/src/main/res/layout/activity_converter.xml b/app/src/main/res/layout/activity_converter.xml index b7d9838..c214e21 100644 --- a/app/src/main/res/layout/activity_converter.xml +++ b/app/src/main/res/layout/activity_converter.xml @@ -40,7 +40,6 @@ android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" android:hint="@string/currency" app:startIconDrawable="@drawable/cash"> @@ -59,9 +58,7 @@ android:layout_height="wrap_content" android:layout_below="@+id/currencyInput" android:layout_alignParentStart="true" - android:layout_alignParentLeft="true" android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" android:layout_marginTop="12dp" android:hint="@string/sumToConvert" app:errorEnabled="true" @@ -89,6 +86,7 @@ android:id="@+id/yearOfOriginAutoComplete" android:layout_width="match_parent" android:layout_height="wrap_content" + android:imeOptions="flagNoExtractUi" android:inputType="none" /> @@ -108,6 +106,7 @@ android:id="@+id/yearOfResultAutoComplete" android:layout_width="match_parent" android:layout_height="wrap_content" + android:imeOptions="flagNoExtractUi" android:inputType="none" /> diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index a0591c3..ab80659 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -6,7 +6,7 @@ De (année) Vers (année) Convertir - Résultat : + Résultat (%1$s) À propos Le passage des Francs à l\'Euro s\'effectue automatiquent à partir de 2002.

Une application créée par corenting.
Site web

Icône de billet par Dave Gandy de www.flaticon.com.

Version : ]]>
Erreur lors de la conversion ! @@ -17,5 +17,7 @@ dollars Devise Aucun montant entré + Dollars US (USD) + Francs et Euros (FRF et EUR) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a3c2155..ef2ef90 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -16,7 +16,7 @@ old francs dollars Currency - Francs and Euros (FRF and EUR) - US dollars (USD) + Francs and Euros (FRF and EUR) + US dollars (USD) No amount entered diff --git a/fastlane/metadata/android/en-US/changelogs/15.txt b/fastlane/metadata/android/en-US/changelogs/15.txt new file mode 100644 index 0000000..e0cde3e --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/15.txt @@ -0,0 +1 @@ +New look diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png index 9a033cc..bdf9e1a 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png index 6d019cf..c2b155e 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png differ diff --git a/fastlane/metadata/android/fr-FR/changelogs/15.txt b/fastlane/metadata/android/fr-FR/changelogs/15.txt new file mode 100644 index 0000000..95bdf16 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/15.txt @@ -0,0 +1 @@ +Nouveau thème diff --git a/fastlane/metadata/android/fr-FR/images/phoneScreenshots/1.png b/fastlane/metadata/android/fr-FR/images/phoneScreenshots/1.png index ed82548..167ee48 100644 Binary files a/fastlane/metadata/android/fr-FR/images/phoneScreenshots/1.png and b/fastlane/metadata/android/fr-FR/images/phoneScreenshots/1.png differ diff --git a/fastlane/metadata/android/fr-FR/images/phoneScreenshots/2.png b/fastlane/metadata/android/fr-FR/images/phoneScreenshots/2.png index 10e0ad1..e8912c1 100644 Binary files a/fastlane/metadata/android/fr-FR/images/phoneScreenshots/2.png and b/fastlane/metadata/android/fr-FR/images/phoneScreenshots/2.png differ