Skip to content

Commit

Permalink
2.9.0
Browse files Browse the repository at this point in the history
Requires macOS 10.13 or later
  • Loading branch information
ZzzM committed Dec 31, 2023
1 parent a5adc04 commit 9d30fb0
Show file tree
Hide file tree
Showing 75 changed files with 1,602 additions and 1,587 deletions.
39 changes: 16 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,48 @@
name: Diana

on:
workflow_dispatch:
push:
tags:
- '*'

workflow_dispatch:

env:
APP_NAME: HostsX
SPARKLE_KEY: ${{ secrets.SPARKLE_KEY }}
BODY_PATH: BODY_PATH.md
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

jobs:

Release:
runs-on: macos-12
runs-on: macos-13
steps:

- name: Checkout
uses: actions/checkout@v2.4.0

uses: actions/checkout@v4.1.1
- name: Setup
uses: actions/setup-node@v3
with:
node-version: 18
- run: |
echo "APP_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
uses: actions/[email protected]

- name: Setup Xcode
uses: maxim-lobanov/[email protected]

- name: Package
- name: Create DMG
run: |
fastlane package
- name: Create
run: |
sh scripts/create_dmg.sh
fastlane create_dmg
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: ${{ env.BODY_PATH }}
files: ${{ env.APP_NAME }}.dmg
body_path: ${{ env.LOG_PATH }}
files: ${{ env.APP_PATH }}

- name: Appcast
uses: actions/github-script@v6
uses: actions/github-script@v7.0.1
if: startsWith(github.ref, 'refs/tags/')
with:
github-token: ${{ secrets.PERSONAL_TOKEN }}
script: |
github.rest.repos.requestPagesBuild({
owner: context.repo.owner,
repo: context.repo.repo,
})
})
35 changes: 9 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,49 +45,32 @@ playground.xcworkspace

# Swift Package Manager
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm
Packages/
Package.pins
Package.resolved
*.xcodeproj
Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
hence it is not needed unless you have added a package configuration file to your project
.swiftpm

.build/

# CocoaPods
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
# Pods/
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/


scripts/test.sh
TEST.md
140 changes: 55 additions & 85 deletions HostsX.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

34 changes: 28 additions & 6 deletions HostsX/Help.storyboard → HostsX/About.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="nrN-Ss-vAW">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="nrN-Ss-vAW">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -35,8 +35,8 @@
<!--About View Controller-->
<scene sceneID="evO-Ep-9HR">
<objects>
<viewController storyboardIdentifier="HostsConfigController" id="h6P-N6-zZA" customClass="AboutViewController" customModule="HostsX" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="5rW-V5-bAX" customClass="HostsView" customModule="HostsX" customModuleProvider="target">
<viewController id="h6P-N6-zZA" customClass="AboutViewController" customModule="HostsX" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="5rW-V5-bAX" customClass="HXView" customModule="HostsX" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="250" height="250"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
Expand Down Expand Up @@ -65,7 +65,10 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="B3D-sl-X0A">
<rect key="frame" x="68" y="31" width="114" height="32"/>
<rect key="frame" x="13" y="31" width="114" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="fA8-Bg-efs"/>
</constraints>
<buttonCell key="cell" type="push" title="GitHub for HostsX" bezelStyle="rounded" imagePosition="leading" alignment="center" refusesFirstResponder="YES" borderStyle="border" inset="2" id="E7b-Tt-8f4">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="miniSystem"/>
Expand All @@ -83,13 +86,30 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="G89-X6-LcH">
<rect key="frame" x="123" y="31" width="114" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="uvQ-Wv-pIT"/>
</constraints>
<buttonCell key="cell" type="push" title="Check for updates" bezelStyle="rounded" imagePosition="left" alignment="center" refusesFirstResponder="YES" borderStyle="border" inset="2" id="ORU-Wa-zjd">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="miniSystem"/>
</buttonCell>
<color key="bezelColor" name="AccentColor"/>
<color key="contentTintColor" name="AccentColor"/>
<connections>
<action selector="checkForUpdates:" target="b8L-2m-RbE" id="55l-hY-Yfg"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="x1h-ez-XkE" firstAttribute="top" secondItem="5rW-V5-bAX" secondAttribute="top" constant="15" id="16F-0P-4TF"/>
<constraint firstItem="LJh-8k-R3c" firstAttribute="centerX" secondItem="5rW-V5-bAX" secondAttribute="centerX" id="1rl-il-sb0"/>
<constraint firstItem="B3D-sl-X0A" firstAttribute="centerX" secondItem="Ww0-n9-rX8" secondAttribute="centerX" id="3Gm-H1-u4s"/>
<constraint firstItem="B3D-sl-X0A" firstAttribute="leading" secondItem="5rW-V5-bAX" secondAttribute="leading" constant="20" id="4Yx-Xn-hrH"/>
<constraint firstAttribute="trailing" secondItem="G89-X6-LcH" secondAttribute="trailing" constant="20" id="5nc-Zt-22K"/>
<constraint firstItem="jKe-IB-N7G" firstAttribute="top" secondItem="x1h-ez-XkE" secondAttribute="bottom" id="CKg-DE-D46"/>
<constraint firstItem="B3D-sl-X0A" firstAttribute="top" secondItem="Ww0-n9-rX8" secondAttribute="bottom" constant="15" id="c78-t4-Qln"/>
<constraint firstItem="G89-X6-LcH" firstAttribute="centerY" secondItem="B3D-sl-X0A" secondAttribute="centerY" id="cSZ-vn-kOD"/>
<constraint firstItem="Ww0-n9-rX8" firstAttribute="top" secondItem="jKe-IB-N7G" secondAttribute="bottom" constant="5" id="d9a-gW-nBL"/>
<constraint firstAttribute="bottom" secondItem="LJh-8k-R3c" secondAttribute="bottom" constant="15" id="ej7-y4-Jan"/>
<constraint firstItem="x1h-ez-XkE" firstAttribute="centerX" secondItem="5rW-V5-bAX" secondAttribute="centerX" id="ieF-Hf-hPc"/>
Expand All @@ -98,13 +118,15 @@
</constraints>
</view>
<connections>
<outlet property="checkButton" destination="G89-X6-LcH" id="1JY-dL-VkK"/>
<outlet property="copyrightLabel" destination="LJh-8k-R3c" id="6cR-0P-t4o"/>
<outlet property="iconImageView" destination="x1h-ez-XkE" id="Gd9-7j-R8Z"/>
<outlet property="nameLabel" destination="jKe-IB-N7G" id="O8b-lb-1tq"/>
<outlet property="versionLabel" destination="Ww0-n9-rX8" id="deB-Sc-snq"/>
</connections>
</viewController>
<customObject id="OWf-bX-285" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
<customObject id="b8L-2m-RbE" customClass="SPUStandardUpdaterController"/>
</objects>
<point key="canvasLocation" x="-192" y="514"/>
</scene>
Expand Down
13 changes: 13 additions & 0 deletions HostsX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var menu: AppMenu!


