bump version to 10

- add option to invert AIR input
- create seperate settings page
master
esterTion 2020-09-08 17:07:02 +08:00
parent 8a2a526687
commit 049407e1b5
8 changed files with 141 additions and 39 deletions

View File

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
1961EB742507451600C79BF8 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 1961EB732507451600C79BF8 /* Settings.bundle */; };
1968E72624086C2200784829 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1968E72524086C2200784829 /* AppDelegate.m */; };
1968E72924086C2200784829 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1968E72824086C2200784829 /* ViewController.m */; };
1968E72C24086C2200784829 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1968E72A24086C2200784829 /* Main.storyboard */; };
@ -21,6 +22,7 @@
/* Begin PBXFileReference section */
1277586B240D1432002C27EE /* MainApp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainApp.h; sourceTree = "<group>"; };
1961EB732507451600C79BF8 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
1968E72124086C2200784829 /* Brokenithm-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Brokenithm-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1968E72424086C2200784829 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
1968E72524086C2200784829 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@ -84,6 +86,7 @@
19F40719240CFCFF00D7F506 /* MainApp.m */,
1968E72724086C2200784829 /* ViewController.h */,
1968E72824086C2200784829 /* ViewController.m */,
1961EB732507451600C79BF8 /* Settings.bundle */,
1968E72A24086C2200784829 /* Main.storyboard */,
1968E72D24086C2B00784829 /* Assets.xcassets */,
1968E73224086C2B00784829 /* Info.plist */,
@ -170,6 +173,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1961EB742507451600C79BF8 /* Settings.bundle in Resources */,
1968E72E24086C2B00784829 /* Assets.xcassets in Resources */,
19F40723240FE2B800D7F506 /* zh.lproj in Resources */,
1968E72C24086C2200784829 /* Main.storyboard in Resources */,
@ -349,7 +353,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = K9CP5766XY;
INFOPLIST_FILE = "Brokenithm-iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@ -373,7 +377,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = K9CP5766XY;
INFOPLIST_FILE = "Brokenithm-iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Enable Air Input</string>
<key>Key</key>
<string>enableAir</string>
<key>DefaultValue</key>
<true/>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Auto Pop Menu</string>
<key>Key</key>
<string>autoPopMenu</string>
<key>DefaultValue</key>
<false/>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Invert Air Input Layout</string>
<key>Key</key>
<string>invertAir</string>
<key>DefaultValue</key>
<false/>
</dict>
<dict>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
<key>DefaultValue</key>
<string></string>
<key>Title</key>
<string>Hold duration to open side menu</string>
<key>Key</key>
<string>menuDurationTitle</string>
</dict>
<dict>
<key>Type</key>
<string>PSSliderSpecifier</string>
<key>Key</key>
<string>menuDuration</string>
<key>MinimumValue</key>
<real>0.5</real>
<key>DefaultValue</key>
<real>1</real>
<key>MaximumValue</key>
<real>2</real>
</dict>
</array>
</dict>
</plist>

View File

@ -0,0 +1 @@

View File

@ -96,6 +96,7 @@
[server disconnect];
}
- (void)becomeActive {
[self.parentVc becomeActive];
server.IPv4Enabled = YES;
server.IPv6Enabled = YES;
[self acceptConnection];

View File

@ -29,8 +29,10 @@
UILabel *openCloseBtn;
UISwitch *enableAirToggle;
BOOL airEnabled;
UISwitch *autoPopToggle;
BOOL autoPopMenu;
BOOL invertAir;
NSNumber *menuHoldDuration;
UILongPressGestureRecognizer *openCloseHold;
}
@property UIView *airIOView;
@property UIView *sliderIOView;
@ -40,6 +42,7 @@
-(void)connected;
-(void)disconnected;
-(void)becomeInactive;
-(void)becomeActive;
@end

View File

