Interactive Ink

interactive android SDK

Hi,

   I make two activities in android studio, the top is transparent the under is opaque.

 the top like this:

  <?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

        xmlns:custom="http://schemas.android.com/apk/res-auto"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:background="#00000000">

    <com.myscript.iink.getstarted.EditorView

        android:id="@+id/editor_view"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:visibility="invisible"

        android:background="#00000000">

        <com.myscript.iink.getstarted.LayerView

            android:id="@+id/layer_model"

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:layout_marginTop="0dp"

            android:layout_marginLeft="0dp"

            android:layout_marginBottom="0dp"

            android:layout_marginRight="0dp"

            custom:layerType="MODEL"/>

        <!--<com.myscript.iink.uireferenceimplementation.LayerView-->

            <!--android:id="@+id/layer_temporary"-->

            <!--android:layout_width="match_parent"-->

            <!--android:layout_height="match_parent"-->

            <!--android:layout_marginTop="0dp"-->

            <!--android:layout_marginLeft="0dp"-->

            <!--android:layout_marginBottom="0dp"-->

            <!--android:layout_marginRight="0dp"-->

            <!--custom:layerType="TEMPORARY"/>-->

    <com.myscript.iink.getstarted.LayerView

        android:id="@+id/layer_capture"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:layout_marginTop="0dp"

        android:layout_marginLeft="0dp"

        android:layout_marginBottom="0dp"

        android:layout_marginRight="0dp"

        custom:layerType="CAPTURE"/>

    </com.myscript.iink.getstarted.EditorView>

</FrameLayout>

              String str = editor.export_(editor.getRootBlock(),MimeType.LATEX);

              Log.d("Unity",str+" ----------------------------");


the result str is "?",  the two activities is Superposed.  I don't know why?? 





the top activity open, I use code:  Intent intent = new Intent(mActivity,MathActivity.class); mActivity.startActivity(intent);

the top activity is handwriting

  • image


String str = editor.export_(editor.getRootBlock(),MimeType.LATEX);

  Log.d("Unity",str+" ----------------------------");

 

the result str is "?",  the two activities is Superposed.  I don't know why?? 

Dear See Love,

if exporting from a Math Block with content inside of it, there is no reason it is not working.

Best regards,

Olvier

Dear Olvier,

    When I call String str = editor.export_(editor.getRootBlock(),MimeType.LATEX);  I found a error     MathActivity: Failed to edit block "MainBlock"CONFIGURATION_BUNDLE_NOT_FOUND: error: no such configuration bundle math.  Maybe the error cause the Recognition result is '?'.

I don't know why the error happened?

Best regards,

See Love

Dear Olvier,

  the init function like:

    super.onCreate(savedInstanceState);

    engine = IInkApplication.getEngine();

    // configure recognition

    Configuration conf = engine.getConfiguration();

    String confDir = "zip://" + getPackageCodePath() + "!/assets/conf";

    conf.setStringArray("configuration-manager.search-path", new String[] { confDir });

    String tempDir = getFilesDir().getPath() + File.separator + "tmp";

    conf.setString("content-package.temp-folder", tempDir);

    setContentView(R.layout.activity_main);

    Singleton.getInstance().InsertActivity("Math",this);

    editorView = (EditorView) findViewById(R.id.editor_view);

    editorView.setEngine(engine);

    final Editor editor = editorView.getEditor();

    editor.addListener(new IEditorListener()

    {

      @Override

      public void partChanging(Editor editor, ContentPart oldPart, ContentPart newPart)

      {

        // no-op

      }

      @Override

      public void partChanged(Editor editor)

      {

        //invalidateOptionsMenu();

        //invalidateIconButtons();

      }

      @Override

      public void contentChanged(Editor editor, String[] blockIds)

      {

        //invalidateOptionsMenu();

        //invalidateIconButtons();

      }

      @Override

      public void onError(Editor editor, String blockId, String message)

      {

        Log.e(TAG, "Failed to edit block \"" + blockId + "\"" + message);

      }

    });

    editorView.setInputController(new InputController(this, editorView));

    setInputMode(InputController.INPUT_MODE_FORCE_PEN); // If using an active pen, put INPUT_MODE_AUTO here

    String packageName = "File1.iink";

    File file = new File(getFilesDir(), packageName);

    try

    {

      if(file.exists())

      {

        contentPackage = engine.openPackage(file);

        contentPart = contentPackage.getPart(0);

      }

      else

      {

        contentPackage = engine.createPackage(file);

        contentPart = contentPackage.createPart("Math"); // Choose type of content (possible values are: "Text Document", "Text", "Diagram", "Math", and "Drawing")

      }

    }

    catch (IOException e)

    {

      Log.e(TAG, "Failed to open package \"" + packageName + "\"", e);

    }

    catch (IllegalArgumentException e)

    {

      Log.e(TAG, "Failed to open package \"" + packageName + "\"", e);

    }

    setTitle("Type: " + contentPart.getType());

    editorView.post(new Runnable() {

      @Override

      public void run() {

          editorView.getRenderer().setViewOffset(0, 0);

          editorView.getRenderer().setViewScale(2);

          editorView.setVisibility(View.VISIBLE);

          editor.setPart(contentPart);

        }

    });

