Skip to content

Commit e9a578d

Browse files
Refine onboarding selection layout and enable data binding
1 parent ac4d673 commit e9a578d

File tree

4 files changed

+68
-33
lines changed

4 files changed

+68
-33
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ android {
4242

4343
buildFeatures {
4444
viewBinding true
45+
dataBinding true
4546
buildConfig true
4647
}
4748

app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/onboarding/StartPageFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
3232
binding.setSecondIcon(ContextCompat.getDrawable(requireContext(), R.drawable.ic_android_sdk));
3333
binding.setSecondTitle(getString(R.string.android_studio));
3434
binding.setSecondDescription(getString(R.string.android_studio_description));
35-
binding.setThirdIcon(ContextCompat.getDrawable(requireContext(), R.drawable.ic_info));
35+
binding.setThirdIcon(ContextCompat.getDrawable(requireContext(), R.drawable.ic_about));
3636
binding.setThirdTitle(getString(R.string.about));
3737
binding.setThirdDescription(getString(R.string.about_description));
3838

app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/onboarding/ThemeFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
3333
binding.setSecondTitle(getString(R.string.dark_mode));
3434
binding.setSecondDescription(getString(R.string.dark_mode_description));
3535
binding.setThirdIcon(ContextCompat.getDrawable(requireContext(), R.drawable.ic_android));
36-
binding.setThirdTitle(getString(R.string.follow_system_mode));
36+
binding.setThirdTitle(getString(R.string.follow_system));
3737
binding.setThirdDescription(getString(R.string.follow_system_mode_description));
3838

3939
return binding.getRoot();
Lines changed: 65 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,52 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<layout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
xmlns:tools="http://schemas.android.com/tools">
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
54

65
<data>
7-
<variable name="title" type="String" />
8-
<variable name="description" type="String" />
9-
<variable name="firstIcon" type="android.graphics.drawable.Drawable" />
10-
<variable name="firstTitle" type="String" />
11-
<variable name="firstDescription" type="String" />
12-
<variable name="secondIcon" type="android.graphics.drawable.Drawable" />
13-
<variable name="secondTitle" type="String" />
14-
<variable name="secondDescription" type="String" />
15-
<variable name="thirdIcon" type="android.graphics.drawable.Drawable" />
16-
<variable name="thirdTitle" type="String" />
17-
<variable name="thirdDescription" type="String" />
6+
7+
<variable
8+
name="title"
9+
type="String" />
10+
11+
<variable
12+
name="description"
13+
type="String" />
14+
15+
<variable
16+
name="firstIcon"
17+
type="android.graphics.drawable.Drawable" />
18+
19+
<variable
20+
name="firstTitle"
21+
type="String" />
22+
23+
<variable
24+
name="firstDescription"
25+
type="String" />
26+
27+
<variable
28+
name="secondIcon"
29+
type="android.graphics.drawable.Drawable" />
30+
31+
<variable
32+
name="secondTitle"
33+
type="String" />
34+
35+
<variable
36+
name="secondDescription"
37+
type="String" />
38+
39+
<variable
40+
name="thirdIcon"
41+
type="android.graphics.drawable.Drawable" />
42+
43+
<variable
44+
name="thirdTitle"
45+
type="String" />
46+
47+
<variable
48+
name="thirdDescription"
49+
type="String" />
1850
</data>
1951

2052
<androidx.constraintlayout.widget.ConstraintLayout
@@ -29,9 +61,9 @@
2961
android:layout_marginTop="32dp"
3062
android:text="@{title}"
3163
android:textAppearance="?attr/textAppearanceHeadlineMedium"
32-
app:layout_constraintTop_toTopOf="parent"
64+
app:layout_constraintEnd_toEndOf="parent"
3365
app:layout_constraintStart_toStartOf="parent"
34-
app:layout_constraintEnd_toEndOf="parent" />
66+
app:layout_constraintTop_toTopOf="parent" />
3567

3668
<com.google.android.material.textview.MaterialTextView
3769
android:id="@+id/description"
@@ -41,9 +73,9 @@
4173
android:text="@{description}"
4274
android:textAppearance="?attr/textAppearanceBodyMedium"
4375
android:textColor="?attr/colorOnSurfaceVariant"
44-
app:layout_constraintTop_toBottomOf="@id/title"
76+
app:layout_constraintEnd_toEndOf="parent"
4577
app:layout_constraintStart_toStartOf="parent"
46-
app:layout_constraintEnd_toEndOf="parent"/>
78+
app:layout_constraintTop_toBottomOf="@id/title" />
4779

4880
<androidx.constraintlayout.widget.ConstraintLayout
4981
android:id="@+id/selection_group"
@@ -65,43 +97,45 @@
6597

6698
<com.google.android.material.card.MaterialCardView
6799
android:id="@+id/card_first"
68-
style="@style/Widget.App.Card.Selectable"
69100
android:layout_width="match_parent"
70101
android:layout_height="wrap_content">
102+
71103
<include
72104
android:id="@+id/option_first"
73105
layout="@layout/item_onboarding_option"
106+
app:description="@{firstDescription}"
74107
app:icon="@{firstIcon}"
75-
app:title="@{firstTitle}"
76-
app:description="@{firstDescription}" />
108+
app:title="@{firstTitle}" />
77109
</com.google.android.material.card.MaterialCardView>
78110

79111
<com.google.android.material.card.MaterialCardView
80112
android:id="@+id/card_second"
81-
style="@style/Widget.App.Card.Selectable"
82113
android:layout_width="match_parent"
83114
android:layout_height="wrap_content"
84-
android:layout_marginTop="16dp">
115+
android:layout_marginTop="2dp"
116+
app:cardCornerRadius="4dp">
117+
85118
<include
86119
android:id="@+id/option_second"
87120
layout="@layout/item_onboarding_option"
121+
app:description="@{secondDescription}"
88122
app:icon="@{secondIcon}"
89-
app:title="@{secondTitle}"
90-
app:description="@{secondDescription}" />
123+
app:title="@{secondTitle}" />
91124
</com.google.android.material.card.MaterialCardView>
92125

93126
<com.google.android.material.card.MaterialCardView
94127
android:id="@+id/card_third"
95-
style="@style/Widget.App.Card.Selectable"
96128
android:layout_width="match_parent"
97129
android:layout_height="wrap_content"
98-
android:layout_marginTop="16dp">
130+
android:layout_marginTop="2dp"
131+
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardViewBottomRounded">
132+
99133
<include
100134
android:id="@+id/option_third"
101135
layout="@layout/item_onboarding_option"
136+
app:description="@{thirdDescription}"
102137
app:icon="@{thirdIcon}"
103-
app:title="@{thirdTitle}"
104-
app:description="@{thirdDescription}" />
138+
app:title="@{thirdTitle}" />
105139
</com.google.android.material.card.MaterialCardView>
106140

107141
</RadioGroup>
@@ -111,11 +145,11 @@
111145
android:id="@+id/page_indicator"
112146
android:layout_width="wrap_content"
113147
android:layout_height="wrap_content"
114-
android:orientation="horizontal"
115148
android:layout_marginBottom="16dp"
149+
android:orientation="horizontal"
116150
app:layout_constraintBottom_toBottomOf="parent"
117-
app:layout_constraintStart_toStartOf="parent"
118-
app:layout_constraintEnd_toEndOf="parent" />
151+
app:layout_constraintEnd_toEndOf="parent"
152+
app:layout_constraintStart_toStartOf="parent" />
119153

120154
</androidx.constraintlayout.widget.ConstraintLayout>
121155
</layout>

0 commit comments

Comments
 (0)