Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
renewed the project
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra authored and Alexandra committed Dec 22, 2022
0 parents commit f524508
Show file tree
Hide file tree
Showing 30 changed files with 2,085 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ko_fi: traurige
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Bug report
about: Report a bug to help improve Eneko
title: ''
labels: bug
assignees: Traurige

---

**Describe the bug:**

**Steps to reproduce the behavior:**

**System information:**
- iOS version:
- Device:
- Jailbreak:
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Feature request
about: Suggest a feature that can help make Eneko even better
title: ''
labels: enhancement
assignees: Traurige

---

**Describe the requested feature:**

**System information:**
- iOS version:
- Device:
- Jailbreak:
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
.theos
.vscode
packages/
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export ARCHS = arm64 arm64e
export TARGET = iphone:clang:14.4:14.0
export SYSROOT = $(THEOS)/sdks/iPhoneOS14.4.sdk
export PREFIX = $(THEOS)/toolchain/Xcode.xctoolchain/usr/bin/

INSTALL_TARGET_PROCESSES = SpringBoard
SUBPROJECTS = Tweak Preferences

include $(THEOS)/makefiles/common.mk
include $(THEOS_MAKE_PATH)/aggregate.mk
19 changes: 19 additions & 0 deletions Preferences/Cells/CallaLinkCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// CallaLinkCell.h
// Calla Utils
//
// Created by Alexandra (@Traurige)
//

#import <UIKit/UIKit.h>
#import <Preferences/PSSpecifier.h>

@interface CallaLinkCell : PSTableCell
@property(nonatomic, retain)UILabel* label;
@property(nonatomic, retain)UILabel* subtitleLabel;
@property(nonatomic, retain)UIView* tapRecognizerView;
@property(nonatomic, retain)UITapGestureRecognizer* tap;
@property(nonatomic, retain)NSString* title;
@property(nonatomic, retain)NSString* subtitle;
@property(nonatomic, retain)NSString* url;
@end
73 changes: 73 additions & 0 deletions Preferences/Cells/CallaLinkCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// CallaLinkCell.m
// Calla Utils
//
// Created by Alexandra (@Traurige)
//

#import "CallaLinkCell.h"

@implementation CallaLinkCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier specifier:(PSSpecifier *)specifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier specifier:specifier];

if (self) {
[self setTitle:[specifier properties][@"label"]];
[self setSubtitle:[specifier properties][@"subtitle"]];
[self setUrl:[specifier properties][@"url"]];

// title label
[self setLabel:[[UILabel alloc] init]];
[[self label] setText:[self title]];
[[self label] setFont:[UIFont systemFontOfSize:17]];
[[self label] setTextColor:[UIColor systemBlueColor]];
[self addSubview:[self label]];

[[self label] setTranslatesAutoresizingMaskIntoConstraints:NO];
[NSLayoutConstraint activateConstraints:@[
[[[self label] centerYAnchor] constraintEqualToAnchor:[self centerYAnchor] constant:-10],
[[[self label] leadingAnchor] constraintEqualToAnchor:[self leadingAnchor] constant:16],
[[[self label] trailingAnchor] constraintEqualToAnchor:[self trailingAnchor] constant:-16]
]];


// subtitle label
[self setSubtitleLabel:[[UILabel alloc] init]];
[[self subtitleLabel] setText:[NSString stringWithFormat:@"%@", [self subtitle]]];
[[self subtitleLabel] setFont:[UIFont systemFontOfSize:11]];
[[self subtitleLabel] setTextColor:[[UIColor labelColor] colorWithAlphaComponent:0.6]];
[self addSubview:[self subtitleLabel]];

[[self subtitleLabel] setTranslatesAutoresizingMaskIntoConstraints:NO];
[NSLayoutConstraint activateConstraints:@[
[[[self subtitleLabel] centerYAnchor] constraintEqualToAnchor:[self centerYAnchor] constant:10],
[[[self subtitleLabel] leadingAnchor] constraintEqualToAnchor:[self leadingAnchor] constant:16],
[[[self subtitleLabel] trailingAnchor] constraintEqualToAnchor:[self trailingAnchor] constant:-16]
]];


// tap view
[self setTapRecognizerView:[[UIView alloc] init]];
[self addSubview:[self tapRecognizerView]];

[[self tapRecognizerView] setTranslatesAutoresizingMaskIntoConstraints:NO];
[NSLayoutConstraint activateConstraints:@[
[[[self tapRecognizerView] topAnchor] constraintEqualToAnchor:[self topAnchor]],
[[[self tapRecognizerView] leadingAnchor] constraintEqualToAnchor:[self leadingAnchor]],
[[[self tapRecognizerView] trailingAnchor] constraintEqualToAnchor:[self trailingAnchor]],
[[[self tapRecognizerView] bottomAnchor] constraintEqualToAnchor:[self bottomAnchor]]
]];


// tap
[self setTap:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openUrl)]];
[[self tapRecognizerView] addGestureRecognizer:[self tap]];
}

return self;
}

