Skip to content

Commit

Permalink
Merge branch 'roothide:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
hoaug-tran authored Jan 9, 2024
2 parents 54212c3 + 7e66445 commit 1760fcc
Show file tree
Hide file tree
Showing 23 changed files with 445 additions and 94 deletions.
4 changes: 2 additions & 2 deletions Bootstrap.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.4.2;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -470,7 +470,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.4.2;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions Bootstrap/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@interface AppDelegate : UIResponder <UIApplicationDelegate>

+(void)showHudMsg:(NSString*)msg;
+(void)showHudMsg:(NSString*)msg detail:(NSString*)info;
+(void)dismissHud;

+ (void)showAlert:(UIAlertController*)alert;
Expand Down
10 changes: 10 additions & 0 deletions Bootstrap/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ +(void)showHudMsg:(NSString*)msg
});
}

+(void)showHudMsg:(NSString*)msg detail:(NSString*)info
{
dispatch_async(dispatch_get_main_queue(), ^{
switchHud = [MBProgressHUD showHUDAddedTo:UIApplication.sharedApplication.keyWindow animated:YES];
[switchHud showAnimated:YES];
switchHud.label.text = msg;
switchHud.detailsLabel.text = info;
});
}

+(void)dismissHud {
dispatch_async(dispatch_get_main_queue(), ^{
[switchHud hideAnimated:YES];
Expand Down
121 changes: 102 additions & 19 deletions Bootstrap/AppViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@interface PrivateApi_LSApplicationWorkspace
- (NSArray*)allInstalledApplications;
- (bool)openApplicationWithBundleID:(id)arg1;
- (BOOL)openApplicationWithBundleID:(id)arg1;
- (NSArray*)privateURLSchemes;
- (NSArray*)publicURLSchemes;
- (BOOL)_LSPrivateRebuildApplicationDatabasesForSystemApps:(BOOL)arg1
Expand Down Expand Up @@ -93,21 +93,29 @@ - (void)viewDidLoad {
[refreshControl addTarget:self action:@selector(startRefresh) forControlEvents:UIControlEventValueChanged];
self.tableView.refreshControl = refreshControl;

[self updateData];
[self updateData:YES];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(startRefresh)
selector:@selector(startRefresh2)
name:UIApplicationWillEnterForegroundNotification
object:nil];
}

- (void)startRefresh {
[self.tableView.refreshControl beginRefreshing];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self updateData];
[self updateData:YES];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView.refreshControl endRefreshing];
});
});
}

- (void)startRefresh2 {
[self.tableView.refreshControl beginRefreshing];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self updateData:NO];
dispatch_async(dispatch_get_main_queue(), ^{
[self reloadSearch];
[self.tableView reloadData];
[self.tableView.refreshControl endRefreshing];
});
});
Expand All @@ -119,7 +127,7 @@ - (void)viewWillAppear:(BOOL)animated {
[self.tableView.refreshControl endRefreshing];
}

- (void)updateData {
- (void)updateData:(BOOL)sort {
NSMutableArray* applications = [NSMutableArray new];
PrivateApi_LSApplicationWorkspace* _workspace = [NSClassFromString(@"LSApplicationWorkspace") new];
NSArray* allInstalledApplications = [_workspace allInstalledApplications];
Expand Down Expand Up @@ -152,15 +160,67 @@ - (void)updateData {

if([app.bundleURL.path.lastPathComponent isEqualToString:@"Bootstrap.app"])
continue;

if([app.bundleIdentifier isEqualToString:NSBundle.mainBundle.bundleIdentifier]
|| [app.bundleIdentifier isEqualToString:@"com.roothide.Bootstrap"])
continue;

[applications addObject:app];
}

NSArray *appsSortedByName = [applications sortedArrayUsingComparator:^NSComparisonResult(AppList *app1, AppList *app2) {
return [app1.name localizedStandardCompare:app2.name];
}];
if(sort)
{
NSArray *appsSortedByName = [applications sortedArrayUsingComparator:^NSComparisonResult(AppList *app1, AppList *app2) {
struct stat st;
BOOL enabled1 = lstat([app1.bundleURL.path stringByAppendingPathComponent:@".jbroot"].fileSystemRepresentation, &st)==0;
BOOL enabled2 = lstat([app2.bundleURL.path stringByAppendingPathComponent:@".jbroot"].fileSystemRepresentation, &st)==0;
if(enabled1 || enabled2) {
return [@(enabled2) compare:@(enabled1)];
}

if(app1.isHiddenApp || app2.isHiddenApp) {
return [@(app1.isHiddenApp) compare:@(app2.isHiddenApp)];
}

return [app1.name localizedStandardCompare:app2.name];
}];

self->appsArray = appsSortedByName;
}
else
{
NSMutableArray *newapps = [NSMutableArray array];
[applications enumerateObjectsUsingBlock:^(AppList *newobj, NSUInteger idx, BOOL * _Nonnull stop) {
__block BOOL hasBeenContained = NO;
[self->appsArray enumerateObjectsUsingBlock:^(AppList *obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj.bundleIdentifier isEqualToString:newobj.bundleIdentifier]) {
hasBeenContained = YES;
*stop = YES;
}
}];
if (!hasBeenContained) {
[newapps addObject:newobj];
}
}];

NSMutableArray *tmpArray = [NSMutableArray array];
[self->appsArray enumerateObjectsUsingBlock:^(AppList *obj, NSUInteger idx, BOOL * _Nonnull stop) {
[applications enumerateObjectsUsingBlock:^(AppList *newobj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj.bundleIdentifier isEqualToString:newobj.bundleIdentifier]) {
[tmpArray addObject:newobj];
*stop = YES;
}
}];
}];

