Skip to content

Commit 9f85735

Browse files
committed
Push for support
1 parent 8d0bb87 commit 9f85735

File tree

7 files changed

+100
-41
lines changed

7 files changed

+100
-41
lines changed

Bop.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#import <Foundation/Foundation.h>
22
#import <spawn.h>
3-
#import <MediaRemote.h>
3+
#import "MediaRemote.h"
44

55

6-
@interface Bop: NSObject
7-
-(id)init;
6+
@interface Bop : NSObject{
7+
}
8+
+ (id)sharedInstance;
89
-(void)buttonPressed_LG:(char) button;
910
-(void)respring_LG:(BOOL)safeMode;
11+
-(void)pauseMusic;
12+
-(void)repeatMusic;
13+
-(void)skipTrack;
14+
-(void)f15Music;
15+
-(void)b15Music;
16+
-(void)loadPrefs;
1017
@end

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(THEOS)/makefiles/common.mk
77

88
TWEAK_NAME = Bop
99
Bop_FILES = Tweak.xm
10-
Bop_EXTRA_FRAMEWORKS += Cephei CepheiPrefs
10+
Bop_EXTRA_FRAMEWORKS += Cephei
1111
Bop_PRIVATE_FRAMEWORKS = MediaRemote
1212

1313
include $(THEOS_MAKE_PATH)/tweak.mk

Tweak.xm

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@
44
#define POWER_BUTTON 104
55
#define HOME_BUTTON 101
66

7-
static NSString *respringSequence = @"UDUD";
8-
static NSString *safeModeSequence = @"SSUDUD";
9-
static id sharedInstance;
7+
static NSString *pauseMusicSequence = @"";
8+
static NSString *skipTrackSequence = @"";
9+
static NSString *toggleRepeatSequence = @"";
10+
static NSString *f15Sequence = @"";
11+
static NSString *b15Sequence = @"";
12+
static NSTimer *bopTimer;
13+
14+
15+
static void loadPrefs();
16+
17+
18+
id sharedInstance;
1019
static BOOL tweakEnabled = YES;
1120
static BOOL isRunning = NO;
12-
//static NSString *pauseMusicSequence = @"V";
1321

1422
static void triggerButton(char button) {
1523
if (tweakEnabled && !isRunning) {
@@ -30,7 +38,6 @@ static void triggerButton(char button) {
3038
}
3139
%end
3240

33-
3441
//iOS 13.3 and below
3542
%hook SBFluidSwitcherGestureManager
3643
-(void)grabberTongueBeganPulling:(id)arg1 withDistance:(double)arg2 andVelocity:(double)arg3 {
@@ -42,13 +49,11 @@ static void triggerButton(char button) {
4249

4350

4451
%hook SpringBoard
45-
4652
-(void)_ringerChanged:(struct __IOHIDEvent *)arg1 {
4753
triggerButton('S');
4854
%orig;
4955
}
5056

51-
5257
-(_Bool)_handlePhysicalButtonEvent:(UIPressesEvent *)arg1 {
5358
// type = 101 -> Home button
5459
// type = 104 -> Power button
@@ -92,37 +97,48 @@ static void triggerButton(char button) {
9297

9398

9499
@implementation Bop
95-
96100
NSMutableString *sequence = [@"" mutableCopy];
97101
NSTimeInterval lastPress;
98102

103+
+ (id)sharedInstance{
104+
return sharedInstance;
105+
}
106+
99107
-(id)init {
100108
lastPress = 0.0;
101109
return self;
102110
}
103111

112+
113+
104114
-(void)buttonPressed_LG:(char)button {
105115

106116
NSTimeInterval now = [[NSDate date] timeIntervalSince1970] * 1000;
107-
if (now - lastPress > 650.0)
117+
if (now - lastPress > 650.0){
108118
[sequence setString:@""];
119+
} else {
120+
if(bopTimer)
121+
[bopTimer invalidate];
122+
}
109123
if (now - lastPress < 100.0)
110124
[sequence deleteCharactersInRange:NSMakeRange([sequence length]-1, 1)];
111125
lastPress = now;
112126

113127
[sequence appendFormat:@"%c", button];
114-
NSLog(@"[BOP] Sequence:%@ Added:%c" , sequence, button);
115-
if ([respringSequence length] >= [safeModeSequence length]) {
116-
if ([[sequence copy] containsString: respringSequence])
117-
[self respring_LG:NO];
118-
else if ([[sequence copy] containsString: safeModeSequence])
119-
[self respring_LG:YES];
120-
} else {
121-
if ([[sequence copy] containsString: safeModeSequence])
122-
[self respring_LG:YES];
123-
else if ([[sequence copy] containsString: respringSequence])
124-
[self respring_LG:NO];
125-
}
128+
NSLog(@"[BOP] Sequence:%@ Added:%c", sequence, button);
129+
bopTimer = [NSTimer scheduledTimerWithTimeInterval:2.0
130+
target:self
131+
selector:@selector(interpSeq)
132+
userInfo:nil
133+
repeats:NO];
134+
}
135+
-(void)interpSeq {
136+
137+
if([[sequence copy] isEqualToString: pauseMusicSequence]) {[self pauseMusic];}
138+
if([[sequence copy] isEqualToString: skipTrackSequence]) {[self skipTrack];}
139+
if([[sequence copy] isEqualToString: toggleRepeatSequence]) {[self repeatMusic];}
140+
if([[sequence copy] isEqualToString: f15Sequence]) {[self f15Music];}
141+
if([[sequence copy] isEqualToString: b15Sequence]) {[self b15Music];}
126142
}
127143

128144
-(void)respring_LG:(BOOL)safeMode {
@@ -136,16 +152,36 @@ NSTimeInterval lastPress;
136152
posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL);
137153
}
138154
}
155+
-(void)pauseMusic{
156+
MRMediaRemoteSendCommand(kMRTogglePlayPause, 0);
157+
}
158+
-(void)repeatMusic{
159+
MRMediaRemoteSendCommand(kMRToggleRepeat, 0);
160+
}
161+
-(void)skipTrack{
162+
MRMediaRemoteSendCommand(kMRNextTrack, 0);
163+
}
164+
-(void)f15Music{
165+
MRMediaRemoteSendCommand(kMRSkipFifteenSeconds, 0);
166+
}
167+
-(void)b15Music{
168+
MRMediaRemoteSendCommand(kMRGoBackFifteenSeconds, 0);
169+
}
170+
-(void)loadPrefs{
171+
loadPrefs();
172+
}
173+
139174

140175
@end
141176

142177

143178

144-
//static void loadPrefs() {
145-
// NSDictionary *prefs = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.squidkingdom.boppreferences.defaults"];
146-
// pauseMusicSequence = [[prefs objectForKey:@"pauseMusicSequence"] uppercaseString];
147-
//}
179+
static void loadPrefs() {
180+
NSDictionary *prefs = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.squidkingdom.boppreferences.defaults"];
181+
pauseMusicSequence = [[prefs objectForKey:@"pauseMusicSequence"] uppercaseString];
182+
skipTrackSequence = [[prefs objectForKey:@"skipTrackSequence"] uppercaseString];
183+
}
148184

149185
%ctor {
150-
//loadPrefs();
186+
loadPrefs();
151187
}

boppreferences/BOPRootListController.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,14 @@
135135
@interface BOPRootListController : HBRootListController
136136
@end
137137

138+
@interface Bop : NSObject
139+
140+
-(void)loadPrefs;
141+
+(id)sharedInstance;
142+
@end
143+
138144
@interface LifeguardBigTextCell : PSTableCell{
139145
UILabel* _label;
140146
}
141147
-(UIColor*) coverUp;
142-
143-
144-
145148
@end

boppreferences/BOPRootListController.m

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ - (void) viewDidLoad {
1010
self.navigationController.navigationBar.prefersLargeTitles = false;
1111
self.navigationController.navigationItem.largeTitleDisplayMode =
1212
UINavigationItemLargeTitleDisplayModeNever;
13+
[[self navigationItem] setRightBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"Apply"
14+
style:UIBarButtonItemStylePlain
15+
target:self
16+
action:@selector(respring)]];
1317
}
1418
}
1519

@@ -20,6 +24,11 @@ - (void) viewDidAppear:(BOOL)animated {
2024
self.navigationController.navigationBar.prefersLargeTitles = false;
2125
self.navigationController.navigationItem.largeTitleDisplayMode =
2226
UINavigationItemLargeTitleDisplayModeNever;
27+
28+
[[self navigationItem] setRightBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"Apply"
29+
style:UIBarButtonItemStylePlain
30+
target:self
31+
action:@selector(respring)]];
2332
}
2433
}
2534

