Skip to content

Commit

Permalink
1.2
Browse files Browse the repository at this point in the history
- Add "BeFake" functionality: upload custom BeReals from camera roll, spoof location and the time the photo was taken
- Stability improvements (random app crashes aren't caused by Bea. BeReal itself is aware of those crashes)
  • Loading branch information
yandevelop committed Jun 6, 2023
1 parent 89e7e07 commit e4162a6
Show file tree
Hide file tree
Showing 18 changed files with 1,270 additions and 56 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.theos/
packages/
.DS_Store
Versions/
Versions/
Utilities/errorCodes
notes
realmoji
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ TARGET := iphone:clang:latest:14.0
INSTALL_TARGET_PROCESSES = BeReal
ARCHS = arm64 arm64e
FINALPACKAGE = 1
PACKAGE_VERSION = 1.1.2
PACKAGE_VERSION = 1.2

export SYSROOT = $(THEOS)/sdks/iPhoneOS15.5.sdk

Expand All @@ -12,6 +12,15 @@ TWEAK_NAME = Bea

Bea_FILES = Tweak/Tweak.x
Bea_CFLAGS = -fobjc-arc
Bea_FRAMEWORKS = UIKit
Bea_LDFLAGS += -ObjC
Bea_FRAMEWORKS = UIKit MapKit

ifeq ($(JAILED), 1)
Bea_CFLAGS += -D JAILED=1
endif

ifeq ($(LEGACY_SUPPORT), 1)
Bea_CFLAGS += -D LEGACY_SUPPORT=1
endif

include $(THEOS_MAKE_PATH)/tweak.mk
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
# Bea
Bea adds small enhancements to the BeReal. app.

## Installation
1. Add https://havoc.app to your package manager.
2. Install Bea
Bea is an iOS tweak that adds enhancements to the BeReal. app.

## Compatibility
All iOS devices running iOS 14 or later.
Compatible with all iOS devices running iOS 14 or later.

## Features
- View BeReals without posting your own
- Upload BeReals from the camera roll:
- Post on time, even if you're posting late
- Set a custom location
- Set a custom retake count
- Download BeReals
- Bypass screenshot detection

## Build
<table><tr><td>
To build Bea for the purpose of injecting it into an IPA and installing it through sideloading, set the JAILED flag to true.</td></tr></table>

- Clone this repository using `git clone https://github.com/yandevelop/Bea`
- `cd Bea`
- Run `make package`

## Installation
1. Add https://havoc.app to your package manager.
2. Install Bea

## License
You may not copy, modify, sublicense or distribute the source code or any packages from it.

6 changes: 5 additions & 1 deletion Tweak/Tweak.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "../Utilities/BeaUtilities.m"
#import "../Utilities/UploadViewController/BeaUploadViewController.m"
#import <rootless.h>

BOOL isUnblurred = NO;
BOOL isUnblurred = NO;

NSString *authorizationKey = nil;
142 changes: 99 additions & 43 deletions Tweak/Tweak.x
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#import "Tweak.h"


%hook DoublePhotoView
- (void)layoutSubviews {
%orig;

UIView *doublePhotoView = (UIView *)self;

if ([doublePhotoView.subviews.lastObject isKindOfClass:[BeaButton class]] || doublePhotoView.frame.size.width < 180) return;

// make the view accept touches (dragging photos etc)
doublePhotoView.superview.userInteractionEnabled = YES;

UIResponder *responder = self;
while (responder && ![responder isKindOfClass:[UIViewController class]]) {
responder = [responder nextResponder];
Expand All @@ -27,26 +32,32 @@

%hook UIAlertController
- (void)viewDidLoad {
UIAlertController *alertController = (UIAlertController *)self;
%orig;
if (isUnblurred) return;

UIAlertController *alertController = (UIAlertController *)self;

if (![alertController.presentingViewController isKindOfClass:objc_getClass("BeReal.NavigationController")]) return %orig;
UIAlertAction *thirdAction = alertController.actions[2];
id block = [thirdAction valueForKey:@"_handler"];
if (block) {
void (^handler)(UIAlertAction *) = block;
handler(thirdAction);
isUnblurred = YES;
if ([alertController.actions[2].title isEqual:@"👀 Unblur"]) {
UIAlertAction *thirdAction = alertController.actions[2];
id block = [thirdAction valueForKey:@"_handler"];
if (block) {
void (^handler)(UIAlertAction *) = block;
handler(thirdAction);
}
}
}

- (void)viewWillAppear:(id)arg1 {
%orig;
if ([self.presentingViewController isKindOfClass:objc_getClass("BeReal.NavigationController")] || [self.presentingViewController isKindOfClass:[UINavigationController class]]) {
if (isUnblurred) return;
UIAlertController *alertController = (UIAlertController *)self;
if ([alertController.actions[2].title isEqual:@"👀 Unblur"]) {
// Set the whole view to hidden
self.view.superview.hidden = YES;

isUnblurred = YES;

// Dismiss the UIAlertController automatically
// Dismiss the UIAlertController
[self dismissViewControllerAnimated:NO completion:nil];
}
}
Expand All @@ -55,40 +66,63 @@
%hook HomeViewController
- (void)viewDidLoad {
%orig;
UIViewController *homeViewController = (UIViewController *)self;

if (!isUnblurred && [homeViewController respondsToSelector:@selector(openDebugMenu)] && [homeViewController.childViewControllers.lastObject isKindOfClass:objc_getClass("BeReal.SUIFeedViewController")]) {
[homeViewController performSelector:@selector(openDebugMenu)];
UIViewController *homeViewController = (UIViewController *)self;

if (!isUnblurred && [homeViewController respondsToSelector:@selector(openDebugMenu)] && [homeViewController.childViewControllers.lastObject isKindOfClass:objc_getClass("BeReal.SUIFeedViewController")]) {
[homeViewController performSelector:@selector(openDebugMenu)];
#ifndef LEGACY_SUPPORT
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSComparisonResult result = [version compare:@"1.1.2" options:NSNumericSearch];
if (result == NSOrderedAscending) {
BeaAlertView *alertView = [[BeaAlertView alloc] init];
[homeViewController.view addSubview:alertView];
}
#endif
}

NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSComparisonResult result = [version compare:@"1.1.2" options:NSNumericSearch];
if (result == NSOrderedAscending) {
BeaAlertView *alertView = [[BeaAlertView alloc] init];
[homeViewController.view addSubview:alertView];
}
}
UIImageView *beRealLogoView = [self valueForKey:@"ibNavBarLogoImageView"];
beRealLogoView.userInteractionEnabled = YES;

#ifdef JAILED
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"Bea" ofType:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
UIImage *beFakeLogo = [UIImage imageWithContentsOfFile:[bundle pathForResource:@"BeFake" ofType:@"png"]];
#else
NSBundle *bundle = [NSBundle bundleWithPath:ROOT_PATH_NS(@"/Library/Application Support/Bea.bundle")];
UIImage *beFakeLogo = [UIImage imageNamed:@"BeFake.png" inBundle:bundle compatibleWithTraitCollection:nil];
#endif

CGSize targetSize = beRealLogoView.image.size;

UIGraphicsBeginImageContextWithOptions(targetSize, NO, 0);
[beFakeLogo drawInRect:CGRectMake(0, 0, targetSize.width, targetSize.height)];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

beRealLogoView.image = resizedImage;

UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[beRealLogoView addGestureRecognizer:tapGestureRecognizer];
}
%end

%hook SwiftView
- (void)layoutSubviews {
%orig;
UIView *s = (UIView *)self;
// removes the eye view and the post late button from the blurred view
for (UIView *v in s.subviews) {
if (v.frame.size.width <= 48 && v.frame.size.width > 32) {
v.hidden = YES;
}
if (([v isKindOfClass:objc_getClass("SwiftUI._UIGraphicsView")] || [v isKindOfClass:[UIView class]]) && v.frame.size.width > 350 && v.subviews.count == 0) {
v.hidden = YES;
}
}
%new
- (void)handleTap:(UITapGestureRecognizer *)gestureRecognizer {

UIViewController *vc = (UIViewController *)self;
// display the error view here
if (!authorizationKey) return;
BeaUploadViewController *beaUploadViewController = [[BeaUploadViewController alloc] initWithAuthorization:authorizationKey];
beaUploadViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[vc presentViewController:beaUploadViewController animated:YES completion:nil];
}
%end


%hook CALayer
- (void)setFilters:(NSArray *)filter {
return;
if (!isUnblurred) return;
%orig;
}
%end

Expand All @@ -100,7 +134,7 @@
UITableView *labelView = vc.view.subviews.firstObject;

UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, labelView.frame.size.width, 50)];
headerLabel.text = @"Bea 1.1.2\nmade with ❤️ by yan";
headerLabel.text = @"Bea 1.2\nmade with ❤️ by yan";
headerLabel.numberOfLines = 0;
headerLabel.font = [UIFont fontWithName:@"Inter" size:10];
headerLabel.textAlignment = NSTextAlignmentCenter;
Expand Down Expand Up @@ -135,14 +169,36 @@
}
%end

%hook NSMutableURLRequest
-(void)setAllHTTPHeaderFields:(NSDictionary *)arg1 {
%orig;
if ([[arg1 allKeys] containsObject:@"Authorization"] && !authorizationKey) {
authorizationKey = arg1[@"Authorization"];
}
}
%end

%hook UIHostingView
- (void)layoutSubviews {
%orig;
UIView *s = (UIView *)self;
for (UIView *v in s.superview.subviews) {
if ((v.frame.size.width <= 48 && v.frame.size.width > 32) || (([v isKindOfClass:objc_getClass("SwiftUI._UIGraphicsView")] || [v isKindOfClass:[UIView class]]) && v.frame.size.width > 350 && v.subviews.count == 0)) {
v.hidden = YES;
}
}
}
%end

%ctor {
%init(HomeViewController = objc_getClass("_TtC6BeReal18HomeViewController"),
DoublePhotoView = objc_getClass("RealComponents.DoublePhotoView"),
SettingsViewController = objc_getClass("_TtC6BeReal22SettingsViewController"),
SwiftView = objc_getClass("_TtCC7SwiftUI17HostingScrollView22PlatformGroupContainer"));
#ifdef LEGACY_SUPPORT
Class photoView = objc_getClass("BeReal.DoublePhotoView");
#else
Class photoView = objc_getClass("RealComponents.DoublePhotoView");
#endif

// Enable dualCamera?
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"debug_dualCameraPreviewEnabled"];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"debug_developerModeEnabled"];
%init(HomeViewController = objc_getClass("_TtC6BeReal18HomeViewController"),
DoublePhotoView = photoView,
SettingsViewController = objc_getClass("_TtC6BeReal22SettingsViewController"),
UIHostingView = objc_getClass("_TtC7SwiftUIP33_A34643117F00277B93DEBAB70EC0697116_UIInheritedView"));
}
11 changes: 9 additions & 2 deletions Utilities/BeaUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ + (void)downloadImage:(id)sender {
UIButton *button = (UIButton *)sender;
UIView *tableContentView = button.superview.superview;
UIImageView *imageView = nil;

#ifdef LEGACY_SUPPORT
NSString *viewClass = @"BeReal.DoublePhotoView";
#else
NSString *viewClass = @"RealComponents.DoublePhotoView";
#endif

for (UIView *view in tableContentView.subviews) {
if ([NSStringFromClass([view class]) isEqualToString:@"RealComponents.DoublePhotoView"]) {
if ([NSStringFromClass([view class]) isEqualToString:viewClass]) {
imageView = view.subviews.firstObject;
break;
}
Expand Down Expand Up @@ -125,7 +132,7 @@ - (void)setupAlertView {
}

- (void)updateButtonTapped {
NSString *appStoreLink = @"https://apps.apple.com/de/app/id1459645446";
NSString *appStoreLink = @"https://apps.apple.com/app/id1459645446";
NSURL *appStoreURL = [NSURL URLWithString:appStoreLink];

if ([[UIApplication sharedApplication] canOpenURL:appStoreURL]) {
Expand Down
7 changes: 7 additions & 0 deletions Utilities/InfoViewController/BeaInfoViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@interface BeaInfoViewController : UIViewController
@property (nonatomic, strong) UIImageView *profileImageView;
@property (nonatomic, strong) UILabel *twitterLabel;
@property (nonatomic, strong) UILabel *smallLabel;
@property (nonatomic, strong) UIView *wrapperView;
@property (nonatomic, strong) UILabel *versionLabel;
@end
Loading

0 comments on commit e4162a6

Please sign in to comment.