mirror of
https://github.com/lint/PhotoCtrl
synced 2025-07-07 12:46:47 +00:00
Add files
This commit is contained in:
13
Makefile
Normal file
13
Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
ARCHS = arm64 arm64e
|
||||
|
||||
include $(THEOS)/makefiles/common.mk
|
||||
|
||||
TWEAK_NAME = PhotoCtrl
|
||||
PhotoCtrl_FILES = Tweak.xm
|
||||
#PhotoCtrl_CFLAGS = -fobjc-arc
|
||||
PhotoCtrl_FRAMEWORKS = UIKit
|
||||
|
||||
include $(THEOS_MAKE_PATH)/tweak.mk
|
||||
|
||||
after-install::
|
||||
install.exec "killall -9 MobileSlideShow"
|
7
PhotoCtrl.plist
Normal file
7
PhotoCtrl.plist
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
Filter = {
|
||||
Bundles = (
|
||||
"com.apple.mobileslideshow"
|
||||
);
|
||||
};
|
||||
}
|
274
Tweak.xm
Normal file
274
Tweak.xm
Normal file
@ -0,0 +1,274 @@
|
||||
|
||||
@interface PUCollectionView : UICollectionView
|
||||
@property(assign,nonatomic) id delegate;
|
||||
@property(assign,nonatomic) NSArray* visibleCells;
|
||||
@property(assign,nonatomic) NSArray* indexPathsForVisibleItems;
|
||||
-(id) idexPathForItemAtPoint:(id) arg1;
|
||||
-(id) cellForItemAtIndexPath:(id) arg1;
|
||||
-(id) indexPathForCell:(id) arg1;
|
||||
-(void) _updateVisibleCellsNow:(BOOL) arg1;
|
||||
|
||||
@end
|
||||
|
||||
@interface PUPhotosGridViewController
|
||||
@property(assign,nonatomic)id assetCollection;
|
||||
@property(assign,nonatomic)id assetCollectionAssets;
|
||||
@property(assign, nonatomic)id dataSource;
|
||||
@property(assign, nonatomic) id collectionView;
|
||||
@property(assign, nonatomic) UINavigationItem *navigationItem;
|
||||
-(void) handleToggleSelectionOfItemAtIndexPath:(NSIndexPath*) arg1;
|
||||
-(void) setSelected:(BOOL) arg1 itemsAtIndexes:(id) arg2 inSection:(long long) arg3 animated:(BOOL) arg4;
|
||||
-(BOOL) isEditing;
|
||||
-(NSInteger) collectionView:(id) arg1 numberOfItemsInSection:(NSInteger) arg2;
|
||||
|
||||
//custom elememnts
|
||||
@property(assign,nonatomic) BOOL ctrlEnabled;
|
||||
@property(assign,nonatomic) NSIndexPath* ctrlFirstIndexPath;
|
||||
@property(assign,nonatomic) UIBarButtonItem* ctrlButton;
|
||||
@property(assign,nonatomic) UITapGestureRecognizer* ctrlTapRecognizer;
|
||||
@property(assign,nonatomic) UIImageView* ctrlSelectOverlayView;
|
||||
|
||||
-(void)updateCtrlButton;
|
||||
|
||||
@end
|
||||
|
||||
@interface PUPhotosGridCell : UIView
|
||||
@property(assign, nonatomic) id photoContentView;
|
||||
-(void) prepareForReuse;
|
||||
|
||||
//custom elements
|
||||
@property(retain, nonatomic) UIImageView *ctrlSelectOverlayView;
|
||||
-(void) removeSelectOverlayViewImage;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
%group Tweak
|
||||
|
||||
%hook PUPhotosGridViewController
|
||||
%property(assign,nonatomic) BOOL ctrlEnabled;
|
||||
%property(assign,nonatomic) NSIndexPath* ctrlFirstIndexPath;
|
||||
%property(assign, nonatomic) UIBarButtonItem* ctrlButton;
|
||||
%property(assign, nonatomic) UITapGestureRecognizer* ctrlTapRecognizer;
|
||||
%property(assign,nonatomic) UIImageView* ctrlSelectOverlayView;
|
||||
|
||||
%new
|
||||
-(void) updateCtrlButton{
|
||||
if ([self ctrlEnabled]){
|
||||
[[self ctrlButton] setTintColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.5]];
|
||||
[self ctrlTapRecognizer].cancelsTouchesInView = YES;
|
||||
} else {
|
||||
[[self ctrlButton] setTintColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0]];
|
||||
[self ctrlTapRecognizer].cancelsTouchesInView = NO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%new
|
||||
-(void) ctrlButtonPressed{
|
||||
|
||||
if (![self ctrlEnabled]){
|
||||
[self setCtrlEnabled:YES];
|
||||
} else {
|
||||
[self setCtrlEnabled:NO];
|
||||
}
|
||||
|
||||
|
||||
[self updateCtrlButton];
|
||||
[self setCtrlFirstIndexPath:nil];
|
||||
}
|
||||
|
||||
|
||||
-(void) updateNavigationBarAnimated:(BOOL) arg1{
|
||||
%orig;
|
||||
|
||||
UINavigationItem* navItem = [self navigationItem];
|
||||
|
||||
if ([self isEditing]){
|
||||
UIBarButtonItem* ctrlButton = [self ctrlButton];
|
||||
[navItem setLeftBarButtonItem:ctrlButton];
|
||||
} else {
|
||||
[navItem setLeftBarButtonItem:nil];
|
||||
[self setCtrlEnabled:NO];
|
||||
}
|
||||
|
||||
[self updateCtrlButton];
|
||||
}
|
||||
|
||||
|
||||
-(void) viewDidLoad{
|
||||
%orig;
|
||||
|
||||
[self setCtrlEnabled:NO];
|
||||
[self setCtrlFirstIndexPath:nil];
|
||||
|
||||
id collectionView = [self collectionView];
|
||||
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:collectionView action:@selector(ctrlScreenTapRecognized:)];
|
||||
tap.numberOfTapsRequired = 1;
|
||||
tap.cancelsTouchesInView = NO;
|
||||
[collectionView addGestureRecognizer:tap];
|
||||
[self setCtrlTapRecognizer:tap];
|
||||
[tap release];
|
||||
|
||||
UIBarButtonItem* ctrlButton = [[UIBarButtonItem alloc] initWithTitle:@"Ctrl" style:UIBarButtonItemStylePlain target:self action:@selector(ctrlButtonPressed)];
|
||||
[self setCtrlButton:ctrlButton];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
%end
|
||||
|
||||
|
||||
%hook PUCollectionView
|
||||
|
||||
%new
|
||||
-(void)ctrlScreenTapRecognized:(id) sender {
|
||||
|
||||
id gvController = [self delegate];
|
||||
|
||||
if ([gvController ctrlEnabled]){
|
||||
|
||||
CGPoint tapPoint = [sender locationInView:self];
|
||||
NSIndexPath *nextIndexPath = [self indexPathForItemAtPoint:tapPoint];
|
||||
|
||||
if (![gvController ctrlFirstIndexPath]){
|
||||
|
||||
[gvController setCtrlFirstIndexPath:nextIndexPath];
|
||||
|
||||
|
||||
PUPhotosGridCell* firstSelectedCell = [self cellForItemAtIndexPath:nextIndexPath];
|
||||
|
||||
firstSelectedCell.ctrlSelectOverlayView = [[UIImageView alloc] init];
|
||||
firstSelectedCell.ctrlSelectOverlayView.frame = CGRectMake(0,0,31,31);
|
||||
firstSelectedCell.ctrlSelectOverlayView.image = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/PhotoCtrl/check.png"];
|
||||
|
||||
[firstSelectedCell addSubview:firstSelectedCell.ctrlSelectOverlayView];
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
//PUPhotosGridCell* firstSelectedCell = [self cellForItemAtIndexPath:[gvController ctrlFirstIndexPath]];
|
||||
|
||||
//[firstSelectedCell.ctrlSelectOverlayView removeFromSuperview];
|
||||
//firstSelectedCell.ctrlSelectOverlayView = nil;
|
||||
|
||||
NSRange indexRange;
|
||||
NSInteger firstRow = [gvController ctrlFirstIndexPath].row;
|
||||
NSInteger firstSection = [gvController ctrlFirstIndexPath].section;
|
||||
NSInteger nextRow = nextIndexPath.row;
|
||||
NSInteger nextSection = nextIndexPath.section;
|
||||
|
||||
NSInteger lowRow = 0;
|
||||
NSInteger highRow = 0;
|
||||
NSInteger lowSection = 0;
|
||||
NSInteger highSection = 0;
|
||||
NSInteger sectionItemCount = 0;
|
||||
|
||||
if (firstRow == nextRow && nextSection == firstSection){
|
||||
|
||||
[gvController setCtrlFirstIndexPath:nil];
|
||||
|
||||
} else {
|
||||
|
||||
if (nextSection == firstSection){
|
||||
|
||||
if (firstRow < nextRow){
|
||||
indexRange = NSMakeRange(firstRow, nextRow - firstRow + 1);
|
||||
} else {
|
||||
indexRange = NSMakeRange(nextRow, firstRow - nextRow + 1);
|
||||
}
|
||||
|
||||
[gvController setSelected:YES itemsAtIndexes:[%c(NSIndexSet) indexSetWithIndexesInRange:indexRange] inSection:(long long)firstSection animated:NO];
|
||||
|
||||
} else {
|
||||
|
||||
if (nextSection > firstSection){
|
||||
|
||||
lowRow = firstRow;
|
||||
lowSection = firstSection;
|
||||
highRow = nextRow;
|
||||
highSection = nextSection;
|
||||
|
||||
} else if (nextSection < firstSection){
|
||||
|
||||
lowRow = nextRow;
|
||||
lowSection = nextSection;
|
||||
highRow = firstRow;
|
||||
highSection = firstSection;
|
||||
|
||||
}
|
||||
|
||||
for (NSInteger i = lowSection; i <= highSection; i++){
|
||||
sectionItemCount = [gvController collectionView:self numberOfItemsInSection:i];
|
||||
|
||||
if (i == lowSection){
|
||||
indexRange = NSMakeRange(lowRow, sectionItemCount - lowRow);
|
||||
} else if (i == highSection){
|
||||
indexRange = NSMakeRange(0, highRow+1);
|
||||
} else {
|
||||
indexRange = NSMakeRange(0, sectionItemCount);
|
||||
}
|
||||
|
||||
[gvController setSelected:YES itemsAtIndexes:[%c(NSIndexSet) indexSetWithIndexesInRange:indexRange] inSection:(long long)i animated:NO];
|
||||
}
|
||||
}
|
||||
|
||||
[gvController handleToggleSelectionOfItemAtIndexPath:nextIndexPath];
|
||||
|
||||
[gvController setCtrlEnabled:NO];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[gvController updateCtrlButton];
|
||||
}
|
||||
|
||||
|
||||
-(id) dequeueReusableCellWithReuseIdentifier: (id) arg1 forIndexPath:(id) arg2{
|
||||
id orig = %orig;
|
||||
|
||||
id gvController = [self delegate];
|
||||
|
||||
if ([orig ctrlSelectOverlayView]){
|
||||
|
||||
[orig ctrlSelectOverlayView].image = nil;
|
||||
|
||||
if ([gvController ctrlEnabled] && [gvController ctrlFirstIndexPath]){
|
||||
|
||||
NSIndexPath* firstIndexPath = [gvController ctrlFirstIndexPath];
|
||||
NSIndexPath* thisIndexPath = arg2;
|
||||
|
||||
HBLogDebug(@"firstIndexPath: %ld-%ld thisIndexPath: %ld-%ld", (long)firstIndexPath.section, (long)firstIndexPath.row, (long)thisIndexPath.section, (long)thisIndexPath.row);
|
||||
|
||||
if ( firstIndexPath.section == thisIndexPath.section && firstIndexPath.row == thisIndexPath.row){
|
||||
|
||||
[orig ctrlSelectOverlayView].image = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/PhotoCtrl/check.png"];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return orig;
|
||||
}
|
||||
|
||||
%end
|
||||
|
||||
|
||||
%hook PUPhotosGridCell
|
||||
%property(retain,nonatomic) UIImageView* ctrlSelectOverlayView;
|
||||
%end
|
||||
|
||||
%end
|
||||
|
||||
|
||||
%ctor{
|
||||
@autoreleasepool{
|
||||
%init(Tweak);
|
||||
}
|
||||
}
|
||||
|
||||
|
9
control
Normal file
9
control
Normal file
@ -0,0 +1,9 @@
|
||||
Package: com.lint.photoctrl
|
||||
Name: PhotoCtrl
|
||||
Depends: mobilesubstrate
|
||||
Version: 1.0.0
|
||||
Architecture: iphoneos-arm
|
||||
Description: Adds a "ctrl + shift" like function for selecting photos.
|
||||
Maintainer: lint <apieceoflint@protonmail.com>
|
||||
Author: lint <apieceoflint@protonmail.com>
|
||||
Section: Tweaks
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Reference in New Issue
Block a user