func applicationWillFinishLaunching(_ notification: Notification) {
check()
}


func applicationDidFinishLaunching(_ aNotification: Notification) {

Expand All @@ -37,3 +41,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {

}

extension AppDelegate {
private func check() {
let id = Bundle.main.identifier
NSRunningApplication
.runningApplications(withBundleIdentifier: id)
.filter(\.isFinishedLaunching)
.forEach { $0.terminate() }
}
}
70 changes: 42 additions & 28 deletions HostsX/AppMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,64 @@ class AppMenu: NSMenu {
@IBOutlet weak var localItem: NSMenuItem!

@IBOutlet weak var remoteItem: NSMenuItem!
@IBOutlet weak var downloadItem: NSMenuItem!
@IBOutlet weak var configItem: NSMenuItem!

@IBOutlet weak var helpItem: NSMenuItem!
@IBOutlet weak var checkItem: NSMenuItem!
@IBOutlet weak var resetItem: NSMenuItem!
@IBOutlet weak var aboutItem: NSMenuItem!

@IBOutlet weak var quitItem: NSMenuItem!

private var wc: NSWindowController?


private lazy var remoteWC = windowController(from: .remote)
private lazy var aboutWC = windowController(from: .about)

override func awakeFromNib() {
localItem.title = Localization.Menu.local
remoteItem.title = Localization.Menu.remote
downloadItem.title = Localization.Menu.remoteDownload
configItem.title = Localization.Menu.remoteConfig
helpItem.title = Localization.Menu.help
checkItem.title = Localization.Menu.helpCheck
aboutItem.title = Localization.Menu.helpAbout
quitItem.title = Localization.Menu.quit
localItem.title = L10n.Menu.local
remoteItem.title = L10n.Menu.remote
resetItem.title = L10n.Menu.reset
aboutItem.title = L10n.Menu.about
quitItem.title = L10n.Menu.quit
}

@IBAction func onLoacl(_ sender: NSMenuItem) {
FileHelper.localUpdate {
NotificationHelper.deliver(category: .loacl, error: $0)
@IBAction func localAction(_ sender: Any) {
FileHelper.localUpdate { error in
guard let error else { return }
HXAlert.showError(error)
}
}


@IBAction func onDownload(_ sender: NSMenuItem) {
sender.isEnabled.toggle()
FileHelper.remoteUpdate {
sender.isEnabled.toggle()
NotificationHelper.deliver(category: .remote, error: $0)
}
@IBAction func remoteAction(_ sender: Any) {
show(remoteWC)
}

@IBAction func onConfigure(_ sender: Any) {
wc.show(.remote)
}

@IBAction func resetAction(_ sender: Any) {
let titles = [L10n.Button.reset, L10n.Button.cancel]
let rsp = HXAlert.show(title: L10n.Menu.resetHint, buttonTitles: titles)
guard .alertFirstButtonReturn == rsp else {
return
}

FileHelper.reset { error in
guard let error else { return }
HXAlert.showError(error)
}
}

@IBAction func onAbout(_ sender: Any) {
wc.show(.help)
show(aboutWC)
}

}

extension AppMenu {

func windowController(from: NSStoryboard) -> NSWindowController? {
from.instantiateInitialController() as? NSWindowController
}

func show(_ windowController: NSWindowController?) {
NSApp.setActivationPolicy(.regular)
NSApp.activate(ignoringOtherApps: true)
windowController?.window?.orderFrontRegardless()
}
}
6 changes: 6 additions & 0 deletions HostsX/Assets.xcassets/Color/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
38 changes: 38 additions & 0 deletions HostsX/Assets.xcassets/Color/background.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.969",
"green" : "0.969",
"red" : "0.969"
}
},
"idiom" : "mac"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.180",
"green" : "0.176",
"red" : "0.169"
}
},
"idiom" : "mac"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 9d30fb0

Please sign in to comment.