Skip to content

Commit

Permalink
camera sample (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
oblomov-dev authored Nov 24, 2024
1 parent a354efd commit 7a0aa4d
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/z2ui5_cl_demo_app_000.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,13 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel->generic_tile(
header = 'Camera'
subheader = ''
press = client->_event( 'z2ui5_cl_demo_app_306' )
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

* panel->generic_tile(
* header = 'Camera & Picture'
Expand Down
121 changes: 121 additions & 0 deletions src/z2ui5_cl_demo_app_306.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
CLASS z2ui5_cl_demo_app_306 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.
INTERFACES z2ui5_if_app.

TYPES:
BEGIN OF ty_picture,
time TYPE string,
id TYPE string,
name TYPE string,
data TYPE string,
selected type abap_bool,
END OF ty_picture.

DATA mt_picture TYPE STANDARD TABLE OF ty_picture WITH EMPTY KEY.
DATA mt_picture_out TYPE STANDARD TABLE OF ty_picture WITH EMPTY KEY.
DATA mv_pic_display TYPE string.
DATA mv_check_init TYPE abap_bool.
DATA mv_picture_base TYPE string.

PROTECTED SECTION.

METHODS view_display
IMPORTING
client TYPE REF TO z2ui5_if_client.

PRIVATE SECTION.
ENDCLASS.



CLASS z2ui5_cl_demo_app_306 IMPLEMENTATION.


METHOD view_display.

DATA(view) = z2ui5_cl_xml_view=>factory( ).

DATA(cont) = view->shell( ).
DATA(page) = cont->page( title = 'abap2UI5 - Device Camera Picture'
navbuttonpress = client->_event( 'BACK' )
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL )
)->header_content(
)->link( text = 'Source_Code' target = '_blank'
)->get_parent( ).

page->_z2ui5( )->camera_picture(
value = client->_bind_edit( mv_picture_base )
onphoto = client->_event( 'CAPTURE' )
).

page->list(
headertext = 'List Ouput'
items = client->_bind_edit( mt_picture_out )
mode = `SingleSelectMaster`
selectionchange = client->_event( 'DISPLAY' )
)->standard_list_item(
title = '{NAME}'
description = '{NAME}'
icon = '{ICON}'
info = '{INFO}'
selected = `{SELECTED}`
).

IF mv_pic_display IS NOT INITIAL.
page->_generic( ns = 'html' name = 'center'
)->_generic( ns = 'html' name = 'img' t_prop = value #(
( n = 'src' v = mv_pic_display )
) ).
ENDIF.

client->view_display( view->stringify( ) ).

ENDMETHOD.


METHOD z2ui5_if_app~main.

IF mv_check_init = abap_false.
mv_check_init = abap_true.

view_display( client ).
* client->view_display( z2ui5_cl_xml_view=>factory(
* )->_generic( ns = `html` name = `script` )->_cc_plain_xml( z2ui5_cl_cc_camera_pic=>get_js( ) )->get_parent(
* )->_z2ui5( )->timer( delayms = `200` finished = client->_event( 'START' )
* )->stringify( ) ).

ENDIF.

CASE client->get( )-event.

WHEN 'CAPTURE'.
INSERT VALUE #( data = mv_picture_base time = sy-uzeit ) INTO TABLE mt_picture.
CLEAR mv_picture_base.
client->view_model_update( ).

WHEN 'START'.


WHEN 'DISPLAY'.
DATA(lt_sel) = mt_picture_out.
DELETE lt_sel WHERE selected = abap_false.
data(ls_sel) = lt_sel[ 1 ].
mv_pic_display = mt_picture[ ls_sel-id ]-data.
view_display( client ).

WHEN 'BACK'.
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).

ENDCASE.

mt_picture_out = VALUE #( ).
LOOP AT mt_picture INTO DATA(ls_pic).
INSERT VALUE #( name = `picture ` && sy-tabix id = sy-tabix ) INTO TABLE mt_picture_out.
ENDLOOP.

ENDMETHOD.
ENDCLASS.
16 changes: 16 additions & 0 deletions src/z2ui5_cl_demo_app_306.clas.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>Z2UI5_CL_DEMO_APP_306</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>ndc - camera</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

0 comments on commit 7a0aa4d

Please sign in to comment.