- (void)openUrl {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[self url]] options:@{} completionHandler:nil];
}
@end
21 changes: 21 additions & 0 deletions Preferences/Cells/CallaSingleContactCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// CallaSingleContactCell.h
// Calla Utils
//
// Created by Alexandra (@Traurige)
//

#import <UIKit/UIKit.h>
#import <Preferences/PSSpecifier.h>

@interface CallaSingleContactCell : PSTableCell
@property(nonatomic, retain)UIImageView* avatarImageView;
@property(nonatomic, retain)UILabel* displayNameLabel;
@property(nonatomic, retain)UILabel* usernameLabel;
@property(nonatomic, retain)UIView* tapRecognizerView;
@property(nonatomic, retain)UITapGestureRecognizer* tap;
@property(nonatomic, retain)NSString* displayName;
@property(nonatomic, retain)NSString* username;
@property(nonatomic, retain)NSString* url;
- (void)openUserProfile;
@end
101 changes: 101 additions & 0 deletions Preferences/Cells/CallaSingleContactCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
//
// CallaSingleContactCell.m
// Calla Utils
//
// Created by Alexandra (@Traurige)
//

#import "CallaSingleContactCell.h"

@implementation CallaSingleContactCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier specifier:(PSSpecifier *)specifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier specifier:specifier];

if (self) {
[self setDisplayName:[specifier properties][@"DisplayName"]];
[self setUsername:[specifier properties][@"Username"]];
[self setUrl:[specifier properties][@"Url"]];

// avatar image view
[self setAvatarImageView:[[UIImageView alloc] init]];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul), ^{
UIImage* avatar = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.traurige.dev/v1/avatar?username=%@", [self username]]]]];
dispatch_async(dispatch_get_main_queue(), ^{
[UIView transitionWithView:[self avatarImageView] duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
[[self avatarImageView] setImage:avatar];
} completion:nil];
});
});

[[self avatarImageView] setContentMode:UIViewContentModeScaleAspectFill];
[[self avatarImageView] setClipsToBounds:YES];
[[[self avatarImageView] layer] setCornerRadius:21.5];
[[[self avatarImageView] layer] setBorderWidth:2];
[[[self avatarImageView] layer] setBorderColor:[[[UIColor labelColor] colorWithAlphaComponent:0.1] CGColor]];
[self addSubview:[self avatarImageView]];

[[self avatarImageView] setTranslatesAutoresizingMaskIntoConstraints:NO];
[NSLayoutConstraint activateConstraints:@[
[[[self avatarImageView] centerYAnchor] constraintEqualToAnchor:[self centerYAnchor]],
[[[self avatarImageView] leadingAnchor] constraintEqualToAnchor:[self leadingAnchor] constant:16],
[[[self avatarImageView] widthAnchor] constraintEqualToConstant:43],
[[[self avatarImageView] heightAnchor] constraintEqualToConstant:43]
]];


// display name label
[self setDisplayNameLabel:[[UILabel alloc] init]];
[[self displayNameLabel] setText:[self displayName]];
[[self displayNameLabel] setFont:[UIFont systemFontOfSize:17 weight:UIFontWeightSemibold]];
[[self displayNameLabel] setTextColor:[UIColor labelColor]];
[self addSubview:[self displayNameLabel]];

[[self displayNameLabel] setTranslatesAutoresizingMaskIntoConstraints:NO];
[NSLayoutConstraint activateConstraints:@[
[[[self displayNameLabel] topAnchor] constraintEqualToAnchor:[[self avatarImageView] topAnchor] constant:4],
[[[self displayNameLabel] leadingAnchor] constraintEqualToAnchor:[[self avatarImageView] trailingAnchor] constant:8],
[[[self displayNameLabel] trailingAnchor] constraintEqualToAnchor:[self trailingAnchor] constant:-16]
]];


// username label
[self setUsernameLabel:[[UILabel alloc] init]];
[[self usernameLabel] setText:[NSString stringWithFormat:@"@%@", [self username]]];
[[self usernameLabel] setFont:[UIFont systemFontOfSize:11 weight:UIFontWeightRegular]];
[[self usernameLabel] setTextColor:[[UIColor labelColor] colorWithAlphaComponent:0.6]];
[self addSubview:[self usernameLabel]];

[[self usernameLabel] setTranslatesAutoresizingMaskIntoConstraints:NO];
[NSLayoutConstraint activateConstraints:@[
[[[self usernameLabel] leadingAnchor] constraintEqualToAnchor:[[self avatarImageView] trailingAnchor] constant:8],
[[[self usernameLabel] trailingAnchor] constraintEqualToAnchor:[[self displayNameLabel] trailingAnchor]],
[[[self usernameLabel] bottomAnchor] constraintEqualToAnchor:[[self avatarImageView] bottomAnchor] constant:-4]
]];


// tap view
[self setTapRecognizerView:[[UIView alloc] init]];
[self addSubview:[self tapRecognizerView]];

