Skip to content

Commit

Permalink
Version 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
corenting committed Sep 6, 2020
1 parent 188dc7b commit 655c6d6
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package fr.corenting.convertisseureurofranc

import android.content.Context
import android.widget.ArrayAdapter
import android.widget.Filter


class AutocompleteAdapter<T>(context: Context, resource: Int, objects: List<T>) :
ArrayAdapter<T>(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) {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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),
Expand All @@ -67,25 +66,39 @@ 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) {
converter = when (position) {
0 -> USAConverter(applicationContext)
else -> FranceConverter(applicationContext)
}
currentConverter = position
initYearInputs()
}

Expand Down Expand Up @@ -178,7 +191,7 @@ class ConverterActivity : AppCompatActivity() {
autoCompleteTextView: AutoCompleteTextView,
items: List<String>
) {
val adapter = ArrayAdapter(this, R.layout.list_item, items)
val adapter = AutocompleteAdapter(this, R.layout.list_item, items)
autoCompleteTextView.setAdapter(adapter)
}

Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/activity_converter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

Expand All @@ -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"
Expand Down Expand Up @@ -89,6 +86,7 @@
android:id="@+id/yearOfOriginAutoComplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="flagNoExtractUi"
android:inputType="none" />

</com.google.android.material.textfield.TextInputLayout>
Expand All @@ -108,6 +106,7 @@
android:id="@+id/yearOfResultAutoComplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="flagNoExtractUi"
android:inputType="none" />

</com.google.android.material.textfield.TextInputLayout>
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="yearOfOrigin">De (année)</string>
<string name="yearOfResult">Vers (année)</string>
<string name="convertButton">Convertir</string>
<string name="resultText">Résultat :</string>
<string name="resultText">Résultat (%1$s)</string>
<string name="actionAbout">À propos</string>
<string name="aboutText"><![CDATA[Le passage des anciens Francs aux nouveaux Francs s\'effectue automatiquement à partir de 1960.<br>Le passage des Francs à l\'Euro s\'effectue automatiquent à partir de 2002.<br><br>Une application créée par corenting.<br><a href="http://www.corenting.fr">Site web</a><br><br>Icône de billet par Dave Gandy de <a href="www.flaticon.com">www.flaticon.com</a>.<br><br>Version :&nbsp;]]></string>
<string name="errorToast">Erreur lors de la conversion !</string>
Expand All @@ -17,5 +17,7 @@
<string name="dollars">dollars</string>
<string name="currency">Devise</string>
<string name="no_amount_entered">Aucun montant entré</string>
<string name="usa_currencies">Dollars US (USD)</string>
<string name="france_currencies">Francs et Euros (FRF et EUR)</string>

</resources>
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<string name="oldFrancs">old francs</string>
<string name="dollars">dollars</string>
<string name="currency">Currency</string>
<string name="france_currencies" translatable="false">Francs and Euros (FRF and EUR)</string>
<string name="usa_currencies" translatable="false">US dollars (USD)</string>
<string name="france_currencies">Francs and Euros (FRF and EUR)</string>
<string name="usa_currencies">US dollars (USD)</string>
<string name="no_amount_entered">No amount entered</string>
</resources>
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/15.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New look
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions fastlane/metadata/android/fr-FR/changelogs/15.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Nouveau thème
Binary file modified fastlane/metadata/android/fr-FR/images/phoneScreenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/fr-FR/images/phoneScreenshots/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 655c6d6

Please sign in to comment.