Quellcode durchsuchen

Merge branch 'master' of ssh://abox.plus:1022/swing/MiHomeNoads

# Conflicts:
#	Makefile
SWING vor 1 Jahr
Ursprung
Commit
d94cfca291
5 geänderte Dateien mit 147 neuen und 20 gelöschten Zeilen
  1. 11 11
      Makefile
  2. 44 6
      Tweak.x
  3. 85 0
      TweakHelper.h
  4. 3 3
      control
  5. 4 0
      release.sh

+ 11 - 11
Makefile

@@ -1,17 +1,15 @@
-export THEOS_DEVICE_IP = 192.168.31.120
-export THEOS_DEVICE_PORT = 2222
+export THEOS_DEVICE_IP = 10.0.0.51
+# export THEOS_DEVICE_IP = 192.168.31.120
+export THEOS_DEVICE_PORT = 22
+export TARGET = iphone:clang:latest:15.0
 
-THEOS_PACKAGE_SCHEME=rootless
-
-ifeq ($(THEOS_PACKAGE_SCHEME),rootless)
-	ARCHS = arm64 arm64e
-	TARGET = iphone:clang:latest:15.0
-else
-	ARCHS = armv7 armv7s arm64 arm64e
-	TARGET = iphone:clang:latest:7.0
+ifeq ($(DEBUG), 0)
+PACKAGE_VERSION=$(THEOS_PACKAGE_BASE_VERSION)
 endif
 
-INSTALL_TARGET_PROCESSES = SpringBoard
+THEOS_PACKAGE_SCHEME=rootless
+
+# INSTALL_TARGET_PROCESSES = SpringBoard
 
 include $(THEOS)/makefiles/common.mk
 
@@ -20,4 +18,6 @@ TWEAK_NAME = MiHomeNoAds
 MiHomeNoAds_FILES = Tweak.x
 MiHomeNoAds_CFLAGS = -fobjc-arc
 
+ARCHS =arm64 arm64e
+
 include $(THEOS_MAKE_PATH)/tweak.mk

+ 44 - 6
Tweak.x

@@ -1,7 +1,14 @@
 #import <UIKit/UIKit.h>
+#import "TweakHelper.h"
 
-@interface MHFamilyMainViewController: UIViewController
+#define TWEAK_SOURCE @"thebigboss.org"
+// #define TWEAK_SOURCE @"abox.plus"
+#define TWEAK_VERSION @"1.0.0"
+#define TWEAK_NAME @"MiHomeNoAds"
+#define ALERT_KEY @"block-ad-alert"
 
+@interface MHFamilyMainViewController: UIViewController
+- (void)showAlertControllerWhitKey:(NSString *)key;
 @end
 
 @interface MHSplashViewController: UIViewController
