Lockscreen


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

Lockscreen 은 HSP 에서 확장 라이브러리로 제공하는 API 로 aar 라이브러리 파일과 build.gradle 파일을 수정하여 사용할 수 있다. 

라이브러리 추가 방법은 Android 개발 가이드의 내용을 참조하면 된다.

Lockscreen 은 보안을 위해 앱에 화면을 점유 하고 설정한 비밀번호가 맞을 경우에 만 화면을 복구하는 기능을 가지고 있으며, Optional 한 기능이므로 사용자가 별도로 개발하여 사용해도 무방하다. 


hasPincode

hasPincode 는 비밀번호가 설정되어 있는지 알아보는 method 이며 비밀번호가 설정 되어있을 경우 true 를 아닐 경우 false 를 반환 한다. 

Example

// 3.10.18 이상
DAPLockscreen.hasPincode(activity, {
   // TODO
}) {
   // TODO
}

// 3.10.18 이하
val hasPincode = DAPLockscreen.hasPincode(activity)
// 3.10.18 이상
DAPLockscreen.hasPincode(activity, result -> {
       // TODO
   }, e -> {
       // TODO
   })

// 3.10.18 이하
if (DAPLockscreen.hasPincode(activity)) {
   // TODO
} else {
   // TODO
}

createPincode

createPincode 는 비밀번호를 설정하기 위해 다이얼이 있는 창을 띄운다. 

Example

// 3.10.18 이상
DAPLockscreen.createPincode(activity, {
   // TODO
}) {
   // TODO
}

// 3.10.18 이하
DAPLockscreen.createPincode(activity) { requestCode, resultCode, intent ->
   // TODO
}
// 3.10.18 이상
DAPLockscreen.createPincode(activity, , result -> {
       // TODO
   }, e -> {
       // TODO
   });

// 3.10.18 이하
DAPLockscreen.createPincode(activity, (requestCode, resultCode, intent) -> {
   // TODO
});

show

show 는 설정 되어 있는 비밀번호를 확인하기 위해 다이얼이 있는 창을 띄운다. 

Example

// 3.10.18 이상
DAPLockscreen.show(activity, {
   // TODO
}) {
   // TODO
}

// 3.10.18 이하
DAPLockscreen.show(activity) { requestCode, resultCode, intent ->
   // TODO
}
// 3.10.18 이상
DAPLockscreen.show(activity, result -> {
       // TODO
   }, e -> {
       // TODO
   });

// 3.10.18 이하
DAPLockscreen.show(activity, (requestCode, resultCode, intent) -> {
   // TODO
});

changePincode

changePincode 설정 되어 있는 비밀번호를 변경하기 위해 다이얼이 있는 창을 띄운다. 

Example

// 3.10.18 이상
DAPLockscreen.changePincode(activity, {
   // TODO
}) {
   // TODO
}

// 3.10.18 이하
DAPLockscreen.changePincode(activity) { requestCode, resultCode, intent ->
   // TODO
}
// 3.10.18 이상
DAPLockscreen.changePincode(activity, result -> {
       // TODO
   }, e -> {
       // TODO
   });

// 3.10.18 이하
DAPLockscreen.changePincode(activity, (requestCode, resultCode, intent) -> {
   // TODO
});

기본 Layout

Lockscreen 은 hone_lockscreen_main.xml 을 이용하여 레이아웃을 구성하고 있으며 해당 파일 App 단에서 생성하여 UI 를 변경할 수 있다. 

hone_lockscreen_main.xml

<RelativeLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="@drawable/hone_lockscreen_main_background">

   <ImageView
       android:id="@+id/lock_icon"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentTop="true"
       android:layout_centerHorizontal="true"
       android:layout_marginTop="@dimen/hone_lockscreen_lock_icon_margin_top"
       android:src="@drawable/hone_lockscreen_ic_https_white_45dp"/>

   <TextView
       android:id="@+id/message"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/lock_icon"
       android:layout_centerHorizontal="true"
       android:layout_marginTop="@dimen/hone_lockscreen_message_margin_top"
       android:text="@string/hone_lockscreen_enter_your_pincode"
       android:textColor="@android:color/white"
       android:textSize="@dimen/hone_lockscreen_message_size"/>

   <LinearLayout
       android:id="@+id/dot_layout"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/message"
       android:layout_centerHorizontal="true"
       android:layout_marginTop="@dimen/hone_lockscreen_dot_layout_margin_top"
       android:orientation="horizontal">

       <ImageView
           android:id="@+id/pin1"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginRight="@dimen/hone_lockscreen_pin_margin_right"
           android:src="@drawable/hone_lockscreen_ic_dot_disable_24dp"/>
       <ImageView
           android:id="@+id/pin2"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginRight="@dimen/hone_lockscreen_pin_margin_right"
           android:src="@drawable/hone_lockscreen_ic_dot_disable_24dp"/>
       <ImageView
           android:id="@+id/pin3"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginRight="@dimen/hone_lockscreen_pin_margin_right"
           android:src="@drawable/hone_lockscreen_ic_dot_disable_24dp"/>
       <ImageView
           android:id="@+id/pin4"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/hone_lockscreen_ic_dot_disable_24dp"/>
   </LinearLayout>

   <RelativeLayout
       android:id="@+id/number_layout"
       android:layout_marginLeft="@dimen/hone_lockscreen_number_layout_margin_hor"
       android:layout_marginRight="@dimen/hone_lockscreen_number_layout_margin_hor"
       android:layout_marginBottom="@dimen/hone_lockscreen_number_layout_margin_bottom"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_centerHorizontal="true"
       android:layout_alignParentBottom="true">

       <TextView
           android:id="@+id/num_1"
           android:text="1"
           style="@style/hone_lockscreen_number" />

       <TextView
           android:id="@+id/num_2"
           android:text="2"
           style="@style/hone_lockscreen_number"
           android:layout_centerHorizontal="true" />

       <TextView
           android:id="@+id/num_3"
           android:text="3"
           style="@style/hone_lockscreen_number"
           android:layout_alignParentRight="true" />

       <TextView
           android:id="@+id/num_4"
           android:text="4"
           style="@style/hone_lockscreen_number"
           android:layout_below="@+id/num_1" />

       <TextView
           android:id="@+id/num_5"
           android:text="5"
           android:layout_below="@+id/num_2"
           style="@style/hone_lockscreen_number"
           android:layout_centerHorizontal="true" />

       <TextView
           android:id="@+id/num_6"
           android:text="6"
           android:layout_below="@+id/num_3"
           style="@style/hone_lockscreen_number"
           android:layout_alignParentRight="true" />

       <TextView
           android:id="@+id/num_7"
           android:text="7"
           android:layout_below="@+id/num_4"
           style="@style/hone_lockscreen_number" />

       <TextView
           android:id="@+id/num_8"
           android:text="8"
           android:layout_below="@+id/num_5"
           style="@style/hone_lockscreen_number"
           android:layout_centerHorizontal="true" />

       <TextView
           android:id="@+id/num_9"
           android:text="9"
           android:layout_below="@+id/num_6"
           style="@style/hone_lockscreen_number"
           android:layout_alignParentRight="true" />

       <TextView
           android:id="@+id/num_0"
           android:text="0"
           android:layout_below="@+id/num_8"
           style="@style/hone_lockscreen_number"
           android:layout_centerHorizontal="true" />

       <ImageView
           android:id="@+id/back"
           style="@style/hone_lockscreen_number"
           android:src="@drawable/hone_lockscreen_ic_arrow_back_white_24dp"
           android:layout_below="@+id/num_9"
           android:layout_marginTop="@dimen/hone_lockscreen_number_back_margin_top"
           android:layout_alignParentRight="true" />

   </RelativeLayout>
</RelativeLayout>