Skip to content

Commit

Permalink
Release: 1.0.1 beta09 (#62)
Browse files Browse the repository at this point in the history
* feat: add native video sample

* chore: update SDK to 1.0.1-beta09
  • Loading branch information
MortezaNedaei authored Nov 3, 2024
1 parent 5ca7f32 commit 4de62f9
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 9 deletions.
10 changes: 7 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ appcompat = "1.7.0"
leakcanary = "2.14"
material = "1.12.0"
constraintlayout = "2.1.4"
navigation-fragment-ktx = "2.8.1"
navigation-fragment-ktx = "2.8.2"
google-appset = "16.1.0"
google-ads-identifier = "18.1.0"
tapsell = "1.0.1-beta08"
tapsell = "1.0.1-beta09"
lifecycle-livedata-ktx = "2.8.6"
lifecycle-viewmodel-ktx = "2.8.6"
lifecycle-runtime-ktx = "2.8.6"
activity = "1.9.2"
activity-compose = "1.9.2"
compose-bom = "2024.09.02"
compose-bom = "2024.09.03"
coil = "2.6.0"
appium = "9.3.0"

[libraries]
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation-fragment-ktx" }
Expand Down Expand Up @@ -60,6 +61,9 @@ ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
material3 = { group = "androidx.compose.material3", name = "material3" }
coil = { module = "io.coil-kt:coil", version.ref = "coil" }

appium = { module = "io.appium:java-client", version.ref = "appium" }

androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
Expand Down
1 change: 1 addition & 0 deletions maestro/TapsellUITester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ rm -rf maestro-outputs
maestro test rewarded.yaml
maestro test interstitial.yaml
maestro test native.yaml
maestro test native-video.yaml
maestro test native-multiple.yaml
maestro test standard.yaml
maestro test preroll.yaml
Expand Down
39 changes: 39 additions & 0 deletions maestro/native-video.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
appId: ir.tapsell.sample
---
- launchApp:
appId: ir.tapsell.sample
clearState: true
- startRecording: Native
- extendedWaitUntil:
visible: "onInitializationComplete.*"
timeout: 15000
- tapOn:
text: Native Banner
- tapOn:
text: Tapsell Legacy
repeat: 1
delay: 2000
- tapOn:
text: Native Video
repeat: 1
delay: 2000
- tapOn:
text: Request
repeat: 1
delay: 5000
- extendedWaitUntil:
visible: .*onSuccess.*
timeout: 5000
- tapOn:
text: Show
waitToSettleTimeoutMs: 2000
- assertVisible:
text: .*onAdImpression.*
- tapOn:
text: .*کلیک.*
- back
- assertVisible:
text: .*onAdClicked.*
- stopRecording
- takeScreenshot: maestro-outputs/Native
- stopApp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import ir.tapsell.sample.R
import ir.tapsell.sample.databinding.FragmentNativeBannerBinding
import ir.tapsell.sample.utils.addChip
import ir.tapsell.shared.MULTIPLE_NATIVE_REQUESTS_COUNT
import ir.tapsell.shared.TapsellNativeAdNetworks
import ir.tapsell.shared.TapsellKeys
import ir.tapsell.shared.TapsellKeys.TapsellMediationKeys
import ir.tapsell.shared.TapsellNativeAdNetworks
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

Expand All @@ -38,6 +39,11 @@ class NativeBannerFragment : Fragment() {
TapsellNativeAdNetworks.map { adNetwork ->
binding.chipAdNetworks.addChip(requireContext(), adNetwork.name) {
binding.inputZone.setText(adNetwork.native)
updateZoneInput(adNetwork)
binding.tvSwitchNativeVideo.setOnClickListener {
binding.switchNativeType.isChecked = binding.switchNativeType.isChecked.not()
updateZoneInput(adNetwork)
}
}
}

Expand All @@ -59,6 +65,20 @@ class NativeBannerFragment : Fragment() {
}
}

/**
* handle native video and native banner
*/
private fun updateZoneInput(adNetwork: TapsellKeys) {
if (binding.switchNativeType.isChecked) {
// Native video is only available for `TapsellMediationKeys` and `LegacyKeys`
when (adNetwork) {
is TapsellMediationKeys -> binding.inputZone.setText(adNetwork.nativeVideo)
is TapsellKeys.LegacyKeys -> binding.inputZone.setText(adNetwork.nativeVideo)
else -> binding.inputZone.setText(adNetwork.native)
}
}
}

private fun requestAd(count: Int = 1) {
viewModel.requestAd(binding.inputZone.text.toString(), count)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class NativeBannerViewModel : BaseViewModel() {

var responseIds = hashSetOf<String>()
private set
var isNativeVideo = false
private set

fun requestAd(zoneId: String, count: Int = 1) {
object : RequestResultListener {
Expand Down Expand Up @@ -68,4 +70,8 @@ class NativeBannerViewModel : BaseViewModel() {
})
}
}

fun setNativeVideo(isNativeVideo: Boolean) {
this.isNativeVideo = isNativeVideo
}
}
25 changes: 24 additions & 1 deletion sample-kotlin/src/main/res/layout/fragment_native_banner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,35 @@
app:selectionRequired="true"
app:singleSelection="true" />

<LinearLayout
android:id="@+id/ly_switch_native_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chip_adNetworks">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/tv_switch_native_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/h5"
android:text="@string/native_video" />

<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/switch_native_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false" />
</LinearLayout>


<com.google.android.material.button.MaterialButton
android:id="@+id/btn_request"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/request"
android:layout_marginVertical="8dp"
android:text="@string/request"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down
12 changes: 8 additions & 4 deletions shared/src/main/java/ir/tapsell/shared/TapsellKeys.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ sealed interface TapsellKeys : TapsellAdTypes {
override val interstitial get() = INTERSTITIAL
override val appOpen get() = APP_OPEN
override val banner get() = BANNER
override val native get() = NATIVE
override val native get() = NATIVE_BANNER
val nativeVideo get() = NATIVE_VIDEO
override val preRoll get() = PRE_ROLL
private const val REWARDED = "1d710cc7-5e96-46ac-a3e9-8463300333e6"
private const val INTERSTITIAL = "b3972749-f62a-475a-9ff2-cfc9e2a40f87"
private const val APP_OPEN = NO_SUPPORT_KEY
private const val NATIVE = "d217e3e6-0070-4120-925d-5d39d0298893"
private const val NATIVE_BANNER = "d217e3e6-0070-4120-925d-5d39d0298893"
private const val NATIVE_VIDEO = "f3fb937a-bb3d-4e54-8d4c-2f4aa963c74c"
private const val BANNER = "e3d5999c-5990-4e31-8ce9-642ce040a7f4"
private const val PRE_ROLL = "6977a96f-e265-4895-b219-33bb6ba3df85"
}
Expand All @@ -47,11 +49,13 @@ sealed interface TapsellKeys : TapsellAdTypes {
override val rewarded get() = REWARDED
override val interstitial get() = INTERSTITIAL
override val banner get() = BANNER
override val native get() = NATIVE
override val native get() = NATIVE_BANNER
override val preRoll get() = PRE_ROLL
val nativeVideo get() = NATIVE_VIDEO
private const val REWARDED = "63b92f04-3d0f-4805-84a4-abeccf4edc18"
private const val INTERSTITIAL = "0c4e2849-feea-4688-8280-0b0ae2ee0728"
private const val NATIVE = "b1b92bca-8a54-4b82-9f53-90ea2b1a912c"
private const val NATIVE_BANNER = "b1b92bca-8a54-4b82-9f53-90ea2b1a912c"
private const val NATIVE_VIDEO = "236e51ac-4fed-4263-b50a-7240558c73cb"
private const val BANNER = "4bf4e11d-0967-41e6-91f6-a128d9462f2a"
private const val PRE_ROLL = "628f60d7-8fd0-4aea-a840-2d2947121dd5"
}
Expand Down

0 comments on commit 4de62f9

Please sign in to comment.