Skip to content

Commit 84d0f25

Browse files
refactor: Modernize lesson screen layouts and bump version
This commit refactors several lesson screens to use a standardized and more modern layout structure. It also expands localization support and increments the version code. Key changes: - **Refactored Layouts**: The `ImagesActivity` and `RetrofitActivity` layouts have been updated to use common, included layouts (`lesson_description_section`, `lesson_section_header`) for a more consistent UI. This also involves restructuring with `FastScrollScrollView` and `CardView`. - **Navigation Drawer**: Added a button to programmatically open the navigation drawer in `NavigationDrawerActivity`. - **HTML Text Rendering**: Implemented `HtmlCompat` in `AndroidStartProjectActivity` to render HTML content from a string resource, enabling richer text formatting. - **Localization**: Expanded the `resourceConfigurations` in `app/build.gradle` to include a wider range of languages and locales. - **Version Bump**: Incremented the `versionCode` from 55 to 56.
1 parent 0dc6b98 commit 84d0f25

File tree

8 files changed

+130
-62
lines changed

8 files changed

+130
-62
lines changed

app/build.gradle

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,38 @@ android {
1313
applicationId 'com.d4rk.androidtutorials.java'
1414
minSdk 23
1515
targetSdk 36
16-
versionCode 55
16+
versionCode 56
1717
versionName '5.0.3'
1818
vectorDrawables.useSupportLibrary = true
1919
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
20-
resourceConfigurations += ['en', 'de', 'es', 'fr', 'hi', 'hu', 'in', 'it', 'ja', 'ro', 'ru', 'tr', 'sv', 'bg', 'pl', 'uk']
20+
resourceConfigurations += [
21+
'ar-rEG',
22+
'bg-rBG',
23+
'bn-rBD',
24+
'de-rDE',
25+
'en',
26+
'es-rGQ',
27+
'es-rMX',
28+
'fil-rPH',
29+
'fr-rFR',
30+
'hi-rIN',
31+
'hu-rHU',
32+
'in-rID',
33+
'it-rIT',
34+
'ja-rJP',
35+
'ko-rKR',
36+
'pl-rPL',
37+
'pt-rBR',
38+
'ro-rRO',
39+
'ru-rRU',
40+
'sv-rSE',
41+
'th-rTH',
42+
'tr-rTR',
43+
'uk-rUA',
44+
'ur-rPK',
45+
'vi-rVN',
46+
'zh-rTW'
47+
]
2148
}
2249

2350
buildTypes {

app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/android/lessons/navigation/drawer/NavigationDrawerActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ protected void onCreate(Bundle savedInstanceState) {
2525
binding.drawerLayout.closeDrawer(GravityCompat.START);
2626
return true;
2727
});
28+
binding.buttonOpenDrawer.setOnClickListener(v -> binding.drawerLayout.openDrawer(GravityCompat.START));
2829

