Thursday, October 2, 2014

[Requirement]Beautiful Custom AlertView

Preview TUT
Requirements:
    -Theos
    -Files (download below)
    -Brain
1) DOWNLOAD FILES:
    - Download this if you want make an in-app Hack Manager + Alert: https://www.sendspace.com/file/6q63ch
    - Download this if you want make just a cool Alert: https://www.sendspace.com/file/7tuii9

Note: if you will use config.h to write your hack in Tweak.xm file, download the first pack.

Then, move the files:

If you downloaded the first pack
    -Put "cploaderheader.h", "config.h" and "Tweak.xm" in your project folder.
    -Put "libalertview.a" in /var/theos/lib
   
If you downloaded the second pack:
    -Put "cploaderheader.h" and "Tweak.xm" in your project folder.
    -Put "libalertview.a" in /var/theos/lib
   
2) Edit the Makefile

Add these strings in your Makefile under "XXX_FILES = Tweak.xm"


1
2
      AlertTest_FRAMEWORKS = UIKit OpenGLES QuartzCore CoreGraphics CoreImage
AlertTest_LDFLAGS = -O3 -DALT_RELEASE -lalertview

3) Let's analyze and Edit the code!

Open cploaderheader.h file

This is the list of usable types of buttons (colors)


 1
2
3
4
5
6
7
8
9
10
11
typedef NS_ENUM(NSInteger, SIAlertViewButtonType) {
SIAlertViewButtonTypeDefault = 0,
SIAlertViewButtonTypeDestructive,
SIAlertViewButtonTypeCancel,
SIAlertViewButtonTypeWarm,
SIAlertViewButtonTypeBlue,
SIAlertViewButtonTypeGreen,
SIAlertViewButtonTypePurple,
SIAlertViewButtonTypeYellow,
SIAlertViewButtonTypePink
};

This is the list of usable types of effects to close the alert (popup)


1
2
3
4
5
6
7
typedef NS_ENUM(NSInteger, SIAlertViewTransitionStyle) {
SIAlertViewTransitionStyleSlideFromBottom = 0,
SIAlertViewTransitionStyleSlideFromTop,
SIAlertViewTransitionStyleFade,
SIAlertViewTransitionStyleBounce,
SIAlertViewTransitionStyleDropDown
};
   
This is where you can set all effects, colors, countdown, actions, tags...


 1
2
3
4
5
6
7
8
9
10
void didFinishLaunching2(CFNotificationCenterRef center,void *observer,CFStringRef name, const void *object, CFDictionaryRef info) 
//if you are using just alert files pack, this line will be a little different. Don't worry and don't change the original one
{
AlertView* a = [[AlertView alloc]initWithTitle:title2 andMessage:message2 backgroundblurRate:1.8f
enableCountdown:YES countdown:100 alertviewAlpha:0.6F AnimationType:SIAlertViewTransitionStyleSlideFromTop];
[a addButtonWithTitle:@"1 Shot Kill" type:SIAlertViewButtonTypeGreen handler:button_call_back id:1];
[a addButtonWithTitle:@"God Mode" type:SIAlertViewButtonTypeYellow handler:button_call_back id:2];
[a addButtonWithTitle:@"Donate" type:SIAlertViewButtonTypeBlue handler:button_call_back id:3];
[a show];
}

EDIT THE ALERT
   
What you can edit in the alert:
   
    -backgroundblurRate:1.8f  ----> This is used to set blur the background image below the alert
    -enableCountdown:YES ----> This is used to enable(YES)/disable(NO) the countdown. If enabled, a countdown will appear at the top of alert (it's an animated countdown that each second change color)
    -countdown:100 ----> After 100 second the alert will auto hide (Obviously works just if you enabled the countdown)
    -alertviewAlpha:0.6F ----> This is the transparency of alert
    -AnimationType:SIAlertViewTransitionStyleSlideFromTop ----> This is the effect used to close the popup (you can change it with one of the effects written in the "Let's analyze the code!" part)
 What you can edit for each button:
    -addButtonWithTitle:@"1 Shot Kill" ----> 1 Shot Kill is the title of button
    -type:SIAlertViewButtonTypeGreen ----> This is the type (color) of button (you can change it with one of the effects written in the "Let's analyze the code!" part)
    -handler:button_call_back ----> We will see later what it's
    -id:1 ----> all buttons with the same id (tag) and the same handler will do the same action (a lot of "same" :o). So change the number after "id" if you want use another action

What you can add:
   
    -Before [a show]; you can add some things to customize colors, fonts ecc
    -[a setTitleColor:[UIColor redColor]];//don't use it if you are using Countdown because the app will crash
    -[a setMessageColor:[UIColor redColor]];
    -[a setTitleFont:[UIFont fontWithName:@"Verdana" size:25.0f]];  //Allowed fonts = http://support.apple.com/en-us/ht5878
    -[a setMessageFont:[UIFont fontWithName:@"Verdana" size:25.0f]];  //Allowed fonts = http://support.apple.com/en-us/ht5878
    -[a setShadowRadius:4];
   
This is the function to assign to each button an action


1
2
3
4
5
6
7
8
9
        bool button_call_back(int Tag,UIButton* a)
{
if(Tag == 1)
{
//here the code for the action
return NO;
}
return YES;
}
   
Edit/Add action for button

Some explanations:

    -button_call_back ----> you can edit this, but must be the same in "handler"
    -if(Tag == 1) ----> check the Tag. The Tag is the id used in the button function. So all buttons with id:1 will do the following action
    -return NO; ----> when you click the button, the alert WON'T hide
    -return YES; ----> when you click the button, the alert WILL hide

Obviously instead "//here the code for the action" put your action code. Examples:


1
2
CNWrite(CNAddr(0xIDAOffset),"HackedHex"); //to use the button to apply an hack
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"www.xxx.com"]]; //to open an url in safari

Obviously2 you can add more "if(Tag == X)":


 1
2
3
4
5
6
7
8
9
10
11
12
13
14
        bool button_call_back(int Tag,UIButton* a)
{
if(Tag == 1)
{
//here the code for the action1
return NO;
}
if(Tag == 2)
{
//here the code for the action2
return NO;
}
return YES; //all other buttons that haven't id:1 or id:2 will use return YES; so they will close the popup
}
   
ADD THE ALERT IN YOUR TWEAK

Open your Tweak.xm and add this at the top:


 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <Foundation/Foundation.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#import <AdSupport/ASIdentifierManager.h>
#import <mach/mach.h>
#include <mach-o/dyld.h>
#import <mach/mach_traps.h>
#include <time.h>
#include <fcntl.h>
#include <mach-o/dyld.h>
#include <mach-o/ldsyms.h>
#include <sys/stat.h>
#include <cploaderheader.h>

CNConstructor(SexyAss)
{
init_alertview(@"AlertTitle",@"AlertMessage");
}

//here the rest of your hack/tweak code (if you have more)
//if you will use config.h to inject. add #include <config.h> at the top of Tweak.xm and add the file in your project folder
   
NOTE: - DON'T include config.h in your Tweak.xm because it's already included in cploaderheader.h file ---> if you download the first pack
      - Include config.h in your Tweak.xm if you will need it to code inject or what else ---> if you download the second pack

     
Some Example Codes:
    -AlertExample: https://www.sendspace.com/file/cptewd
    -HackManagerExample: https://www.sendspace.com/file/p30qql

Great TUT from Supergiu and caoyin

0 comments:

Post a Comment