Skip to content

Commit

Permalink
disable ad framework
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Nov 24, 2023
1 parent d046703 commit 42e3724
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
1 change: 0 additions & 1 deletion Habitica/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ dependencies {
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.firebase:firebase-config-ktx'
implementation 'com.google.firebase:firebase-perf-ktx'
implementation 'com.google.android.gms:play-services-ads:22.4.0'
implementation "com.google.android.gms:play-services-auth:$play_auth_version"
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation "com.google.android.gms:play-services-wearable:$play_wearables_version"
Expand Down
6 changes: 0 additions & 6 deletions Habitica/google-services.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
},
Expand Down Expand Up @@ -62,9 +59,6 @@
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import android.provider.Settings
import android.util.Log
import androidx.core.content.edit
import androidx.core.os.bundleOf
import com.google.android.gms.ads.AdRequest
/*import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.LoadAdError
import com.google.android.gms.ads.MobileAds
import com.google.android.gms.ads.OnUserEarnedRewardListener
import com.google.android.gms.ads.RequestConfiguration
import com.google.android.gms.ads.rewarded.RewardItem
import com.google.android.gms.ads.rewarded.RewardedAd
import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback
import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback*/
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.habitrpg.android.habitica.BuildConfig
Expand Down Expand Up @@ -63,8 +63,8 @@ fun String.md5(): String? {
}
}

class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boolean) -> Unit) : OnUserEarnedRewardListener {
private var rewardedAd: RewardedAd? = null
class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boolean) -> Unit) {
//private var rewardedAd: RewardedAd? = null

companion object {
private enum class AdStatus {
Expand Down Expand Up @@ -111,16 +111,16 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo
val android_id: String =
Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
val deviceId: String = android_id.md5()?.uppercase() ?: ""
val configuration = RequestConfiguration.Builder().setTestDeviceIds(listOf(deviceId)).build()
MobileAds.setRequestConfiguration(configuration)
//val configuration = RequestConfiguration.Builder().setTestDeviceIds(listOf(deviceId)).build()
//MobileAds.setRequestConfiguration(configuration)
}

currentAdStatus = AdStatus.INITIALIZING
MobileAds.initialize(context) {
/*MobileAds.initialize(context) {
currentAdStatus = AdStatus.READY
onComplete()
FirebaseCrashlytics.getInstance().recordException(Throwable("Ads Initialized"))
}
}*/
}

fun whenAdsInitialized(context: Context, onComplete: () -> Unit) {
Expand Down Expand Up @@ -156,7 +156,7 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo

fun prepare(onComplete: ((Boolean) -> Unit)? = null) {
whenAdsInitialized(activity) {
val adRequest = AdRequest.Builder()
/*val adRequest = AdRequest.Builder()
.build()
if (BuildConfig.DEBUG || BuildConfig.TESTING_LEVEL == "staff" || BuildConfig.TESTING_LEVEL == "alpha") {
Expand Down Expand Up @@ -184,7 +184,7 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo
onComplete?.invoke(true)
}
}
)
)*/
}
}

Expand All @@ -209,22 +209,22 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo
}

private fun configureReward() {
rewardedAd?.run { }
//rewardedAd?.run { }
}

private fun showRewardedAd() {
if (nextAdAllowedDate(type)?.after(Date()) == true) {
return
}
if (rewardedAd != null) {
/*if (rewardedAd != null) {
rewardedAd?.show(activity, this)
setNextAllowedDate(type)
} else {
Log.d(TAG, "The rewarded ad wasn't ready yet.")
}
}*/
}

override fun onUserEarnedReward(rewardItem: RewardItem) {
/*override fun onUserEarnedReward(rewardItem: RewardItem) {
Analytics.sendEvent(
"adRewardEarned",
EventCategory.BEHAVIOUR,
Expand All @@ -240,5 +240,5 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo
)
)
rewardAction(true)
}
}*/
}

0 comments on commit 42e3724

Please sign in to comment.