widget layout tool improvements

This commit is contained in:
True Zhuanjia
2026-03-22 14:01:09 +08:00
parent d092b93a29
commit dbe91f5b07
6 changed files with 253 additions and 71 deletions
+123 -54
View File
@@ -1387,52 +1387,6 @@
}
}
},
"Alias (optional)" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "别名 (允许留空)"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "別名 (可選)"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "別名 (可選)"
}
}
}
},
"Alias label (optional)" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "别名标签 (可留空)"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "別名標籤 (可選)"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "別名標籤 (可選)"
}
}
}
},
"All Settings" : {
"extractionState" : "manual",
"localizations" : {
@@ -2032,25 +1986,25 @@
}
}
},
"Command" : {
"Command: " : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "命令"
"value" : "命令: "
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "指令"
"value" : "指令: "
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "指令"
"value" : "指令: "
}
}
}
@@ -2902,6 +2856,29 @@
}
}
},
"e.g. ctrl, lswheel, wasdpad..." : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "如ctrl, lswheel, wasdpad..."
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "如ctrl, lswheel, wasdpad..."
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "如ctrl, lswheel, wasdpad..."
}
}
}
},
"edgeSlidingSensitivityStackTip" : {
"extractionState" : "manual",
"localizations" : {
@@ -4332,6 +4309,29 @@
}
}
},
"Label: " : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "标签: "
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "標籤: "
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "標籤: "
}
}
}
},
"Later" : {
"extractionState" : "manual",
"localizations" : {
@@ -5324,6 +5324,29 @@
}
}
},
"No widget selected" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "请先点选一个控件"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "請先點選一個小工具"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "請先點選一個小工具"
}
}
}
},
"Nothing to Undo" : {
"extractionState" : "manual",
"localizations" : {
@@ -5710,6 +5733,29 @@
}
}
},
"optional" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "可留空"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "可選"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "可選"
}
}
}
},
"Options" : {
"extractionState" : "manual",
"localizations" : {
@@ -6935,6 +6981,29 @@
}
}
},
"r - round/circle, s - square/rect" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "r - 圆形, s - 方形"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "r - 圓形, s - 方形"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "r - 圓形, s - 方形"
}
}
}
},
"Read Widget Instruction" : {
"extractionState" : "manual",
"localizations" : {
@@ -7771,25 +7840,25 @@
}
}
},
"Shape (r - round, s - square)" : {
"Shape: " : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "按键形状 (r - 圆形, s - 方形)"
"value" : "形状: "
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "形狀 (r - 圓形, s - 方形)"
"value" : "形狀: "
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "形狀 (r - 圓形, s - 方形)"
"value" : "形狀: "
}
}
}
+21
View File
@@ -106,6 +106,27 @@ import Foundation
}
}
@objc static var autoPopSoftKeyboard: Bool = true
@objc static var textFieldShouldResignAfterReturn: Bool = false
@objc static func getAtrributedPlaceHolder(text:String)-> NSAttributedString {
if #available(iOS 13.0, *) {
return NSAttributedString(
string: text,
attributes: [
.font: UIFont.systemFont(ofSize: 15),
.foregroundColor: UIColor.placeholderText
])
} else {
return NSAttributedString(
string: text,
attributes: [
.font: UIFont.systemFont(ofSize: 15),
.foregroundColor: UIColor.lightText
])
}
}
static var kScaleLayerKey: UInt8 = 0
@objc static func setVerticalScale(view: UIView, show: Bool) {
// 移除旧的
@@ -659,6 +659,7 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
}
- (IBAction) addTapped:(id)sender{
GenericUtils.autoPopSoftKeyboard = false;
NSMutableDictionary* widgetInitParams = [NSMutableDictionary dictionary];
@@ -667,24 +668,51 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"Command"];
UILabel *label = [[UILabel alloc] init];
label.text = [LocalizationHelper localizedStringForKey:@"Command: "];
label.font = [UIFont systemFontOfSize:15];
[label sizeToFit];
textField.leftView = label;
textField.leftViewMode = UITextFieldViewModeAlways;
textField.attributedPlaceholder = [GenericUtils getAtrributedPlaceHolderWithText:[LocalizationHelper localizedStringForKey:@"e.g. ctrl, lswheel, wasdpad..."]];
textField.font = [UIFont systemFontOfSize:15];
textField.keyboardType = UIKeyboardTypeASCIICapable;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
textField.delegate = self;
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"Alias label (optional)"];
UILabel *label = [[UILabel alloc] init];
label.text = [LocalizationHelper localizedStringForKey:@"Label: "];
label.font = [UIFont systemFontOfSize:15];
[label sizeToFit];
textField.leftView = label;
textField.leftViewMode = UITextFieldViewModeAlways;
textField.attributedPlaceholder = [GenericUtils getAtrributedPlaceHolderWithText:[LocalizationHelper localizedStringForKey:@"optional"]];
textField.font = [UIFont systemFontOfSize:15];
textField.keyboardType = UIKeyboardTypeDefault;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
textField.delegate = self;
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"Shape (r - round, s - square)"];
UILabel *label = [[UILabel alloc] init];
label.text = [LocalizationHelper localizedStringForKey:@"Shape: "];
label.font = [UIFont systemFontOfSize:15];
[label sizeToFit];
textField.leftView = label;
textField.leftViewMode = UITextFieldViewModeAlways;
textField.attributedPlaceholder = [GenericUtils getAtrributedPlaceHolderWithText:[LocalizationHelper localizedStringForKey:@"r - round/circle, s - square/rect"]];
textField.font = [UIFont systemFontOfSize:15];
textField.keyboardType = UIKeyboardTypeASCIICapable;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
textField.delegate = self;
}];
@@ -719,6 +747,7 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
- (IBAction) editTapped:(id)sender{
GenericUtils.autoPopSoftKeyboard = false;
NSMutableDictionary* widgetInitParams = [NSMutableDictionary dictionary];
@@ -726,29 +755,67 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
message:[LocalizationHelper localizedStringForKey:@"Edit Selected Widget"]
preferredStyle:UIAlertControllerStyleAlert];
if(self->selectedWidgetView == nil) return;
if(self->selectedWidgetView == nil) {
AlertControllerUtil.autoCompletion = true;
[AlertControllerUtil showAlertIn:self
title:@""
message:[LocalizationHelper localizedStringForKey:@"No widget selected"]
withCancel:NO
buttonTitle:@""
countdown:1
action:^{}
completion:^{}];
return;
};
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"Command"];
UILabel *label = [[UILabel alloc] init];
label.text = [LocalizationHelper localizedStringForKey:@"Command: "];
label.font = [UIFont systemFontOfSize:15];
[label sizeToFit];
textField.leftView = label;
textField.leftViewMode = UITextFieldViewModeAlways;
textField.attributedPlaceholder = [GenericUtils getAtrributedPlaceHolderWithText:[LocalizationHelper localizedStringForKey:@"e.g. ctrl, lswheel, wasdpad..."]];
textField.font = [UIFont systemFontOfSize:15];
textField.keyboardType = UIKeyboardTypeASCIICapable;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
textField.delegate = self;
textField.text = [self->selectedWidgetView.cmdString lowercaseString];
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"Alias label (optional)"];
UILabel *label = [[UILabel alloc] init];
label.text = [LocalizationHelper localizedStringForKey:@"Label: "];
label.font = [UIFont systemFontOfSize:15];
[label sizeToFit];
textField.leftView = label;
textField.leftViewMode = UITextFieldViewModeAlways;
textField.attributedPlaceholder = [GenericUtils getAtrributedPlaceHolderWithText:[LocalizationHelper localizedStringForKey:@"optional"]];
textField.font = [UIFont systemFontOfSize:15];
textField.keyboardType = UIKeyboardTypeDefault;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
textField.delegate = self;
textField.text = self->selectedWidgetView.widgetLabel;
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"Shape (r - round, s - square)"];
UILabel *label = [[UILabel alloc] init];
label.text = [LocalizationHelper localizedStringForKey:@"Shape: "];
label.font = [UIFont systemFontOfSize:15];
[label sizeToFit];
textField.leftView = label;
textField.leftViewMode = UITextFieldViewModeAlways;
textField.attributedPlaceholder = [GenericUtils getAtrributedPlaceHolderWithText:[LocalizationHelper localizedStringForKey:@"r - round/circle, s - square/rect"]];
textField.font = [UIFont systemFontOfSize:15];
textField.keyboardType = UIKeyboardTypeASCIICapable;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
textField.delegate = self;
textField.text = self->selectedWidgetView.shape;
if([self->selectedWidgetView.shape isEqualToString: @"largeSquare"]) textField.enabled = false;
}];
@@ -897,6 +964,7 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
/* show pop up notification that lets users choose to save the current OSC layout configuration as a profile they can load when they want. User can also choose to cancel out of this pop up */
- (IBAction) saveTapped:(id)sender {
/*
OSCProfile* targetProfile = [profilesManager getAllProfiles][0];
OSCProfile* currentProfile = [profilesManager getSelectedProfile];
@@ -1686,12 +1754,24 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
}
}
// UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder]; // 收起键盘
[selectedWidgetView setAutoTapIntervalByTextWithStr:textField.text];
if(textField == _autoTapField){
[textField resignFirstResponder]; // 收起键盘
[selectedWidgetView setAutoTapIntervalByTextWithStr:textField.text];
}
return YES;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if (GenericUtils.autoPopSoftKeyboard) {
return YES;
} else {
GenericUtils.autoPopSoftKeyboard = YES;
return NO;
}
}
- (void)applyShadowForiOS13:(UIStackView* )stack {
stack.backgroundColor = [UIColor clearColor];
@@ -20,7 +20,7 @@
#import "HostCollectionViewController.h"
@interface MainFrameViewController : UICollectionViewController <DiscoveryCallback, PairCallback, AppCallback, AppAssetCallback, NSURLConnectionDelegate, SWRevealViewControllerDelegate, HostCardActionDelegate, AppViewUpdateLoopDelegate>
@interface MainFrameViewController : UICollectionViewController <DiscoveryCallback, PairCallback, AppCallback, AppAssetCallback, NSURLConnectionDelegate, SWRevealViewControllerDelegate, HostCardActionDelegate, AppViewUpdateLoopDelegate, UITextFieldDelegate>
@property (nonatomic, strong) IBOutlet UIBarButtonItem *settingsButton;
#if !TARGET_OS_TV
@@ -723,6 +723,7 @@ static NSMutableSet* hostList;
- (void) addHostTapped {
Log(LOG_D, @"Tapped add host");
GenericUtils.autoPopSoftKeyboard = GenericUtils.isIPhone ? false : true;
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@"Add Host Manually"]
message:[LocalizationHelper localizedStringForKey:@"Enter IP address to add host manually"]
preferredStyle:UIAlertControllerStyleAlert];
@@ -732,6 +733,7 @@ static NSMutableSet* hostList;
textField.keyboardType = UIKeyboardTypeASCIICapable;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
textField.delegate = self;
}];
[alertController addAction:[UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Cancel"]
@@ -2404,6 +2406,15 @@ static NSMutableSet* hostList;
return YES;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if (GenericUtils.autoPopSoftKeyboard) {
return YES;
} else {
GenericUtils.autoPopSoftKeyboard = YES;
return NO;
}
}
#if !TARGET_OS_TV
- (BOOL)shouldAutorotate {
return YES;
@@ -37,7 +37,6 @@
bool settingsViewJustLoaded;
bool settingsViewJustExpanded;
bool settingsViewAlreadyAppeared;
bool autoPopKeyboard;
uint16_t oswLayoutFingers;
CustomEdgeSlideGestureRecognizer *slideToCloseSettingsViewRecognizer;
NSMutableDictionary *_settingStackDict;
@@ -570,7 +569,6 @@ BOOL isCustomResolution(int resolutionSelected) {
settingsViewJustExpanded = false;
settingsViewAlreadyAppeared = true;
autoPopKeyboard = true;
}
- (void)viewWillDisappear:(BOOL)animated{
@@ -2233,6 +2231,7 @@ BOOL isCustomResolution(int resolutionSelected) {
}
- (void)showCustomOswTip {
GenericUtils.autoPopSoftKeyboard = GenericUtils.isIPhone ? false : true;
NSString* edgeSide = self.slideToSettingsScreenEdgeSelector.selectedSegmentIndex == 1 ? [LocalizationHelper localizedStringForKey:@"left"] : [LocalizationHelper localizedStringForKey:@"right"];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@"Rebase in Streaming"]
message:[LocalizationHelper localizedStringForKey:@"Open widget tool in streaming by:\nSliding from %@ screen edge to open cmd tool.\nOr tap %d fingers on stream view, number of fingers required:", edgeSide, self->oswLayoutFingers]
@@ -2241,6 +2240,7 @@ BOOL isCustomResolution(int resolutionSelected) {
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"%d", self->oswLayoutFingers];
textField.keyboardType = UIKeyboardTypeNumberPad;
textField.delegate = self;
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Cancel"]
@@ -2997,7 +2997,7 @@ BOOL isCustomResolution(int resolutionSelected) {
- (void)softKeyboardHeightSwitchFlipped:(UISwitch* )sender{
if(sender.isOn && !settingsViewJustLoaded){
autoPopKeyboard = false;
GenericUtils.autoPopSoftKeyboard = false;
[GenericUtils setVerticalScaleWithView:self.view show:true];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@""]
message:[LocalizationHelper localizedStringForKey:@"Enter the relative height of the soft keyboard according to the scale (make sure app is in landscape fullscreen mode):"]
@@ -3017,7 +3017,6 @@ BOOL isCustomResolution(int resolutionSelected) {
handler:^(UIAlertAction *action) {
[GenericUtils setVerticalScaleWithView:self.view show:false];
[sender setOn:self->softKeyboardHeight!=0];
self->autoPopKeyboard = true;
}];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"OK"]
@@ -3026,7 +3025,6 @@ BOOL isCustomResolution(int resolutionSelected) {
self->softKeyboardHeight = [GenericUtils toCGFloat:alertController.textFields[0].text];
[GenericUtils setVerticalScaleWithView:self.view show:false];
[sender setOn:self->softKeyboardHeight!=0];
self->autoPopKeyboard = true;
}];
[alertController addAction:cancelAction];
[alertController addAction:okAction];
@@ -3036,10 +3034,10 @@ BOOL isCustomResolution(int resolutionSelected) {
// UITextFieldDelegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if (autoPopKeyboard) {
if (GenericUtils.autoPopSoftKeyboard) {
return YES;
} else {
autoPopKeyboard = YES;
GenericUtils.autoPopSoftKeyboard = YES;
return NO;
}
}
@@ -3193,6 +3191,7 @@ BOOL isCustomResolution(int resolutionSelected) {
}
- (void) promptCustomResolutionDialog {
GenericUtils.autoPopSoftKeyboard = GenericUtils.isIPhone ? false : true;
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey: @"Enter Custom Resolution"] message:nil preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
@@ -3200,6 +3199,7 @@ BOOL isCustomResolution(int resolutionSelected) {
textField.clearButtonMode = UITextFieldViewModeAlways;
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.keyboardType = UIKeyboardTypeNumberPad;
textField.delegate = self;
if (resolutionTable[RESOLUTION_TABLE_CUSTOM_INDEX].width == 0) {
textField.text = @"";
@@ -3214,6 +3214,7 @@ BOOL isCustomResolution(int resolutionSelected) {
textField.clearButtonMode = UITextFieldViewModeAlways;
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.keyboardType = UIKeyboardTypeNumberPad;
textField.delegate = self;
if (resolutionTable[RESOLUTION_TABLE_CUSTOM_INDEX].height == 0) {
textField.text = @"";