2930
setupSyntaxFab(binding.floatingButtonShowSyntax, () -> {
3031
Intent intent = new Intent(this, CodeActivity.class);

app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/android/lessons/networking/retrofit/RetrofitActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.d4rk.androidtutorials.java.ui.screens.android.lessons.common.LessonCodeTabsActivity;
1313
import com.d4rk.androidtutorials.java.ui.screens.android.lessons.networking.retrofit.tabs.RetrofitTabCodeFragment;
1414
import com.d4rk.androidtutorials.java.ui.screens.android.lessons.networking.retrofit.tabs.RetrofitTabLayoutFragment;
15+
import com.d4rk.androidtutorials.java.ui.utils.LessonUiUtils;
1516
import com.d4rk.androidtutorials.java.utils.EdgeToEdgeHelper;
1617
import com.google.gson.annotations.SerializedName;
1718

@@ -24,6 +25,8 @@
2425
import retrofit2.converter.gson.GsonConverterFactory;
2526
import retrofit2.http.GET;
2627

28+
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
29+
2730
/**
2831
* Demonstrates a simple HTTP request using Retrofit.
2932
*/
@@ -37,6 +40,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3740
binding = ActivityRetrofitBinding.inflate(getLayoutInflater());
3841
setContentView(binding.getRoot());
3942
EdgeToEdgeHelper.applyEdgeToEdge(getWindow(), binding.getRoot());
43+
LessonUiUtils.setupDescriptionSection(binding.descriptionSection, R.string.summary_retrofit, false);
44+
new FastScrollerBuilder(binding.scrollView).useMd2Style().build();
4045
Retrofit retrofit = new Retrofit.Builder()
4146
.baseUrl("https://jsonplaceholder.typicode.com/")
4247
.addConverterFactory(GsonConverterFactory.create())

app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/android/lessons/start/AndroidStartProjectActivity.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import com.d4rk.androidtutorials.java.ui.components.navigation.UpNavigationActivity;
1212
import com.d4rk.androidtutorials.java.utils.EdgeToEdgeHelper;
1313

14+
import androidx.core.text.HtmlCompat;
15+
1416
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
1517

1618
public class AndroidStartProjectActivity extends UpNavigationActivity {
@@ -37,6 +39,10 @@ protected void onCreate(Bundle savedInstanceState) {
3739
AdUtils.loadBanner(binding.adViewBottom);
3840
AdUtils.loadBanner(binding.adView);
3941
new FastScrollerBuilder(binding.scrollView).useMd2Style().build();
42+
binding.textViewThirdStepSummary.setText(HtmlCompat.fromHtml(
43+
getString(R.string.summary_third_step),
44+
HtmlCompat.FROM_HTML_MODE_LEGACY
45+
));
4046
binding.textViewThirdStepSummary.setMovementMethod(LinkMovementMethod.getInstance());
4147
}
42-
}
48+
}

app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/android/lessons/views/images/ImagesActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.d4rk.androidtutorials.java.ui.screens.android.lessons.common.LessonCodeTabsActivity;
99
import com.d4rk.androidtutorials.java.ui.screens.android.lessons.views.images.tabs.ImagesTabCodeFragment;
1010
import com.d4rk.androidtutorials.java.ui.screens.android.lessons.views.images.tabs.ImagesTabLayoutFragment;
11+
import com.d4rk.androidtutorials.java.ui.utils.LessonUiUtils;
1112
import com.d4rk.androidtutorials.java.utils.EdgeToEdgeHelper;
1213

1314
import java.util.Arrays;
@@ -23,6 +24,7 @@ protected void onCreate(Bundle savedInstanceState) {
2324
binding = ActivityImagesBinding.inflate(getLayoutInflater());
2425
setContentView(binding.getRoot());
2526
EdgeToEdgeHelper.applyEdgeToEdge(getWindow(), binding.getRoot());
27+
LessonUiUtils.setupDescriptionSection(binding.descriptionSection, R.string.summary_image_view, true);
2628
new FastScrollerBuilder(binding.scrollView).useMd2Style().build();
2729
setupSyntaxFab(binding.floatingButtonShowSyntax, () -> startActivity(
2830
LessonCodeTabsActivity.createIntent(

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

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,55 +8,42 @@
88

99
<me.zhanghai.android.fastscroll.FastScrollScrollView
1010
android:id="@+id/scroll_view"
11-
android:layout_width="match_parent"
12-
android:layout_height="match_parent"
13-
android:layout_marginBottom="80dp">
11+
android:layout_width="0dp"
12+
android:layout_height="0dp"
13+
android:layout_marginBottom="80dp"
14+
app:layout_constraintBottom_toBottomOf="parent"
15+
app:layout_constraintEnd_toEndOf="parent"
16+
app:layout_constraintStart_toStartOf="parent"
17+
app:layout_constraintTop_toTopOf="parent">
1418

1519
<androidx.appcompat.widget.LinearLayoutCompat
1620
android:layout_width="match_parent"
1721
android:layout_height="wrap_content"
1822
android:orientation="vertical"
1923
android:paddingHorizontal="24dp">
2024

21-
<com.google.android.material.textview.MaterialTextView
22-
style="@style/TextAppearance.Material3.HeadlineLarge"
23-
android:layout_width="wrap_content"
24-
android:layout_height="wrap_content"
25-
android:layout_marginTop="24dp"
26-
android:text="@string/description"
27-
app:fontFamily="@font/font_poppins" />
25+
<include
26+
android:id="@+id/description_section"
27+
layout="@layout/lesson_description_section" />
2828

29-
<com.google.android.material.card.MaterialCardView
30-
android:layout_width="match_parent"
31-
android:layout_height="wrap_content"
32-
android:layout_marginVertical="24dp"
33-
app:cardCornerRadius="24dp"
34-
app:contentPadding="24dp">
35-
36-
<com.google.android.material.textview.MaterialTextView
37-
android:layout_width="match_parent"
38-
android:layout_height="wrap_content"
39-
android:text="@string/summary_image_view" />
40-
</com.google.android.material.card.MaterialCardView>
41-
42-
<com.google.android.material.textview.MaterialTextView
43-
style="@style/TextAppearance.Material3.HeadlineLarge"
44-
android:layout_width="wrap_content"
45-
android:layout_height="wrap_content"
46-
android:text="@string/layout_preview"
47-
app:fontFamily="@font/font_poppins" />
29+
<include
30+
android:id="@+id/layout_preview_header"
31+
layout="@layout/lesson_section_header"
32+
tools:text="@string/layout_preview" />
4833

4934
<com.google.android.material.card.MaterialCardView
5035
android:id="@+id/card_view"
51-
style="@style/Widget.Material3.CardView.Elevated"
36+
style="@style/Widget.Material3.CardView.Outlined"
5237
android:layout_width="match_parent"
5338
android:layout_height="wrap_content"
54-
android:layout_marginVertical="24dp"
55-
app:cardCornerRadius="24dp">
39+
android:layout_marginTop="24dp"
40+
android:layout_marginBottom="24dp"
41+
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardViewTopRoundedOutlined">
5642

5743
<androidx.appcompat.widget.AppCompatImageView
5844
android:layout_width="match_parent"
59-
android:layout_height="match_parent"
45+
android:layout_height="wrap_content"
46+
android:adjustViewBounds="true"
6047
android:contentDescription="@string/image_view_preview_desc"
6148
android:scaleType="centerCrop"
6249
android:src="@drawable/im_image_view"

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222
app:layout_constraintStart_toStartOf="parent"
2323
app:layout_constraintTop_toTopOf="parent" />
2424

25+
<com.google.android.material.button.MaterialButton
26+
android:id="@+id/button_open_drawer"
27+
style="@style/Widget.Material3.Button.ElevatedButton"
28+
android:layout_width="wrap_content"
29+
android:layout_height="wrap_content"
30+
android:layout_marginTop="16dp"
31+
android:text="@string/navigation_drawer"
32+
android:tooltipText="@string/navigation_drawer"
33+
app:layout_constraintEnd_toEndOf="parent"
34+
app:layout_constraintStart_toStartOf="parent"
35+
app:layout_constraintTop_toBottomOf="@id/text_view" />
36+
2537
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
2638
android:id="@+id/floating_button_show_syntax"
2739
style="@style/Widget.Material3.ExtendedFloatingActionButton.Icon.Surface"

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

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,68 @@
22
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
5-
android:id="@+id/constraintLayout"
5+
android:id="@+id/container"
66
android:layout_width="match_parent"
77
android:layout_height="match_parent">
88

9-
<com.google.android.material.textview.MaterialTextView
10-
android:id="@+id/textViewSummary"
9+
<me.zhanghai.android.fastscroll.FastScrollScrollView
10+
android:id="@+id/scroll_view"
1111
android:layout_width="0dp"
12-
android:layout_height="wrap_content"
13-
android:padding="16dp"
14-
android:text="@string/summary_retrofit"
12+
android:layout_height="0dp"
13+
android:layout_marginBottom="80dp"
14+
app:layout_constraintBottom_toBottomOf="parent"
1515
app:layout_constraintEnd_toEndOf="parent"
1616
app:layout_constraintStart_toStartOf="parent"
17-
app:layout_constraintTop_toTopOf="parent" />
17+
app:layout_constraintTop_toTopOf="parent">
1818

19-
<com.google.android.material.button.MaterialButton
20-
android:id="@+id/buttonFetch"
21-
style="@style/Widget.Material3.Button.ElevatedButton"
22-
android:layout_width="wrap_content"
23-
android:layout_height="wrap_content"
24-
android:layout_marginTop="16dp"
25-
android:text="@string/fetch_data"
26-
app:layout_constraintEnd_toEndOf="parent"
27-
app:layout_constraintStart_toStartOf="parent"
28-
app:layout_constraintTop_toBottomOf="@id/textViewSummary" />
19+
<androidx.appcompat.widget.LinearLayoutCompat
20+
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
22+
android:orientation="vertical"
23+
android:paddingHorizontal="24dp">
2924

30-
<com.google.android.material.textview.MaterialTextView
31-
android:id="@+id/textViewResult"
32-
android:layout_width="0dp"
33-
android:layout_height="wrap_content"
34-
android:layout_marginTop="16dp"
35-
android:padding="16dp"
36-
app:layout_constraintEnd_toEndOf="parent"
37-
app:layout_constraintStart_toStartOf="parent"
38-
app:layout_constraintTop_toBottomOf="@id/buttonFetch" />
25+
<include
26+
android:id="@+id/description_section"
27+
layout="@layout/lesson_description_section" />
28+
29+
<include
30+
android:id="@+id/layout_preview_header"
31+
layout="@layout/lesson_section_header"
32+
tools:text="@string/layout_preview" />
33+
34+
<androidx.appcompat.widget.LinearLayoutCompat
35+
android:layout_width="match_parent"
36+
android:layout_height="wrap_content"
37+
android:layout_marginTop="24dp"
38+
android:orientation="vertical">
39+
40+
<com.google.android.material.textview.MaterialTextView
41+
android:id="@+id/request_hint"
42+
style="@style/TextAppearance.Material3.BodyLarge"
43+
android:layout_width="match_parent"
44+
android:layout_height="wrap_content"
45+
android:text="@string/fetch_data"
46+
tools:ignore="DuplicateSpeakableTextCheck" />
47+
48+
<com.google.android.material.button.MaterialButton
49+
android:id="@+id/buttonFetch"
50+
style="@style/Widget.Material3.Button.ElevatedButton"
51+
android:layout_width="wrap_content"
52+
android:layout_height="wrap_content"
53+
android:layout_gravity="center_horizontal"
54+
android:layout_marginTop="16dp"
55+
android:text="@string/fetch_data" />
56+
57+
<com.google.android.material.textview.MaterialTextView
58+
android:id="@+id/textViewResult"
59+
style="@style/TextAppearance.Material3.BodyLarge"
60+
android:layout_width="match_parent"
61+
android:layout_height="wrap_content"
62+
android:layout_marginTop="16dp"
63+
tools:text="@string/snack_general_error" />
64+
</androidx.appcompat.widget.LinearLayoutCompat>
65+
</androidx.appcompat.widget.LinearLayoutCompat>
66+
</me.zhanghai.android.fastscroll.FastScrollScrollView>
3967

4068
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
4169
android:id="@+id/floating_button_show_syntax"

0 commit comments

Comments
 (0)