Esempio n. 1
0
  @Override
  public boolean onCreateOptionsMenu(android.view.Menu menu) {
    super.onCreateOptionsMenu(menu);
    try {
      if (processBA.subExists("activity_actionbarhomeclick")) {
        Class.forName("android.app.ActionBar")
            .getMethod("setHomeButtonEnabled", boolean.class)
            .invoke(getClass().getMethod("getActionBar").invoke(this), true);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (menuItems == null) return false;
    for (B4AMenuItem bmi : menuItems) {
      android.view.MenuItem mi = menu.add(bmi.title);
      if (bmi.drawable != null) mi.setIcon(bmi.drawable);
      if (android.os.Build.VERSION.SDK_INT >= 11) {
        try {
          if (bmi.addToBar) {
            android.view.MenuItem.class.getMethod("setShowAsAction", int.class).invoke(mi, 1);
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      mi.setOnMenuItemClickListener(
          new B4AMenuItemsClickListener(bmi.eventName.toLowerCase(BA.cul)));
    }

    return true;
  }
Esempio n. 2
0
 @Override
 public boolean onKeyUp(int keyCode, android.view.KeyEvent event) {
   if (onKeyUpSubExist == null) onKeyUpSubExist = processBA.subExists("activity_keyup");
   if (onKeyUpSubExist) {
     Boolean res =
         (Boolean) processBA.raiseEvent2(_activity, false, "activity_keyup", false, keyCode);
     if (res == null || res == true) return true;
   }
   return super.onKeyUp(keyCode, event);
 }
Esempio n. 3
0
 @Override
 public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
   if (onKeySubExist == null) onKeySubExist = processBA.subExists("activity_keypress");
   if (onKeySubExist) {
     if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK
         && android.os.Build.VERSION.SDK_INT >= 18) {
       HandleKeyDelayed hk = new HandleKeyDelayed();
       hk.kc = keyCode;
       BA.handler.post(hk);
       return true;
     } else {
       boolean res = new HandleKeyDelayed().runDirectly(keyCode);
       if (res) return true;
     }
   }
   return super.onKeyDown(keyCode, event);
 }
Esempio n. 4
0
 public void onWindowFocusChanged(boolean hasFocus) {
   super.onWindowFocusChanged(hasFocus);
   if (processBA.subExists("activity_windowfocuschanged"))
     processBA.raiseEvent2(null, true, "activity_windowfocuschanged", false, hasFocus);
 }