Skip to content

Commit

Permalink
version 1.0 -> 1.1
Browse files Browse the repository at this point in the history
"Spotlight action"
Added secret code to Preferences textfield (if it already exists)
Refined status item icon
Added CLI status to README

In Menu:
token display (click or Cmd+C to copy)
Cmd+, hotkey for preferences window
  • Loading branch information
artginzburg committed Jan 27, 2020
1 parent 35248e2 commit 8ce0820
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 23 deletions.
4 changes: 4 additions & 0 deletions 2FA to Tray.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,13 @@
CODE_SIGN_ENTITLEMENTS = "2FA to Tray/2FAtoTray.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
INFOPLIST_FILE = "2FA to Tray/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.dafuqtor.2FAtoTray;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -298,11 +300,13 @@
CODE_SIGN_ENTITLEMENTS = "2FA to Tray/2FAtoTray.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
INFOPLIST_FILE = "2FA to Tray/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.dafuqtor.2FAtoTray;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
18 changes: 17 additions & 1 deletion 2FA to Tray/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ class OTP {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
textfield.becomeFirstResponder()
}

if !self.secret.isEmpty {
textfield.stringValue = self.secret
}

let response = alert.runModal()

Expand Down Expand Up @@ -153,5 +157,17 @@ class OTP {

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

func applicationShouldHandleReopen(_ sender: NSApplication,
hasVisibleWindows flag: Bool) -> Bool
{
otp.copy()
if let button = statusItem.button {
button.highlight(true)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
button.highlight(false)
}
}
print("handled reopen")
return true
}
}
Binary file modified 2FA to Tray/Assets.xcassets/StatusIcon.imageset/Mac128x1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 2FA to Tray/Assets.xcassets/StatusIcon.imageset/Mac32x1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 2FA to Tray/Assets.xcassets/StatusIcon.imageset/Mac32x2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions 2FA to Tray/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@
<customObject id="dok-4Z-Dc3" customClass="StatusMenuController" customModule="_FA_to_Tray" customModuleProvider="target">
<connections>
<outlet property="statusMenu" destination="Xfq-v7-Hh9" id="IVL-Qf-J99"/>
<outlet property="tokenDisplay" destination="zOQ-XV-e7G" id="1d5-EH-Qe4"/>
</connections>
</customObject>
<menu id="Xfq-v7-Hh9">
<menu showsStateColumn="NO" id="Xfq-v7-Hh9">
<items>
<menuItem title="Change secret" id="UPw-mj-LC4">
<modifierMask key="keyEquivalentModifierMask"/>
<menuItem title="Token" hidden="YES" enabled="NO" keyEquivalent="c" indentationLevel="1" id="zOQ-XV-e7G">
<connections>
<action selector="tokenDisplayClicked:" target="dok-4Z-Dc3" id="Ccq-RI-Ctx"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="4gT-no-BVk"/>
<menuItem title="Change secret..." keyEquivalent="," indentationLevel="1" id="UPw-mj-LC4">
<connections>
<action selector="changeSecret:" target="dok-4Z-Dc3" id="Heu-pl-tvM"/>
</connections>
</menuItem>
<menuItem title="Quit" keyEquivalent="q" id="YdM-ld-HSz" userLabel="Quit">
<menuItem title="Quit" keyEquivalent="q" indentationLevel="1" id="YdM-ld-HSz" userLabel="Quit">
<connections>
<action selector="terminate:" target="-1" id="gjK-Ut-vGN"/>
</connections>
Expand Down
4 changes: 2 additions & 2 deletions 2FA to Tray/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
32 changes: 21 additions & 11 deletions 2FA to Tray/StatusMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

import Cocoa

class StatusMenuController: NSObject {
let otp = OTP()

let statusItem = NSStatusBar.system.statusItem(withLength: 22)

class StatusMenuController: NSObject, NSMenuDelegate {

func resize(image: NSImage, w: Int, h: Int) -> NSImage {
let destSize = NSMakeSize(CGFloat(w), CGFloat(h))
Expand All @@ -23,13 +27,9 @@ class StatusMenuController: NSObject {
@IBOutlet weak var statusMenu: NSMenu!

@IBAction func changeSecret(_ sender: Any) {
self.otp.showAlert()
otp.showAlert()
}

let statusItem = NSStatusBar.system.statusItem(withLength: 22)

let otp = OTP()


class mouseHandlerView: NSView {

var onLeftMouseDown: (()->())? = nil
Expand All @@ -54,9 +54,10 @@ class StatusMenuController: NSObject {

override func awakeFromNib() {
statusItem.menu = statusMenu
statusMenu.delegate = self
statusItem.isVisible = true
if let button = statusItem.button {
let statusIcon = resize(image: NSImage(named: "StatusIcon")!, w: 20, h: 20)
let statusIcon = resize(image: NSImage(named: "StatusIcon")!, w: 22, h: 22)
statusIcon.isTemplate = true
button.image = statusIcon
button.target = self
Expand All @@ -80,13 +81,13 @@ class StatusMenuController: NSObject {

mouseView.onLeftMouseDown = {
button.highlight(true)
self.otp.copy()
otp.copy()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
button.highlight(false)
}
if (NSApp.currentEvent?.clickCount == 2) {
print("Doubleclick")
self.otp.showAlert()
otp.showAlert()
}
}

Expand All @@ -98,7 +99,16 @@ class StatusMenuController: NSObject {
}
}

@IBOutlet weak var tokenDisplay: NSMenuItem!
@IBAction func tokenDisplayClicked(_ sender: NSMenuItem) {
otp.copy()
}

func menuNeedsUpdate(_ menu: NSMenu) {

if !otp.token.isEmpty {
tokenDisplay.title = otp.token
}
tokenDisplay.isHidden = otp.token.isEmpty
tokenDisplay.isEnabled = !otp.token.isEmpty
}
}
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ brew cask install dafuqtor/tap/2fatotray

#### Direct Download · **[Latest Release](//github.com/DaFuqtor/2FAtoTray/releases/latest/download/2FAtoTray.zip) ([![GitHub release](https://img.shields.io/github/release/dafuqtor/2fatotray?label=%20&color=gray)](//github.com/DaFuqtor/2FAtoTray/releases))**

> [![Build Status](https://app.bitrise.io/app/94efe673ad3ac640/status.svg?token=TgJkjwx_27BVoz877mKocQ)](https://app.bitrise.io/app/94efe673ad3ac640)
<br>

<h2 align="right">:mag: Usage</h2>
<p align="right"><kbd>Click</kbd> &nbsp·&nbsp to copy</p>
<p align="right"><kbd>RMB</kbd> &nbsp·&nbsp to open menu</p>
<br>

## Settings (in menu)
<p align="right"><kbd>Double Click</kbd> &nbsp·&nbsp to change secret</p>
<p align="right"><kbd>⌘</kbd><kbd>Space</kbd> &nbsp·&nbsp type <code>2fa</code> &nbsp·&nbsp hit <kbd>Enter</kbd>&nbsp·&nbsp to copy</p>

1. Change generator seed
<h4> All the actions are also available in menu </h4>

<br>

Expand All @@ -39,7 +40,7 @@ brew cask install dafuqtor/tap/2fatotray

#### Instant Mode

> After launching, the program copies the code and exits. (useful with Spotlight)
> After launching, the program copies the code and exits (so, completely minimizing battery usage)
```powershell
defaults write com.dafuqtor.2FAtoTray instantMode 1
Expand Down
Binary file modified icons/status.psd
Binary file not shown.

0 comments on commit 8ce0820

Please sign in to comment.