Commit c3ad571c by Demid Merzlyakov

IOS-175: move AppConfig and AdConfig to the Core.

parent f7988497
......@@ -115,7 +115,6 @@
CD6B304325726AD1004B34B3 /* DefaultTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6B304225726AD1004B34B3 /* DefaultTheme.swift */; };
CD6C22EA26677BE000D75659 /* ConfigManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6C22E926677BDF00D75659 /* ConfigManager.swift */; };
CD6C22EE26677DBC00D75659 /* PushNotificationsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6C22ED26677DBC00D75659 /* PushNotificationsManager.swift */; };
CD6C22F1266780BE00D75659 /* AdConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6C22E726677B4900D75659 /* AdConfig.swift */; };
CD6C22F2266780ED00D75659 /* AdConfigManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6C22E626677B4900D75659 /* AdConfigManager.swift */; };
CD6C22F32667815000D75659 /* EnvironmentManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6C22E526677B4900D75659 /* EnvironmentManager.swift */; };
CD71709025FA317700A63C27 /* ForecastTimePeriodView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD71708F25FA317700A63C27 /* ForecastTimePeriodView.swift */; };
......@@ -415,7 +414,6 @@
CD6B304225726AD1004B34B3 /* DefaultTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultTheme.swift; sourceTree = "<group>"; };
CD6C22E526677B4900D75659 /* EnvironmentManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EnvironmentManager.swift; sourceTree = "<group>"; };
CD6C22E626677B4900D75659 /* AdConfigManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdConfigManager.swift; sourceTree = "<group>"; };
CD6C22E726677B4900D75659 /* AdConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdConfig.swift; sourceTree = "<group>"; };
CD6C22E926677BDF00D75659 /* ConfigManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigManager.swift; sourceTree = "<group>"; };
CD6C22ED26677DBC00D75659 /* PushNotificationsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushNotificationsManager.swift; sourceTree = "<group>"; };
CD71708F25FA317700A63C27 /* ForecastTimePeriodView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastTimePeriodView.swift; sourceTree = "<group>"; };
......@@ -983,7 +981,6 @@
children = (
CD6C22E526677B4900D75659 /* EnvironmentManager.swift */,
CD6C22E626677B4900D75659 /* AdConfigManager.swift */,
CD6C22E726677B4900D75659 /* AdConfig.swift */,
);
path = Configuration;
sourceTree = "<group>";
......@@ -1848,7 +1845,6 @@
files = (
CD6C22F32667815000D75659 /* EnvironmentManager.swift in Sources */,
CD6C22F2266780ED00D75659 /* AdConfigManager.swift in Sources */,
CD6C22F1266780BE00D75659 /* AdConfig.swift in Sources */,
CD35DFD0260344A500F2138F /* ForecastConditionView.swift in Sources */,
CD857EA7268B45DD00B5E069 /* PromotionSmallWidgetView.swift in Sources */,
CD2ABF32261489F700C1A92E /* LocationCellFactory.swift in Sources */,
......@@ -1955,7 +1951,6 @@
CD6B303E25726960004B34B3 /* ThemeProtocol.swift in Sources */,
CD6B303B2572680C004B34B3 /* SelfSizingButton.swift in Sources */,
CDC62C4726C13BE300156643 /* OnboardingContentController.swift in Sources */,
CD9B6B1125DBC723001D9B80 /* CubicCurveAlgorithm.swift in Sources */,
CD8B60B4263819790055CB3F /* NotificationsViewController.swift in Sources */,
CD67617026259D220079D273 /* RadarMapLayersController.swift in Sources */,
CEC8FBAF2639756A0001A6BF /* OnboardingViewController.swift in Sources */,
......
......@@ -7,14 +7,13 @@
//
import UIKit
import OneWeatherCore
import OneWeatherAnalytics
extension Notification.Name {
public static let adConfigChanged = Notification.Name(rawValue: "AdConfig.Changed")
}
public typealias AdPlacementName = String
public let placementNameTodayBanner: AdPlacementName = "today_banner"
public let placementNameTodaySquare: AdPlacementName = "today_square"
public let placementNameForecastHourlyBanner: AdPlacementName = "forecast_hourly_banner"
......
......@@ -6,6 +6,7 @@
//
import Foundation
import OneWeatherCore
import GoogleMobileAds
class NativeAdView: GADNativeAdView {
......
......@@ -7,8 +7,9 @@
//
import Foundation
import GoogleMobileAds
import OneWeatherAnalytics
import OneWeatherCore
import GoogleMobileAds
protocol NativeBannerContainerViewDelegate: AnyObject {
func adLoader(_ adLoader: GADAdLoader, didReceive nativeAd: GADNativeAd)
......
......@@ -12,39 +12,6 @@ import FirebaseRemoteConfig
import OneWeatherAnalytics
import OneWeatherCore
public struct AppConfig: Codable {
public let popularCities: [GeoNamesPlace]?
public let adConfig: AdConfig
public let ccpaUpdateInterval: TimeInterval?
public let nwsAlertsViaMoEngageEnabled: Bool
public let showAttPrompt: Bool
public let shortsLeftBelowCount: Int
public let shortsLastNudgeEnabled: Bool
public let shortsSwipeUpNudgeCount: Int
public let showOnboarding: Bool
public init(popularCities: [GeoNamesPlace]?,
adConfig: AdConfig,
ccpaUpdateInterval: TimeInterval?,
nwsAlertsViaMoEngageEnabled: Bool,
showAttPrompt: Bool,
shortsLeftBelowCountKey: Int,
shortsLastNudgeEnabledKey: Bool,
shortsSwipeUpNudgeCountKey: Int,
showOnboarding: Bool
) {
self.popularCities = popularCities
self.adConfig = adConfig
self.ccpaUpdateInterval = ccpaUpdateInterval
self.nwsAlertsViaMoEngageEnabled = nwsAlertsViaMoEngageEnabled
self.showAttPrompt = showAttPrompt
self.shortsLeftBelowCount = shortsLeftBelowCountKey
self.shortsLastNudgeEnabled = shortsLastNudgeEnabledKey
self.shortsSwipeUpNudgeCount = shortsSwipeUpNudgeCountKey
self.showOnboarding = showOnboarding
}
}
public protocol ConfigManagerDelegate {
func dataUpdated(by configManager: ConfigManager)
}
......
......@@ -77,6 +77,10 @@
CDFE458D26566BD50021A29F /* Storage.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFE458C26566BD50021A29F /* Storage.swift */; };
CDFE459426566D7B0021A29F /* HealthSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFE459326566D7B0021A29F /* HealthSource.swift */; };
CDFE459626566D860021A29F /* FIPSSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFE459526566D860021A29F /* FIPSSource.swift */; };
CE72A75F26D627E300F13CF7 /* AppConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE72A75E26D627E300F13CF7 /* AppConfig.swift */; };
CE72A76126D627FF00F13CF7 /* AdConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE72A76026D627FF00F13CF7 /* AdConfig.swift */; };
CE72A76426D6285800F13CF7 /* AdTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE72A76326D6285800F13CF7 /* AdTypes.swift */; };
CE72A76626D6299300F13CF7 /* AdPlacement.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE72A76526D6299300F13CF7 /* AdPlacement.swift */; };
CEFE851826948C15003C67D3 /* SmartTextProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFE851726948C15003C67D3 /* SmartTextProvider.swift */; };
CEFE851C2694986D003C67D3 /* SmartText.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFE851B2694986D003C67D3 /* SmartText.swift */; };
CEFE85202694C4BC003C67D3 /* DefaultSmartText.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFE851F2694C4BC003C67D3 /* DefaultSmartText.swift */; };
......@@ -176,6 +180,10 @@
CDFE458C26566BD50021A29F /* Storage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Storage.swift; sourceTree = "<group>"; };
CDFE459326566D7B0021A29F /* HealthSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HealthSource.swift; sourceTree = "<group>"; };
CDFE459526566D860021A29F /* FIPSSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FIPSSource.swift; sourceTree = "<group>"; };
CE72A75E26D627E300F13CF7 /* AppConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConfig.swift; sourceTree = "<group>"; };
CE72A76026D627FF00F13CF7 /* AdConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdConfig.swift; sourceTree = "<group>"; };
CE72A76326D6285800F13CF7 /* AdTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdTypes.swift; sourceTree = "<group>"; };
CE72A76526D6299300F13CF7 /* AdPlacement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdPlacement.swift; sourceTree = "<group>"; };
CEFE851726948C15003C67D3 /* SmartTextProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmartTextProvider.swift; sourceTree = "<group>"; };
CEFE851B2694986D003C67D3 /* SmartText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmartText.swift; sourceTree = "<group>"; };
CEFE851D2694C477003C67D3 /* SmartTextMacro.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmartTextMacro.swift; sourceTree = "<group>"; };
......@@ -352,6 +360,7 @@
CD615F942655269200B717DB /* ModelObjects */ = {
isa = PBXGroup;
children = (
CE72A75D26D627D100F13CF7 /* Config */,
CDBC243E2656740E00F9F4E2 /* AppData.swift */,
CD615F862655269200B717DB /* GeoNamesPlace.swift */,
CD11AFEC26651E0A00EC4BA0 /* WdtWeatherSourceError.swift */,
......@@ -458,6 +467,25 @@
path = Sources;
sourceTree = "<group>";
};
CE72A75D26D627D100F13CF7 /* Config */ = {
isa = PBXGroup;
children = (
CE72A76226D6284300F13CF7 /* Ads */,
CE72A75E26D627E300F13CF7 /* AppConfig.swift */,
);
path = Config;
sourceTree = "<group>";
};
CE72A76226D6284300F13CF7 /* Ads */ = {
isa = PBXGroup;
children = (
CE72A76026D627FF00F13CF7 /* AdConfig.swift */,
CE72A76326D6285800F13CF7 /* AdTypes.swift */,
CE72A76526D6299300F13CF7 /* AdPlacement.swift */,
);
path = Ads;
sourceTree = "<group>";
};
CEFE851926949844003C67D3 /* SmartTexts */ = {
isa = PBXGroup;
children = (
......@@ -649,8 +677,11 @@
CD91685826552FD000EC04EF /* DefaultSettingsFactory.swift in Sources */,
CEFE851C2694986D003C67D3 /* SmartText.swift in Sources */,
CDFE459626566D860021A29F /* FIPSSource.swift in Sources */,
CE72A76126D627FF00F13CF7 /* AdConfig.swift in Sources */,
CE72A76426D6285800F13CF7 /* AdTypes.swift in Sources */,
CD91685926552FD000EC04EF /* DefaultSettings.swift in Sources */,
CD91685A26552FD000EC04EF /* DefaultSettingsImperial.swift in Sources */,
CE72A75F26D627E300F13CF7 /* AppConfig.swift in Sources */,
CD91685B26552FD000EC04EF /* DefaultSettingsMetric.swift in Sources */,
CEFE85282694C5F7003C67D3 /* HumiditySmartText.swift in Sources */,
CD615FB82655295C00B717DB /* UIColor+Hex.swift in Sources */,
......@@ -681,6 +712,7 @@
CD3883EC2657B83D0070FD6F /* FIPSResponse.swift in Sources */,
CEFE85222694C57A003C67D3 /* OngoingPrecipitationSmartText.swift in Sources */,
CD615F96265526E700B717DB /* UpdatableModelObjectInTime.swift in Sources */,
CE72A76626D6299300F13CF7 /* AdPlacement.swift in Sources */,
CD615F97265526E700B717DB /* PartialLocation.swift in Sources */,
CD615F98265526E700B717DB /* GeoNamesPlace.swift in Sources */,
CD615F99265526E700B717DB /* Location.swift in Sources */,
......
//
// AdConfig.swift
// BaconReader
// OneWeatherCore
//
// Created by Steve Pint on 5/2/19.
// Copyright © 2019 OneLouder Apps. All rights reserved.
// Created by Demid Merzlyakov on 25.08.2021.
//
import UIKit
import Foundation
public struct AdConfig: Codable {
public typealias AdPlacementName = String
public struct AdConfig {
private static let defaultA9MaxCachedPerPlacement: UInt = 2
public var adsEnabled: Bool
......@@ -21,6 +22,22 @@ public struct AdConfig: Codable {
return placements?[name]
}
public init() {
adsEnabled = true
a9RefreshRate = 0
a9MaxCachedPerPlacement = AdConfig.defaultA9MaxCachedPerPlacement
}
}
extension AdConfig: Equatable {
public static func == (lhs: AdConfig, rhs: AdConfig) -> Bool {
return lhs.adsEnabled == rhs.adsEnabled &&
lhs.a9RefreshRate == rhs.a9RefreshRate &&
lhs.placements == rhs.placements
}
}
extension AdConfig: Codable {
struct CodingKeys: CodingKey {
var stringValue: String
init(stringValue: String) {
......@@ -35,12 +52,6 @@ public struct AdConfig: Codable {
static let placements = CodingKeys(stringValue: "placements")
}
init() {
adsEnabled = true
a9RefreshRate = 0
a9MaxCachedPerPlacement = AdConfig.defaultA9MaxCachedPerPlacement
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
......@@ -73,52 +84,3 @@ public struct AdConfig: Codable {
try container.encodeIfPresent(placements, forKey: .placements)
}
}
public enum AdType: String, Codable {
case banner = "banner"
case square = "mrec"
case interstitial = "interstitial"
}
extension AdConfig: Equatable {
public static func == (lhs: AdConfig, rhs: AdConfig) -> Bool {
return lhs.adsEnabled == rhs.adsEnabled &&
lhs.a9RefreshRate == rhs.a9RefreshRate &&
lhs.placements == rhs.placements
}
}
public struct ContentUrlConfig : Codable {
var enabled: Bool
}
extension ContentUrlConfig: Equatable {
public static func == (lhs: ContentUrlConfig, rhs: ContentUrlConfig) -> Bool {
return lhs.enabled == rhs.enabled
}
}
public struct AdPlacement: Codable {
public var name: String
public var adUnitId: String
public var a9SlotId: String?
public var refreshInterval: TimeInterval
public var type: AdType
enum CodingKeys: String, CodingKey {
case name
case adUnitId = "ad_unit_id"
case a9SlotId = "a9_slot_id"
case refreshInterval = "refresh_interval"
case type
}
}
extension AdPlacement: Equatable {
public static func == (lhs: AdPlacement, rhs: AdPlacement) -> Bool {
return lhs.name == rhs.name &&
lhs.adUnitId == rhs.adUnitId &&
lhs.a9SlotId == rhs.a9SlotId &&
lhs.refreshInterval == rhs.refreshInterval
}
}
//
// AdPlacement.swift
// OneWeatherCore
//
// Created by Demid Merzlyakov on 25.08.2021.
//
import Foundation
public struct AdPlacement: Codable {
public var name: String
public var adUnitId: String
public var a9SlotId: String?
public var refreshInterval: TimeInterval
public var type: AdType
enum CodingKeys: String, CodingKey {
case name
case adUnitId = "ad_unit_id"
case a9SlotId = "a9_slot_id"
case refreshInterval = "refresh_interval"
case type
}
}
extension AdPlacement: Equatable {
public static func == (lhs: AdPlacement, rhs: AdPlacement) -> Bool {
return lhs.name == rhs.name &&
lhs.adUnitId == rhs.adUnitId &&
lhs.a9SlotId == rhs.a9SlotId &&
lhs.refreshInterval == rhs.refreshInterval
}
}
//
// AdTypes.swift
// OneWeatherCore
//
// Created by Demid Merzlyakov on 25.08.2021.
//
import Foundation
public enum AdType: String, Codable {
case banner = "banner"
case square = "mrec"
case interstitial = "interstitial"
}
//
// AppConfig.swift
// OneWeatherCore
//
// Created by Demid Merzlyakov on 25.08.2021.
//
import Foundation
public struct AppConfig: Codable {
public let popularCities: [GeoNamesPlace]?
public let adConfig: AdConfig
public let ccpaUpdateInterval: TimeInterval?
public let nwsAlertsViaMoEngageEnabled: Bool
public let showAttPrompt: Bool
public let shortsLeftBelowCount: Int
public let shortsLastNudgeEnabled: Bool
public let shortsSwipeUpNudgeCount: Int
public let showOnboarding: Bool
public init(popularCities: [GeoNamesPlace]?,
adConfig: AdConfig,
ccpaUpdateInterval: TimeInterval?,
nwsAlertsViaMoEngageEnabled: Bool,
showAttPrompt: Bool,
shortsLeftBelowCountKey: Int,
shortsLastNudgeEnabledKey: Bool,
shortsSwipeUpNudgeCountKey: Int,
showOnboarding: Bool
) {
self.popularCities = popularCities
self.adConfig = adConfig
self.ccpaUpdateInterval = ccpaUpdateInterval
self.nwsAlertsViaMoEngageEnabled = nwsAlertsViaMoEngageEnabled
self.showAttPrompt = showAttPrompt
self.shortsLeftBelowCount = shortsLeftBelowCountKey
self.shortsLastNudgeEnabled = shortsLastNudgeEnabledKey
self.shortsSwipeUpNudgeCount = shortsSwipeUpNudgeCountKey
self.showOnboarding = showOnboarding
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment