Skip to content

Commit 14116ce

Browse files
authored
Add showLogo param to NTP (#6539)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1200204095367872/task/1210986747757521?focus=true ### Description - Adds an optional `showLogo` param to hide the logo from NTP. ### Steps to test this PR - [ ] Verify that NTP works as expected - [ ] Verify that the Search Tab on the Input Screen works as expected
1 parent 5ca7737 commit 14116ce

File tree

6 files changed

+30
-15
lines changed

6 files changed

+30
-15
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class NewTabLegacyPageView @JvmOverloads constructor(
7373
context: Context,
7474
attrs: AttributeSet? = null,
7575
defStyle: Int = 0,
76+
private val showLogo: Boolean = true,
7677
) : LinearLayout(context, attrs, defStyle) {
7778

7879
@Inject
@@ -136,10 +137,15 @@ class NewTabLegacyPageView @JvmOverloads constructor(
136137
val isHomeBackgroundLogoVisible = (!viewState.onboardingComplete || viewState.message == null) &&
137138
viewState.favourites.isEmpty()
138139

139-
if (isHomeBackgroundLogoVisible) {
140-
homeBackgroundLogo.showLogo()
140+
if (!showLogo && isHomeBackgroundLogoVisible) {
141+
this.gone()
141142
} else {
142-
homeBackgroundLogo.hideLogo()
143+
this.show()
144+
if (isHomeBackgroundLogoVisible) {
145+
homeBackgroundLogo.showLogo()
146+
} else {
147+
homeBackgroundLogo.hideLogo()
148+
}
143149
}
144150
if (viewState.message != null && viewState.onboardingComplete) {
145151
showRemoteMessage(viewState.message, viewState.newMessage)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class RealNewTabPageProvider @Inject constructor(
5151
)
5252
class NewTabLegacyPage @Inject constructor() : NewTabPagePlugin {
5353

54-
override fun getView(context: Context): View {
55-
return NewTabLegacyPageView(context)
54+
override fun getView(context: Context, showLogo: Boolean): View {
55+
return NewTabLegacyPageView(context, showLogo = showLogo)
5656
}
5757
}
5858

app/src/test/java/com/duckduckgo/app/browser/newtab/NewTabPageProviderTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ class NewTabPageProviderTest {
125125
}
126126

127127
class LegacyNewTabPlugin : NewTabPagePlugin {
128-
override fun getView(context: Context): View {
128+
override fun getView(context: Context, showLogo: Boolean): View {
129129
return View(context)
130130
}
131131
}
132132

133-
class NewNewTabPlugin() : NewTabPagePlugin {
134-
override fun getView(context: Context): View {
133+
class NewNewTabPlugin : NewTabPagePlugin {
134+
override fun getView(context: Context, showLogo: Boolean): View {
135135
return View(context)
136136
}
137137
}

new-tab-page/new-tab-page-api/src/main/java/com/duckduckgo/newtabpage/api/NewTabPagePlugin.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ interface NewTabPagePlugin : ActivePlugin {
2929

3030
/**
3131
* This method returns a [View] that will be used as the NewTabPage content
32+
* @param context The context to create the view with
33+
* @param showLogo Whether to show the logo in the new tab page
3234
* @return [View]
3335
*/
34-
fun getView(context: Context): View
36+
fun getView(context: Context, showLogo: Boolean = true): View {
37+
return getView(context)
38+
}
3539

3640
companion object {
3741
const val PRIORITY_LEGACY_NTP = 0

new-tab-page/new-tab-page-impl/src/main/java/com/duckduckgo/newtabpage/impl/NewTabPage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import javax.inject.Inject
3535
)
3636
class NewTabPage @Inject constructor() : NewTabPagePlugin {
3737

38-
override fun getView(context: Context): View {
39-
return NewTabPageView(context)
38+
override fun getView(context: Context, showLogo: Boolean): View {
39+
return NewTabPageView(context, showLogo = showLogo)
4040
}
4141
}

new-tab-page/new-tab-page-impl/src/main/java/com/duckduckgo/newtabpage/impl/view/NewTabPageView.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import com.duckduckgo.newtabpage.impl.databinding.ViewNewTabPageBinding
4343
import com.duckduckgo.newtabpage.impl.view.NewTabPageViewModel.ViewState
4444
import dagger.android.support.AndroidSupportInjection
4545
import javax.inject.Inject
46-
import kotlinx.coroutines.cancel
4746
import kotlinx.coroutines.flow.launchIn
4847
import kotlinx.coroutines.flow.onEach
4948
import logcat.logcat
@@ -53,6 +52,7 @@ class NewTabPageView @JvmOverloads constructor(
5352
context: Context,
5453
attrs: AttributeSet? = null,
5554
defStyle: Int = 0,
55+
private val showLogo: Boolean = true,
5656
) : LinearLayout(context, attrs, defStyle) {
5757

5858
@Inject
@@ -96,10 +96,15 @@ class NewTabPageView @JvmOverloads constructor(
9696
if (viewState.loading) {
9797
binding.newTabContentShimmer.startShimmer()
9898
} else {
99-
if (viewState.showDax) {
100-
binding.ddgLogo.show()
99+
if (!showLogo && viewState.showDax) {
100+
this.gone()
101101
} else {
102-
binding.ddgLogo.gone()
102+
this.show()
103+
if (viewState.showDax) {
104+
binding.ddgLogo.show()
105+
} else {
106+
binding.ddgLogo.gone()
107+
}
103108
}
104109

105110
if (viewState.sections.isEmpty()) {

0 commit comments

Comments
 (0)