Skip to content

Commit bb17bb4

Browse files
authored
Updated default browser bottom sheet texts and low priorit message text to prevent widows and improve text handling. (#6611)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1200581511062568/task/1211065154998330?focus=true ### Description This PR enhances the text formatting in the default browser prompts by applying the `preventWidows()` extension function to titles and headings. This prevents single words from appearing alone on the last line of text, improving readability and visual appearance. Key changes: - Added dynamic text setting for default browser bottom sheet dialog title and subtitle - Applied `preventWidows()` to the new tab page default browser message heading - Updated layout files to use tools:text instead of android:text for preview purposes ### Steps to test this PR Code review. See screenshots. ### UI changes | Bottomsheet | Message | | ------ | ----- | |<img width="1080" height="2400" alt="Screenshot_20250819_184421" src="https://github.com/user-attachments/assets/21887dac-6eec-486c-a74a-18412c43e2fa" />|<img width="1080" height="2400" alt="Screenshot_20250819_184245" src="https://github.com/user-attachments/assets/fe44868e-f9c4-492e-9a61-56b1ee0f3d8d" />|
1 parent 7560003 commit bb17bb4

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

app/src/main/java/com/duckduckgo/app/browser/defaultbrowsing/prompts/ui/DefaultBrowserBottomSheetDialog.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import android.content.Context
2121
import android.content.DialogInterface
2222
import android.view.LayoutInflater
2323
import android.widget.FrameLayout
24+
import androidx.core.content.ContextCompat.getString
25+
import com.duckduckgo.app.browser.R as BrowserR
2426
import com.duckduckgo.app.browser.databinding.BottomSheetDefaultBrowserBinding
27+
import com.duckduckgo.common.utils.extensions.preventWidows
2528
import com.duckduckgo.mobile.android.R as CommonR
2629
import com.google.android.material.R
2730
import com.google.android.material.bottomsheet.BottomSheetBehavior
@@ -43,6 +46,11 @@ class DefaultBrowserBottomSheetDialog(private val context: Context) : BottomShee
4346
this.behavior.state = BottomSheetBehavior.STATE_EXPANDED
4447
this.behavior.isDraggable = false
4548

49+
binding.defaultBrowserBottomSheetDialogTitle.text =
50+
getString(context, BrowserR.string.defaultBrowserBottomSheetDialogTitle).preventWidows()
51+
binding.defaultBrowserBottomSheetDialogSubTitle.text =
52+
getString(context, BrowserR.string.defaultBrowserBottomSheetDialogSubTitle).preventWidows()
53+
4654
setOnShowListener { dialogInterface ->
4755
setRoundCorners(dialogInterface)
4856
eventListener?.onShown()

app/src/main/java/com/duckduckgo/app/browser/newtab/LowPriorityMessagingModelImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.duckduckgo.app.browser.newtab.NewTabLegacyPageViewModel.Command.Launc
2525
import com.duckduckgo.app.pixels.AppPixelName
2626
import com.duckduckgo.app.statistics.pixels.Pixel
2727
import com.duckduckgo.common.ui.view.MessageCta.Message
28+
import com.duckduckgo.common.utils.extensions.preventWidows
2829
import com.duckduckgo.di.scopes.AppScope
2930
import com.squareup.anvil.annotations.ContributesBinding
3031
import javax.inject.Inject
@@ -62,7 +63,7 @@ class LowPriorityMessagingModelImpl @Inject constructor(
6263
DefaultBrowserMessage(
6364
Message(
6465
topIllustration = com.duckduckgo.mobile.android.R.drawable.ic_device_mobile_default,
65-
title = context.getString(R.string.newTabPageDefaultBrowserMessageHeading),
66+
title = context.getString(R.string.newTabPageDefaultBrowserMessageHeading).preventWidows(),
6667
action = context.getString(R.string.newTabPageDefaultBrowserMessagePrimaryCta),
6768
action2 = context.getString(R.string.newTabPageDefaultBrowserMessageSecondaryCta),
6869
),

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,24 @@
4949
tools:ignore="ContentDescription" />
5050

5151
<com.duckduckgo.common.ui.view.text.DaxTextView
52+
android:id="@+id/defaultBrowserBottomSheetDialogTitle"
5253
android:layout_width="match_parent"
5354
android:layout_height="wrap_content"
5455
android:layout_marginTop="24dp"
5556
android:paddingHorizontal="24dp"
5657
android:gravity="center"
57-
android:text="@string/defaultBrowserBottomSheetDialogTitle"
58+
tools:text="@string/defaultBrowserBottomSheetDialogTitle"
5859
app:textType="primary"
5960
app:typography="h1" />
6061

6162
<com.duckduckgo.common.ui.view.text.DaxTextView
63+
android:id="@+id/defaultBrowserBottomSheetDialogSubTitle"
6264
android:layout_width="match_parent"
6365
android:layout_height="wrap_content"
6466
android:layout_marginTop="24dp"
6567
android:paddingHorizontal="24dp"
6668
android:gravity="center"
67-
android:text="@string/defaultBrowserBottomSheetDialogSubTitle"
69+
tools:text="@string/defaultBrowserBottomSheetDialogSubTitle"
6870
app:textType="primary"
6971
app:typography="body1" />
7072

0 commit comments

Comments
 (0)