Skip to content

Commit 4aaa9a2

Browse files
committed
feat: oh my ads
Signed-off-by: Lessica <82flex@gmail.com>
1 parent 7bfb415 commit 4aaa9a2

File tree

14 files changed

+120
-16
lines changed

14 files changed

+120
-16
lines changed

.bartycrouch.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ignoreKeys = ["#bartycrouch-ignore!", "#bc-ignore!", "#i!"]
1313
codePaths = ["."]
1414
subpathsToIgnore = [".git", "carthage", "pods", "build", ".build", "docs"]
1515
localizablePaths = ["TrollFools"]
16-
defaultToKeys = false
16+
defaultToKeys = true
1717
additive = false
1818
customFunction = "LocalizedStringResource"
1919
unstripped = false

TrollFools/App.swift

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ final class App: Identifiable, ObservableObject {
1414
let teamID: String
1515
let url: URL
1616
let version: String?
17+
let isAdvertisement: Bool
1718

1819
@Published var isDetached: Bool = false
1920
@Published var isAllowedToAttachOrDetach: Bool
@@ -37,7 +38,8 @@ final class App: Identifiable, ObservableObject {
3738
teamID: String,
3839
url: URL,
3940
version: String? = nil,
40-
alternateIcon: UIImage? = nil
41+
alternateIcon: UIImage? = nil,
42+
isAdvertisement: Bool = false
4143
) {
4244
self.id = id
4345
self.name = name
@@ -49,6 +51,7 @@ final class App: Identifiable, ObservableObject {
4951
self.isAllowedToAttachOrDetach = type == "User" && InjectorV3.main.isAllowedToAttachOrDetachMetadataInBundle(url)
5052
self.isInjected = InjectorV3.main.checkIsInjectedAppBundle(url)
5153
self.alternateIcon = alternateIcon
54+
self.isAdvertisement = isAdvertisement
5255
}
5356

5457
func reload() {
@@ -65,3 +68,28 @@ final class App: Identifiable, ObservableObject {
6568
self.isInjected = InjectorV3.main.checkIsInjectedAppBundle(url)
6669
}
6770
}
71+
72+
extension App {
73+
static let advertisementApp: App = {
74+
[
75+
App(
76+
id: NSLocalizedString("Record your phone calls like never before.", comment: ""),
77+
name: NSLocalizedString("TrollRecorder", comment: ""),
78+
type: "System",
79+
teamID: "GXZ23M5TP2",
80+
url: URL(string: "https://havoc.app/package/trollrecorder")!,
81+
alternateIcon: .init(named: "tricon-default"),
82+
isAdvertisement: true
83+
),
84+
App(
85+
id: NSLocalizedString("Bringing back the most advanced system and security analysis tool.", comment: ""),
86+
name: NSLocalizedString("Reveil", comment: ""),
87+
type: "System",
88+
teamID: "GXZ23M5TP2",
89+
url: URL(string: "https://havoc.app/package/reveil")!,
90+
alternateIcon: .init(named: "reveil-default"),
91+
isAdvertisement: true
92+
),
93+
].randomElement()!
94+
}()
95+
}

TrollFools/AppListCell.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ struct AppListCell: View {
141141
if #available(iOS 15.0, *) {
142142
Text(highlightedId)
143143
.font(.subheadline)
144-
.lineLimit(1)
144+
.lineLimit(2)
145145
} else {
146146
Text(app.id)
147147
.font(.subheadline)
148-
.lineLimit(1)
148+
.lineLimit(2)
149149
}
150150
}
151151

@@ -170,10 +170,13 @@ struct AppListCell: View {
170170
.foregroundColor(.secondary)
171171
.lineLimit(1)
172172
}
173+
} else if app.isAdvertisement {
174+
Image("badge-ad")
175+
.scaleEffect(1.2)
173176
}
174177
}
175178
.contextMenu {
176-
if !appList.isSelectorMode {
179+
if !appList.isSelectorMode && !app.isAdvertisement {
177180
cellContextMenuWrapper
178181
}
179182
}

TrollFools/AppListModel.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class AppListModel: ObservableObject {
2020
@Published var trollApplications: [App] = []
2121
@Published var appleApplications: [App] = []
2222

23-
@Published var hasTrollRecorder: Bool = false
23+
@Published var isPaidProductInstalled: Bool = false
2424
@Published var unsupportedCount: Int = 0
2525

2626
@Published var isFilzaInstalled: Bool = false
@@ -69,7 +69,7 @@ final class AppListModel: ObservableObject {
6969
}
7070

7171
func reload() {
72-
let allApplications = Self.fetchApplications(&hasTrollRecorder, &unsupportedCount)
72+
let allApplications = Self.fetchApplications(&isPaidProductInstalled, &unsupportedCount)
7373
allApplications.forEach { $0.appList = self }
7474
self._allApplications = allApplications
7575
if let filzaURL {
@@ -101,9 +101,10 @@ final class AppListModel: ObservableObject {
101101
private static let excludedIdentifiers: Set<String> = [
102102
"com.opa334.Dopamine",
103103
"org.coolstar.SileoStore",
104+
"xyz.willy.Zebra",
104105
]
105106

106-
private static func fetchApplications(_ hasTrollRecorder: inout Bool, _ unsupportedCount: inout Int) -> [App] {
107+
private static func fetchApplications(_ isPaidProductInstalled: inout Bool, _ unsupportedCount: inout Int) -> [App] {
107108
let allApps: [App] = LSApplicationWorkspace.default()
108109
.allApplications()
109110
.compactMap { proxy in
@@ -116,8 +117,8 @@ final class AppListModel: ObservableObject {
116117
return nil
117118
}
118119

119-
if id == "wiki.qaq.trapp" {
120-
hasTrollRecorder = true
120+
if id == "wiki.qaq.trapp" || id == "com.82flex.reveil" {
121+
isPaidProductInstalled = true
121122
}
122123

123124
guard !id.hasPrefix("wiki.qaq.") && !id.hasPrefix("com.82flex.") else {

TrollFools/AppListView.swift

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct AppListView: View {
3333
""", appNameString, appVersionString, NSLocalizedString("Copyright", comment: ""), NSLocalizedString("Made with ♥ by OwnGoal Studio", comment: ""))
3434
}
3535

36-
let repoURL = URL(string: "https://github.com/Lessica/TrollFools")
36+
let repoURL = URL(string: "https://github.com/Lessica/TrollFools")!
3737

3838
func filteredAppList(_ apps: [App]) -> some View {
3939
ForEach(apps, id: \.id) { app in
@@ -54,15 +54,27 @@ struct AppListView: View {
5454
}
5555
}
5656

57+
var advertisementButton: some View {
58+
Button {
59+
UIApplication.shared.open(App.advertisementApp.url)
60+
} label: {
61+
if #available(iOS 16.0, *) {
62+
AppListCell(app: App.advertisementApp)
63+
} else {
64+
AppListCell(app: App.advertisementApp)
65+
.padding(.vertical, 4)
66+
}
67+
}
68+
.foregroundColor(.primary)
69+
}
70+
5771
var appListFooterView: some View {
5872
VStack(alignment: .leading, spacing: 8) {
5973
Text(appString)
6074
.font(.footnote)
6175

6276
Button {
63-
if let repoURL {
64-
UIApplication.shared.open(repoURL)
65-
}
77+
UIApplication.shared.open(repoURL)
6678
} label: {
6779
Text(NSLocalizedString("Source Code", comment: ""))
6880
.font(.footnote)
@@ -126,6 +138,10 @@ struct AppListView: View {
126138
}
127139

128140
Section {
141+
if !appList.isPaidProductInstalled {
142+
advertisementButton
143+
}
144+
129145
filteredAppList(appList.trollApplications)
130146
} header: {
131147
Text(NSLocalizedString("TrollStore Applications", comment: ""))
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "badge-ad.svg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
Lines changed: 4 additions & 0 deletions
Loading
17.1 KB
Loading

0 commit comments

Comments
 (0)