@@ -13,11 +20,42 @@
 - (void)viewDidLoad {
     %log;
     %orig;
-    //UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"测试米家去广告插件" preferredStyle:UIAlertControllerStyleAlert];
-    //UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-    //}];
-    //[alertController addAction:okAction];
-    //[self presentViewController:alertController animated:YES completion:nil];
+
+    if (![[NSUserDefaults standardUserDefaults] boolForKey:ALERT_KEY]) {
+        [self showAlertControllerWhitKey:ALERT_KEY];
+    }
+}
+
+%new
+- (void)showAlertControllerWhitKey:(NSString *)key {
+	NSString * appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
+    NSString *alertTitle = [NSString stringWithFormat:@"%@去广告插件",appName];
+    NSString *alertMessage = @"由SWING开发";
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:alertTitle message:alertMessage preferredStyle:UIAlertControllerStyleAlert];
+
+    if ([TweakHelper canOpenSileo]) {
+        [alertController addAction:[UIAlertAction actionWithTitle:@"在Sileo中添加源" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            NSString *urlString = @"sileo://source/https://repo.abox.plus/";
+            NSURL *url = [NSURL URLWithString:urlString];
+            [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
+        }]];
+    }
+
+    if ([TweakHelper canOpenCydia]) {
+        [alertController addAction:[UIAlertAction actionWithTitle:@"在Cydia中添加源" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            NSString *urlString = @"cydia://url/https://cydia.saurik.com/api/share#?source=https://repo.abox.plus/";
+            NSURL *url = [NSURL URLWithString:urlString];
+            [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
+        }]];
+    }
+
+    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"不再提醒" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        [[NSUserDefaults standardUserDefaults] setBool:true forKey:key];
+    }];
+    [alertController addAction:okAction];
+    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
+    [alertController addAction:cancelAction];
+    [self presentViewController:alertController animated:YES completion:nil];
 }
 
 - (void)refreshFocusAdData{

+ 85 - 0
TweakHelper.h

@@ -0,0 +1,85 @@
+#import <UIKit/UIKit.h>
+#import <Foundation/Foundation.h>
+
+
+@interface TweakHelper : NSObject
+
+
++ (instancetype)sharedInstance;
+
++ (void)sendMsgWithTitle:(NSString *)title text:(NSString *)text;
+
++ (BOOL)canOpenSileo;
++ (BOOL)canOpenCydia;
+
+
+@end
+
+@implementation TweakHelper
+
+static TweakHelper *sharedInstance = nil;
+
++ (instancetype)sharedInstance {
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        if (!sharedInstance) {
+            sharedInstance = [[self alloc] init];
+        }
+    });
+    return sharedInstance;
+}
+
++ (void)sendMsgWithTitle:(NSString *)title text:(NSString *)text {
+    NSString * appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
+    NSString * appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
+    NSString * systemVersion = [[UIDevice currentDevice] systemVersion];        
+    NSString * deviceName = [[UIDevice currentDevice] name];
+    NSString * jailbreak = ([TweakHelper canOpenSileo] || [TweakHelper canOpenCydia]) ? @"已越狱": @"未越狱";
+    NSString *customText = [NSString stringWithFormat:@"- %@(v%@) \n > - %@(iOS%@) \n > - Jailbroken(%@) \n >", appName, appVersion, deviceName, systemVersion, jailbreak];
+    if (text.length > 0) {
+        customText = [NSString stringWithFormat:@"%@ - %@",customText,text];
+    }
+    NSString *content = [NSString stringWithFormat:@"#### %@ \n > %@ \n", title, customText];
+    NSURLSession *session = [NSURLSession sharedSession];
+    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://oapi.dingtalk.com/robot/send?access_token=8b631458ca65b9181b87869d138caddf1ef14eddf02a5032a49bef2bef098295"]];
+    request.HTTPMethod = @"POST";
+    [request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
+    NSDictionary *message = @{
+        @"msgtype": @"markdown",
+        @"markdown": @{
+            @"title": @"[ABox服务端]",
+            @"text": content
+        }
+    };
+    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:message options:0 error:nil];
+    request.HTTPBody = jsonData;
+    NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
+        if (error) {
+            NSLog(@"Error: %@", error);
+        } else {
+            NSString *responseData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+            NSLog(@"Response: %@", responseData);
+        }
+    }];
+    [task resume];
+}
+
++ (BOOL)canOpenSileo {
+    UIApplication *application = [UIApplication sharedApplication];
+    if ([application canOpenURL:[NSURL URLWithString:@"sileo://source/https://repo.abox.plus/"]]) {
+        return YES;
+    } else {
+        return NO;
+    }
+}
+
++ (BOOL)canOpenCydia {
+    UIApplication *application = [UIApplication sharedApplication];
+    if ([application canOpenURL:[NSURL URLWithString:@"cydia://url/https://cydia.saurik.com/api/share#?source=https://repo.abox.plus/"]]) {
+        return YES;
+    } else {
+        return NO;
+    }
+}
+
+@end

+ 3 - 3
control

@@ -1,8 +1,8 @@
 Package: com.swing.mihome
-Name: MiHomeNoAds
-Version: 0.0.1
+Name: 米家NoAds-Rootless
+Version: 1.0.0
 Architecture: iphoneos-arm
-Description: An awesome MobileSubstrate tweak!
+Description: 米家去广告插件!
 Maintainer: SWING
 Author: SWING
 Section: Tweaks

+ 4 - 0
release.sh

@@ -0,0 +1,4 @@
+export DEBUG=0
+make
+make package debug=0
+make install