Skip to content

Commit

Permalink
1.3.5
Browse files Browse the repository at this point in the history
- Fix BeReal crashing on versions >= 1.22.0
- Restructure project
- Overall efficiency improvements
  • Loading branch information
yandevelop committed Feb 7, 2024
1 parent 1b1feda commit 8f7912b
Show file tree
Hide file tree
Showing 35 changed files with 215 additions and 302 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ packages/
Versions/
Utilities/errorCodes
notes
realmoji
realmoji
changelog
Releases/
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
TARGET := iphone:clang:latest:14.0
INSTALL_TARGET_PROCESSES = BeReal
ARCHS = arm64 arm64e
FINALPACKAGE = 1
PACKAGE_VERSION = 1.3.4

THEOS_DEVICE_IP = 192.168.102.61

THEOS_PACKAGE_SCHEME = rootless
PACKAGE_VERSION = 1.3.5

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = Bea

$(TWEAK_NAME)_FILES = Tweak/Tweak.x
$(TWEAK_NAME)_FILES = Tweak/$(TWEAK_NAME).x
$(TWEAK_NAME)_CFLAGS = -fobjc-arc
$(TWEAK_NAME)_FRAMEWORKS = UIKit MapKit

Expand Down
6 changes: 3 additions & 3 deletions Tweak/Tweak.h → Tweak/Bea.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "../Utilities/BeaUtilities.m"
#import "Utilities/Helpers/Helpers.h"
#import "../Utilities/Managers/TokenManager/BeaTokenManager.m"
#import "../Utilities/ViewControllers/UploadViewController/BeaUploadViewController.m"
#import "../Utilities/BeFake/ViewControllers/UploadViewController/BeaUploadViewController.m"

BOOL isUnblurred = NO;
NSDictionary *headers;

@interface CAFilter : NSObject
@property (copy) NSString * name;
@property (copy) NSString *name;
@end

@interface DoublePhotoView : UIView
Expand Down
75 changes: 35 additions & 40 deletions Tweak/Tweak.x → Tweak/Bea.x
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#import "Tweak.h"

#import "Bea.h"

%hook DoublePhotoView
%property (nonatomic, strong) BeaButton *downloadButton;

- (void)drawRect:(CGRect)rect {
%orig;

Expand All @@ -17,9 +15,6 @@

if ([self downloadButton]) return;

[[self superview] setUserInteractionEnabled:YES];
[[[self superview] superview] setUserInteractionEnabled:YES];

BeaButton *downloadButton = [BeaButton downloadButton];
downloadButton.layer.zPosition = 99;

Expand All @@ -30,6 +25,15 @@
[[[self downloadButton] trailingAnchor] constraintEqualToAnchor:[self trailingAnchor] constant:-11.6],
[[[self downloadButton] bottomAnchor] constraintEqualToAnchor:[self topAnchor] constant:47.333]
]];

// backwards compatibility: if the user has a newer version of BeReal installed,
// the native unblur function doesnt exist and the the download button must be hidden manually
// if we remove this check on older version, this will effectively hide the whole DoublePhotoView because
// the native unblur function already removed all unneccessary views and the last object becomes the
// DoublePhotoView
if (isUnblurred) return;
// hide the "Post late button"
[[[[[[[self superview] superview] superview] superview] superview] subviews] lastObject].hidden = YES;
}


Expand All @@ -49,28 +53,23 @@
}
%end