@ -22,7 +22,12 @@
- (void)viewDidLoad {
[super viewDidLoad];
pendingHideStatus = NO;
[NSUserDefaults.standardUserDefaults registerDefaults:@{@"enableAir":@YES, @"autoPopMenu":@YES}];
[NSUserDefaults.standardUserDefaults registerDefaults:@{
@"enableAir": @YES,
@"autoPopMenu": @YES,
@"invertAir": @NO,
@"menuDuration": @1.0
}];
funcViewOn = YES;
openCloseEventOnce = NO;
@ -40,9 +45,8 @@
CGRect screenSize = [UIScreen mainScreen].bounds;
screenWidth = screenSize.size.width;
screenHeight = screenSize.size.height;
float offsetY = 0, sliderHeight = screenHeight;
self.airIOView = [[UIView alloc] initWithFrame:CGRectMake(0, offsetY, screenWidth, screenHeight*0.4)];
offsetY += screenHeight*0.4;
float sliderHeight = screenHeight;
self.airIOView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight*0.4)];
self.sliderIOView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, sliderHeight)];
self.airIOView.backgroundColor = [UIColor blackColor];
self.airIOView.layer.borderWidth = 1.0f;
@ -83,7 +87,7 @@
openCloseBtn.text = @"◀";
openCloseBtn.font = [UIFont systemFontOfSize:30];
UITapGestureRecognizer *openCloseTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeFunc)];
UILongPressGestureRecognizer *openCloseHold = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(openOrCloseFunc)];
openCloseHold = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(openOrCloseFunc)];
openCloseHold.minimumPressDuration = 1;
[openCloseBtnBorder addGestureRecognizer:openCloseTap];
[openCloseBtnBorder addGestureRecognizer:openCloseHold];
@ -106,7 +110,7 @@
}
UIView *enableAir;
UILabel *enableAirLabel;
enableAir = [[UIView alloc] initWithFrame:CGRectMake(0, 240, 200, 60)];
enableAir = [[UIView alloc] initWithFrame:CGRectMake(0, offset, 200, 60)];
enableAir.backgroundColor = [UIColor blackColor];
enableAir.layer.borderColor = [UIColor whiteColor].CGColor;
enableAir.layer.borderWidth = 1.0;
@ -118,31 +122,20 @@
enableAirLabel.text = [[NSBundle mainBundle] localizedStringForKey:@"Enable Air Input" value:@"" table:nil];
[enableAir addSubview:enableAirLabel];
enableAirToggle = [[UISwitch alloc] initWithFrame:CGRectMake(135, 13, 50, 27)];
BOOL pref = [NSUserDefaults.standardUserDefaults boolForKey:@"enableAir"];
[enableAirToggle setOn:pref animated:NO];
[enableAirToggle addTarget:self action:@selector(enableAirChanged) forControlEvents:UIControlEventValueChanged];
[self updateAirEnabled:pref];
[enableAir addSubview:enableAirToggle];
offset += 60;
UIView *autoPop;
UILabel *autoPopLabel;
autoPop = [[UIView alloc] initWithFrame:CGRectMake(0, 300, 200, 60)];
autoPop.backgroundColor = [UIColor blackColor];
autoPop.layer.borderColor = [UIColor whiteColor].CGColor;
autoPop.layer.borderWidth = 1.0;
[functionBtnView addSubview:autoPop];
autoPopLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 130, 60)];
autoPopLabel.textAlignment = NSTextAlignmentRight;
autoPopLabel.textColor = [UIColor whiteColor];
autoPopLabel.numberOfLines = 1;
autoPopLabel.text = [[NSBundle mainBundle] localizedStringForKey:@"Auto Pop Menu" value:@"" table:nil];
[autoPop addSubview:autoPopLabel];
autoPopToggle = [[UISwitch alloc] initWithFrame:CGRectMake(135, 13, 50, 27)];
pref = [NSUserDefaults.standardUserDefaults boolForKey:@"autoPopMenu"];
[autoPopToggle setOn:pref animated:NO];
[autoPopToggle addTarget:self action:@selector(autoPopChanged) forControlEvents:UIControlEventValueChanged];
autoPopMenu = pref;
[autoPop addSubview:autoPopToggle];
FunctionButton *moreBtn = [[FunctionButton alloc] initAtY:offset];
offset += 60;
moreBtn.name = @"more_setting_button";
moreBtn.text = [[NSBundle mainBundle] localizedStringForKey:@"More..." value:@"" table:nil];
moreBtn.userInteractionEnabled = YES;
UITapGestureRecognizer *moreBtnTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jumpToSetting)];
[moreBtn addGestureRecognizer:moreBtnTap];
[functionBtnView addSubview:moreBtn];
[self loadPrefs];
[enableAirToggle addTarget:self action:@selector(enableAirChanged) forControlEvents:UIControlEventValueChanged];
}
}
@ -193,6 +186,24 @@
NSLog(@"server created");
}
-(void)loadPrefs {
// enable air
BOOL pref = [NSUserDefaults.standardUserDefaults boolForKey:@"enableAir"];
[enableAirToggle setOn:pref animated:NO];
[self updateAirEnabled:pref];
// auto pop
autoPopMenu = [NSUserDefaults.standardUserDefaults boolForKey:@"autoPopMenu"];
// invert air
pref = [NSUserDefaults.standardUserDefaults boolForKey:@"invertAir"];
[self updateAirInverted:pref];
// hold duration
menuHoldDuration = [NSUserDefaults.standardUserDefaults valueForKey:@"menuDuration"];
openCloseHold.minimumPressDuration = [menuHoldDuration floatValue];
}
-(void)updateLed:(NSData*)rgbData {
if (rgbData.length != 32*3) return;
NSMutableArray *colorArr = [NSMutableArray arrayWithCapacity:33];
@ -225,10 +236,14 @@
airEnabled = enable;
}
-(void)autoPopChanged{
BOOL pref = autoPopToggle.on;
[NSUserDefaults.standardUserDefaults setBool:pref forKey:@"autoPopMenu"];
autoPopMenu = pref;
-(void)updateAirInverted:(BOOL)invert {
if (invertAir != invert) {
CGRect screenSize = [UIScreen mainScreen].bounds;
screenWidth = screenSize.size.width;
screenHeight = screenSize.size.height;
self.airIOView.frame = CGRectMake(0, invert ? screenHeight * 0.6 : 0, screenWidth, screenHeight * 0.4);
invertAir = invert;
}
}
-(void)openOrCloseFunc {
@ -262,6 +277,9 @@
[self sendIoBuf:&buf];
}
}
-(void)jumpToSetting {
[UIApplication.sharedApplication openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
-(BOOL)prefersStatusBarHidden { return kCFCoreFoundationVersionNumber < 1443.00; }
-(UIRectEdge)preferredScreenEdgesDeferringSystemGestures { return UIRectEdgeAll; }
@ -317,8 +335,17 @@
}
CGPoint point = [touch locationInView:nil];
float pointX = screenWidth - point.x, pointY = point.y;
if (airEnabled && pointY < airHeight) {
int idx = pointY / airIOHeight;
BOOL inAirRange = airEnabled && (
(invertAir && pointY > screenHeight - airHeight) ||
(!invertAir && pointY < airHeight)
);
if (inAirRange) {
int idx;
if (invertAir) {
idx = (screenHeight - pointY) / airIOHeight;
} else {
idx = pointY / airIOHeight;
}
uint8_t airIdx[] = {4,5,2,3,0,1};
buf.air[airIdx[idx]] = 1;
} else {
@ -380,5 +407,8 @@
struct ioBuf buf = {0};
[self sendIoBuf:&buf];
}
-(void)becomeActive {
[self loadPrefs];
}
@end

View File

@ -4,5 +4,5 @@
"Enable Air Input" = "启用Air输入";
"Insert Coin" = "投币";
"Read Card" = "刷卡";
"Auto Pop Menu" = "自动弹出菜单";
"More..." = "更多设置…";
}