Skip to content

Commit d6dd3d2

Browse files
Add style for action button group
1 parent eca9bec commit d6dd3d2

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/home/HomeFragment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
6363
new FastScrollerBuilder(binding.scrollView)
6464
.useMd2Style()
6565
.build();
66-
binding.btnGooglePlay.setOnClickListener(v -> startActivity(homeViewModel.getOpenPlayStoreIntent()));
66+
binding.btnGooglePlay.setOnClickListener(v ->
67+
startActivity(homeViewModel.getOpenPlayStoreIntent()));
68+
binding.btnLearnMore.setOnClickListener(v ->
69+
startActivity(homeViewModel.getLearnMoreIntent()));
6770
}
6871

6972
@Override

app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/home/HomeViewModel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public Intent getOpenPlayStoreIntent() {
9999
return buildPlayStoreIntent(getPlayStoreUrlUseCase.invoke());
100100
}
101101

102+
public Intent getLearnMoreIntent() {
103+
return new Intent(Intent.ACTION_VIEW, Uri.parse("https://developer.android.com"));
104+
}
105+
102106
/**
103107
* Builds an intent to open the Google Play listing for the provided package.
104108
*/

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,28 @@
115115
android:layout_marginTop="8dp"
116116
android:orientation="horizontal">
117117

118-
<com.google.android.material.button.MaterialButton
119-
android:id="@+id/btn_google_play"
118+
<com.google.android.material.button.MaterialButtonToggleGroup
119+
android:id="@+id/home_action_button_group"
120+
style="@style/Widget.App.ButtonGroup"
120121
android:layout_width="wrap_content"
121-
android:layout_height="wrap_content"
122-
android:text="@string/get_on_google_play"
123-
app:icon="@drawable/ic_play_store_tinted" />
122+
android:layout_height="wrap_content">
123+
124+
<com.google.android.material.button.MaterialButton
125+
android:id="@+id/btn_google_play"
126+
android:layout_width="wrap_content"
127+
android:layout_height="wrap_content"
128+
android:checkable="false"
129+
android:text="@string/get_on_google_play"
130+
app:icon="@drawable/ic_play_store_tinted" />
131+
132+
<com.google.android.material.button.MaterialButton
133+
android:id="@+id/btn_learn_more"
134+
android:layout_width="wrap_content"
135+
android:layout_height="wrap_content"
136+
android:checkable="false"
137+
android:text="@string/learn_more" />
138+
139+
</com.google.android.material.button.MaterialButtonToggleGroup>
124140
</androidx.appcompat.widget.LinearLayoutCompat>
125141
</androidx.appcompat.widget.LinearLayoutCompat>
126142
</com.google.android.material.card.MaterialCardView>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
<string name="main_card_title">Discover Android Studio Tutorials</string>
1717
<string name="main_card_subtitle">Featuring Kotlin and Java Editions</string>
1818
<string name="main_card_description">The Kotlin Edition has been updated with dynamic lessons, AI assistant, and more. Experience the future of Android development!</string>
19-
<string name="get_on_google_play">Get it on Google Play</string>
20-
<string name="play_store">Play Store</string>
19+
<string name="get_on_google_play">Get it on Google Play</string>
20+
<string name="learn_more">Learn More</string>
21+
<string name="play_store">Play Store</string>
2122

2223
<string name="android_studio">Android Studio</string>
2324

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<style name="Widget.App.ButtonGroup" parent="Widget.Material3.ButtonGroup" />
4+
</resources>

0 commit comments

Comments
 (0)