Skip to content

Commit 1c124e1

Browse files
authored
Merge pull request #152 from corenting/feat/update-theme
feat: update theme
2 parents 87e9c1f + 5d23137 commit 1c124e1

File tree

10 files changed

+48
-59
lines changed

10 files changed

+48
-59
lines changed

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ apply plugin: 'kotlin-android'
33

44
android {
55
compileSdkVersion 33
6-
buildToolsVersion "33.0.0"
6+
buildToolsVersion "33.0.1"
77

88
defaultConfig {
99
applicationId "fr.corenting.convertisseureurofranc"
1010
minSdkVersion 17
1111
targetSdkVersion 33
12-
versionCode 20
13-
versionName "2.11"
12+
versionCode 21
13+
versionName "2.12"
1414
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1515
}
1616

app/src/main/java/fr/corenting/convertisseureurofranc/ConverterActivity.kt

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import android.widget.Toast
88
import androidx.activity.viewModels
99
import androidx.appcompat.app.AppCompatActivity
1010
import androidx.appcompat.app.AppCompatDelegate
11+
import androidx.appcompat.widget.Toolbar
1112
import androidx.core.widget.doOnTextChanged
1213
import fr.corenting.convertisseureurofranc.converters.ConverterAbstract
1314
import fr.corenting.convertisseureurofranc.converters.FranceConverter
@@ -31,6 +32,10 @@ class ConverterActivity : AppCompatActivity() {
3132
AppCompatDelegate.setDefaultNightMode(ThemeUtils.getThemeToUse(this))
3233
super.onCreate(savedInstanceState)
3334

35+
// Set toolbar
36+
val toolbar = findViewById<Toolbar>(R.id.topAppBar)
37+
setSupportActionBar(toolbar)
38+
3439
// Binding and view
3540
binding = ActivityConverterBinding.inflate(layoutInflater)
3641
val view = binding.root
@@ -64,16 +69,16 @@ class ConverterActivity : AppCompatActivity() {
6469
onConverterChange(it)
6570

6671
// Update selected in list (used at app opening)
67-
binding.currencyAutoComplete.setText(
72+
binding.currencyTextView.setText(
6873
currenciesList[converters[it::class.java] ?: 0]
6974
)
7075
}
7176
}
7277

7378
//Set currency spinner content
74-
val adapter = AutoCompleteAdapter(this, R.layout.list_item, currenciesList)
75-
binding.currencyAutoComplete.setAdapter(adapter)
76-
binding.currencyAutoComplete.setOnItemClickListener { _, _, position, _ ->
79+
val adapter = DropdownAdapter(this, R.layout.list_item, currenciesList)
80+
binding.currencyTextView.setAdapter(adapter)
81+
binding.currencyTextView.setOnItemClickListener { _, _, position, _ ->
7782

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

92-
binding.yearOfOriginAutoComplete.setText(latestYear.toString())
97+
binding.yearOfOriginEditText.setText(latestYear.toString())
9398
binding.yearOfOriginInput.hint = getString(R.string.yearOfOrigin, firstYear, latestYear)
94-
binding.yearOfOriginAutoComplete.doOnTextChanged { text, _, _, _ ->
99+
binding.yearOfOriginEditText.doOnTextChanged { text, _, _, _ ->
95100
YearInputTextHandler.doOnTextChanged(
96101
applicationContext,
97102
newConverter,
98-
binding.yearOfOriginAutoComplete,
103+
binding.yearOfOriginEditText,
99104
binding.yearOfOriginInput
100105
)
101106
try {
@@ -111,13 +116,13 @@ class ConverterActivity : AppCompatActivity() {
111116
newConverter.getCurrencyFromYear(latestYear)
112117
)
113118

114-
binding.yearOfResultAutoComplete.setText(latestYear.toString())
119+
binding.yearOfResultEditText.setText(latestYear.toString())
115120
binding.yearOfResultInput.hint = getString(R.string.yearOfResult, firstYear, latestYear)
116-
binding.yearOfResultAutoComplete.doOnTextChanged { text, _, _, _ ->
121+
binding.yearOfResultEditText.doOnTextChanged { text, _, _, _ ->
117122
YearInputTextHandler.doOnTextChanged(
118123
applicationContext,
119124
newConverter,
120-
binding.yearOfResultAutoComplete,
125+
binding.yearOfResultEditText,
121126
binding.yearOfResultInput
122127
)
123128
try {
@@ -173,8 +178,8 @@ class ConverterActivity : AppCompatActivity() {
173178
binding.convertButton.setOnClickListener { v ->
174179
binding.convertButton.requestFocus()
175180
binding.sumToConvertInput.clearFocus()
176-
binding.yearOfOriginAutoComplete.clearFocus()
177-
binding.yearOfResultAutoComplete.clearFocus()
181+
binding.yearOfOriginEditText.clearFocus()
182+
binding.yearOfResultEditText.clearFocus()
178183
Utils.hideSoftKeyboard(v)
179184
doConversion(converterViewModel)
180185
}
@@ -184,9 +189,9 @@ class ConverterActivity : AppCompatActivity() {
184189
try {
185190
binding.sumToConvertInput.error = null
186191
val yearOfOrigin =
187-
Integer.parseInt(binding.yearOfOriginAutoComplete.text.toString())
192+
Integer.parseInt(binding.yearOfOriginEditText.text.toString())
188193
val yearOfResult =
189-
Integer.parseInt(binding.yearOfResultAutoComplete.text.toString())
194+
Integer.parseInt(binding.yearOfResultEditText.text.toString())
190195
val amount = java.lang.Float.parseFloat(binding.sumToConvertText.text.toString())
191196
val convertedAmount =
192197
converterViewModel.doConversion(yearOfOrigin, yearOfResult, amount)

app/src/main/java/fr/corenting/convertisseureurofranc/AutoCompleteAdapter.kt renamed to app/src/main/java/fr/corenting/convertisseureurofranc/DropdownAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import android.widget.ArrayAdapter
55
import android.widget.Filter
66

77

8-
class AutoCompleteAdapter<T>(context: Context, resource: Int, objects: List<T>) :
8+
class DropdownAdapter<T>(context: Context, resource: Int, objects: List<T>) :
99
ArrayAdapter<T>(context, resource, objects) {
1010

1111
override fun getFilter(): Filter {

app/src/main/res/layout/activity_converter.xml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99

1010
<com.google.android.material.appbar.MaterialToolbar
1111
android:id="@+id/topAppBar"
12-
style="@style/Widget.MaterialComponents.Toolbar.Primary"
1312
android:layout_width="match_parent"
1413
android:layout_height="?attr/actionBarSize"
15-
android:theme="@style/AppTheme.Toolbar"
14+
android:background="?attr/colorPrimary"
15+
android:theme="@style/ThemeOverlay.Material3.Dark.ActionBar"
1616
app:menu="@menu/converter"
17-
app:subtitleTextColor="@android:color/white"
18-
app:title="@string/appName"
19-
app:titleTextColor="@android:color/white" />
17+
app:popupTheme="@style/ThemeOverlay.Material3.Light"
18+
app:title="@string/appName" />
2019

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

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

2827
<RelativeLayout
29-
android:layout_width="wrap_content"
30-
android:layout_height="wrap_content"
28+
android:layout_width="match_parent"
29+
android:layout_height="match_parent"
3130
android:paddingLeft="@dimen/activity_horizontal_margin"
3231
android:paddingTop="@dimen/activity_vertical_margin"
3332
android:paddingRight="@dimen/activity_horizontal_margin"
@@ -44,7 +43,7 @@
4443
app:startIconDrawable="@drawable/cash">
4544

4645
<AutoCompleteTextView
47-
android:id="@+id/currencyAutoComplete"
46+
android:id="@+id/currencyTextView"
4847
android:layout_width="match_parent"
4948
android:layout_height="wrap_content"
5049
android:inputType="none" />
@@ -83,10 +82,9 @@
8382
app:startIconDrawable="@drawable/calendar">
8483

8584
<com.google.android.material.textfield.TextInputEditText
86-
android:id="@+id/yearOfOriginAutoComplete"
85+
android:id="@+id/yearOfOriginEditText"
8786
android:layout_width="match_parent"
8887
android:layout_height="wrap_content"
89-
9088
android:inputType="number" />
9189

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

105-
<AutoCompleteTextView
106-
android:id="@+id/yearOfResultAutoComplete"
103+
<com.google.android.material.textfield.TextInputEditText
104+
android:id="@+id/yearOfResultEditText"
107105
android:layout_width="match_parent"
108106
android:layout_height="wrap_content"
109107
android:inputType="number" />

app/src/main/res/values-night/colors.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
<resources>
3+
<style name="AppTheme" parent="Theme.Material3.Dark.NoActionBar">
4+
<item name="colorPrimary">@color/md_theme_dark_primary</item>
5+
</style>
6+
</resources>

app/src/main/res/values/colors.xml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
<!--?xml version="1.0" encoding="UTF-8"?-->
21
<resources>
3-
<color name="primaryColor">#03A9F4</color>
4-
<color name="primaryDarkColor">#0288D1</color>
5-
<color name="secondaryColor">#F48FB1</color>
6-
<color name="secondaryDarkColor">#E91E63</color>
7-
8-
<color name="statusBarColor">#0288D1</color>
9-
</resources>
2+
<color name="md_theme_light_primary">#03A9F4</color>
3+
<color name="md_theme_dark_primary">#006493</color>
4+
</resources>

app/src/main/res/values/themes.xml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
<resources xmlns:tools="http://schemas.android.com/tools">
2-
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
3-
<item name="colorPrimary">@color/primaryColor</item>
4-
<item name="colorPrimaryVariant">@color/primaryDarkColor</item>
5-
<item name="colorSecondary">@color/secondaryColor</item>
6-
<item name="colorSecondaryVariant">@color/secondaryDarkColor</item>
71

8-
<item name="android:statusBarColor" tools:targetApi="lollipop">@color/statusBarColor</item>
9-
</style>
2+
<resources>
3+
<style name="AppTheme" parent="Theme.Material3.Light.NoActionBar">
4+
<item name="colorPrimary">@color/md_theme_light_primary</item>
105

11-
<style name="AppTheme.Toolbar" parent="ThemeOverlay.MaterialComponents.Toolbar.Primary">
12-
<item name="colorOnPrimary">@android:color/white</item>
13-
<item name="popupTheme">@style/ThemeOverlay.AppCompat.DayNight</item>
146
</style>
15-
</resources>
7+
</resources>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update theme
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Mise à jour du thème

0 commit comments

Comments
 (0)