Skip to content

Commit

Permalink
Making disabling ads easy (and disabled by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecNew10 committed Apr 6, 2023
1 parent 17a33c9 commit 0588479
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions appdb/Startup/Global.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func debugLog(_ arg: Any) {

enum Global {

static let showAds: Bool = false

static let adsId: String = "5209496"
#if DEBUG
static let DEBUG = true
Expand Down
12 changes: 6 additions & 6 deletions appdb/Tabs/Featured/Details/Details.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Details: LoadingTableView {
fetchInfo(type: dynamicType, trackid: dynamicTrackid)
}

if !Global.DEBUG && !Preferences.isPlus {
if Global.showAds && !Global.DEBUG && !Preferences.isPlus {
UnityAds.initialize(Global.adsId, testMode: Global.adsTestMode, initializationDelegate: self)
}
}
Expand Down Expand Up @@ -187,13 +187,13 @@ class Details: LoadingTableView {
if link.cracker == link.uploader {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "downloadUnified", for: indexPath) as? DetailsDownloadUnified else { return UITableViewCell() }
cell.accessoryType = shouldHideDisclosureIndicator ? .none : .disclosureIndicator
cell.configure(with: link, installEnabled: adsLoaded)
cell.configure(with: link, installEnabled: !Global.showAds || adsLoaded)
cell.button.addTarget(self, action: #selector(self.install), for: .touchUpInside)
return cell
} else {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "download", for: indexPath) as? DetailsDownload else { return UITableViewCell() }
cell.accessoryType = shouldHideDisclosureIndicator ? .none : .disclosureIndicator
cell.configure(with: link, installEnabled: adsLoaded)
cell.configure(with: link, installEnabled: !Global.showAds || adsLoaded)
cell.button.addTarget(self, action: #selector(self.install), for: .touchUpInside)
return cell
}
Expand Down Expand Up @@ -288,7 +288,7 @@ class Details: LoadingTableView {

@objc private func install(sender: RoundedButton) {
currentInstallButton = sender
if Global.DEBUG || Preferences.isPlus {
if !Global.showAds || Global.DEBUG || Preferences.isPlus {
actualInstall(sender: currentInstallButton!)
} else {
UnityAds.show(self, placementId: "Interstitial_iOS", showDelegate: self)
Expand Down Expand Up @@ -539,7 +539,7 @@ extension Details: UnityAdsInitializationDelegate {
func initializationComplete() {
adsInitialized = true

if !Global.DEBUG && !Preferences.isPlus {
if Global.showAds && !Global.DEBUG && !Preferences.isPlus {
UnityAds.load("Interstitial_iOS", loadDelegate: self)
}
}
Expand Down Expand Up @@ -574,7 +574,7 @@ extension Details: UnityAdsShowDelegate {
if indexForSegment == .download {
tableView.reloadData()
}
if !Global.DEBUG && !Preferences.isPlus {
if Global.showAds && !Global.DEBUG && !Preferences.isPlus {
UnityAds.load("Interstitial_iOS", loadDelegate: self)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UnityAds
class AltStoreAppDetails: LoadingTableView {

var adsInitialized: Bool = false
var adsLoaded: Bool = Global.DEBUG || Preferences.isPlus
var adsLoaded: Bool = !Global.showAds || Global.DEBUG || Preferences.isPlus
var currentInstallButton: RoundedButton?

var app: AltStoreApp!
Expand Down Expand Up @@ -42,7 +42,7 @@ class AltStoreAppDetails: LoadingTableView {
setUp()
initializeCells()

if !Global.DEBUG && !Preferences.isPlus {
if Global.showAds && !Global.DEBUG && !Preferences.isPlus {
UnityAds.initialize(Global.adsId, testMode: Global.adsTestMode, initializationDelegate: self)
}
}
Expand Down Expand Up @@ -103,7 +103,7 @@ class AltStoreAppDetails: LoadingTableView {

@objc func install(sender: RoundedButton) {
currentInstallButton = sender
if Global.DEBUG || Preferences.isPlus {
if !Global.showAds || Global.DEBUG || Preferences.isPlus {
actualInstall(sender: currentInstallButton!)
} else {
UnityAds.show(self, placementId: "Interstitial_iOS", showDelegate: self)
Expand Down Expand Up @@ -222,7 +222,7 @@ extension AltStoreAppDetails: UnityAdsInitializationDelegate {
func initializationComplete() {
adsInitialized = true

if !Global.DEBUG && !Preferences.isPlus {
if Global.showAds && !Global.DEBUG && !Preferences.isPlus {
UnityAds.load("Interstitial_iOS", loadDelegate: self)
}
}
Expand Down

0 comments on commit 0588479

Please sign in to comment.