- auto save favorite settings with order
- auto setup morebutton menu in 2 settings mode
This commit is contained in:
1 parent
b036e01afc
commit
3120cd785b
5 files changed
+79
-28
No files matched your search
@@ -28,6 +28,11 @@ typedef NS_ENUM(NSInteger, TouchEventPriorityEnum) {
|
|||||||
TouchMovePriority// deprecated by GUI
|
TouchMovePriority// deprecated by GUI
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, SettingsMenuMode) {
|
||||||
|
AllSettings,
|
||||||
|
FavoriteSettings,
|
||||||
|
};
|
||||||
|
|
||||||
- (void) saveSettingsWithBitrate:(NSInteger)bitrate
|
- (void) saveSettingsWithBitrate:(NSInteger)bitrate
|
||||||
framerate:(NSInteger)framerate
|
framerate:(NSInteger)framerate
|
||||||
height:(NSInteger)height
|
height:(NSInteger)height
|
||||||
|
|||||||
@@ -137,6 +137,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#import "DataManager.h"
|
||||||
|
|
||||||
|
|
||||||
@class SWRevealViewController;
|
@class SWRevealViewController;
|
||||||
@protocol SWRevealViewControllerDelegate;
|
@protocol SWRevealViewControllerDelegate;
|
||||||
@@ -349,6 +351,7 @@ typedef enum
|
|||||||
@optional
|
@optional
|
||||||
- (void)switchToFavoriteSettings;
|
- (void)switchToFavoriteSettings;
|
||||||
- (void)switchToAllSettings;
|
- (void)switchToAllSettings;
|
||||||
|
- (SettingsMenuMode)getSettingsMenuMode;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#import "SWRevealViewController.h"
|
#import "SWRevealViewController.h"
|
||||||
#import "LocalizationHelper.h"
|
#import "LocalizationHelper.h"
|
||||||
#import "DataManager.h"
|
|
||||||
#import "ThemeManager.h"
|
#import "ThemeManager.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -644,6 +643,7 @@ static CGFloat scaledValue( CGFloat v1, CGFloat min2, CGFloat max2, CGFloat min1
|
|||||||
NSMutableArray *_animationQueue;
|
NSMutableArray *_animationQueue;
|
||||||
BOOL _userInteractionStore;
|
BOOL _userInteractionStore;
|
||||||
UIViewController *_primaryViewController;
|
UIViewController *_primaryViewController;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FrontViewPositionNone = 0xff;
|
const int FrontViewPositionNone = 0xff;
|
||||||
@@ -862,6 +862,7 @@ const int FrontViewPositionNone = 0xff;
|
|||||||
|
|
||||||
- (void)willMoveToPosition{
|
- (void)willMoveToPosition{
|
||||||
_separatorLine.hidden = _frontViewPosition == FrontViewPositionLeft;
|
_separatorLine.hidden = _frontViewPosition == FrontViewPositionLeft;
|
||||||
|
if(_frontViewPosition != FrontViewPositionLeft) [self setupMoreButtonMenu];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -985,7 +986,7 @@ const int FrontViewPositionNone = 0xff;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setupMoreButton{
|
- (void)setupMoreButton{
|
||||||
_moreButton = [[UIBarButtonItem alloc] init];
|
if(!_moreButton) _moreButton = [[UIBarButtonItem alloc] init];
|
||||||
|
|
||||||
//[moreButton setAction:@selector(moreButtonTapped:)];
|
//[moreButton setAction:@selector(moreButtonTapped:)];
|
||||||
if (@available(iOS 13.0, *)) {
|
if (@available(iOS 13.0, *)) {
|
||||||
@@ -997,39 +998,60 @@ const int FrontViewPositionNone = 0xff;
|
|||||||
} else {
|
} else {
|
||||||
[_moreButton setTitle:[LocalizationHelper localizedStringForKey:@"More"]];
|
[_moreButton setTitle:[LocalizationHelper localizedStringForKey:@"More"]];
|
||||||
}
|
}
|
||||||
|
// more option button
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UIAction* )getFavoriteMenuAction API_AVAILABLE(ios(13.0)){
|
||||||
|
return [UIAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Favorite Settings"] image:[UIImage systemImageNamed:@"bookmark"] identifier:nil handler:^(__kindof UIAction * _Nonnull action) {
|
||||||
|
[self favoriteSettingSelected];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
- (UIAction* )getAllSettingMenuAction API_AVAILABLE(ios(13.0)){
|
||||||
|
return [UIAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"All Settings"] image:[UIImage systemImageNamed:@"circle.grid.3x3"] identifier:nil handler:^(__kindof UIAction * _Nonnull action) {
|
||||||
|
[self allSettingSelected];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setupMoreButtonMenu{
|
||||||
if (@available(iOS 14.0, *)) {
|
if (@available(iOS 14.0, *)) {
|
||||||
UIAction *favoriteSettingAction = [UIAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Favorite Settings"] image:[UIImage systemImageNamed:@"bookmark"] identifier:nil handler:^(__kindof UIAction * _Nonnull action) {
|
UIMenu *menu;
|
||||||
[self favoriteSettingSelected];
|
|
||||||
}];
|
|
||||||
|
|
||||||
UIAction *allSettingAction = [UIAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"All Settings"] image:[UIImage systemImageNamed:@"circle.grid.3x3"] identifier:nil handler:^(__kindof UIAction * _Nonnull action) {
|
|
||||||
[self allSettingSelected];
|
|
||||||
}];
|
|
||||||
|
|
||||||
// 创建菜单
|
// 创建菜单
|
||||||
UIMenu *menu = [UIMenu menuWithTitle:@"" children:@[favoriteSettingAction, allSettingAction]];
|
switch ([self getSettingsMenuMode]) {
|
||||||
|
case AllSettings:
|
||||||
|
menu = [UIMenu menuWithTitle:@"" children:@[[self getFavoriteMenuAction]]];
|
||||||
|
break;
|
||||||
|
case FavoriteSettings:
|
||||||
|
menu = [UIMenu menuWithTitle:@"" children:@[[self getAllSettingMenuAction]]];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
_moreButton.menu = menu;
|
_moreButton.menu = menu;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
[_moreButton setTarget:self];
|
[_moreButton setTarget:self];
|
||||||
[_moreButton setAction:@selector(moreButtonTapped:)];
|
[_moreButton setAction:@selector(moreButtonTapped:)];
|
||||||
}
|
}
|
||||||
// more option button
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moreButtonTapped:(UIBarButtonItem *)sender {
|
- (void)moreButtonTapped:(UIBarButtonItem *)sender {
|
||||||
UIMenuItem *item1 = [[UIMenuItem alloc] initWithTitle:@"操作1" action:@selector(favoriteSettingSelected)];
|
if (@available(iOS 14.0, *)) {
|
||||||
UIMenuItem *item2 = [[UIMenuItem alloc] initWithTitle:@"操作2" action:@selector(allSettingsSelected)];
|
|
||||||
|
|
||||||
UIMenuController *menuController = [UIMenuController sharedMenuController];
|
} else {
|
||||||
[menuController setMenuItems:@[item1, item2]];
|
UIMenuItem *item1 = [[UIMenuItem alloc] initWithTitle:@"操作1" action:@selector(favoriteSettingSelected)];
|
||||||
|
UIMenuItem *item2 = [[UIMenuItem alloc] initWithTitle:@"操作2" action:@selector(allSettingsSelected)];
|
||||||
UIView *targetView = [sender valueForKey:@"view"];
|
|
||||||
[menuController setTargetRect:targetView.bounds inView:targetView];
|
UIMenuController *menuController = [UIMenuController sharedMenuController];
|
||||||
[menuController setMenuVisible:YES animated:YES];
|
[menuController setMenuItems:@[item1, item2]];
|
||||||
|
|
||||||
[self becomeFirstResponder];
|
UIView *targetView = [sender valueForKey:@"view"];
|
||||||
|
[menuController setTargetRect:targetView.bounds inView:targetView];
|
||||||
|
[menuController setMenuVisible:YES animated:YES];
|
||||||
|
|
||||||
|
[self becomeFirstResponder];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)canBecomeFirstResponder {
|
- (BOOL)canBecomeFirstResponder {
|
||||||
@@ -1043,13 +1065,28 @@ const int FrontViewPositionNone = 0xff;
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (SettingsMenuMode)getSettingsMenuMode {
|
||||||
|
if ([self.navBarMenuDelegate respondsToSelector:@selector(getSettingsMenuMode)]) {
|
||||||
|
return [self.navBarMenuDelegate getSettingsMenuMode];
|
||||||
|
|
||||||
|
} else return AllSettings;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)favoriteSettingSelected {
|
- (void)favoriteSettingSelected {
|
||||||
|
if (@available(iOS 13.0, *)) {
|
||||||
|
UIAction* allSettings = [self getAllSettingMenuAction];
|
||||||
|
if (@available(iOS 14.0, *)) _moreButton.menu = [UIMenu menuWithTitle:@"" children:@[allSettings]];
|
||||||
|
}
|
||||||
if ([self.navBarMenuDelegate respondsToSelector:@selector(switchToFavoriteSettings)]) {
|
if ([self.navBarMenuDelegate respondsToSelector:@selector(switchToFavoriteSettings)]) {
|
||||||
[self.navBarMenuDelegate switchToFavoriteSettings];
|
[self.navBarMenuDelegate switchToFavoriteSettings];
|
||||||
} else NSLog(@"Delegate not set or does not respond to switchToFavoriteSettings:");
|
} else NSLog(@"Delegate not set or does not respond to switchToFavoriteSettings:");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)allSettingSelected {
|
- (void)allSettingSelected {
|
||||||
|
if (@available(iOS 13.0, *)) {
|
||||||
|
UIAction* favoriteSettings = [self getFavoriteMenuAction];
|
||||||
|
if (@available(iOS 14.0, *)) _moreButton.menu = [UIMenu menuWithTitle:@"" children:@[favoriteSettings]];
|
||||||
|
}
|
||||||
if ([self.navBarMenuDelegate respondsToSelector:@selector(switchToAllSettings)]) {
|
if ([self.navBarMenuDelegate respondsToSelector:@selector(switchToAllSettings)]) {
|
||||||
[self.navBarMenuDelegate switchToAllSettings];
|
[self.navBarMenuDelegate switchToAllSettings];
|
||||||
} else NSLog(@"Delegate not set or does not respond to switchToAllSettings:");
|
} else NSLog(@"Delegate not set or does not respond to switchToAllSettings:");
|
||||||
|
|||||||
@@ -104,11 +104,6 @@
|
|||||||
|
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
typedef NS_ENUM(NSInteger, SettingsMenuMode) {
|
|
||||||
AllSettings,
|
|
||||||
FavoriteSettings,
|
|
||||||
};
|
|
||||||
|
|
||||||
- (void)saveSettings;
|
- (void)saveSettings;
|
||||||
+ (bool)isLandscapeNow;
|
+ (bool)isLandscapeNow;
|
||||||
- (void)updateResolutionTable;
|
- (void)updateResolutionTable;
|
||||||
|
|||||||
@@ -364,6 +364,10 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
exitButton.frame = CGRectMake(0, 20, 200, 50); // Adjust Y and height as needed
|
exitButton.frame = CGRectMake(0, 20, 200, 50); // Adjust Y and height as needed
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
- (SettingsMenuMode)getSettingsMenuMode{
|
||||||
|
return currentSettingsMenuMode;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)edgeSwiped {
|
- (void)edgeSwiped {
|
||||||
[self simulateSettingsButtonPress];
|
[self simulateSettingsButtonPress];
|
||||||
}
|
}
|
||||||
@@ -747,6 +751,7 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
// [parentStack addSubview:capturedStack];
|
// [parentStack addSubview:capturedStack];
|
||||||
originalIndex = newIndex;
|
originalIndex = newIndex;
|
||||||
capturedStack.hidden = NO;
|
capturedStack.hidden = NO;
|
||||||
|
[self saveFavoriteSettingStackIdentifiers];
|
||||||
}
|
}
|
||||||
// 移除快照视图,显示原始视图
|
// 移除快照视图,显示原始视图
|
||||||
break;
|
break;
|
||||||
@@ -804,6 +809,13 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
|
|
||||||
|
|
||||||
- (void)saveFavoriteSettingStackIdentifiers {
|
- (void)saveFavoriteSettingStackIdentifiers {
|
||||||
|
|
||||||
|
[_favoriteSettingStackIdentifiers removeAllObjects];
|
||||||
|
|
||||||
|
for(NSInteger i = 0; i < parentStack.arrangedSubviews.count; i++){
|
||||||
|
[_favoriteSettingStackIdentifiers addObject:parentStack.arrangedSubviews[i].accessibilityIdentifier];
|
||||||
|
}
|
||||||
|
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:_favoriteSettingStackIdentifiers forKey:@"FavoriteSettingStackIdentifiers"];
|
[[NSUserDefaults standardUserDefaults] setObject:_favoriteSettingStackIdentifiers forKey:@"FavoriteSettingStackIdentifiers"];
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
}
|
}
|
||||||
@@ -1734,7 +1746,6 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
externalDisplayMode:externalDisplayMode
|
externalDisplayMode:externalDisplayMode
|
||||||
localMousePointerMode:localMousePointerMode
|
localMousePointerMode:localMousePointerMode
|
||||||
settinsMenuMode:currentSettingsMenuMode];
|
settinsMenuMode:currentSettingsMenuMode];
|
||||||
[self saveFavoriteSettingStackIdentifiers];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning {
|
- (void)didReceiveMemoryWarning {
|
||||||
|
|||||||
Reference in new issue
Block a user