@@ -44,8 +53,8 @@ - (instancetype) init {
4453
appearanceSettings.navigationBarTintColor = [UIColor blackColor];
4554

4655
}
47-
appearanceSettings.navigationBarTitleColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
48-
appearanceSettings.statusBarTintColor = [UIColor blackColor];
56+
appearanceSettings.navigationBarTitleColor = [UIColor clearColor];
57+
appearanceSettings.statusBarTintColor = [UIColor clearColor];
4958
appearanceSettings.tintColor = [UIColor colorWithRed:0.373 green:0.753 blue:0.914 alpha:1];
5059
appearanceSettings.navigationBarBackgroundColor = [UIColor colorWithRed:0.37 green:0.89 blue:0.87 alpha:1];
5160
self.hb_appearanceSettings = appearanceSettings;
@@ -63,11 +72,13 @@ - (NSArray *) specifiers {
6372
return _specifiers;
6473
}
6574
- (void) respring {
66-
pid_t pid;
67-
const char* args[] = {"killall", "-9", "SpringBoard", NULL};
68-
[HBRespringController respringAndReturnTo:[NSURL URLWithString:@"prefs:root=Bop"]];
6975

70-
posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL);
76+
[[Bop sharedInstance] loadPrefs];
77+
// pid_t pid;
78+
// const char* args[] = {"killall", "-9", "SpringBoard", NULL};
79+
// [HBRespringController respringAndReturnTo:[NSURL URLWithString:@"prefs:root=Bop"]];
80+
//
81+
// posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL);
7182

7283
}
7384

boppreferences/Resources/Root.plist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@
119119
<string>HBPackageNameHeaderCell</string>
120120
<key>packageIdentifier</key>
121121
<string>com.squidkingdom.bop</string>
122+
<key>showVersion</key>
123+
<false/>
122124
<key>backgroundGradientColors</key>
123125
<array>
124126
<string>#5FE4DD</string>
@@ -171,7 +173,7 @@
171173
<key>label</key>
172174
<string>Toggle Repeat:</string>
173175
<key>key</key>
174-
<string>pauseMusicSequence</string>
176+
<string>toggleRepeatSequence</string>
175177
<key>noAutoCorrect</key>
176178
<true/>
177179
<key>defaults</key>

control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Depends: mobilesubstrate, ws.hbang.common (>= 1.11)
44
Version: 1.2
55
Architecture: iphoneos-arm
66
Description: Control music on your device using the hardware buttons.
7-
Author: Brady <oskiekid@gmail.com>
7+
Author: Brady Holland <oskiekid@gmail.com>
88
Section: Tweaks

0 commit comments

Comments
 (0)