Пример #1
0
 @Override
 public boolean deleteSurroundingText(int leftLength, int rightLength) {
   // Android SDK 16+ doesn't send key events for backspace but calls this method
   NativeInterface.Activity.onKeyDown(KeyEvent.KEYCODE_DEL, this.delKeyDownEvent);
   NativeInterface.Activity.onKeyUp(KeyEvent.KEYCODE_DEL, this.delKeyUpEvent);
   return super.deleteSurroundingText(leftLength, rightLength);
 }
Пример #2
0
 public static void create(
     String title, String text, String ok, String yes, String no, String cancel, int iconId) {
   DialogFactory.dialogBuilder = new AlertDialog.Builder(NativeInterface.Activity);
   DialogFactory.dialogBuilder.setTitle(title != null ? title : "");
   DialogFactory.dialogBuilder.setMessage(text != null ? text : "");
   if (ok != null) {
     DialogFactory.dialogBuilder.setPositiveButton(ok, new Ok());
   } else {
     if (yes != null) {
       DialogFactory.dialogBuilder.setPositiveButton(yes, new Yes());
     }
     if (no != null) {
       DialogFactory.dialogBuilder.setNegativeButton(no, new No());
     }
   }
   if (cancel != null) {
     DialogFactory.dialogBuilder.setNeutralButton(cancel, new Cancel());
   }
   switch (iconId) {
     case 1:
       DialogFactory.dialogBuilder.setIcon(android.R.drawable.ic_dialog_info);
       break;
     case 2:
       DialogFactory.dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
       break;
     default:
       break;
   }
   if (DialogFactory.useDialogFragment) {
     try {
       DialogFragment dialogFragment = new DialogFragment();
       dialogFragment.show(NativeInterface.Activity.getFragmentManager(), "april-dialog");
     } catch (java.lang.Throwable e) {
       android.util.Log.w(
           "april",
           "This Android OS version does not support DialogFragment, defaulting to legacy Activity.showDialog().");
       DialogFactory.useDialogFragment = false;
     }
   }
   if (!DialogFactory.useDialogFragment) {
     NativeInterface.Activity.runOnUiThread(
         new Runnable() {
           public void run() {
             NativeInterface.Activity.showDialog(DialogFactory.dialogIndex);
             DialogFactory.dialogIndex++;
           }
         });
   }
 }
Пример #3
0
 public void onSurfaceCreated(GL10 gl, EGLConfig config) {
   NativeInterface.onSurfaceCreated();
   if (!NativeInterface.Running) {
     NativeInterface.setVariables(NativeInterface.DataPath, NativeInterface.ArchivePath);
     String args[] = {NativeInterface.ApkPath}; // adding argv[0]
     NativeInterface.init(args);
     NativeInterface.Running = true;
     // needed for keyboard height
     NativeInterface.Activity.getWindow()
         .getDecorView()
         .getViewTreeObserver()
         .addOnGlobalLayoutListener(
             new ViewTreeObserver.OnGlobalLayoutListener() {
               @Override
               public void onGlobalLayout() {
                 View view = NativeInterface.AprilActivity.getView();
                 Rect r = new Rect();
                 view.getWindowVisibleDisplayFrame(r);
                 float heightRatio =
                     1.0f - (float) (r.bottom - r.top) / view.getRootView().getHeight();
                 NativeInterface.onVirtualKeyboardChanged((heightRatio > 0.15f), heightRatio);
               }
             });
   }
 }
Пример #4
0
 public void onDrawFrame(GL10 gl) {
   if (!NativeInterface.render()) {
     NativeInterface.Activity.finish();
   }
 }