Skip to content

Commit

Permalink
Merge pull request #152 from corenting/feat/update-theme
Browse files Browse the repository at this point in the history
feat: update theme
  • Loading branch information
corenting authored Nov 23, 2022
2 parents 87e9c1f + 5d23137 commit 1c124e1
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 59 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ apply plugin: 'kotlin-android'

android {
compileSdkVersion 33
buildToolsVersion "33.0.0"
buildToolsVersion "33.0.1"

defaultConfig {
applicationId "fr.corenting.convertisseureurofranc"
minSdkVersion 17
targetSdkVersion 33
versionCode 20
versionName "2.11"
versionCode 21
versionName "2.12"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.widget.Toolbar
import androidx.core.widget.doOnTextChanged
import fr.corenting.convertisseureurofranc.converters.ConverterAbstract
import fr.corenting.convertisseureurofranc.converters.FranceConverter
Expand All @@ -31,6 +32,10 @@ class ConverterActivity : AppCompatActivity() {
AppCompatDelegate.setDefaultNightMode(ThemeUtils.getThemeToUse(this))
super.onCreate(savedInstanceState)

// Set toolbar
val toolbar = findViewById<Toolbar>(R.id.topAppBar)
setSupportActionBar(toolbar)

// Binding and view
binding = ActivityConverterBinding.inflate(layoutInflater)
val view = binding.root
Expand Down Expand Up @@ -64,16 +69,16 @@ class ConverterActivity : AppCompatActivity() {
onConverterChange(it)

// Update selected in list (used at app opening)
binding.currencyAutoComplete.setText(
binding.currencyTextView.setText(
currenciesList[converters[it::class.java] ?: 0]
)
}
}

//Set currency spinner content
val adapter = AutoCompleteAdapter(this, R.layout.list_item, currenciesList)
binding.currencyAutoComplete.setAdapter(adapter)
binding.currencyAutoComplete.setOnItemClickListener { _, _, position, _ ->
val adapter = DropdownAdapter(this, R.layout.list_item, currenciesList)
binding.currencyTextView.setAdapter(adapter)
binding.currencyTextView.setOnItemClickListener { _, _, position, _ ->

val converterClass =
converters.entries.associate { (key, value) -> value to key }[position]
Expand All @@ -89,13 +94,13 @@ class ConverterActivity : AppCompatActivity() {
val latestYear = newConverter.latestYear
val firstYear = newConverter.firstYear

binding.yearOfOriginAutoComplete.setText(latestYear.toString())
binding.yearOfOriginEditText.setText(latestYear.toString())
binding.yearOfOriginInput.hint = getString(R.string.yearOfOrigin, firstYear, latestYear)
binding.yearOfOriginAutoComplete.doOnTextChanged { text, _, _, _ ->
binding.yearOfOriginEditText.doOnTextChanged { text, _, _, _ ->
YearInputTextHandler.doOnTextChanged(
applicationContext,
newConverter,
binding.yearOfOriginAutoComplete,
binding.yearOfOriginEditText,
binding.yearOfOriginInput
)
try {
Expand All @@ -111,13 +116,13 @@ class ConverterActivity : AppCompatActivity() {
newConverter.getCurrencyFromYear(latestYear)
)

binding.yearOfResultAutoComplete.setText(latestYear.toString())
binding.yearOfResultEditText.setText(latestYear.toString())
binding.yearOfResultInput.hint = getString(R.string.yearOfResult, firstYear, latestYear)
binding.yearOfResultAutoComplete.doOnTextChanged { text, _, _, _ ->
binding.yearOfResultEditText.doOnTextChanged { text, _, _, _ ->
YearInputTextHandler.doOnTextChanged(
applicationContext,
newConverter,
binding.yearOfResultAutoComplete,
binding.yearOfResultEditText,
binding.yearOfResultInput
)
try {
Expand Down Expand Up @@ -173,8 +178,8 @@ class ConverterActivity : AppCompatActivity() {
binding.convertButton.setOnClickListener { v ->
binding.convertButton.requestFocus()
binding.sumToConvertInput.clearFocus()
binding.yearOfOriginAutoComplete.clearFocus()
binding.yearOfResultAutoComplete.clearFocus()
binding.yearOfOriginEditText.clearFocus()
binding.yearOfResultEditText.clearFocus()
Utils.hideSoftKeyboard(v)
doConversion(converterViewModel)
}
Expand All @@ -184,9 +189,9 @@ class ConverterActivity : AppCompatActivity() {
try {
binding.sumToConvertInput.error = null
val yearOfOrigin =
Integer.parseInt(binding.yearOfOriginAutoComplete.text.toString())
Integer.parseInt(binding.yearOfOriginEditText.text.toString())
val yearOfResult =
Integer.parseInt(binding.yearOfResultAutoComplete.text.toString())
Integer.parseInt(binding.yearOfResultEditText.text.toString())
val amount = java.lang.Float.parseFloat(binding.sumToConvertText.text.toString())
val convertedAmount =
converterViewModel.doConversion(yearOfOrigin, yearOfResult, amount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.widget.ArrayAdapter
import android.widget.Filter


class AutoCompleteAdapter<T>(context: Context, resource: Int, objects: List<T>) :
class DropdownAdapter<T>(context: Context, resource: Int, objects: List<T>) :
ArrayAdapter<T>(context, resource, objects) {

override fun getFilter(): Filter {
Expand Down
22 changes: 10 additions & 12 deletions app/src/main/res/layout/activity_converter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
style="@style/Widget.MaterialComponents.Toolbar.Primary"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/AppTheme.Toolbar"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.Material3.Dark.ActionBar"
app:menu="@menu/converter"
app:subtitleTextColor="@android:color/white"
app:title="@string/appName"
app:titleTextColor="@android:color/white" />
app:popupTheme="@style/ThemeOverlay.Material3.Light"
app:title="@string/appName" />

</com.google.android.material.appbar.AppBarLayout>

Expand All @@ -26,8 +25,8 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
Expand All @@ -44,7 +43,7 @@
app:startIconDrawable="@drawable/cash">

<AutoCompleteTextView
android:id="@+id/currencyAutoComplete"
android:id="@+id/currencyTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none" />
Expand Down Expand Up @@ -83,10 +82,9 @@
app:startIconDrawable="@drawable/calendar">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/yearOfOriginAutoComplete"
android:id="@+id/yearOfOriginEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"

android:inputType="number" />

</com.google.android.material.textfield.TextInputLayout>
Expand All @@ -102,8 +100,8 @@
android:hint="@string/yearOfResult"
app:startIconDrawable="@drawable/calendar">

<AutoCompleteTextView
android:id="@+id/yearOfResultAutoComplete"
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/yearOfResultEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/res/values-night/colors.xml

This file was deleted.

6 changes: 6 additions & 0 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

<resources>
<style name="AppTheme" parent="Theme.Material3.Dark.NoActionBar">
<item name="colorPrimary">@color/md_theme_dark_primary</item>
</style>
</resources>
11 changes: 3 additions & 8 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<!--?xml version="1.0" encoding="UTF-8"?-->
<resources>
<color name="primaryColor">#03A9F4</color>
<color name="primaryDarkColor">#0288D1</color>
<color name="secondaryColor">#F48FB1</color>
<color name="secondaryDarkColor">#E91E63</color>

<color name="statusBarColor">#0288D1</color>
</resources>
<color name="md_theme_light_primary">#03A9F4</color>
<color name="md_theme_dark_primary">#006493</color>
</resources>
16 changes: 4 additions & 12 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryVariant">@color/primaryDarkColor</item>
<item name="colorSecondary">@color/secondaryColor</item>
<item name="colorSecondaryVariant">@color/secondaryDarkColor</item>

<item name="android:statusBarColor" tools:targetApi="lollipop">@color/statusBarColor</item>
</style>
<resources>
<style name="AppTheme" parent="Theme.Material3.Light.NoActionBar">
<item name="colorPrimary">@color/md_theme_light_primary</item>

<style name="AppTheme.Toolbar" parent="ThemeOverlay.MaterialComponents.Toolbar.Primary">
<item name="colorOnPrimary">@android:color/white</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.DayNight</item>
</style>
</resources>
</resources>
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/21.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update theme
1 change: 1 addition & 0 deletions fastlane/metadata/android/fr-FR/changelogs/21.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mise à jour du thème

0 comments on commit 1c124e1

Please sign in to comment.