@@ -81,6 +81,7 @@ Licensed to the Apache Software Foundation (ASF) under one
8181import java .io .InputStream ;
8282import java .lang .reflect .InvocationTargetException ;
8383import java .lang .reflect .Method ;
84+ import java .util .Arrays ;
8485
8586@ SuppressLint ("SetJavaScriptEnabled" )
8687public class ThemeableBrowser extends CordovaPlugin {
@@ -707,6 +708,13 @@ public boolean onTouch(View v, MotionEvent event) {
707708 });
708709
709710 if (features .menu .items != null ) {
711+ if (features .menu .cancel != null ) {
712+ EventLabel cancelEventLabel = new EventLabel ();
713+ cancelEventLabel .label = features .menu .cancel ;
714+ cancelEventLabel .event = "cancel" ;
715+ features .menu .items = ArrayHelper .push (features .menu .items , cancelEventLabel );
716+ }
717+
710718 HideSelectedAdapter <EventLabel > adapter
711719 = new HideSelectedAdapter <EventLabel >(
712720 cordova .getActivity (),
@@ -1542,6 +1550,7 @@ private static class BrowserButton extends Event {
15421550
15431551 private static class BrowserMenu extends BrowserButton {
15441552 public EventLabel [] items ;
1553+ public String cancel ;
15451554 }
15461555
15471556 private static class Toolbar {
@@ -1557,4 +1566,17 @@ private static class Title {
15571566 public String staticText ;
15581567 public boolean showPageTitle ;
15591568 }
1569+
1570+ public static class ArrayHelper {
1571+ public static <T > T [] push (T [] arr , T item ) {
1572+ T [] tmp = Arrays .copyOf (arr , arr .length + 1 );
1573+ tmp [tmp .length - 1 ] = item ;
1574+ return tmp ;
1575+ }
1576+
1577+ public static <T > T [] pop (T [] arr ) {
1578+ T [] tmp = Arrays .copyOf (arr , arr .length - 1 );
1579+ return tmp ;
1580+ }
1581+ }
15601582}
0 commit comments