Skip to content

Commit

Permalink
ACTIONS: adding clear-up very long press + improving contrast on secu…
Browse files Browse the repository at this point in the history
…re entries with foreground title
  • Loading branch information
Commit-La-Grenouille committed Dec 21, 2022
1 parent 6b42e39 commit c5f9890
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Once assigned to a key, you will be able to use this as a slot for keeping somet
- __to save or replace__: hold the key at least 0.5 sec (but not too long !) and the text preview will appear on the key
- __to save or replace (sensitive)__: hold the key at least 1 sec and the icon will show a padlock with a timestamp
- __to use__: press the key to paste it wherever the focus is
- __to reset__: hold the key at least 3 sec and the icon will go back to the original empty icon

(see the Security sub-section below on the 2 possible ways to save text)

Expand Down
14 changes: 9 additions & 5 deletions Sources/Clipboard-Buddy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
FA0F7B6F2105CBC30028CF34 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1330;
LastUpgradeCheck = 1420;
ORGANIZATIONNAME = "Elgato Systems";
TargetAttributes = {
FA0F7B762105CBC30028CF34 = {
Expand Down Expand Up @@ -394,6 +394,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand All @@ -412,7 +413,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = Vendor/SocketRocket/;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -455,6 +456,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -467,7 +469,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = Vendor/SocketRocket/;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand All @@ -479,8 +481,9 @@
buildSettings = {
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
DEAD_CODE_STRIPPING = YES;
INSTALL_PATH = "net.localhost.streamdeck.clipboard-buddy.sdPlugin";
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
PRODUCT_BUNDLE_IDENTIFIER = "net.localhost.streamdeck.clipboard-buddy";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -491,8 +494,9 @@
buildSettings = {
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
DEAD_CODE_STRIPPING = YES;
INSTALL_PATH = "net.localhost.streamdeck.clipboard-buddy.sdPlugin";
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
PRODUCT_BUNDLE_IDENTIFIER = "net.localhost.streamdeck.clipboard-buddy";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
21 changes: 17 additions & 4 deletions Sources/MyStreamDeckPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
#import <AppKit/AppKit.h>


#define MIN_LONG_PRESS 0.5
#define MIN_LONG_PRESS 0.5
#define SECURE_PRESS 1.0
#define CLEAR_PRESS 3.0

// Size of the images
#define IMAGE_SIZE 144
Expand Down Expand Up @@ -339,7 +340,7 @@ - (void)keyUpForAction:(NSString *)action withContext:(id)context withPayload:(N
// Logging the length of the key press for future reference
[_connectionManager logMessage: [NSString stringWithFormat:@"[KEY UP] Key pressed for %20lf sec", diff]];

if (diff >= MIN_LONG_PRESS ) {
if (diff >= MIN_LONG_PRESS) {

// Grabbing the current data in the clipboard
NSString * clipboardContent = [_pboard stringForType:NSStringPboardType];
Expand All @@ -359,15 +360,27 @@ - (void)keyUpForAction:(NSString *)action withContext:(id)context withPayload:(N
// Showing the copy worked
[_connectionManager showOKForContext:context];

if (diff >= SECURE_PRESS) {
if (diff >= SECURE_PRESS && diff < CLEAR_PRESS) {
// Changing the background to convey we have sensitive data there
[_connectionManager setImage:_base64PostitSecure withContext:context withTarget:kESDSDKTarget_HardwareAndSoftware];

// Adding a safe title to avoid leaking sensitive data
// TODO: Adding a safe title to avoid leaking sensitive data
NSString * secureTitle = askUserForLabel(_daFo);
[_connectionManager logMessage:[NSString stringWithFormat:@"We asked the user and got the label (%@)", secureTitle]];

[_connectionManager setTitle:secureTitle withContext:context withTarget:kESDSDKTarget_HardwareAndSoftware];
}
else if (diff >= CLEAR_PRESS) {
// Purging the struct by resetting to the default value
NSString * dictKey = keyFromCoord(payload[@"coordinates"]);
_tileText[dictKey] = dictKey;

// Changing the background to convey we have purged the data
[_connectionManager setImage:_base64PostitSleepy withContext:context withTarget:kESDSDKTarget_HardwareAndSoftware];

// And clearing the text if it was a secure entry
[_connectionManager setTitle:@"" withContext:context withTarget:kESDSDKTarget_HardwareAndSoftware];
}
else {
NSString * textToDisplay = _tileText[ keyFromCoord(payload[@"coordinates"]) ];

Expand Down
Binary file modified Sources/net.localhost.streamdeck.clipboard-buddy.sdPlugin/postit-secure.png
100755 → 100644
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 Sources/net.localhost.streamdeck.clipboard-buddy.sdPlugin/[email protected]
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c5f9890

Please sign in to comment.