Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,11 @@ jobs:
echo "$(sha256sum packages/*)" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.package_info.outputs.id }}_${{ steps.package_info.outputs.version }}
path: packages/*

- name: Create release
if: ${{ inputs.create_release }}
uses: softprops/action-gh-release@v2
with:
draft: true
files: packages/*
files: packages/*.ipa
tag_name: v${{ steps.ipa_info.outputs.version }}-${{ steps.package_info.outputs.version }}
body: ${{ steps.hash_files.outputs.hashes }}
13 changes: 7 additions & 6 deletions FeedFilterSettingsViewController.x
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
extern NSBundle *redditFilterBundle;
extern UIImage *iconWithName(NSString *iconName);
extern Class CoreClass(NSString *name);

#define LOC(x, d) [redditFilterBundle localizedStringForKey:x value:d table:nil]

%subclass FeedFilterSettingsViewController : BaseTableViewController
Expand All @@ -30,7 +29,6 @@ extern Class CoreClass(NSString *name);
case 0: {
toggleCell = [tableView dequeueReusableCellWithIdentifier:kToggleCellID
forIndexPath:indexPath];

switch (indexPath.row) {
case 0:
mainLabelText = LOC(@"filter.settings.promoted.title", @"Promoted");
Expand Down Expand Up @@ -105,11 +103,9 @@ extern Class CoreClass(NSString *name);

([cell respondsToSelector:@selector(mainLabel)] ? cell.mainLabel : cell.imageLabelView.mainLabel)
.text = mainLabelText;

([cell respondsToSelector:@selector(detailLabel)] ? cell.detailLabel
: cell.imageLabelView.detailLabel)
.text = detailLabelText;

UIImage *iconImage;
for (NSString *iconName in iconNames) {
iconImage = iconWithName(iconName);
Expand Down Expand Up @@ -182,9 +178,14 @@ extern Class CoreClass(NSString *name);
- (void)viewDidLoad {
%orig;
self.title = @"RedditFilter";
[self.tableView registerClass:CoreClass(@"ToggleImageTableViewCell")

// Provide safe fallbacks to prevent crashes if Reddit removes/renames classes
Class toggleCellClass = CoreClass(@"ToggleImageTableViewCell") ?: [UITableViewCell class];
Class labelCellClass = CoreClass(@"ImageLabelTableViewCell") ?: [UITableViewCell class];

[self.tableView registerClass:toggleCellClass
forCellReuseIdentifier:kToggleCellID];
[self.tableView registerClass:CoreClass(@"ImageLabelTableViewCell")
[self.tableView registerClass:labelCellClass
forCellReuseIdentifier:kLabelCellID];
}
%new
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ INSTALL_TARGET_PROCESSES = RedditApp Reddit

ARCHS = arm64

PACKAGE_VERSION = 1.1.8
PACKAGE_VERSION = 1.2.1
ifdef APP_VERSION
PACKAGE_VERSION := $(APP_VERSION)-$(PACKAGE_VERSION)
endif
Expand All @@ -28,4 +28,11 @@ ifeq ($(SIDELOADED),1)
include $(THEOS_MAKE_PATH)/aggregate.mk
endif

include $(THEOS_MAKE_PATH)/tweak.mk
include $(THEOS_MAKE_PATH)/tweak.mk

# Copy preference bundle resources to staging directory
after-stage::
$(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceBundles/RedditFilter.bundle/en.lproj$(ECHO_END)
$(ECHO_NOTHING)if [ -d "layout/Library/Application Support/RedditFilter.bundle" ]; then \
cp -r "layout/Library/Application Support/RedditFilter.bundle"/* "$(THEOS_STAGING_DIR)/Library/PreferenceBundles/RedditFilter.bundle/"; \
fi$(ECHO_END)
115 changes: 54 additions & 61 deletions Settings.x
Original file line number Diff line number Diff line change
Expand Up @@ -7,87 +7,36 @@ NSBundle *redditFilterBundle;
extern UIImage *iconWithName(NSString *iconName);
extern NSString *localizedString(NSString *key, NSString *table);

@interface AppSettingsViewController ()
@property(nonatomic, assign) NSInteger feedFilterSectionIndex;
@end

@interface UserDrawerViewController ()
- (void)navigateToRedditFilterSettings;
@end

%hook AppSettingsViewController
%property(nonatomic, assign) NSInteger feedFilterSectionIndex;
- (void)viewDidLoad {
%orig;
for (int section = 0; section < [self numberOfSectionsInTableView:self.tableView]; section++) {
BaseTableReusableView *headerView = (BaseTableReusableView *)[self tableView:self.tableView
viewForHeaderInSection:section];
if (!headerView) continue;
BaseLabel *label = headerView.contentView.subviews[0];
for (NSString *key in @[ @"drawer.settings.feedOptions", @"drawer.settings.viewOptions" ]) {
if ([label.text isEqualToString:[localizedString(key, @"user") uppercaseString]]) {
self.feedFilterSectionIndex = section;
return;
}
}
}
self.feedFilterSectionIndex = 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSInteger result = %orig;
if (section == self.feedFilterSectionIndex) result++;
return result;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == self.feedFilterSectionIndex &&
indexPath.row == [self tableView:tableView numberOfRowsInSection:indexPath.section] - 1) {
UIImage *iconImage = [iconWithName(@"icon_filter") ?: iconWithName(@"icon-filter-outline")
imageScaledToSize:CGSizeMake(20, 20)];
UIImage *accessoryIconImage =
[iconWithName(@"icon_forward") imageScaledToSize:CGSizeMake(20, 20)];
ImageLabelTableViewCell *cell = [self dequeueSettingsCellForTableView:tableView
indexPath:indexPath
leadingImage:iconImage
text:@"RedditFilter"];
[cell setCustomAccessoryImage:accessoryIconImage];
return cell;
}
return %orig;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == self.feedFilterSectionIndex &&
indexPath.row == [self tableView:tableView numberOfRowsInSection:indexPath.section] - 1) {
[self.navigationController
pushViewController:[(FeedFilterSettingsViewController *)[objc_getClass(
"FeedFilterSettingsViewController") alloc]
initWithStyle:UITableViewStyleGrouped]
animated:YES];
return;
}
%orig;
}
%end

// We keep this just in case the side menu still works, as it provides a backup entry point.
%hook UserDrawerViewController

- (void)defineAvailableUserActions {
%orig;
[self.availableUserActions addObject:@1337];
}

- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([tableView isEqual:self.actionsTableView] &&
self.availableUserActions[indexPath.row].unsignedIntegerValue == 1337) {
UITableViewCell *cell =
[self.actionsTableView dequeueReusableCellWithIdentifier:@"UserDrawerActionTableViewCell"];

cell.textLabel.text = @"RedditFilter";
cell.imageView.image = [[iconWithName(@"rpl3/filter") ?: iconWithName(@"icon_filter") ?: iconWithName(@"icon-filter-outline")
imageScaledToSize:CGSizeMake(20, 20)]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

UIImage *icon = iconWithName(@"rpl3/filter") ?: iconWithName(@"icon_filter") ?: iconWithName(@"icon-filter-outline");
if (icon) {
cell.imageView.image = [[icon imageScaledToSize:CGSizeMake(20, 20)] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
return cell;
}
return %orig;
}

%new
- (void)navigateToRedditFilterSettings {
[self dismissViewControllerAnimated:YES completion:nil];
Expand All @@ -96,6 +45,7 @@ extern NSString *localizedString(NSString *key, NSString *table);
initWithStyle:UITableViewStyleGrouped];
[[self currentNavigationController] pushViewController:filterSettingsViewController animated:YES];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([tableView isEqual:self.actionsTableView] &&
self.availableUserActions[indexPath.row].unsignedIntegerValue == 1337) {
Expand All @@ -105,6 +55,49 @@ extern NSString *localizedString(NSString *key, NSString *table);
}
%end

%hook UIViewController

- (void)viewWillAppear:(BOOL)animated {
%orig;

NSString *name = NSStringFromClass([self class]);

if ([name containsString:@"RedditSliceKit"] &&
[name containsString:@"AppSettingsView"] &&
[name containsString:@"HostingController"]) {

if (self.navigationItem.rightBarButtonItems) {
for (UIBarButtonItem *item in self.navigationItem.rightBarButtonItems) {
if (item.tag == 1337) return;
}
}

UIBarButtonItem *filterButton = [[UIBarButtonItem alloc] initWithTitle:@"RedditFilter"
style:UIBarButtonItemStylePlain
target:self
action:@selector(openRedditFilterFromNav)];
filterButton.tag = 1337; // Tag to identify our button

[filterButton setTitlePositionAdjustment:UIOffsetMake(0, 3.5) forBarMetrics:UIBarMetricsDefault];

// 5. Add it to the Navigation Bar
NSMutableArray *items = [self.navigationItem.rightBarButtonItems mutableCopy];
if (!items) items = [NSMutableArray array];
[items insertObject:filterButton atIndex:0]; // Add to the start of the list (right side)

self.navigationItem.rightBarButtonItems = items;
}
}

%new
- (void)openRedditFilterFromNav {
// Launch the Tweak Settings
FeedFilterSettingsViewController *vc = [(FeedFilterSettingsViewController *)[objc_getClass("FeedFilterSettingsViewController") alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:vc animated:YES];
}

%end

%ctor {
redditFilterBundle = [NSBundle bundleWithPath:[NSBundle.mainBundle pathForResource:@"RedditFilter"
ofType:@"bundle"]];
Expand Down
Loading