Skip to content

Commit

Permalink
add user-agent and screen resolutions
Browse files Browse the repository at this point in the history
Signed-off-by: 82Flex <82flex@gmail.com>
  • Loading branch information
Lessica committed Feb 1, 2024
1 parent e4bb8b4 commit 908bc75
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"identity" : "colorfulx",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Lakr233/ColorfulX",
"location" : "https://github.com/Lakr233/ColorfulX.git",
"state" : {
"revision" : "11aae9e92a2f846ed26d275d0d3d6fad85d16837",
"version" : "2.3.1"
Expand Down
25 changes: 25 additions & 0 deletions Reveil/ViewModels/Enums/EntryKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ enum EntryKey: Codable, Equatable, Hashable, RawRepresentable {
case RadioTech
case HostName
case DisplayResolution
case ScreenPhysicalResolution
case ScreenPhysicalScale
case ScreenLogicalResolution
case ScreenLogicalScale

// Operating System
case System
case UserAgent
case KernelVersion
case KernelRelease
case KernelMaximumVnodes
Expand Down Expand Up @@ -226,8 +231,18 @@ enum EntryKey: Codable, Equatable, Hashable, RawRepresentable {
self = .HostName
case "DisplayResolution":
self = .DisplayResolution
case "ScreenPhysicalResolution":
self = .ScreenPhysicalResolution
case "ScreenPhysicalScale":
self = .ScreenPhysicalScale
case "ScreenLogicalResolution":
self = .ScreenLogicalResolution
case "ScreenLogicalScale":
self = .ScreenLogicalScale
case "System":
self = .System
case "UserAgent":
self = .UserAgent
case "KernelVersion":
self = .KernelVersion
case "KernelRelease":
Expand Down Expand Up @@ -494,8 +509,18 @@ enum EntryKey: Codable, Equatable, Hashable, RawRepresentable {
"HostName"
case .DisplayResolution:
"DisplayResolution"
case .ScreenPhysicalResolution:
"ScreenPhysicalResolution"
case .ScreenPhysicalScale:
"ScreenPhysicalScale"
case .ScreenLogicalResolution:
"ScreenLogicalResolution"
case .ScreenLogicalScale:
"ScreenLogicalScale"
case .System:
"System"
case .UserAgent:
"UserAgent"
case .KernelVersion:
"KernelVersion"
case .KernelRelease:
Expand Down
51 changes: 47 additions & 4 deletions Reveil/ViewModels/Modules/DeviceInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,25 @@ final class DeviceInformation: Module {
return techName
}

private var displaySizeDescription: String {
let mainScreen = UIScreen.main
return "\(Int(mainScreen.fixedCoordinateSpace.bounds.height * mainScreen.scale))×\(Int(mainScreen.fixedCoordinateSpace.bounds.width * mainScreen.scale))"
}
private let mainScreen = UIScreen.main

private lazy var displaySizeDescription: String = {
let displayWidth = Int(mainScreen.fixedCoordinateSpace.bounds.width * mainScreen.scale)
let displayHeight = Int(mainScreen.fixedCoordinateSpace.bounds.height * mainScreen.scale)
return "\(displayWidth)×\(displayHeight)"
}()

private lazy var physicalSizeDescription: String = {
let physicalWidth = Int(mainScreen.nativeBounds.width)
let physicalHeight = Int(mainScreen.nativeBounds.height)
return "\(physicalWidth)×\(physicalHeight)"
}()

private lazy var logicalSizeDescription: String = {
let logicalWidth = Int(mainScreen.fixedCoordinateSpace.bounds.width)
let logicalHeight = Int(mainScreen.fixedCoordinateSpace.bounds.height)
return "\(logicalWidth)×\(logicalHeight)"
}()

lazy var basicEntries: [BasicEntry] = updatableEntryKeys.compactMap { basicEntry(key: $0) }

Expand All @@ -104,6 +119,10 @@ final class DeviceInformation: Module {
.RadioTech,
.HostName,
.DisplayResolution,
.ScreenPhysicalResolution,
.ScreenPhysicalScale,
.ScreenLogicalResolution,
.ScreenLogicalScale,
]

func basicEntry(key: EntryKey, style _: ValueStyle = .detailed) -> BasicEntry? {
Expand Down Expand Up @@ -152,6 +171,30 @@ final class DeviceInformation: Module {
name: NSLocalizedString("DISPLAY_RESOLUTION", comment: "Display Resolution"),
value: displaySizeDescription
)
case .ScreenPhysicalResolution:
return BasicEntry(
key: .ScreenPhysicalResolution,
name: NSLocalizedString("SCREEN_PHYSICAL_RESOLUTION", comment: "Screen Physical Resolution"),
value: physicalSizeDescription
)
case .ScreenPhysicalScale:
return BasicEntry(
key: .ScreenPhysicalScale,
name: NSLocalizedString("SCREEN_PHYSICAL_SCALE", comment: "Screen Physical Scale"),
value: String(format: "%.3f", mainScreen.nativeScale)
)
case .ScreenLogicalResolution:
return BasicEntry(
key: .ScreenLogicalResolution,
name: NSLocalizedString("SCREEN_LOGICAL_RESOLUTION", comment: "Screen Logical Resolution"),
value: logicalSizeDescription
)
case .ScreenLogicalScale:
return BasicEntry(
key: .ScreenLogicalScale,
name: NSLocalizedString("SCREEN_LOGICAL_SCALE", comment: "Screen Logical Scale"),
value: String(format: "%.3f", mainScreen.scale)
)
default:
break
}
Expand Down
19 changes: 19 additions & 0 deletions Reveil/ViewModels/Modules/OperatingSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
//

import Foundation
#if canImport(WebKit)
import WebKit
#endif

final class OperatingSystem: Module {
static let shared = OperatingSystem()
Expand All @@ -28,6 +31,15 @@ final class OperatingSystem: Module {
return "Version \(productVersion) (Build \(productBuildVersion))"
}()

private let gUserAgentString: String? = {
#if canImport(WebKit)
let userAgent = WKWebView().value(forKey: "userAgent") as? String
return userAgent
#else
return nil
#endif
}()

private let gBufferFormatter: ByteCountFormatter = {
let formatter = ByteCountFormatter()
formatter.countStyle = .memory
Expand Down Expand Up @@ -84,6 +96,7 @@ final class OperatingSystem: Module {

let updatableEntryKeys: [EntryKey] = [
.System,
.UserAgent,
.KernelVersion,
.KernelRelease,
.KernelMaximumVnodes,
Expand All @@ -104,6 +117,12 @@ final class OperatingSystem: Module {
name: NSLocalizedString("SYSTEM", comment: "System"),
value: gSystemVersionString ?? BasicEntry.unknownValue
)
case .UserAgent:
return BasicEntry(
key: .UserAgent,
name: NSLocalizedString("USER_AGENT", comment: "User Agent"),
value: gUserAgentString ?? BasicEntry.unknownValue
)
case .KernelVersion:
return BasicEntry(
key: .KernelVersion,
Expand Down
3 changes: 2 additions & 1 deletion Reveil/ViewModels/SecurityCheck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,8 @@ enum SecurityCheck: CaseIterable, Codable, Equatable, Hashable, RawRepresentable
case .identifiedBundleIdentifier:
.identifiedBundleIdentifier(Security.shared.checkMainBundleIdentifier() ? .passed : .failed)
case .identifiedMobileProvisioningProfile:
.identifiedMobileProvisioningProfile(Security.shared.checkMobileProvisioningProfileHash() ? .passed : .failed)
.identifiedMobileProvisioningProfile(.unchanged)
// .identifiedMobileProvisioningProfile(Security.shared.checkMobileProvisioningProfileHash() ? .passed : .failed)
case .identifiedResources:
.identifiedResources(Security.shared.checkResourceHashes() ? .passed : .failed)
case .identifiedMachO:
Expand Down
15 changes: 15 additions & 0 deletions Reveil/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,18 @@
/* Scanning… */
"SCANNING" = "Scanning…";

/* Screen Logical Resolution */
"SCREEN_LOGICAL_RESOLUTION" = "Screen Logical Resolution";

/* Screen Logical Scale */
"SCREEN_LOGICAL_SCALE" = "Screen Logical Scale";

/* Screen Physical Resolution */
"SCREEN_PHYSICAL_RESOLUTION" = "Screen Physical Resolution";

/* Screen Physical Scale */
"SCREEN_PHYSICAL_SCALE" = "Screen Physical Scale";

/* Seatbelt special port is available */
"SEATBELT_SPECIAL_PORT_IS_AVAILABLE" = "Seatbelt special port is available";

Expand Down Expand Up @@ -1033,6 +1045,9 @@
/* Used: %@ */
"USED_DESCRIPTION" = "Used: %@";

/* User Agent */
"USER_AGENT" = "User Agent";

/* User Memory */
"USER_MEMORY" = "User Memory";

Expand Down
15 changes: 15 additions & 0 deletions Reveil/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,18 @@
/* Scanning… */
"SCANNING" = "Escaneando…";

/* TODO: Screen Logical Resolution */
"SCREEN_LOGICAL_RESOLUTION" = "Screen Logical Resolution";

/* TODO: Screen Logical Scale */
"SCREEN_LOGICAL_SCALE" = "Screen Logical Scale";

/* TODO: Screen Physical Resolution */
"SCREEN_PHYSICAL_RESOLUTION" = "Screen Physical Resolution";

/* TODO: Screen Physical Scale */
"SCREEN_PHYSICAL_SCALE" = "Screen Physical Scale";

/* Seatbelt special port is available */
"SEATBELT_SPECIAL_PORT_IS_AVAILABLE" = "El puerto especial de Seatbelt está disponible";

Expand Down Expand Up @@ -1033,6 +1045,9 @@
/* Used: %@ */
"USED_DESCRIPTION" = "Usado: %@";

/* User Agent */
"USER_AGENT" = "Agente de usuario";

/* User Memory */
"USER_MEMORY" = "Memoria del usuario";

Expand Down
15 changes: 15 additions & 0 deletions Reveil/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,18 @@
/* Scanning… */
"SCANNING" = "扫描中";

/* Screen Logical Resolution */
"SCREEN_LOGICAL_RESOLUTION" = "屏幕逻辑分辨率";

/* Screen Logical Scale */
"SCREEN_LOGICAL_SCALE" = "屏幕逻辑缩放率";

/* Screen Physical Resolution */
"SCREEN_PHYSICAL_RESOLUTION" = "屏幕物理分辨率";

/* Screen Physical Scale */
"SCREEN_PHYSICAL_SCALE" = "屏幕物理缩放率";

/* Seatbelt special port is available */
"SEATBELT_SPECIAL_PORT_IS_AVAILABLE" = "已开放沙盒特权端口";

Expand Down Expand Up @@ -1033,6 +1045,9 @@
/* Used: %@ */
"USED_DESCRIPTION" = "已使用:%@";

/* User Agent */
"USER_AGENT" = "用户代理";

/* User Memory */
"USER_MEMORY" = "用户内存";

Expand Down

0 comments on commit 908bc75

Please sign in to comment.