Screen


Screen은 3.0.0 버전 이상 부터 제공되며 해당 라이브러리를 추가하여 사용해야 된다.

Screen 는 디바이스의 화면 밝기 제어 및 화면 캡처 기능을 제공한다.
확장 프레임워크 파일을 추가하여 사용할 수 있으며 추가 방법은 iOS 개발 가이드 의 내용을 참조한다.


brightness

화면 밝기 설정 기능이며 호출 방법은 다음과 같다. 0~100 범위로 밝기를 설정할 수 있다.

 

Example

///////////////
// 3.10.18 이상
///////////////
let deviceAPI = DAPScreen()
let infoParam = DAPScreenBrightnessParam()
let calcValue = (Int)(value * 100)
infoParam.value = NSNumber(value: calcValue)
deviceAPI.execute(with: infoParam, completion: { (dict) in
}, failure: { (resultError) in
   guard let error = resultError else {
       return
    }
   
})


///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPScreen()
let params = [value * 100]
deviceAPI.execute(withActionName: "brightness", params: params, completion: { (dict) in
}, failure: { (resultError) in
   guard let error = resultError else {
       return
    }
   
})

///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPScreen new];
DAPScreenBrightnessParam *infoParam = [DAPScreenBrightnessParam new];
infoParam.value = [NSNumber numberWithInt:70];
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
    NSLog(@"%@", resultDict);
} failure:^(NSError *error) {
    [self showErrorDlgWithError:error];
}];


///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPScreen new];
NSArray *params = [NSArray arrayWithObjects:[NSNumber numberWithInt:70], nil];
[deviceAPI executeWithActionName:@"brightness" params:params completion:^(NSDictionary *resultDict) {
    NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
    NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];

capture

capture 는 3.6.12 버전 이상 부터 제공되며 해당 라이브러리를 추가하여 사용해야 된다.

capture 는 현재 구동중인 앱의 화면을 기준으로 이미지 파일을 생성하고 그 이미지 경로를 전달하도록 설계 되었으며 capture 이미지 내에 워터 마크를 추가할 수도 있다.
워터 마크가 추가되었을 경우에는 오른쪽 하단으로 위치가 고정되며 워터마크의 크기나 마진 값은 사용자가 워터 마크 이미지를 통해 조절할 수 있다.
capture 를 위해서 필요한 인자는 아래와 같으며 해당 인자는 Optional 한 값이므로 입력하지 않아도 무방하다.

스크린샷 2018-11-06 오전 10.42.38.png

인자 정보

NameDescriptions
watermarkPathcapture 화면에 표기할 워터마크 이미지의 경로로 ‘비즈앱 아이디 / 세부경로’ 로 이루어진다. 예) main/watermark/mark.png
  

capture 이미지의 저장 경로는 /appname/Library/honemobile/ScreenCapture/ (플러그인에서 사용하는 기본 경로이다. 앱의 라이브러리 폴더에 저장 된다.) 이고 파일명은 timestamp 형태로 생성하여 PNG 포맷에 이미지 퀄리티는 100으로 저장한 뒤 그 경로를 반환 한다.
이때 capture 에 대상이 되는 View 는 현재 보여지고 있는 RootViewController 화면을 캡쳐 하도록 구현되어 있다.
기본 Root 화면을 캡쳐를 하기 때문에 커스텀 영역 및 Window 화면 모두 캡쳐가 가능하다.

Example

///////////////
// 3.10.18 이상
///////////////
let api = DAPScreen()
let param = DAPScreenCaptureParam()
param.watermarkPath = "main/icon.png"
api.execute(with: param, completion: { (dict) in
   
}) { (resultError) in
   
}


///////////////
// 3.10.18 이하
///////////////
let api = DAPScreen()
let params = ["main/icon.png"]
api.execute(withActionName: "capture", params: params, completion: { (dict) in
   guard let resultDict = dict else {
       return
    }

}) { (resultError) in
   guard let error = resultError else {
       return
    }
}

///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPScreen new];
DAPScreenCaptureParam *infoParam = [DAPScreenCaptureParam new];
infoParam.watermarkPath = @"main/icon.png";
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
    NSLog(@"%@", resultDict);
} failure:^(NSError *error) {
    [self showErrorDlgWithError:error];
}];


///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPScreen new];
NSArray *params = [NSArray arrayWithObjects:@"main/icon.png", nil];
[deviceAPI executeWithActionName:@"capture" params:params completion:^(NSDictionary *resultDict) {
    NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
    NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];