[tmpArray addObjectsFromArray:newapps];
self->appsArray = tmpArray.copy;
}

self->appsArray = appsSortedByName;
dispatch_async(dispatch_get_main_queue(), ^{
[self reloadSearch];
[self.tableView reloadData];
});
}

#pragma mark - Table view data source
Expand Down Expand Up @@ -206,10 +266,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

AppList* app = isFiltered? filteredApps[indexPath.row] : appsArray[indexPath.row];

UIImage *image = app.icon;
cell.imageView.image = [self imageWithImage:image scaledToSize:CGSizeMake(40, 40)];
if(!app.isHiddenApp) {
UIImage *image = app.icon;
cell.imageView.image = [self imageWithImage:image scaledToSize:CGSizeMake(40, 40)];
cell.textLabel.text = app.name;
} else {
cell.textLabel.text = app.bundleIdentifier;
}

cell.textLabel.text = app.name;
cell.detailTextLabel.text = app.bundleIdentifier;

UISwitch *theSwitch = [[UISwitch alloc] init];
Expand All @@ -223,6 +287,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[theSwitch addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];

cell.accessoryView = theSwitch;

UILongPressGestureRecognizer *gest = [[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(cellLongPress:)];
[cell.contentView addGestureRecognizer:gest];
gest.view.tag = indexPath.row | indexPath.section<<32;
gest.minimumPressDuration = 1;

return cell;
}

Expand Down Expand Up @@ -255,14 +326,26 @@ - (void)switchChanged:(id)sender {
killAllForApp(app.bundleURL.path.UTF8String);

//refresh app cache list
[self updateData];
dispatch_async(dispatch_get_main_queue(), ^{
[self reloadSearch];
[self.tableView reloadData];
});
[self updateData:NO];

[AppDelegate dismissHud];

});
}

