Skip to content

Commit

Permalink
update 3.5
Browse files Browse the repository at this point in the history
- New option to hide views count
- Fix save tweet as image issue
  • Loading branch information
BandarHL committed Dec 25, 2022
1 parent fb58b63 commit 3282cc3
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 25 deletions.
25 changes: 12 additions & 13 deletions BHTwitter/BHDownloadInlineButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,28 @@

@interface BHDownloadInlineButton : UIButton
{
unsigned long long _displayType;
unsigned long long _inlineActionType;
NSUInteger _displayType;
NSUInteger _inlineActionType;
T1StatusInlineActionsView *_delegate;
id _buttonAnimator;
}

+ (CGSize)buttonImageSizeUsingViewModel:(id)arg1 options:(unsigned long long)arg2 overrideButtonSize:(CGSize)arg3 account:(id)arg4;
+ (CGSize)buttonImageSizeUsingViewModel:(id)arg1 options:(NSUInteger)arg2 overrideButtonSize:(CGSize)arg3 account:(id)arg4;
@property(retain, nonatomic) id buttonAnimator;
@property(retain, nonatomic) T1StatusInlineActionsView *delegate;
@property(nonatomic) unsigned long long inlineActionType;
@property(nonatomic) unsigned long long displayType;
- (id)_t1_imageNamed:(id)arg1 fitSize:(struct CGSize)arg2 fillColor:(id)arg3;
- (void)setTouchInsets:(struct UIEdgeInsets)arg1;
@property(nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;
@property(nonatomic) NSUInteger inlineActionType;
@property(nonatomic) NSUInteger displayType;
- (void)setTouchInsets:(UIEdgeInsets)arg1;
- (id)_t1_imageNamed:(id)arg1 fitSize:(CGSize)arg2 fillColor:(id)arg3;
- (_Bool)shouldShowCount;
- (double)extraWidth;
- (unsigned long long)touchInsetPriority;
- (unsigned long long)alternateInlineActionType;
- (unsigned long long)visibility;
- (NSUInteger)touchInsetPriority;
- (NSUInteger)alternateInlineActionType;
- (NSUInteger)visibility;
- (NSString *)actionSheetTitle;
- (_Bool)enabled;
- (void)statusDidUpdate:(id)arg1 options:(NSUInteger)arg2 displayTextOptions:(NSUInteger)arg3 animated:(BOOL)arg4;
- (void)statusDidUpdate:(id)arg1 options:(NSUInteger)arg2 displayTextOptions:(NSUInteger)arg3 animated:(BOOL)arg4 featureSwitches:(id)arg5;
- (id)initWithOptions:(unsigned long long)arg1 overrideSize:(struct CGSize)arg2 account:(id)arg3;

- (instancetype)initWithOptions:(NSUInteger)arg1 overrideSize:(CGSize)arg2 account:(id)arg3;
@end

66 changes: 55 additions & 11 deletions BHTwitter/BHDownloadInlineButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ @interface BHDownloadInlineButton () <BHDownloadDelegate>
@end

@implementation BHDownloadInlineButton
+ (CGSize)buttonImageSizeUsingViewModel:(id)arg1 options:(unsigned long long)arg2 overrideButtonSize:(CGSize)arg3 account:(id)arg4 {
static const NSString *KEY_HIT_TEST_EDGE_INSETS = @"HitTestEdgeInsets";

+ (CGSize)buttonImageSizeUsingViewModel:(id)arg1 options:(NSUInteger)arg2 overrideButtonSize:(CGSize)arg3 account:(id)arg4 {
return CGSizeZero;
}

Expand All @@ -31,7 +33,7 @@ - (void)statusDidUpdate:(id)arg1 options:(NSUInteger)arg2 displayTextOptions:(NS
[self setTintColor:[UIColor colorFromHexString:@"6D6E70"]];
}
}
- (id)initWithOptions:(unsigned long long)arg1 overrideSize:(struct CGSize)arg2 account:(id)arg3 {
- (instancetype)initWithOptions:(NSUInteger)arg1 overrideSize:(CGSize)arg2 account:(id)arg3 {
self = [super initWithFrame:CGRectMake(0, 0, arg2.width, arg2.height)];
if (self != nil) {
[self setInlineActionType:80];
Expand All @@ -41,7 +43,7 @@ - (id)initWithOptions:(unsigned long long)arg1 overrideSize:(struct CGSize)arg2
}
return self;
}
- (id)_t1_imageNamed:(id)arg1 fitSize:(struct CGSize)arg2 fillColor:(id)arg3 {
- (id)_t1_imageNamed:(id)arg1 fitSize:(CGSize)arg2 fillColor:(id)arg3 {
return nil;
}
- (void)DownloadHandler:(UIButton *)sender {
Expand Down Expand Up @@ -137,46 +139,88 @@ - (void)DownloadHandler:(UIButton *)sender {
TFNMenuSheetViewController *alert = [[objc_getClass("TFNMenuSheetViewController") alloc] initWithActionItems:[NSArray arrayWithArray:actions]];
[alert tfnPresentedCustomPresentFromViewController:topMostController() animated:YES completion:nil];
}
- (void)setTouchInsets:(struct UIEdgeInsets)arg1 {
return;

- (void)setTouchInsets:(UIEdgeInsets)arg1 {
if ([self.delegate.delegate isKindOfClass:objc_getClass("T1StandardStatusInlineActionsViewAdapter")]) {
[self setImageEdgeInsets:arg1];
[self setHitTestEdgeInsets:arg1];
}
}

// https://stackoverflow.com/a/13067285
- (void)setHitTestEdgeInsets:(UIEdgeInsets)hitTestEdgeInsets {
NSValue *value = [NSValue value:&hitTestEdgeInsets withObjCType:@encode(UIEdgeInsets)];
objc_setAssociatedObject(self, &KEY_HIT_TEST_EDGE_INSETS, value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (UIEdgeInsets)hitTestEdgeInsets {
NSValue *value = objc_getAssociatedObject(self, &KEY_HIT_TEST_EDGE_INSETS);
if (value) {
UIEdgeInsets edgeInsets; [value getValue:&edgeInsets]; return edgeInsets;
} else {
return UIEdgeInsetsZero;
}
}

- (bool)enabled {
return true;
}

- (NSString *)actionSheetTitle {
return @"BHDownload";
}
- (unsigned long long)visibility {

- (NSUInteger)visibility {
return 1;
}
- (unsigned long long)alternateInlineActionType {

- (NSUInteger)alternateInlineActionType {
return 6;
}
- (unsigned long long)touchInsetPriority {

- (NSUInteger)touchInsetPriority {
return 2;
}

- (double)extraWidth {
return 48;
return 40;
}

- (bool)shouldShowCount {
return false;
}
- (unsigned long long)displayType {

- (NSUInteger)displayType {
return self->_displayType;
}
- (unsigned long long)inlineActionType {

- (NSUInteger)inlineActionType {
return self->_inlineActionType;
}

- (T1StatusInlineActionsView *)delegate {
return self->_delegate;
}

- (id)buttonAnimator {
return self->_buttonAnimator;
}

- (void)downloadProgress:(float)progress {
self.hud.detailTextLabel.text = [BHTManager getDownloadingPersent:progress];
}

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
if (UIEdgeInsetsEqualToEdgeInsets(self.hitTestEdgeInsets, UIEdgeInsetsZero) || !self.enabled || self.hidden) {
return [super pointInside:point withEvent:event];
}

CGRect relativeFrame = self.bounds;
CGRect hitFrame = UIEdgeInsetsInsetRect(relativeFrame, self.hitTestEdgeInsets);

return CGRectContainsPoint(hitFrame, point);
}

- (void)downloadDidFinish:(NSURL *)filePath Filename:(NSString *)fileName {
NSString *DocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true).firstObject;
NSFileManager *manager = [NSFileManager defaultManager];
Expand Down
1 change: 1 addition & 0 deletions BHTwitter/BHTManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@
+ (BOOL)alwaysOpenSafari;
+ (BOOL)hideWhoToFollow;
+ (BOOL)hideTopicsToFollow;
+ (BOOL)hideViewCount;
@end

3 changes: 3 additions & 0 deletions BHTwitter/BHTManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ + (BOOL)hideWhoToFollow {
+ (BOOL)hideTopicsToFollow {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hide_topics_to_follow"];
}
+ (BOOL)hideViewCount {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hide_view_count"];
}

+ (UIViewController *)BHTSettingsWithAccount:(TFNTwitterAccount *)twAccount {
SettingsViewController *pref = [[SettingsViewController alloc] initWithTwitterAccount:twAccount];
Expand Down
8 changes: 8 additions & 0 deletions BHTwitter/BHTwitter.xm
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@
tweetView = [(T1StandardStatusView *)actionsView.superview eventHandler];
} else if ([actionsView.superview isKindOfClass:%c(T1TweetDetailsFocalStatusView)]) { // Focus tweet
tweetView = [(T1TweetDetailsFocalStatusView *)actionsView.superview eventHandler];
} else if ([actionsView.superview isKindOfClass:%c(T1ConversationFocalStatusView)]) { // Focus tweet
tweetView = [(T1ConversationFocalStatusView *)actionsView.superview eventHandler];
} else {
return %orig;
}
Expand Down Expand Up @@ -487,6 +489,8 @@
tweetView = [(T1StandardStatusView *)actionsView.superview eventHandler];
} else if ([actionsView.superview isKindOfClass:%c(T1TweetDetailsFocalStatusView)]) { // Focus tweet
tweetView = [(T1TweetDetailsFocalStatusView *)actionsView.superview eventHandler];
} else if ([actionsView.superview isKindOfClass:%c(T1ConversationFocalStatusView)]) { // Focus tweet
tweetView = [(T1ConversationFocalStatusView *)actionsView.superview eventHandler];
} else {
return %orig;
}
Expand Down Expand Up @@ -518,6 +522,10 @@
[newOrig addObject:%c(BHDownloadInlineButton)];
}

if ([newOrig containsObject:%c(TTAStatusInlineAnalyticsButton)] && [BHTManager hideViewCount]) {
[newOrig removeObject:%c(TTAStatusInlineAnalyticsButton)];
}

return [newOrig copy];
}
%end
Expand Down
2 changes: 1 addition & 1 deletion BHTwitter/Package/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: com.bandarhl.BHTwitter
Name: BHTwitter
Version: 3.4
Version: 3.5
Description: Awesome tweak for Twitter
Section: Tweaks
Depends: firmware (>= 13.0), mobilesubstrate, ws.hbang.common (>= 1.17)
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
"ORIG_TWEET_STYLE_OPTION_TITLE" = "تعطيل النمط الجديد للتغريدة";
"ORIG_TWEET_STYLE_OPTION_DETAIL_TITLE" = "إجبار التطبيق على استخدام النمط الأساسي";

"HIDE_VIEW_COUNT_OPTION_TITLE" = "إخفاء عدد مُشاهدة التغريدة";
"HIDE_VIEW_COUNT_OPTION_DETAIL_TITLE" = "إزالة عدد المُشاهدات من التغريدة";

"FONT_OPTION_TITLE" = "تفعيل تغيير خط التطبيق";
"FONT_OPTION_DETAIL_TITLE" = "خيار لتفعيل تغيير خط تويتر";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
"ORIG_TWEET_STYLE_OPTION_TITLE" = "Disable edge to edge tweet style";
"ORIG_TWEET_STYLE_OPTION_DETAIL_TITLE" = "Force Twitter to use the original tweet style.";

"HIDE_VIEW_COUNT_OPTION_TITLE" = "Hide view count";
"HIDE_VIEW_COUNT_OPTION_DETAIL_TITLE" = "Remove view count from tweet";

"FONT_OPTION_TITLE" = "Enable changing font";
"FONT_OPTION_DETAIL_TITLE" = "Option to allow changing Twitter font and show font picker.";

Expand Down
3 changes: 3 additions & 0 deletions BHTwitter/SettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ - (NSArray *)specifiers {
// Layout customization section
PSSpecifier *origTweetStyle = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"ORIG_TWEET_STYLE_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"ORIG_TWEET_STYLE_OPTION_DETAIL_TITLE"] key:@"old_style" defaultValue:true changeAction:nil];

PSSpecifier *hideViewCount = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"HIDE_VIEW_COUNT_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"HIDE_VIEW_COUNT_OPTION_DETAIL_TITLE"] key:@"hide_view_count" defaultValue:false changeAction:nil];

PSSpecifier *font = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"FONT_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"FONT_OPTION_DETAIL_TITLE"] key:@"en_font" defaultValue:false changeAction:nil];

PSSpecifier *regularFontsPicker = [self newButtonCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"REQULAR_FONTS_PICKER_OPTION_TITLE"] detailTitle:[[NSUserDefaults standardUserDefaults] objectForKey:@"bhtwitter_font_1"] dynamicRule:@"en_font, ==, 0" action:@selector(showRegularFontPicker:)];
Expand Down Expand Up @@ -249,6 +251,7 @@ - (NSArray *)specifiers {

layoutSection, // 2
origTweetStyle,
hideViewCount,
font,
regularFontsPicker,
boldFontsPicker,
Expand Down
4 changes: 4 additions & 0 deletions BHTwitter/TWHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@
@property(nonatomic) __weak id <TTACoreStatusViewEventHandler> eventHandler;
@end

@interface T1ConversationFocalStatusView : UIView
@property(nonatomic) __weak id <TTACoreStatusViewEventHandler> eventHandler;
@end

@interface TFNButtonBarView : UIView
@property(nonatomic) double trailingViewsSpacing;
@property(nonatomic) double leadingViewsSpacing;
Expand Down

0 comments on commit 3282cc3

Please sign in to comment.