Skip to content

Commit 22b6f6b

Browse files
authored
Merge pull request #20 from nicholasrout/feature/androidx-update
Update AndroidX and Material Components
2 parents 67b59d3 + 400ecdb commit 22b6f6b

File tree

12 files changed

+62
-80
lines changed

12 files changed

+62
-80
lines changed

Diff for: app/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ dependencies {
4343
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
4444
implementation project(':info')
4545
implementation project(':common')
46-
implementation "androidx.emoji:emoji:$androidx_version"
47-
implementation "androidx.emoji:emoji-bundled:$androidx_version"
48-
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
49-
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
46+
implementation "androidx.emoji:emoji:$emoji_version"
47+
implementation "androidx.emoji:emoji-bundled:$emoji_version"
5048
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
5149
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
5250
implementation "androidx.room:room-runtime:$room_version"
5351
kapt "androidx.room:room-compiler:$room_version"
5452
implementation "android.arch.navigation:navigation-fragment-ktx:$navigation_version"
5553
implementation "android.arch.navigation:navigation-ui-ktx:$navigation_version"
5654
implementation "android.arch.work:work-runtime-ktx:$work_version"
55+
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
56+
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
5757
implementation "com.google.dagger:dagger:$dagger_version"
5858
kapt "com.google.dagger:dagger-compiler:$dagger_version"
5959
implementation "com.google.dagger:dagger-android:$dagger_version"

Diff for: app/src/main/java/com/ricknout/rugbyranker/MainActivity.kt

+2-16
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@ import androidx.lifecycle.ViewModelProvider
55
import androidx.lifecycle.ViewModelProviders
66
import androidx.navigation.findNavController
77
import androidx.navigation.ui.setupWithNavController
8-
import com.ricknout.rugbyranker.common.ui.OnBackPressedListener
9-
import com.ricknout.rugbyranker.common.ui.OnBackPressedProvider
108
import com.ricknout.rugbyranker.ui.rankings.MensRankingsViewModel
119
import com.ricknout.rugbyranker.ui.rankings.WomensRankingsViewModel
1210
import dagger.android.support.DaggerAppCompatActivity
1311
import kotlinx.android.synthetic.main.activity_main.*
1412
import me.saket.fluidresize.sample.FluidContentResizer
1513
import javax.inject.Inject
1614

17-
class MainActivity : DaggerAppCompatActivity(), OnBackPressedProvider {
18-
19-
private var onBackPressedListener: OnBackPressedListener? = null
15+
class MainActivity : DaggerAppCompatActivity() {
2016

2117
@Inject
2218
lateinit var viewModelFactory: ViewModelProvider.Factory
@@ -61,18 +57,8 @@ class MainActivity : DaggerAppCompatActivity(), OnBackPressedProvider {
6157
FluidContentResizer.listen(this)
6258
}
6359

64-
override fun setOnBackPressedListener(onBackPressedListener: OnBackPressedListener?) {
65-
this.onBackPressedListener = onBackPressedListener
66-
}
67-
6860
override fun onBackPressed() {
6961
if (FluidContentResizer.isAnimating()) return
70-
val onBackPressedHandled = onBackPressedListener?.onBackPressed() ?: false
71-
if (!onBackPressedHandled) super.onBackPressed()
72-
}
73-
74-
override fun onDestroy() {
75-
onBackPressedListener = null
76-
super.onDestroy()
62+
super.onBackPressed()
7763
}
7864
}

Diff for: app/src/main/java/com/ricknout/rugbyranker/ui/rankings/RankingsFragment.kt

+16-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.ricknout.rugbyranker.ui.rankings
22

3-
import android.content.Context
43
import android.content.Intent
54
import android.os.Bundle
65
import android.view.LayoutInflater
@@ -25,8 +24,6 @@ import androidx.emoji.text.EmojiCompat
2524
import com.ricknout.rugbyranker.ui.common.MatchResultListAdapter
2625
import com.ricknout.rugbyranker.common.ui.BackgroundClickOnItemTouchListener
2726
import com.ricknout.rugbyranker.ui.common.WorldRugbyRankingListAdapter
28-
import com.ricknout.rugbyranker.common.ui.OnBackPressedListener
29-
import com.ricknout.rugbyranker.common.ui.OnBackPressedProvider
3027
import com.ricknout.rugbyranker.common.ui.SimpleTextWatcher
3128
import com.ricknout.rugbyranker.util.FlagUtils
3229
import androidx.core.content.getSystemService
@@ -37,7 +34,7 @@ import com.ricknout.rugbyranker.vo.RankingsType
3734
import kotlinx.android.synthetic.main.fragment_rankings.*
3835
import kotlinx.android.synthetic.main.include_add_edit_match_bottom_sheet.*
3936

40-
class RankingsFragment : DaggerFragment(), OnBackPressedListener {
37+
class RankingsFragment : DaggerFragment() {
4138

4239
@Inject
4340
lateinit var viewModelFactory: ViewModelProvider.Factory
@@ -102,6 +99,7 @@ class RankingsFragment : DaggerFragment(), OnBackPressedListener {
10299
setupSnackbars()
103100
setupViewModel()
104101
setupSwipeRefreshLayout()
102+
setupOnBackPressed()
105103
setTitle()
106104
}
107105

@@ -322,6 +320,20 @@ class RankingsFragment : DaggerFragment(), OnBackPressedListener {
322320
}
323321
}
324322

323+
private fun setupOnBackPressed() {
324+
requireActivity().addOnBackPressedCallback {
325+
if (::bottomSheetBehavior.isInitialized && bottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) {
326+
if (bottomSheetBehavior.isHideable && bottomSheetBehavior.skipCollapsed) {
327+
bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
328+
} else {
329+
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
330+
}
331+
return@addOnBackPressedCallback true
332+
}
333+
false
334+
}
335+
}
336+
325337
private fun hasMatchResults() = viewModel.hasMatchResults()
326338

327339
private fun getMatchResultCount() = viewModel.getMatchResultCount()
@@ -508,24 +520,6 @@ class RankingsFragment : DaggerFragment(), OnBackPressedListener {
508520
viewModel.endEditMatchResult()
509521
}
510522

511-
override fun onBackPressed(): Boolean {
512-
if (::bottomSheetBehavior.isInitialized && bottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) {
513-
if (bottomSheetBehavior.isHideable && bottomSheetBehavior.skipCollapsed) {
514-
bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
515-
} else {
516-
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
517-
}
518-
return true
519-
}
520-
return super.onBackPressed()
521-
}
522-
523-
override fun onAttach(context: Context?) {
524-
super.onAttach(context)
525-
(context as? OnBackPressedProvider ?: throw ClassCastException("$context must implement OnBackPressedProvider"))
526-
.setOnBackPressedListener(this)
527-
}
528-
529523
private fun hideSoftInput() {
530524
val imm: InputMethodManager? = requireContext().getSystemService()
531525
imm?.hideSoftInputFromWindow(view?.rootView?.windowToken, 0)

Diff for: app/src/main/res/layout/include_add_edit_match_bottom_sheet.xml

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
android:background="@drawable/bg_bottom_sheet"
1212
android:clickable="true"
1313
android:focusable="true"
14+
android:theme="@style/RugbyRankerTheme.Secondary"
1415
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
1516
app:behavior_hideable="true"
1617
app:behavior_peekHeight="@dimen/height_peek"
@@ -93,7 +94,6 @@
9394
android:layout_marginTop="@dimen/spacing_standard"
9495
android:layout_marginEnd="@dimen/spacing_standard"
9596
android:hint="@string/hint_home_team"
96-
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
9797
app:layout_constraintTop_toBottomOf="@id/addEditMatchPeekGuideline"
9898
app:layout_constraintStart_toStartOf="@id/startGuideline"
9999
app:layout_constraintEnd_toStartOf="@id/homePointsTextInputLayout">
@@ -115,7 +115,6 @@
115115
android:layout_width="@dimen/width_points"
116116
android:layout_height="0dp"
117117
android:hint="@string/hint_points"
118-
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
119118
app:layout_constraintTop_toTopOf="@id/homeTeamTextInputLayout"
120119
app:layout_constraintBottom_toBottomOf="@id/homeTeamTextInputLayout"
121120
app:layout_constraintEnd_toEndOf="@id/endGuideline">
@@ -136,7 +135,6 @@
136135
android:layout_marginTop="@dimen/spacing_standard"
137136
android:layout_marginEnd="@dimen/spacing_standard"
138137
android:hint="@string/hint_away_team"
139-
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
140138
app:layout_constraintTop_toBottomOf="@id/homeTeamTextInputLayout"
141139
app:layout_constraintStart_toStartOf="@id/startGuideline"
142140
app:layout_constraintEnd_toStartOf="@id/awayPointsTextInputLayout">
@@ -158,7 +156,6 @@
158156
android:layout_width="@dimen/width_points"
159157
android:layout_height="0dp"
160158
android:hint="@string/hint_points"
161-
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
162159
app:layout_constraintTop_toTopOf="@id/awayTeamTextInputLayout"
163160
app:layout_constraintBottom_toBottomOf="@id/awayTeamTextInputLayout"
164161
app:layout_constraintEnd_toEndOf="@id/endGuideline">

Diff for: build.gradle

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ buildscript {
44
ext.target_sdk_version = 28
55
ext.gradle_build_tools_version = '3.3.0-beta02'
66
ext.kotlin_version = '1.3.0'
7-
ext.androidx_version = '1.0.0'
7+
ext.androidx_core_version = '1.1.0-alpha01'
8+
ext.androidx_core_ktx_version = '1.0.1'
9+
ext.androidx_activity_version = '1.0.0-alpha01'
10+
ext.androidx_fragment_version = '1.1.0-alpha01'
811
ext.constraintlayout_version = "2.0.0-alpha2"
9-
ext.retrofit_version = "2.4.0"
12+
ext.recyclerview_version = '1.0.0'
13+
ext.emoji_version = '1.0.0'
14+
ext.browser_version = '1.0.0'
15+
ext.material_version = "1.1.0-alpha01"
1016
ext.lifecycle_version = "2.0.0"
1117
ext.room_version = "2.1.0-alpha02"
1218
ext.navigation_version = "1.0.0-alpha07"
1319
ext.work_version = "1.0.0-alpha10"
20+
ext.retrofit_version = "2.4.0"
1421
ext.dagger_version = '2.16'
1522
ext.oss_licenses_plugin_version = "0.9.3"
1623
ext.play_services_oss_licenses_version = "16.0.1"

Diff for: common/build.gradle

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ android {
2121
dependencies {
2222
implementation fileTree(dir: 'libs', include: ['*.jar'])
2323
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
24-
api "androidx.appcompat:appcompat:$androidx_version"
25-
api "androidx.recyclerview:recyclerview:$androidx_version"
24+
api "androidx.core:core:$androidx_core_version"
25+
api "androidx.core:core-ktx:$androidx_core_ktx_version"
26+
api "androidx.activity:activity-ktx:$androidx_activity_version"
27+
api "androidx.fragment:fragment-ktx:$androidx_fragment_version"
2628
api "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
27-
api "com.google.android.material:material:$androidx_version"
28-
api "androidx.core:core-ktx:$androidx_version"
29+
api "androidx.recyclerview:recyclerview:$recyclerview_version"
30+
api "com.google.android.material:material:$material_version"
2931
testImplementation "junit:junit:$test_junit_version"
3032
androidTestImplementation "androidx.test:runner:$test_runner_version"
3133
androidTestImplementation "androidx.test.espresso:espresso-core:$test_espresso_version"

Diff for: common/src/main/java/com/ricknout/rugbyranker/common/ui/OnBackPressedListener.kt

-6
This file was deleted.

Diff for: common/src/main/java/com/ricknout/rugbyranker/common/ui/OnBackPressedProvider.kt

-6
This file was deleted.

Diff for: common/src/main/res/values-v23/styles.xml

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
<style name="RugbyRankerTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
44
<item name="colorPrimary">@color/color_primary</item>
55
<item name="colorPrimaryDark">@color/color_primary_dark</item>
6+
<item name="colorSecondary">@color/color_secondary</item>
7+
<item name="colorOnSecondary">@color/white</item>
68
<item name="colorAccent">@color/color_secondary</item>
79
<item name="android:windowBackground">@color/color_window_background</item>
810
<item name="android:statusBarColor">@color/color_status_bar</item>
911
<item name="android:windowLightStatusBar">true</item>
1012
<item name="android:navigationBarColor">@color/color_navigation_bar</item>
1113
<item name="bottomNavigationStyle">@style/RugbyRankerBottomNavigationView</item>
12-
<item name="materialButtonStyle">@style/RugbyRankerMaterialButton</item>
13-
<item name="floatingActionButtonStyle">@style/RugbyRankerFloatingActionButton</item>
14+
<item name="textAppearanceButton">@style/RugbyRankerTextAppearance.Button</item>
15+
<item name="textInputStyle">@style/RugbyRankerTextInputLayout</item>
1416
<item name="android:fontFamily">@font/rajdhani</item>
1517
<item name="fontFamily">@font/rajdhani</item>
1618
</style>

Diff for: common/src/main/res/values/styles.xml

+17-12
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@
33
<style name="RugbyRankerTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
44
<item name="colorPrimary">@color/color_primary</item>
55
<item name="colorPrimaryDark">@color/color_primary_dark</item>
6+
<item name="colorSecondary">@color/color_secondary</item>
7+
<item name="colorOnSecondary">@color/white</item>
68
<item name="colorAccent">@color/color_secondary</item>
79
<item name="android:windowBackground">@color/color_window_background</item>
810
<item name="android:statusBarColor">@color/color_status_bar</item>
911
<item name="android:navigationBarColor">@color/color_navigation_bar</item>
1012
<item name="bottomNavigationStyle">@style/RugbyRankerBottomNavigationView</item>
11-
<item name="materialButtonStyle">@style/RugbyRankerMaterialButton</item>
12-
<item name="floatingActionButtonStyle">@style/RugbyRankerFloatingActionButton</item>
13+
<item name="textAppearanceButton">@style/RugbyRankerTextAppearance.Button</item>
14+
<item name="textInputStyle">@style/RugbyRankerTextInputLayout</item>
1315
<item name="android:fontFamily">@font/rajdhani</item>
1416
<item name="fontFamily">@font/rajdhani</item>
1517
</style>
1618

19+
<style name="RugbyRankerTheme.Secondary">
20+
<item name="colorPrimary">@color/color_secondary</item>
21+
<item name="colorPrimaryDark">@color/color_secondary_dark</item>
22+
</style>
23+
1724
<style name="RugbyRankerTheme.Launcher">
1825
<item name="android:windowBackground">@drawable/bg_launcher</item>
1926
<item name="android:navigationBarColor">@color/color_navigation_bar_launcher</item>
@@ -25,12 +32,12 @@
2532

2633
<style name="RugbyRankerTextAppearance.Caption" parent="@style/TextAppearance.MaterialComponents.Caption" />
2734

28-
<style name="RugbyRankerTextAppearance.Chip" parent="TextAppearance.MaterialComponents.Chip">
29-
<item name="android:fontFamily">@font/rajdhani</item>
35+
<style name="RugbyRankerTextAppearance.Button" parent="TextAppearance.MaterialComponents.Button">
36+
<item name="android:textAllCaps">false</item>
3037
</style>
3138

32-
<style name="RugbyRankerMaterialButton" parent="Widget.MaterialComponents.Button">
33-
<item name="android:textAllCaps">false</item>
39+
<style name="RugbyRankerTextAppearance.Chip" parent="TextAppearance.MaterialComponents.Chip">
40+
<item name="android:fontFamily">@font/rajdhani</item>
3441
</style>
3542

3643
<style name="RugbyRankerMaterialButton.TextButton.DoublePadding" parent="Widget.MaterialComponents.Button.TextButton">
@@ -39,14 +46,12 @@
3946
<item name="android:paddingEnd">@dimen/spacing_double</item>
4047
</style>
4148

42-
<style name="RugbyRankerFloatingActionButton" parent="Widget.MaterialComponents.FloatingActionButton">
43-
<item name="android:tint">@color/color_fab_tint</item>
44-
</style>
45-
4649
<style name="RugbyRankerChip" parent="Widget.MaterialComponents.Chip.Action">
4750
<item name="android:textAppearance">@style/RugbyRankerTextAppearance.Chip</item>
48-
<item name="android:textColor">@color/white</item>
49-
<item name="chipBackgroundColor">?attr/colorAccent</item>
51+
<item name="android:textColor">?attr/colorOnSecondary</item>
52+
<item name="chipBackgroundColor">?attr/colorSecondary</item>
5053
</style>
5154

55+
<style name="RugbyRankerTextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox" />
56+
5257
</resources>

Diff for: info/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies {
2323
implementation fileTree(dir: 'libs', include: ['*.jar'])
2424
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
2525
implementation project(':common')
26-
implementation "androidx.browser:browser:$androidx_version"
26+
implementation "androidx.browser:browser:$browser_version"
2727
implementation "com.google.android.gms:play-services-oss-licenses:$play_services_oss_licenses_version"
2828
testImplementation "junit:junit:$test_junit_version"
2929
androidTestImplementation "androidx.test:runner:$test_runner_version"

Diff for: info/src/main/res/layout/fragment_info.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
<LinearLayout
4242
android:layout_width="match_parent"
4343
android:layout_height="match_parent"
44-
android:orientation="vertical">
44+
android:orientation="vertical"
45+
android:theme="@style/RugbyRankerTheme.Secondary">
4546

4647
<com.google.android.material.button.MaterialButton
4748
android:id="@+id/howAreWorldRugbyRankingsCalculatedButton"

0 commit comments

Comments
 (0)