Skip to content

Commit

Permalink
new sample with success and error sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
christianguenter2 committed Nov 18, 2024
1 parent 02aa48c commit c7530f1
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/027c66aaa6591edfa9bb6b42f39e45dd.smim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_SMIM" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<URL>/SAP/PUBLIC/BC/ABAP/mime_demo/z2ui5_demo_error.mp3</URL>
<CLASS>M_APP_L</CLASS>
</asx:values>
</asx:abap>
</abapGit>
Binary file not shown.
9 changes: 9 additions & 0 deletions src/027c66aaa6591edfa9bb6fac299145df.smim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_SMIM" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<URL>/SAP/PUBLIC/BC/ABAP/mime_demo/z2ui5_demo_success.mp3</URL>
<CLASS>M_APP_L</CLASS>
</asx:values>
</asx:abap>
</abapGit>
Binary file not shown.
8 changes: 8 additions & 0 deletions src/z2ui5_cl_demo_app_000.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,14 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel->generic_tile(
header = 'Sound'
subheader = 'Play success and error sounds'
press = client->_event( 'Z2UI5_CL_DEMO_APP_304' )
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel = page->panel(
expandable = abap_false
expanded = abap_true
Expand Down
87 changes: 87 additions & 0 deletions src/z2ui5_cl_demo_app_304.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
CLASS z2ui5_cl_demo_app_304 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES z2ui5_if_app.
DATA magic_key TYPE string.
DATA: BEGIN OF message,
text TYPE string VALUE IS INITIAL,
type TYPE string VALUE 'None',
END OF message.
PROTECTED SECTION.
PRIVATE SECTION.

DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS on_event.

ENDCLASS.


CLASS z2ui5_cl_demo_app_304 IMPLEMENTATION.

METHOD z2ui5_if_app~main.

me->client = client.

IF client->check_on_init( ).
view_display( ).
ENDIF.

on_event( ).

ENDMETHOD.


METHOD view_display.

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

" Note, these are demo sounds and are part of the abap2UI5 sample repo.
" They are NOT meant to use in production.
view->_generic( name = `script`
ns = `html` )->_cc_plain_xml(
|function playSuccess() \{ new Audio("/SAP/PUBLIC/BC/ABAP/mime_demo/z2ui5_demo_success.mp3").play(); \}|
&& |function playError() \{ new Audio("/SAP/PUBLIC/BC/ABAP/mime_demo/z2ui5_demo_error.mp3").play(); \}| ).

DATA(vbox) = view->page( title = `Play success and error sounds` )->vbox( class = `sapUiSmallMargin` ).
vbox->message_strip(
text = client->_bind( message-text )
type = client->_bind( message-type )
visible = `{= !!$` && client->_bind( message-text ) && ` }` ).
vbox->text( text = `The magic key is: abap2UI5` ).
vbox->input( id = `inputApp`
value = client->_bind_edit( magic_key )
placeholder = `Enter magic key`
submit = client->_event( 'enter' ) ).
vbox->button( text = `submit`
type = `accept`
press = client->_event( 'enter' ) ).

view->_z2ui5( )->focus( focusid = `inputApp` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.


METHOD on_event.

IF client->get( )-event = 'enter'.
IF magic_key = `abap2UI5`.
client->follow_up_action( val = `playSuccess()` ).
message-type = 'Success'.
message-text = 'Hooray!'.
ELSE.
client->follow_up_action( val = `playError()` ).
message-type = 'Error'.
message-text = `That wasn't the magic key`.
ENDIF.
CLEAR magic_key.
client->view_model_update( ).
ENDIF.

ENDMETHOD.

ENDCLASS.
16 changes: 16 additions & 0 deletions src/z2ui5_cl_demo_app_304.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_304</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Play Sound</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

0 comments on commit c7530f1

Please sign in to comment.