Skip to content

Commit

Permalink
add tips for qrcode scan, enforce user choose homedir and validate port
Browse files Browse the repository at this point in the history
  • Loading branch information
fuji246 committed Jul 30, 2019
1 parent 95d28f2 commit 79b4818
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 21 deletions.
4 changes: 0 additions & 4 deletions LomoAgent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
3A8BEF0A22E419BB00DAE39C /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3A8BEF0C22E419BB00DAE39C /* Localizable.strings */; };
3A8BEF0F22E419F500DAE39C /* Localizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A8BEF0E22E419F500DAE39C /* Localizable.swift */; };
3A8BEF1122E4BA0B00DAE39C /* LomodService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A8BEF1022E4BA0B00DAE39C /* LomodService.swift */; };
3A8BEF1322E4D67D00DAE39C /* rsync in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3A8BEF1222E4D67D00DAE39C /* rsync */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
3A94CC2E22E407A9002207D5 /* utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A94CC2D22E407A9002207D5 /* utils.swift */; };
3AC3E846229F9B60004EA1D7 /* HyperlinkTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AC3E845229F9B60004EA1D7 /* HyperlinkTextField.swift */; };
/* End PBXBuildFile section */
Expand All @@ -35,7 +34,6 @@
dstPath = "";
dstSubfolderSpec = 6;
files = (
3A8BEF1322E4D67D00DAE39C /* rsync in CopyFiles */,
3A35C5D92240B5F30030FF1B /* avconv in CopyFiles */,
3A35C5DA2240B5F30030FF1B /* lomod in CopyFiles */,
);
Expand Down Expand Up @@ -82,7 +80,6 @@
3A8BEF0D22E419BD00DAE39C /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
3A8BEF0E22E419F500DAE39C /* Localizable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Localizable.swift; sourceTree = "<group>"; };
3A8BEF1022E4BA0B00DAE39C /* LomodService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LomodService.swift; sourceTree = "<group>"; };
3A8BEF1222E4D67D00DAE39C /* rsync */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = rsync; path = dependencies/lomod/Contents/MacOS/rsync; sourceTree = "<group>"; };
3A94CC2D22E407A9002207D5 /* utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = utils.swift; sourceTree = "<group>"; };
3AC3E845229F9B60004EA1D7 /* HyperlinkTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperlinkTextField.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -128,7 +125,6 @@
3A3896EF222F77FA004A2001 = {
isa = PBXGroup;
children = (
3A8BEF1222E4D67D00DAE39C /* rsync */,
3A35C5B52240A01D0030FF1B /* dependencies */,
3A3896FA222F77FA004A2001 /* LomoAgent */,
3A3896F9222F77FA004A2001 /* Products */,
Expand Down
39 changes: 24 additions & 15 deletions LomoAgent/Base.lproj/PreferencesWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
<window title="Settings" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="360" height="280"/>
<rect key="contentRect" x="196" y="240" width="360" height="341"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<view key="contentView" wantsLayer="YES" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="360" height="280"/>
<rect key="frame" x="0.0" y="0.0" width="360" height="341"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dPJ-v8-FX0">
<rect key="frame" x="38" y="242" width="100" height="17"/>
<rect key="frame" x="38" y="304" width="100" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Home Directory" id="lAc-fy-Miv">
<font key="font" usesAppearanceFont="YES"/>
Expand All @@ -42,7 +42,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MB4-Ft-4uC">
<rect key="frame" x="38" y="175" width="109" height="17"/>
<rect key="frame" x="38" y="235" width="109" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Backup Directory" id="ewJ-OL-QHy">
<font key="font" usesAppearanceFont="YES"/>
Expand All @@ -51,7 +51,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3zh-D9-PhM">
<rect key="frame" x="40" y="210" width="280" height="22"/>
<rect key="frame" x="40" y="271" width="280" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="eQt-yd-8Oh">
<font key="font" metaFont="system"/>
Expand All @@ -60,7 +60,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gR2-hd-LuV">
<rect key="frame" x="40" y="142" width="280" height="22"/>
<rect key="frame" x="40" y="203" width="280" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="ETm-o0-aSs">
<font key="font" metaFont="system"/>
Expand All @@ -69,7 +69,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="AyW-Hh-bcP">
<rect key="frame" x="174" y="233" width="73" height="32"/>
<rect key="frame" x="174" y="294" width="73" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Open" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="CTw-zS-X9b">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
Expand All @@ -80,7 +80,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9uI-GV-J4c">
<rect key="frame" x="174" y="165" width="73" height="32"/>
<rect key="frame" x="174" y="226" width="73" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Open" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="uJs-cw-aLe">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
Expand All @@ -91,7 +91,7 @@
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FeW-Jp-XEh">
<rect key="frame" x="38" y="20" width="30" height="17"/>
<rect key="frame" x="38" y="23" width="30" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Port" id="VTa-Lr-Xxo">
<font key="font" metaFont="system"/>
Expand All @@ -100,7 +100,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9j3-TC-mnI">
<rect key="frame" x="247" y="233" width="79" height="32"/>
<rect key="frame" x="247" y="294" width="79" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Select" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="o4F-iv-Nxx">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
Expand All @@ -111,7 +111,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="41g-Kx-m4R">
<rect key="frame" x="247" y="165" width="79" height="32"/>
<rect key="frame" x="247" y="226" width="79" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Select" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Jgq-Kj-pZS">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
Expand All @@ -122,7 +122,7 @@
</connections>
</button>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ha9-zw-3Td">
<rect key="frame" x="220" y="20" width="100" height="100"/>
<rect key="frame" x="220" y="58" width="100" height="100"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="QnP-UT-T1E"/>
</imageView>
Expand All @@ -139,16 +139,25 @@
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hLc-hC-7B1">
<rect key="frame" x="38" y="108" width="83" height="17"/>
<rect key="frame" x="38" y="178" width="83" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Last Backup:" id="WYm-6m-azh">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jL5-5g-WN8">
<rect key="frame" x="36" y="66" width="159" height="84"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" selectable="YES" title="If the service can not be found automatically, you can scan the QR code to finish the initial setup" id="iBo-mW-e8D">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6In-C0-Ox8">
<rect key="frame" x="38" y="61" width="122" height="18"/>
<rect key="frame" x="213" y="22" width="109" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Debug Mode" bezelStyle="regularSquare" imagePosition="left" alignment="center" state="on" inset="2" id="439-ns-a3v">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -163,7 +172,7 @@
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
</connections>
<point key="canvasLocation" x="190" y="181"/>
<point key="canvasLocation" x="190" y="211.5"/>
</window>
</objects>
</document>
4 changes: 2 additions & 2 deletions LomoAgent/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0b8e4c9</string>
<string>5450580</string>
<key>CFBundleVersion</key>
<string>2019_07_21.10_21_21.0.0b8e4c9</string>
<string>2019_07_28.15_43_13.0.5450580</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
Expand Down
4 changes: 4 additions & 0 deletions LomoAgent/Localizable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ let errorChooseBackupMsgLocalized = NSLocalizedString("Backup directory should n

let lastBackupLocalized = NSLocalizedString("Last Backup: ", comment: "")
let setBackupDirFailedLocalized = NSLocalizedString("Set backup directory failed", comment: "")

let invalidPortLocalized = NSLocalizedString("Invalid port", comment: "")
let invalidPortTipsLocalized = NSLocalizedString("The port should be a number in range [1024, 49151]", comment: "")
let homeDirRequiredLocalized = NSLocalizedString("Home directory required!", comment: "")
14 changes: 14 additions & 0 deletions LomoAgent/PreferencesWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ class PreferencesWindow: NSWindowController, NSWindowDelegate {
@IBAction func onPortChange(_ sender: Any) {
let oldPort = UserDefaults.standard.string(forKey: PREF_PORT)
let port = portTextField.stringValue
let p = Int(port)
guard p != nil && p! >= 1024 && p! <= 49151 else {
dialogAlert(message: invalidPortLocalized, info: invalidPortTipsLocalized)
return
}
if oldPort != port {
os_log("Save port: %{public}s", log: .ui, port)
UserDefaults.standard.set(port, forKey: PREF_PORT)
Expand Down Expand Up @@ -245,4 +250,13 @@ class PreferencesWindow: NSWindowController, NSWindowDelegate {

func windowWillClose(_ notification: Notification) {
}

func windowShouldClose(_ sender: NSWindow) -> Bool {
if homeDirTextField.stringValue == "" {
dialogAlert(message: homeDirRequiredLocalized, info: "")
return false
} else {
return true
}
}
}
3 changes: 3 additions & 0 deletions LomoAgent/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
"Error when choosing backup directory" = "Error when choosing backup directory";
"Backup directory should not be the same with home directory" = "Backup directory should not be the same with home directory";
"Last Backup: " = "Last Backup: ";
"Invalid port" = "Invalid port";
"The port should be a number in range [1024, 49151]" = "The port should be a number in range [1024, 49151]";
"Home directory required!" = "Home directory required!";
2 changes: 2 additions & 0 deletions LomoAgent/en.lproj/PreferencesWindow.strings
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
/* Class = "NSButtonCell"; title = "Select"; ObjectID = "o4F-iv-Nxx"; */
"o4F-iv-Nxx.title" = "Select";

"iBo-mW-e8D.title" = "If the service can not be found automatically, you can scan the QR code to configure the service";

/* Class = "NSTextFieldCell"; title = "Home Directory"; ObjectID = "ewJ-OL-QHy"; */
"ewJ-OL-QHy.title" = "Backup Directory";

Expand Down
3 changes: 3 additions & 0 deletions LomoAgent/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
"Error when choosing backup directory" = "选择备份目录出错";
"Backup directory should not be the same with home directory" = "备份目录不能和主目录一样";
"Last Backup: " = "上次备份: ";
"Invalid port" = "无效端口";
"The port should be a number in range [1024, 49151]" = "端口必须是在范围[1024, 49151]之内的数字";
"Home directory required!" = "需要设置主目录!";
2 changes: 2 additions & 0 deletions LomoAgent/zh-Hans.lproj/PreferencesWindow.strings
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
/* Class = "NSButtonCell"; title = "Select"; ObjectID = "o4F-iv-Nxx"; */
"o4F-iv-Nxx.title" = "选择";

"iBo-mW-e8D.title" = "如果服务未能自动发现,您可以通过扫描二维码的方式来配置服务";

/* Class = "NSTextFieldCell"; title = "Home Directory"; ObjectID = "ewJ-OL-QHy"; */
"ewJ-OL-QHy.title" = "备份目录";

Expand Down

0 comments on commit 79b4818

Please sign in to comment.