Dear Olvier,

     When i is handwriting,  the full error message is:                                                                    [ 11-21 14:34:04.577 2955: 2955 E/ ]

                                                                    process stopped due to unexpected signal 13

11-21 14:34:32.281 8074-8275/com.myscript.iink.getstarted E/MathActivity: Failed to edit block "MainBlock"CONFIGURATION_BUNDLE_NOT_FOUND: error: no such configuration bundle math


Best regards,

See Love

Dear Olvier,

  The error is:

  editor.addListener(new IEditorListener()

    {
@Override
public void partChanging(Editor editor, ContentPart oldPart, ContentPart newPart)
{
// no-op
}

@Override
public void partChanged(Editor editor)
{
// invalidateOptionsMenu();
// invalidateIconButtons();
}

@Override
public void contentChanged(Editor editor, String[] blockIds)
{
if(blockIds.length >0)
{
for (int i = 0;i< blockIds.length;i++)
{
Log.d(TAG,blockIds[i]);
}
}
// invalidateOptionsMenu();
// invalidateIconButtons();
}

@Override
public void onError(Editor editor, String blockId, String message)
{
Log.e(TAG, "Failed to edit block \"" + blockId + "\"" + message);
}

});


The callback function is under .   

@Override

      public void onError(Editor editor, String blockId, String message)
{
Log.e(TAG, "Failed to edit block \"" + blockId + "\"" + message);
} Why happened the error?? 
Dear See Love,

the error means the iink is not able to load the math assets. Can you check the math.conf file is located into the recognition-assets\conf\ directory and the math-ak.res and math-grm-atk.res resources are into the recognition-assets\resources\math\ directory of your project?

Best regards,

Olivier

 

Dear Olivier,

      I can find in apk, the math.conf file is in the assets\conf\ directory and the math-ak.res and math-grm-atk.res resources are in the assets\resources\math\ directory, is in My project.


Best regards,


See Love


Dear See Love,

I confirm this is because the math.conf cannot be loaded.

The path to the math.conf is set as follows:

Configuration conf = engine.getConfiguration();
String confDir = "zip://" + getPackageCodePath() + "!/assets/conf";
conf.setStringArray("configuration-manager.search-path", new String[] { confDir });
You should then ensure "confDir" points to "math.conf".

Best regards,

Olivier

Dear Olivier,

    I confirm the confDir is correct, I print it,  I ensure "confDir" points to "math.conf",  I can give your the apk.


Configuration conf = engine.getConfiguration();
String confDir = "zip://" + getPackageCodePath() + "!/assets/conf";
conf.setStringArray("configuration-manager.search-path", new String[] { confDir }); I Make a AAR. if you need i can give you.
Best regards, See Love

Dear Olivier,

   The Code:

Configuration conf = engine.getConfiguration();
String confDir = "zip://" + getPackageCodePath() + "!/assets/conf";
conf.setStringArray("configuration-manager.search-path", new String[] { confDir });

is In the AAR. 

Dear See Love,

when browsing the APK file, are the resources math-ak.res and math-grm-atk.res and the math.conf also in the APK?

Best regards,

Olivier