File tree Expand file tree Collapse file tree 6 files changed +30
-15
lines changed
main/java/com/duckduckgo/app/browser/newtab
test/java/com/duckduckgo/app/browser/newtab
new-tab-page-api/src/main/java/com/duckduckgo/newtabpage/api
new-tab-page-impl/src/main/java/com/duckduckgo/newtabpage/impl Expand file tree Collapse file tree 6 files changed +30
-15
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ class NewTabLegacyPageView @JvmOverloads constructor(
73
73
context : Context ,
74
74
attrs : AttributeSet ? = null ,
75
75
defStyle : Int = 0 ,
76
+ private val showLogo : Boolean = true ,
76
77
) : LinearLayout(context, attrs, defStyle) {
77
78
78
79
@Inject
@@ -136,10 +137,15 @@ class NewTabLegacyPageView @JvmOverloads constructor(
136
137
val isHomeBackgroundLogoVisible = (! viewState.onboardingComplete || viewState.message == null ) &&
137
138
viewState.favourites.isEmpty()
138
139
139
- if (isHomeBackgroundLogoVisible) {
140
- homeBackgroundLogo.showLogo ()
140
+ if (! showLogo && isHomeBackgroundLogoVisible) {
141
+ this .gone ()
141
142
} else {
142
- homeBackgroundLogo.hideLogo()
143
+ this .show()
144
+ if (isHomeBackgroundLogoVisible) {
145
+ homeBackgroundLogo.showLogo()
146
+ } else {
147
+ homeBackgroundLogo.hideLogo()
148
+ }
143
149
}
144
150
if (viewState.message != null && viewState.onboardingComplete) {
145
151
showRemoteMessage(viewState.message, viewState.newMessage)
Original file line number Diff line number Diff line change @@ -51,8 +51,8 @@ class RealNewTabPageProvider @Inject constructor(
51
51
)
52
52
class NewTabLegacyPage @Inject constructor() : NewTabPagePlugin {
53
53
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 )
56
56
}
57
57
}
58
58
Original file line number Diff line number Diff line change @@ -125,13 +125,13 @@ class NewTabPageProviderTest {
125
125
}
126
126
127
127
class LegacyNewTabPlugin : NewTabPagePlugin {
128
- override fun getView (context : Context ): View {
128
+ override fun getView (context : Context , showLogo : Boolean ): View {
129
129
return View (context)
130
130
}
131
131
}
132
132
133
- class NewNewTabPlugin () : NewTabPagePlugin {
134
- override fun getView (context : Context ): View {
133
+ class NewNewTabPlugin : NewTabPagePlugin {
134
+ override fun getView (context : Context , showLogo : Boolean ): View {
135
135
return View (context)
136
136
}
137
137
}
Original file line number Diff line number Diff line change @@ -29,9 +29,13 @@ interface NewTabPagePlugin : ActivePlugin {
29
29
30
30
/* *
31
31
* 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
32
34
* @return [View]
33
35
*/
34
- fun getView (context : Context ): View
36
+ fun getView (context : Context , showLogo : Boolean = true): View {
37
+ return getView(context)
38
+ }
35
39
36
40
companion object {
37
41
const val PRIORITY_LEGACY_NTP = 0
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ import javax.inject.Inject
35
35
)
36
36
class NewTabPage @Inject constructor() : NewTabPagePlugin {
37
37
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 )
40
40
}
41
41
}
Original file line number Diff line number Diff line change @@ -43,7 +43,6 @@ import com.duckduckgo.newtabpage.impl.databinding.ViewNewTabPageBinding
43
43
import com.duckduckgo.newtabpage.impl.view.NewTabPageViewModel.ViewState
44
44
import dagger.android.support.AndroidSupportInjection
45
45
import javax.inject.Inject
46
- import kotlinx.coroutines.cancel
47
46
import kotlinx.coroutines.flow.launchIn
48
47
import kotlinx.coroutines.flow.onEach
49
48
import logcat.logcat
@@ -53,6 +52,7 @@ class NewTabPageView @JvmOverloads constructor(
53
52
context : Context ,
54
53
attrs : AttributeSet ? = null ,
55
54
defStyle : Int = 0 ,
55
+ private val showLogo : Boolean = true ,
56
56
) : LinearLayout(context, attrs, defStyle) {
57
57
58
58
@Inject
@@ -96,10 +96,15 @@ class NewTabPageView @JvmOverloads constructor(
96
96
if (viewState.loading) {
97
97
binding.newTabContentShimmer.startShimmer()
98
98
} else {
99
- if (viewState.showDax) {
100
- binding.ddgLogo.show ()
99
+ if (! showLogo && viewState.showDax) {
100
+ this .gone ()
101
101
} else {
102
- binding.ddgLogo.gone()
102
+ this .show()
103
+ if (viewState.showDax) {
104
+ binding.ddgLogo.show()
105
+ } else {
106
+ binding.ddgLogo.gone()
107
+ }
103
108
}
104
109
105
110
if (viewState.sections.isEmpty()) {
You can’t perform that action at this time.
0 commit comments