- (void)cellLongPress:(UIGestureRecognizer *)recognizer
{
if (recognizer.state == UIGestureRecognizerStateBegan)
{
long tag = recognizer.view.tag;
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:tag&0xFFFFFFFF inSection:tag>>32];

AppList* app = isFiltered? filteredApps[indexPath.row] : appsArray[indexPath.row];

dispatch_async(dispatch_get_global_queue(0, 0), ^{
PrivateApi_LSApplicationWorkspace* _workspace = [NSClassFromString(@"LSApplicationWorkspace") new];
[_workspace openApplicationWithBundleID:app.bundleIdentifier];
});
}
}
@end
37 changes: 28 additions & 9 deletions Bootstrap/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</connections>
</button>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="bPU-Gp-wbI">
<rect key="frame" x="179.5" y="482" width="51" height="31"/>
<rect key="frame" x="179.5" y="504" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="tintColor" name="AccentColor"/>
<color key="onTintColor" name="AccentColor"/>
Expand All @@ -38,36 +38,36 @@
</connections>
</switch>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="L3N-5g-U7l">
<rect key="frame" x="18" y="428" width="137" height="34"/>
<rect key="frame" x="18" y="408" width="137" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonConfiguration key="configuration" style="tinted" image="arrow.clockwise" catalog="system" title="Respring"/>
<connections>
<action selector="respring:" destination="BYZ-38-t0r" eventType="touchUpInside" id="lbu-go-Y79"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="OpenSSH" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZIf-Su-8xG">
<rect key="frame" x="88.5" y="486" width="83" height="23"/>
<rect key="frame" x="88.5" y="508" width="83" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" fixedFrame="YES" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="Bootstrap(beta 3.1)" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="mHC-UO-Fsn">
<rect key="frame" x="20" y="34" width="300" height="51"/>
<textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" fixedFrame="YES" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="Bootstrap(beta 4.2)" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="mHC-UO-Fsn">
<rect key="frame" x="14" y="34" width="300" height="51"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="42"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a00-Is-meU">
<rect key="frame" x="76" y="314" width="177" height="45"/>
<rect key="frame" x="76" y="310" width="177" height="45"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonConfiguration key="configuration" style="filled" image="terminal" catalog="system" title="Bootstrapped"/>
<connections>
<action selector="bootstrap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="4t4-gT-m0w"/>
</connections>
</button>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="vAH-eh-yux">
<rect key="frame" x="3" y="93" width="307" height="215"/>
<rect key="frame" x="3" y="93" width="312" height="215"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="secondarySystemBackgroundColor"/>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
Expand All @@ -82,21 +82,37 @@
</userDefinedRuntimeAttributes>
</textView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EZ0-Bd-3hy">
<rect key="frame" x="89" y="371" width="152" height="34"/>
<rect key="frame" x="89" y="360" width="152" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonConfiguration key="configuration" style="tinted" image="checkmark.seal" catalog="system" title="AppEnabler"/>
<connections>
<action selector="appenabler:" destination="BYZ-38-t0r" eventType="touchUpInside" id="xRE-YA-IhT"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qyj-sw-Fdy">
<rect key="frame" x="163" y="427" width="152" height="35"/>
<rect key="frame" x="163" y="408" width="152" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonConfiguration key="configuration" style="tinted" image="arrow.clockwise" catalog="system" title="RebuildApps"/>
<connections>
<action selector="rebuildapps:" destination="BYZ-38-t0r" eventType="touchUpInside" id="eln-8N-ArQ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fMY-Su-mQL">
<rect key="frame" x="16" y="450" width="139" height="45"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonConfiguration key="configuration" style="tinted" image="arrow.clockwise" catalog="system" title="Reinstall Sileo+Zebra"/>
<connections>
<action selector="reinstallPackageManager:" destination="BYZ-38-t0r" eventType="touchUpInside" id="egA-SC-xt5"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ocj-vU-eoB">
<rect key="frame" x="163" y="450" width="152" height="45"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonConfiguration key="configuration" style="tinted" image="arrow.clockwise" catalog="system" title="Rebuild Icon Cache"/>
<connections>
<action selector="rebuildIconCache:" destination="BYZ-38-t0r" eventType="touchUpInside" id="WQs-ju-vYv"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
Expand All @@ -105,8 +121,11 @@
<outlet property="appEnablerBtn" destination="EZ0-Bd-3hy" id="k9y-cw-Yfn"/>
<outlet property="bootstraBtn" destination="a00-Is-meU" id="chJ-cA-4pr"/>
<outlet property="logView" destination="vAH-eh-yux" id="XVQ-B0-Whq"/>
<outlet property="opensshLabel" destination="ZIf-Su-8xG" id="kqm-4V-SI1"/>
<outlet property="opensshState" destination="bPU-Gp-wbI" id="AD0-vT-lfL"/>
<outlet property="rebuildIconCacheBtn" destination="Ocj-vU-eoB" id="pUg-zo-HAd"/>
<outlet property="rebuildappsBtn" destination="Qyj-sw-Fdy" id="3LT-9H-8bm"/>
<outlet property="reinstallPackageManagerBtn" destination="fMY-Su-mQL" id="E3R-GV-oLX"/>
<outlet property="respringBtn" destination="L3N-5g-U7l" id="lIx-4D-zVr"/>
<outlet property="unbootstrapBtn" destination="LQX-IC-Eof" id="isZ-rT-6Gz"/>
<outlet property="uninstallBtn" destination="LQX-IC-Eof" id="u0Z-hU-k5W"/>
Expand Down
Loading

0 comments on commit 1760fcc

Please sign in to comment.