Skip to content

Commit

Permalink
Add Duck Player prime modal
Browse files Browse the repository at this point in the history
  • Loading branch information
CrisBarreiro committed Aug 1, 2024
1 parent e36c0de commit 6104195
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ import com.duckduckgo.downloads.api.DownloadConfirmationDialogListener
import com.duckduckgo.downloads.api.DownloadsFileActions
import com.duckduckgo.downloads.api.FileDownloader
import com.duckduckgo.downloads.api.FileDownloader.PendingFileDownload
import com.duckduckgo.duckplayer.api.DuckPlayerBottomSheet
import com.duckduckgo.duckplayer.api.DuckPlayerSettingsNoParams
import com.duckduckgo.js.messaging.api.JsCallbackData
import com.duckduckgo.js.messaging.api.JsMessageCallback
Expand Down Expand Up @@ -1545,6 +1546,7 @@ class BrowserTabFragment :
is Command.LaunchScreen -> launchScreen(it.screen, it.payload)
is Command.HideOnboardingDaxDialog -> hideOnboardingDaxDialog(it.onboardingCta)
is Command.OpenDuckPlayerSettings -> globalActivityStarter.start(binding.root.context, DuckPlayerSettingsNoParams)
is Command.OpenDuckPlayerInfo -> DuckPlayerBottomSheet.newInstance().show(childFragmentManager, null)
else -> {
// NO OP
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.duckduckgo.app.browser.duckplayer

import com.duckduckgo.app.browser.commands.Command
import com.duckduckgo.app.browser.commands.Command.OpenDuckPlayerInfo
import com.duckduckgo.app.browser.commands.Command.OpenDuckPlayerSettings
import com.duckduckgo.app.browser.commands.Command.SendResponseToDuckPlayer
import com.duckduckgo.app.browser.commands.Command.SendResponseToJs
Expand Down Expand Up @@ -165,6 +166,9 @@ class DuckPlayerJSHelper @Inject constructor(
"openSettings" -> {
return OpenDuckPlayerSettings
}
"openInfo" -> {
return OpenDuckPlayerInfo
}
"reportPageException", "reportInitException" -> {
Timber.tag(method).d(data.toString())
}
Expand Down
8 changes: 8 additions & 0 deletions duckplayer/duckplayer-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ dependencies {
implementation Kotlin.stdlib.jdk7
implementation AndroidX.core.ktx
implementation KotlinX.coroutines.core
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.recyclerview:recyclerview:1.3.0'
coreLibraryDesugaring Android.tools.desugarJdkLibs
implementation project(path: ':common-ui')
implementation project(path: ':common-utils')
implementation project(':navigation-api')
implementation "com.airbnb.android:lottie:_"
}


Expand All @@ -50,4 +55,7 @@ android {
compileOptions {
coreLibraryDesugaringEnabled = true
}
buildFeatures {
viewBinding true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.duckduckgo.duckplayer.api

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.airbnb.lottie.LottieCompositionFactory
import com.airbnb.lottie.LottieDrawable
import com.duckduckgo.duckplayer.api.databinding.BottomSheetDuckPlayerBinding
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

class DuckPlayerBottomSheet : BottomSheetDialogFragment() {

private lateinit var binding: BottomSheetDuckPlayerBinding

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
binding = BottomSheetDuckPlayerBinding.inflate(inflater, container, false)
LottieCompositionFactory.fromRawRes(context, R.raw.duckplayer)
binding.duckPlayerAnimation.setAnimation(R.raw.duckplayer)
binding.duckPlayerAnimation.playAnimation()
binding.duckPlayerAnimation.repeatCount = LottieDrawable.INFINITE
binding.dismissButton.setOnClickListener {
dismiss()
}
return binding.root
}

companion object {
fun newInstance(): DuckPlayerBottomSheet =
DuckPlayerBottomSheet()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2024 DuckDuckGo
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="16dp" /> <!-- Adjust the radius as needed -->
<solid android:color="#17000000" /> <!-- Background color -->
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="@dimen/daxDialogContentPaddingTop"
tools:context=".DuckPlayerBottomSheet">

<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:id="@+id/animationContainer"
android:layout_height="wrap_content"
app:cardCornerRadius="@dimen/keyline_2"
app:cardBackgroundColor="@color/gray20"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/duckPlayerAnimation"
android:layout_width="260dp"
android:layout_height="146dp"
app:lottie_fileName="your_animation.json"
app:lottie_autoPlay="true"
app:lottie_loop="true"
android:layout_gravity="center"
android:background="@drawable/duck_player_animation_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

</androidx.cardview.widget.CardView>

<com.duckduckgo.common.ui.view.text.DaxTextView
android:id="@+id/title"
app:layout_constraintTop_toBottomOf="@id/animationContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:typography="h1"
android:text="@string/duck_player_info_modal_title"
android:layout_margin="@dimen/keyline_5"
android:gravity="center"/>

<com.duckduckgo.common.ui.view.text.DaxTextView
android:id="@+id/body"
app:layout_constraintTop_toBottomOf="@id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:typography="body1"
android:gravity="center"
android:layout_marginHorizontal="40dp"
android:layout_marginVertical="@dimen/keyline_5"
android:text="@string/duck_player_info_modal_text" />

<com.duckduckgo.common.ui.view.button.DaxButtonPrimary
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/dismissButton"
app:layout_constraintTop_toBottomOf="@id/body"
app:buttonSize="large"
android:layout_marginHorizontal="55dp"
android:layout_marginVertical="@dimen/keyline_5"
android:text="@string/duck_player_info_modal_button"/>

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions duckplayer/duckplayer-api/src/main/res/raw/duckplayer.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions duckplayer/duckplayer-api/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2024 DuckDuckGo
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<resources>
<string name="duck_player_info_modal_title">Drowning in ads on YouTube? Try Duck Player!</string>
<string name="duck_player_info_modal_text">Duck Player lets you watch YouTube without targeted ads in a theater-like experience in DuckDuckGo and what you watch won’t influence your recommendations.</string>
<string name="duck_player_info_modal_button">Got it!</string>
</resources>

0 comments on commit 6104195

Please sign in to comment.