%hook UIAlertController
- (void)viewWillAppear:(id)arg1 {
- (void)viewWillAppear:(BOOL)arg1 {
%orig;
if (isUnblurred) return;

if ([self.actions[2].title isEqual:@"👀 Unblur"]) {
// Set the whole view to hidden
self.view.superview.hidden = YES;

if ([self.actions[2].title isEqual:@"👀 Unblur"] && !isUnblurred) {
self.view.superview.hidden = YES;
UIAlertAction *thirdAction = self.actions[2];
id block = [thirdAction valueForKey:@"_handler"];
if (block) {
dispatch_async(dispatch_get_main_queue(), ^{
void (^handler)(UIAlertAction *) = block;
handler(thirdAction);
});
isUnblurred = YES;
}
isUnblurred = YES;
// Dismiss the UIAlertController automatically
[self dismissViewControllerAnimated:NO completion:nil];
}
[self dismissViewControllerAnimated:NO completion:nil];
}
}
%end

Expand All @@ -79,18 +78,6 @@
- (void)viewDidLoad {
%orig;

if (!isUnblurred && [self respondsToSelector:@selector(openDebugMenu)]) {
//[homeViewController performSelector:@selector(openDebugMenu)];
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
if (version.length > 0) {
NSComparisonResult result = [version compare:@"1.1.2" options:NSNumericSearch];
if (result == NSOrderedAscending) {
BeaAlertView *alertView = [[BeaAlertView alloc] init];
[[self view] addSubview:alertView];
}
}
}

UIStackView *stackView = (UIStackView *)[[self ibNavBarLogoImageView] superview];
stackView.axis = UILayoutConstraintAxisHorizontal;
stackView.alignment = UIStackViewAlignmentCenter;
Expand Down Expand Up @@ -120,6 +107,7 @@

%hook CAFilter
-(void)setValue:(id)arg1 forKey:(id)arg2 {
if (isUnblurred) return %orig;
// remove the blur that gets applied to the BeReals
// this is kind of a fallback if the normal unblur function somehow fails
if ([arg1 isEqual:@(13)] && [self.name isEqual:@"gaussianBlur"]) {
Expand All @@ -130,7 +118,6 @@
%end



%hook SettingsViewController
- (void)viewDidLoad {
%orig;
Expand All @@ -153,12 +140,11 @@
}
%end

// return a nil string so the BeReal photo view is clear :)

%hook NSBundle
- (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)tableName {

// since BeReal 1.4 the bundleIdentifier seems to have changed. Keeping both for backwards compatibility
if ([self.bundleIdentifier isEqualToString:@"Localisation-Localisation-resources"] || [self.bundleIdentifier isEqualToString:@"com.bereal.BRAssets"]) {
if (!isUnblurred & [self.bundleIdentifier isEqualToString:@"Localisation-Localisation-resources"] || [self.bundleIdentifier isEqualToString:@"com.bereal.BRAssets"]) {
if ([key isEqualToString:@"timelineCell_blurredView_button"] || [key isEqualToString:@"timelineCell_blurredView_description_myFriends"] || [key isEqualToString:@"timelineCell_blurredView_title"] || [key isEqualToString:@"timelineCell_blurredView_description_discoveryGlobal"]) {
return @"";
}
Expand All @@ -171,6 +157,7 @@
%hook NSMutableURLRequest
-(void)setAllHTTPHeaderFields:(NSDictionary *)arg1 {
%orig;

if ([[arg1 allKeys] containsObject:@"Authorization"] && [[arg1 allKeys] containsObject:@"bereal-device-id"] && !headers) {
if ([arg1[@"Authorization"] length] > 0) {
headers = (NSDictionary *)arg1;
Expand All @@ -182,11 +169,16 @@


%hook UIHostingView
-(void)setUserInteractionEnabled:(BOOL)arg1 {
%orig(YES);
}

- (void)layoutSubviews {
%orig;
if (isUnblurred) return;
for (UIView *v in [[self superview] subviews]) {
CGFloat width = v.frame.size.width;
if ((width <= 48 && width > 32) || ([v isKindOfClass:[UIView class]] && width > 350 && width < 1400 && v.subviews.count == 0)) {
if ((width <= 49 && width > 32) || ([v isKindOfClass:[UIView class]] && width > 350 && width < 1400 && v.subviews.count == 0)) {
[v setHidden:YES];
}
}
Expand All @@ -195,12 +187,15 @@


%hook UIPageViewController
- (void)viewWillAppear:(id)arg1 {
- (void)viewDidLoad {
%orig;
if ([self.viewControllers.firstObject isKindOfClass:objc_getClass("BeReal.SUIFeedViewController")] && [self.parentViewController isKindOfClass:objc_getClass("BeReal.HomeViewController")] && !isUnblurred) {
HomeViewController *controller = (HomeViewController *)self.parentViewController;
[controller openDebugMenu];
}
if (isUnblurred) return;
dispatch_async(dispatch_get_main_queue(), ^{
if ([self.viewControllers.firstObject isKindOfClass:objc_getClass("BeReal.SUIFeedViewController")] && [self.parentViewController respondsToSelector:@selector(openDebugMenu)] && [self.parentViewController isKindOfClass:objc_getClass("BeReal.HomeViewController")]) {
HomeViewController *controller = (HomeViewController *)self.parentViewController;
[controller openDebugMenu];
}
});
}
%end

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@property (nonatomic, strong) UILabel *versionLabel;
@end

#define TWEAK_VERSION @"1.3.4"
#define TWEAK_VERSION @"1.3.5"
File renamed without changes.
File renamed without changes.
18 changes: 0 additions & 18 deletions Utilities/BeaUtilities.h

This file was deleted.

Loading

0 comments on commit 8f7912b

Please sign in to comment.