Skip to content

Commit

Permalink
feat: resolve qol gh issues (#216)
Browse files Browse the repository at this point in the history
* fix: fix #211

* feat: close #193

* feat: resolve #180

* feat: Improvement of localization function, add Chinese language support (#213)

* Improvement of localization function, add Chinese language support

* Update language files

* chore: add helper method for required restart alert in language

---------

Co-authored-by: khcrysalis <[email protected]>

* chore: include other strings

---------

Co-authored-by: 风轻云断 <[email protected]>
Co-authored-by: khcrysalis <[email protected]>
  • Loading branch information
3 people authored Dec 5, 2024
1 parent 73d2bfc commit e4b0dac
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 32 deletions.
4 changes: 3 additions & 1 deletion Shared/Localizations/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS_ID" = "Identifier";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS_ID_REPLACEMENT" = "Replacement";


"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES" = "Display Names";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES_ID" = "Original Display Name";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES_ID_REPLACEMENT" = "New Display Name";

"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_INSTALLAFTERSIGNED" = "Install after Signing";

Expand Down
4 changes: 3 additions & 1 deletion Shared/Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS_ID" = "Identifier";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS_ID_REPLACEMENT" = "Replacement";


"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES" = "Display Names";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES_ID" = "Original Display Name";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES_ID_REPLACEMENT" = "New Display Name";

"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_INSTALLAFTERSIGNED" = "Install after Signing";

Expand Down
4 changes: 3 additions & 1 deletion Shared/Localizations/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS_ID" = "Identifier";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS_ID_REPLACEMENT" = "Replacement";


"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES" = "Display Names";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES_ID" = "Original Display Name";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES_ID_REPLACEMENT" = "New Display Name";

"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_INSTALLAFTERSIGNED" = "Install after Signing";

Expand Down
4 changes: 3 additions & 1 deletion Shared/Localizations/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS_ID" = "Identifier";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS_ID_REPLACEMENT" = "Replacement";


"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES" = "Display Names";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES_ID" = "Original Display Name";
"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES_ID_REPLACEMENT" = "New Display Name";

"APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_INSTALLAFTERSIGNED" = "Install after Signing";

Expand Down
79 changes: 77 additions & 2 deletions iOS/Delegates/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,81 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIOnboardingViewControlle
NotificationCenter.default.post(name: Notification.Name("sfetch"), object: nil)
}
}

} else {
Debug.shared.log(message: "Invalid or non-HTTPS URL", type: .error)
}
} else if let config = url.absoluteString.range(of: "/install/") {
let fullPath = String(url.absoluteString[config.upperBound...])

if fullPath.starts(with: "https://") {
guard let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootViewController = scene.windows.first?.rootViewController else {
return false
}

DispatchQueue.main.async {
rootViewController.present(self.loaderAlert, animated: true)
}

DispatchQueue.global(qos: .background).async {
do {
let tempDirectory = FileManager.default.temporaryDirectory
let uuid = UUID().uuidString
let destinationURL = tempDirectory.appendingPathComponent("\(uuid).ipa")

// Download the file
if let data = try? Data(contentsOf: URL(string: fullPath)!) {
try data.write(to: destinationURL)

let dl = AppDownload()
try handleIPAFile(destinationURL: destinationURL, uuid: uuid, dl: dl)

DispatchQueue.main.async {
self.loaderAlert.dismiss(animated: true) {
let downloadedApps = CoreDataManager.shared.getDatedDownloadedApps()
if let downloadedApp = downloadedApps.first(where: { $0.uuid == uuid }) {
let signingDataWrapper = SigningDataWrapper(signingOptions: UserDefaults.standard.signingOptions)
signingDataWrapper.signingOptions.installAfterSigned = true

let libraryVC = LibraryViewController()
let ap = SigningsViewController(
signingDataWrapper: signingDataWrapper,
application: downloadedApp,
appsViewController: libraryVC
)

ap.signingCompletionHandler = { success in
if success {
if let workspace = LSApplicationWorkspace.default() {
if let bundleId = downloadedApp.bundleidentifier {
workspace.openApplication(withBundleID: bundleId)
}
}
libraryVC.fetchSources()
libraryVC.tableView.reloadData()
}
}

let navigationController = UINavigationController(rootViewController: ap)

if UIDevice.current.userInterfaceIdiom == .pad {
navigationController.modalPresentationStyle = .formSheet
} else {
navigationController.modalPresentationStyle = .fullScreen
}

rootViewController.present(navigationController, animated: true)
}
}
}
}
} catch {
DispatchQueue.main.async {
self.loaderAlert.dismiss(animated: true)
Debug.shared.log(message: "Failed to handle IPA file: \(error)", type: .error)
}
}
}
} else {
Debug.shared.log(message: "Invalid or non-HTTPS URL", type: .error)
}
Expand All @@ -150,7 +224,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIOnboardingViewControlle
}
// bwah
if url.pathExtension == "ipa" {
guard let rootViewController = UIApplication.shared.keyWindow?.rootViewController else {
guard let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootViewController = scene.windows.first?.rootViewController else {
return false
}

Expand Down
29 changes: 19 additions & 10 deletions iOS/Views/Apps/LibraryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -343,19 +343,28 @@ extension LibraryViewController {
button3.onTap = { [weak self] in
guard let self = self else { return }
self.popupVC.dismiss(animated: true) {
self.present(self.loaderAlert!, animated: true)
let cert = CoreDataManager.shared.getCurrentCertificate()!

resignApp(certificate: cert, appPath: filePath2!) { success in
if success {
CoreDataManager.shared.updateSignedApp(app: source as! SignedApps, newTimeToLive: (cert.certData?.expirationDate)!, newTeamName: (cert.certData?.name)!) { _ in
DispatchQueue.main.async {
self.loaderAlert?.dismiss(animated: true)
Debug.shared.log(message: "Done action??")
self.tableView.reloadRows(at: [indexPath], with: .left)
if let cert = CoreDataManager.shared.getCurrentCertificate() {
self.present(self.loaderAlert!, animated: true)

resignApp(certificate: cert, appPath: filePath2!) { success in
if success {
CoreDataManager.shared.updateSignedApp(app: source as! SignedApps, newTimeToLive: (cert.certData?.expirationDate)!, newTeamName: (cert.certData?.name)!) { _ in
DispatchQueue.main.async {
self.loaderAlert?.dismiss(animated: true)
Debug.shared.log(message: "Done action??")
self.tableView.reloadRows(at: [indexPath], with: .left)
}
}
}
}
} else {
let alert = UIAlertController(
title: String.localized("APP_SIGNING_VIEW_CONTROLLER_NO_CERTS_ALERT_TITLE"),
message: String.localized("APP_SIGNING_VIEW_CONTROLLER_NO_CERTS_ALERT_DESCRIPTION"),
preferredStyle: .alert
)
alert.addAction(UIAlertAction(title: String.localized("LAME"), style: .default))
self.present(alert, animated: true)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions iOS/Views/Signing/SigningData/SigningOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct SigningOptions: Codable {
var installAfterSigned: Bool = false

var bundleIdConfig: [String: String] = [:]
var displayNameConfig: [String: String] = [:]
var toInject: [String] = []

var removePlugins: Bool = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@ class AddIdentifierViewController: UITableViewController {
return textField
}()

init() {
init(mode: IdentifierMode) {
super.init(style: .insetGrouped)

switch mode {
case .bundleId:
identifierTextField.placeholder = String.localized("APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS_ID")
replacementTextField.placeholder = String.localized("APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS_ID_REPLACEMENT")
case .displayName:
identifierTextField.placeholder = String.localized("APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES_ID")
replacementTextField.placeholder = String.localized("APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES_ID_REPLACEMENT")
}
}

required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@

import UIKit

enum IdentifierMode {
case bundleId
case displayName
}

class IdentifiersViewController: UITableViewController {
var signingDataWrapper: SigningDataWrapper
private var newIdentifier: String = ""
private var newReplacement: String = ""
private var mode: IdentifierMode

init(signingDataWrapper: SigningDataWrapper) {
init(signingDataWrapper: SigningDataWrapper, mode: IdentifierMode) {
self.signingDataWrapper = signingDataWrapper
self.mode = mode
super.init(style: .insetGrouped)
title = String.localized("APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS")
title = mode == .bundleId ?
String.localized("APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS") :
String.localized("APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES")
}

required init?(coder: NSCoder) {
Expand All @@ -35,23 +42,41 @@ class IdentifiersViewController: UITableViewController {
}

override func numberOfSections(in tableView: UITableView) -> Int {
return signingDataWrapper.signingOptions.bundleIdConfig.keys.count
switch mode {
case .bundleId:
return signingDataWrapper.signingOptions.bundleIdConfig.keys.count
case .displayName:
return signingDataWrapper.signingOptions.displayNameConfig.keys.count
}
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
let sortedKeys = signingDataWrapper.signingOptions.bundleIdConfig.keys.sorted()
return sortedKeys[section]
switch mode {
case .bundleId:
let sortedKeys = signingDataWrapper.signingOptions.bundleIdConfig.keys.sorted()
return sortedKeys[section]
case .displayName:
let sortedKeys = signingDataWrapper.signingOptions.displayNameConfig.keys.sorted()
return sortedKeys[section]
}
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "IdentifierCell", for: indexPath)

let key = signingDataWrapper.signingOptions.bundleIdConfig.keys.sorted()[indexPath.section]
cell.textLabel?.text = signingDataWrapper.signingOptions.bundleIdConfig[key]
switch mode {
case .bundleId:
let key = signingDataWrapper.signingOptions.bundleIdConfig.keys.sorted()[indexPath.section]
cell.textLabel?.text = signingDataWrapper.signingOptions.bundleIdConfig[key]
case .displayName:
let key = signingDataWrapper.signingOptions.displayNameConfig.keys.sorted()[indexPath.section]
cell.textLabel?.text = signingDataWrapper.signingOptions.displayNameConfig[key]
}

cell.textLabel?.textColor = .secondaryLabel
cell.selectionStyle = .none
return cell
Expand All @@ -66,15 +91,28 @@ class IdentifiersViewController: UITableViewController {
}

private func deleteIdentifier(at index: Int) {
let key = signingDataWrapper.signingOptions.bundleIdConfig.keys.sorted()[index]
signingDataWrapper.signingOptions.bundleIdConfig.removeValue(forKey: key)
switch mode {
case .bundleId:
let key = signingDataWrapper.signingOptions.bundleIdConfig.keys.sorted()[index]
signingDataWrapper.signingOptions.bundleIdConfig.removeValue(forKey: key)
case .displayName:
let key = signingDataWrapper.signingOptions.displayNameConfig.keys.sorted()[index]
signingDataWrapper.signingOptions.displayNameConfig.removeValue(forKey: key)
}
tableView.reloadData()
}

@objc private func addIdentifierTapped() {
let addVC = AddIdentifierViewController()
let addVC = AddIdentifierViewController(mode: mode)
addVC.onAdd = { [weak self] identifier, replacement in
self?.signingDataWrapper.signingOptions.bundleIdConfig[identifier] = replacement
switch self?.mode {
case .bundleId:
self?.signingDataWrapper.signingOptions.bundleIdConfig[identifier] = replacement
case .displayName:
self?.signingDataWrapper.signingOptions.displayNameConfig[identifier] = replacement
case .none:
break
}
self?.tableView.reloadData()
}
navigationController?.pushViewController(addVC, animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ extension SigningsOptionViewController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0: return 2
case 1: return 3
case 1: return 4
default: return 1
}
}
Expand Down Expand Up @@ -150,6 +150,9 @@ extension SigningsOptionViewController {
cell.textLabel?.text = String.localized("APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_IDENTIFIERS")
cell.accessoryType = .disclosureIndicator
case [1,2]:
cell.textLabel?.text = String.localized("APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_DISPLAYNAMES")
cell.accessoryType = .disclosureIndicator
case [1,3]:
let toggleSwitch = UISwitch()
cell.textLabel?.text = String.localized("APP_SIGNING_VIEW_CONTROLLER_CELL_SIGNING_OPTIONS_INSTALLAFTERSIGNED")
toggleSwitch.isOn = signingDataWrapper.signingOptions.installAfterSigned
Expand Down Expand Up @@ -188,7 +191,10 @@ extension SigningsOptionViewController {

present(activityViewController, animated: true, completion: nil)
case [1, 1]:
let l = IdentifiersViewController(signingDataWrapper: signingDataWrapper)
let l = IdentifiersViewController(signingDataWrapper: signingDataWrapper, mode: .bundleId)
navigationController?.pushViewController(l, animated: true)
case [1, 2]:
let l = IdentifiersViewController(signingDataWrapper: signingDataWrapper, mode: .displayName)
navigationController?.pushViewController(l, animated: true)
default:
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ class SigningsViewController: UIViewController {
let newBundleId = signingDataWrapper.signingOptions.bundleIdConfig[currentBundleId] {
mainOptions.mainOptions.bundleId = newBundleId
}

if let currentName = bundle?.name,
let newName = signingDataWrapper.signingOptions.displayNameConfig[currentName] {
mainOptions.mainOptions.name = newName
}
}

required init?(coder: NSCoder) {
Expand Down

0 comments on commit e4b0dac

Please sign in to comment.