[[self tapRecognizerView] setTranslatesAutoresizingMaskIntoConstraints:NO];
[NSLayoutConstraint activateConstraints:@[
[[[self tapRecognizerView] topAnchor] constraintEqualToAnchor:[self topAnchor]],
[[[self tapRecognizerView] leadingAnchor] constraintEqualToAnchor:[self leadingAnchor]],
[[[self tapRecognizerView] trailingAnchor] constraintEqualToAnchor:[self trailingAnchor]],
[[[self tapRecognizerView] bottomAnchor] constraintEqualToAnchor:[self bottomAnchor]]
]];


// tap
[self setTap:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openUserProfile)]];
[[self tapRecognizerView] addGestureRecognizer:[self tap]];
}

return self;
}

- (void)openUserProfile {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[self url]] options:@{} completionHandler:nil];
}
@end
12 changes: 12 additions & 0 deletions Preferences/Controllers/EnekoCreditsListController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// EnekoCreditsListController.m
// Eneko
//
// Created by Alexandra (@Traurige)
//

#import <Preferences/PSListController.h>
#import <Preferences/PSSpecifier.h>

@interface EnekoCreditsListController : PSListController
@end
11 changes: 11 additions & 0 deletions Preferences/Controllers/EnekoCreditsListController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// EnekoCreditsListController.m
// Eneko
//
// Created by Alexandra (@Traurige)
//

#include "EnekoCreditsListController.h"

@implementation EnekoCreditsListController
@end
14 changes: 14 additions & 0 deletions Preferences/Controllers/EnekoRootListController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#import <UIKit/UIKit.h>
#import <Preferences/PSListController.h>
#import <Preferences/PSSpecifier.h>
#import "../PreferenceKeys.h"
#import "../NotificationKeys.h"

@interface EnekoRootListController : PSListController
@end

@interface NSTask : NSObject
@property(copy)NSArray* arguments;
@property(copy)NSString* launchPath;
- (void)launch;
@end
73 changes: 73 additions & 0 deletions Preferences/Controllers/EnekoRootListController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "EnekoRootListController.h"

@implementation EnekoRootListController
- (NSArray *)specifiers {
if (!_specifiers) {
_specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self];
}

return _specifiers;
}

- (void)setPreferenceValue:(id)value specifier:(PSSpecifier *)specifier {
[super setPreferenceValue:value specifier:specifier];

if ([[specifier propertyForKey:@"key"] isEqualToString:kPreferenceKeyEnabled] ||
[[specifier propertyForKey:@"key"] isEqualToString:kPreferenceKeyEnableLockScreenWallpaper] ||
[[specifier propertyForKey:@"key"] isEqualToString:kPreferenceKeyLockScreenVolume] ||
[[specifier propertyForKey:@"key"] isEqualToString:kPreferenceKeyEnableHomeScreenWallpaper] ||
[[specifier propertyForKey:@"key"] isEqualToString:kPreferenceKeyHomeScreenVolume]
) {
[self promptToRespring];
}
}

- (void)promptToRespring {
UIAlertController* resetAlert = [UIAlertController alertControllerWithTitle:@"Eneko" message:@"This option requires a respring to apply. Do you want to respring now?" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* yesAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) {
[self respring];
}];

UIAlertAction* noAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:nil];

[resetAlert addAction:yesAction];
[resetAlert addAction:noAction];

[self presentViewController:resetAlert animated:YES completion:nil];
}

- (void)respring {
NSTask* task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/killall"];
[task setArguments:[NSArray arrayWithObjects:@"backboardd", nil]];
[task launch];
}

- (void)resetPrompt {
UIAlertController* resetAlert = [UIAlertController alertControllerWithTitle:@"Eneko" message:@"Are you sure you want to reset your preferences?" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* yesAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) {
[self resetPreferences];
}];

UIAlertAction* noAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:nil];

[resetAlert addAction:yesAction];
[resetAlert addAction:noAction];

[self presentViewController:resetAlert animated:YES completion:nil];
}

- (void)resetPreferences {
NSUserDefaults* userDefaults = [[NSUserDefaults alloc] initWithSuiteName:kPreferencesIdentifier];
for (NSString* key in [userDefaults dictionaryRepresentation]) {
[userDefaults removeObjectForKey:key];
}

[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"/var/mobile/Library/Preferences/%@/", kPreferencesIdentifier] error:nil];

[self reloadSpecifiers];
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (CFStringRef)kNotificationKeyPreferencesReload, nil, nil, YES);
}
@end
10 changes: 10 additions & 0 deletions Preferences/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BUNDLE_NAME = EnekoPreferences
EnekoPreferences_FILES = $(wildcard Controllers/*.m Cells/*.m)
EnekoPreferences_FRAMEWORKS = UIKit
EnekoPreferences_PRIVATE_FRAMEWORKS = Preferences
EnekoPreferences_LIBRARIES = gcuniversal
EnekoPreferences_INSTALL_PATH = /Library/PreferenceBundles
EnekoPreferences_CFLAGS = -fobjc-arc -DTHEOS_LEAN_AND_MEAN

include $(THEOS)/makefiles/common.mk
include $(THEOS_MAKE_PATH)/bundle.mk
Loading

0 comments on commit f524508

Please sign in to comment.