Skip to content

Commit

Permalink
Merge pull request #36 from leminlimez/main
Browse files Browse the repository at this point in the history
LS Footnote, improved passcode stuff, and other fixes
  • Loading branch information
sourcelocation authored Jan 3, 2023
2 parents 2dcb271 + a62a448 commit fe9bbbc
Show file tree
Hide file tree
Showing 16 changed files with 272 additions and 71 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified RootHelper/.theos/obj/debug/arm64/trolltoolsroothelper
Binary file not shown.
Binary file not shown.
Binary file modified RootHelper/.theos/obj/debug/trolltoolsroothelper
Binary file not shown.
4 changes: 4 additions & 0 deletions TrollTools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
6F63906B294B957900BA22D4 /* LSFootnoteChangerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F63906A294B957900BA22D4 /* LSFootnoteChangerView.swift */; };
6FDA067D2935AA52003CE14A /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 6FDA067C2935AA52003CE14A /* ZIPFoundation */; };
CE141B372903E73F00AB48A7 /* CardChangerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE141B362903E73F00AB48A7 /* CardChangerView.swift */; };
CE141B3A2903F20800AB48A7 /* ThemesSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE141B392903F20800AB48A7 /* ThemesSettingsView.swift */; };
Expand Down Expand Up @@ -53,6 +54,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
6F63906A294B957900BA22D4 /* LSFootnoteChangerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LSFootnoteChangerView.swift; sourceTree = "<group>"; };
CE141B362903E73F00AB48A7 /* CardChangerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardChangerView.swift; sourceTree = "<group>"; };
CE141B392903F20800AB48A7 /* ThemesSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemesSettingsView.swift; sourceTree = "<group>"; };
CE141B3B2903F22F00AB48A7 /* ThemeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -250,6 +252,7 @@
CE7975B0291C4533007A38E7 /* LockscreenRespringView.swift */,
CEF56C3E291C605600DDEBFD /* CalculatorErrorView.swift */,
CEF56C5329215AA900DDEBFD /* CarrierNameChangerView.swift */,
6F63906A294B957900BA22D4 /* LSFootnoteChangerView.swift */,
);
path = Tools;
sourceTree = "<group>";
Expand Down Expand Up @@ -392,6 +395,7 @@
CE7975A5291B1E0C007A38E7 /* ToolsView.swift in Sources */,
CE2BF8242902E07F00AD10BE /* Extensions.swift in Sources */,
CE141B5A290460AE00AB48A7 /* WebclipsThemeManager.swift in Sources */,
6F63906B294B957900BA22D4 /* LSFootnoteChangerView.swift in Sources */,
CEF56C3F291C605600DDEBFD /* CalculatorErrorView.swift in Sources */,
CE7975A7291B2A4B007A38E7 /* GesturesView.swift in Sources */,
CE76386D290AED160099C6F0 /* ProblemReporter.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"pins" : [
{
"identity" : "dynamic",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mhdhejazi/Dynamic",
"state" : {
"branch" : "master",
"revision" : "772883073d044bc754d401cabb6574624eb3778f"
}
},
{
"identity" : "map",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pauljohanneskraft/Map",
"state" : {
"revision" : "a99a9083aac4c5eba1cd83291eb2e222df287f31",
"version" : "0.1.0"
}
},
{
"identity" : "santanderwrappers",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SerenaKit/SantanderWrappers",
"state" : {
"branch" : "main",
"revision" : "78c19b2eeba612b0fb7b13df7ab304062ee22622"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "fddd1c00396eed152c45a46bea9f47b98e59301d",
"version" : "1.2.0"
}
},
{
"identity" : "swiftyxmlparser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/yahoojapan/SwiftyXMLParser",
"state" : {
"revision" : "d7a1d23f04c86c1cd2e8f19247dd15d74e0ea8be",
"version" : "5.6.0"
}
},
{
"identity" : "zipfoundation",
"kind" : "remoteSourceControl",
"location" : "https://github.com/weichsel/ZIPFoundation",
"state" : {
"branch" : "development",
"revision" : "642436f3684009ca7a5e3d6b30f2ecea26f8f772"
}
}
],
"version" : 2
}
Binary file not shown.
Binary file modified TrollTools/.DS_Store
Binary file not shown.
Binary file modified TrollTools/Assets.xcassets/.DS_Store
Binary file not shown.
Binary file added TrollTools/Assets.xcassets/screens/.DS_Store
Binary file not shown.
61 changes: 61 additions & 0 deletions TrollTools/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,71 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>Passcode Theme</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>net.sourceloc.passthm</string>
</array>
</dict>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
<string>public.archive</string>
</array>
<key>UTTypeDescription</key>
<string>Passcode Theme File</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>net.sourceloc.passthm</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>passthm</string>
<string>PASSTHM</string>
</array>
</dict>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
<string>public.archive</string>
</array>
<key>UTTypeDescription</key>
<string>Passcode Theme File</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>net.sourceloc.passthm</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>passthm</string>
<string>PASSTHM</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>
17 changes: 15 additions & 2 deletions TrollTools/Other/TrollToolsApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ struct TrollToolsApp: App {
WindowGroup {
RootView()
.onAppear {
if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String, let url = URL(string: "https://api.github.com/repos/sourcelocation/TrollTools/releases/latest") {
if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? Double, let url = URL(string: "https://api.github.com/repos/sourcelocation/TrollTools/releases/latest") {
let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
guard let data = data else { return }

if let json = try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any] {
if json["tag_name"] as? String != version {
if json["tag_name"] as? Double ?? 2.1 > version {
UIApplication.shared.confirmAlert(title: "Update available", body: "A new TrollTools update is available, do you want to visit releases page?", onOK: {
UIApplication.shared.open(URL(string: "https://github.com/sourcelocation/TrollTools/releases/latest")!)
}, noCancel: false)
Expand All @@ -29,6 +29,19 @@ struct TrollToolsApp: App {
}
try? RootHelper.loadMCM()
}
.onOpenURL(perform: { url in
// for opening passthm files
if url.pathExtension.lowercased() == "passthm" {
let defaultKeySize = PasscodeKeyFaceManager.getDefaultFaceSize()
do {
// try appying the themes
try PasscodeKeyFaceManager.setFacesFromTheme(url, keySize: CGFloat(defaultKeySize), customX: CGFloat(150), customY: CGFloat(150))
// show the passcode screen
//PasscodeEditorView()
ToolsView().activateView(viewName: "PasscodeEditorView", isActive: true)
} catch { UIApplication.shared.alert(body: error.localizedDescription) }
}
})
}
}
}
Expand Down
Binary file modified TrollTools/Views/.DS_Store
Binary file not shown.
86 changes: 86 additions & 0 deletions TrollTools/Views/Tools/LSFootnoteChangerView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// LSFootnoteChangerView.swift
// TrollTools
//
// Created by LeminLimez on 12/15/22.
//

import SwiftUI

struct LSFootnoteChangerView: View {
@State var footnoteText = ""
@State var footnoteOffset: CGFloat = .zero
@State var footnoteSize: [CGFloat] = [.zero, .zero]

var sharedDeviceConfigPath = "/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles/Library/ConfigurationProfiles"

var body: some View {
ZStack {
VStack {
Spacer()
ZStack(alignment: .center) {
Image("lockscreen")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: .infinity)
.padding(.bottom)
.background(GeometryReader { (geometry) -> Color in
DispatchQueue.main.async {
// set the footnote textbox size
footnoteSize[0] = geometry.size.width/3
footnoteSize[1] = geometry.size.height/25

// set the footnote textbox offset
footnoteOffset = -geometry.size.height/2 + (870/990) * geometry.size.height + footnoteSize[1]/2
}
return .clear
})
TextField("Footnote", text: $footnoteText)
.foregroundColor(.white)
.offset(x: 0, y: footnoteOffset)
.frame(width: footnoteSize[0], height: footnoteSize[1], alignment: .center)
.multilineTextAlignment(.center)
}
}
}
//.ignoresSafeArea(.keyboard, edges: .bottom)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {
do {
let url = URL(fileURLWithPath: sharedDeviceConfigPath + "/SharedDeviceConfiguration.plist")

var plistData: Data
if !FileManager.default.fileExists(atPath: url.path) {
plistData = try PropertyListSerialization.data(fromPropertyList: ["LockScreenFootnote": footnoteText], format: .xml, options: 0)
} else {
guard let data = try? Data(contentsOf: url), var plist = try PropertyListSerialization.propertyList(from: data, format: nil) as? [String:Any] else { throw "Couldn't read SharedDeviceConfiguration.plist" }
plist["LockScreenFootnote"] = footnoteText

// Save plist
plistData = try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)
UserDefaults.standard.set(footnoteText, forKey: "LSFootnoteText")
}

// write to file
try RootHelper.writeStr(String(decoding: plistData, as: UTF8.self), to: url)
} catch {
UIApplication.shared.alert(body: "\(error)")
}
}) {
Image(systemName: "checkmark")
}
}
}
.onAppear {
footnoteText = UserDefaults.standard.string(forKey: "LSFootnoteText") ?? ""
}
.navigationTitle("Lock Screen Footnote Changer")
}
}

struct LSFootnoteChangerView_Previews: PreviewProvider {
static var previews: some View {
LSFootnoteChangerView()
}
}
6 changes: 3 additions & 3 deletions TrollTools/Views/Tools/PasscodeEditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct PasscodeEditorView: View {
// export key
Button(action: {
do {
var archiveURL: URL? = try PasscodeKeyFaceManager.exportFaceTheme()
let archiveURL: URL? = try PasscodeKeyFaceManager.exportFaceTheme()
// show share menu
let avc = UIActivityViewController(activityItems: [archiveURL!], applicationActivities: nil)
let view: UIView = UIApplication.shared.windows.first!.rootViewController!.view
Expand Down Expand Up @@ -174,7 +174,7 @@ struct PasscodeEditorView: View {

let customAction = UIAlertAction(title: "Custom", style: .default) { (action) in
// ask the user for a custom size
var sizeAlert = UIAlertController(title: "Enter Key Dimensions", message: "Min: "+String(sizeLimit[0])+", Max: "+String(sizeLimit[1]), preferredStyle: .alert)
let sizeAlert = UIAlertController(title: "Enter Key Dimensions", message: "Min: "+String(sizeLimit[0])+", Max: "+String(sizeLimit[1]), preferredStyle: .alert)
// bring up the text prompts
sizeAlert.addTextField { (textField) in
// text field for width
Expand Down Expand Up @@ -357,7 +357,7 @@ struct PasscodeKeyView: View {
ZStack {
Circle()
.fill(Color(UIColor(red: 1, green: 1, blue: 1, alpha: 0.12)))
.frame(width: 70, height: 70) // background circle
.frame(width: 78, height: 78) // background circle
Circle()
.fill(Color(UIColor(red: 1, green: 1, blue: 1, alpha: 0))) // hidden circle for image
if face == nil {
Expand Down
Loading

0 comments on commit fe9bbbc

Please sign in to comment.