Skip to content

Commit c254194

Browse files
committed
Tappx SDK APP Kotlin version 1.0
0 parents  commit c254194

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2272
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/deploymentTargetSelector.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/migrations.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.android)
4+
}
5+
6+
android {
7+
namespace 'com.example.tappxsdkapp'
8+
compileSdk 35
9+
10+
defaultConfig {
11+
applicationId "com.example.tappxsdkapp"
12+
minSdk 24
13+
targetSdk 35
14+
versionCode 1
15+
versionName "1.0"
16+
17+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18+
}
19+
20+
buildTypes {
21+
release {
22+
minifyEnabled false
23+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24+
}
25+
}
26+
compileOptions {
27+
sourceCompatibility JavaVersion.VERSION_11
28+
targetCompatibility JavaVersion.VERSION_11
29+
}
30+
kotlinOptions {
31+
jvmTarget = '11'
32+
}
33+
}
34+
35+
dependencies {
36+
37+
implementation libs.androidx.core.ktx
38+
implementation libs.androidx.appcompat
39+
implementation libs.material
40+
testImplementation libs.junit
41+
androidTestImplementation libs.androidx.junit
42+
androidTestImplementation libs.androidx.espresso.core
43+
implementation 'com.tappx.sdk.android:tappx-sdk:4.+'
44+
implementation 'com.tappx.sdk.android:omsdk:1.5.2'
45+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

app/src/main/AndroidManifest.xml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:dataExtractionRules="@xml/data_extraction_rules"
8+
android:fullBackupContent="@xml/backup_rules"
9+
android:icon="@mipmap/tappx_icon"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/tappx_icon"
12+
android:supportsRtl="true"
13+
android:theme="@style/Theme.TappxSDKApp"
14+
tools:targetApi="31">
15+
16+
<activity android:name="tappx_sdk_app.views.SplashView" android:screenOrientation="portrait" android:exported="true">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN"/>
19+
<category android:name="android.intent.category.LAUNCHER"/>
20+
</intent-filter>
21+
</activity>
22+
23+
<activity android:name="tappx_sdk_app.views.MainView" android:screenOrientation="portrait" android:exported="true"/>
24+
<activity android:name="tappx_sdk_app.views.BannerView" android:screenOrientation="portrait" android:exported="true"/>
25+
<activity android:name="tappx_sdk_app.views.FullScreenView" android:screenOrientation="portrait" android:exported="true"/>
26+
27+
28+
</application>
29+
30+
31+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package tappx_sdk_app.ads
2+
3+
enum class AdSubType {
4+
phone_320X50,
5+
smart,
6+
MREC_300X250,
7+
tablet_728x90
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package tappx_sdk_app.ads
2+
3+
enum class AdType {
4+
Banner,
5+
MREC,
6+
Interstitial,
7+
Rewarded
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package tappx_sdk_app.ads
2+
3+
import android.content.Context
4+
import android.util.Log
5+
import android.view.ViewGroup
6+
import android.widget.TextView
7+
import com.example.tappxsdkapp.R
8+
import com.tappx.sdk.android.AdRequest
9+
import com.tappx.sdk.android.TappxAdError
10+
import com.tappx.sdk.android.TappxBanner
11+
import com.tappx.sdk.android.TappxBannerListener
12+
13+
class BannerAd(
14+
private val context: Context,
15+
private val bannerContainer: ViewGroup,
16+
private val statusLog: TextView
17+
) {
18+
private var banner: TappxBanner? = null
19+
20+
var adSubType: AdSubType? = null
21+
get() = field
22+
set(value) {
23+
field = value
24+
}
25+
26+
fun loadBanner() {
27+
banner = TappxBanner(context, context.getString(R.string.tappx_key))
28+
when (adSubType) {
29+
AdSubType.phone_320X50 -> banner!!.setAdSize(TappxBanner.AdSize.BANNER_320x50)
30+
AdSubType.tablet_728x90 -> banner!!.setAdSize(TappxBanner.AdSize.BANNER_728x90)
31+
AdSubType.smart -> banner!!.setAdSize(TappxBanner.AdSize.SMART_BANNER)
32+
else -> banner!!.setAdSize(TappxBanner.AdSize.BANNER_320x50)
33+
}
34+
35+
// Add Banner to container
36+
bannerContainer.addView(banner)
37+
38+
// Set refresh configuration
39+
banner!!.setRefreshTimeSeconds(45)
40+
banner!!.setEnableAutoRefresh(false)
41+
42+
// LoadAd
43+
banner!!.loadAd(
44+
AdRequest()
45+
.useTestAds(context.resources.getBoolean(R.bool.useTestAds))
46+
.setEndpoint(context.getString(R.string.endpoint))
47+
)
48+
49+
// Add Listeners
50+
banner!!.setListener(object : TappxBannerListener {
51+
override fun onBannerLoaded(tappxBanner: TappxBanner) {
52+
// Update the log when the banner is successfully loaded
53+
val message = "Banner Loaded Successfully!"
54+
updateLog(message)
55+
}
56+
57+
override fun onBannerLoadFailed(tappxBanner: TappxBanner, tappxAdError: TappxAdError) {
58+
// Log the error when banner load fails
59+
val message = "Banner Load Failed"
60+
updateLog(message)
61+
}
62+
63+
override fun onBannerClicked(tappxBanner: TappxBanner) {
64+
// Log the click event
65+
val message = "Banner Clicked!"
66+
updateLog(message)
67+
}
68+
69+
override fun onBannerExpanded(tappxBanner: TappxBanner) {
70+
// Log the banner expansion
71+
val message = "Banner Expanded!"
72+
updateLog(message)
73+
}
74+
75+
override fun onBannerCollapsed(tappxBanner: TappxBanner) {
76+
// Log the banner collapse
77+
val message = "Banner Collapsed!"
78+
updateLog(message)
79+
}
80+
})
81+
}
82+
83+
// Method to update the TextView inside the ScrollView with log messages
84+
private fun updateLog(message: String) {
85+
if (statusLog.text.isNotEmpty()) {
86+
statusLog.append("\n$message")
87+
} else {
88+
statusLog.append(message)
89+
}
90+
Log.e("Tappx SDK", message)
91+
}
92+
}

0 commit comments

Comments
 (0)