Software Development Kit

Mathwidget issue

When I am trying to implement class of MathWidget to a new project the touch is not recognized and I can't paint/draw the numbers. the code is :

  

package com.myscript.atk.math.sample;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.myscript.atk.math.widget.MathWidgetApi;
import com.myscript.certificate.MyCertificate;

import java.io.File;

public class MainActivity extends Activity
{
  private static final String TAG = "MainActivity";
  private static  String s;

  private MathWidgetApi mWidget;

  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    // Set application title
    setTitle(getResources().getString(R.string.activity_name));

    mWidget = (MathWidgetApi) findViewById(R.id.mathWidget);

    if (!mWidget.registerCertificate(MyCertificate.getBytes()))
    {
      AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(this);
      dlgAlert.setMessage("Please use a valid certificate.");
      dlgAlert.setTitle("Invalid certificate");
      dlgAlert.setCancelable(false);
      dlgAlert.setPositiveButton("OK", new DialogInterface.OnClickListener()
      {
        public void onClick(DialogInterface dialog, int which)
        {

          //dismiss the dialog
        }
      });
      dlgAlert.create().show();
      return;
    }

    mWidget.clearSearchPath();
    mWidget.addSearchDir("zip://" + getPackageCodePath() + "!/assets/conf/");
    mWidget.configure("math", "standard");
    // Configure clear button
    final View clearButton = findViewById(R.id.action_clear);
    if (clearButton != null)
    {
      clearButton.setOnClickListener(new View.OnClickListener()
      {
        @Override
        public void onClick(final View view)
        {
            s = mWidget.getResultAsLaTeX().toString();
            mWidget.clear(true);

        }
      });
    }
  }
public int returnNUm(){
    return Integer.parseInt(s);
}
    @Override
  protected void onDestroy()
  {
    if (mWidget != null)
    {
      mWidget.release();
      mWidget = null;
    }

    super.onDestroy();
  }

}

 

 


Dear App Clock,

the reason is that you are not adding the math.conf and resources files (math-grm-atk.res, math-ak.res) properly in your project;
-first, ensure you add these in the assets:
-Make sur you math.conf file is properly configured
-Add the math-grm-atk.res, math-ak.res

When adding these exactly as below, it worked out of the box:

image



Best regards,

Olivier

it's like the picture and still not working

image

Dear App Clok,

I tried again on my side on it worked immediately!

Are the math.conf and .res files located in the APK?

Best regards,

Olivier

Dear app clock,


Thank you for contacting us.


Based on your code, everything seems correct...


Currently, can you please check the following:

-Are you using a scroll view? Indeed, MathWidget cannot be used in a scroll view

-Do you have an intermediate view, that would capture the events preventing these from the being transfered to the MathWidget?

-Do you have error messages in the logs?

-...


Best regards,


Olivier

no I don't have a scroll view, also not an intermidate view. this is my layout (using snaroid studio): 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@color/background">

  <include
    android:id="@+id/myscript_math_toolbar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    layout="@layout/main_tool_bar" />

  <com.myscript.atk.math.widget.MathWidget
      android:id="@+id/mathWidget"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_alignParentTop="true"
      android:layout_above="@id/myscript_math_toolbar">

    <TextView
        android:id="@+id/showNum"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_marginEnd="164dp"
        android:layout_marginRight="164dp" />


  </com.myscript.atk.math.widget.MathWidget>

</RelativeLayout>

 

also when I am trying to use my in app  the widget module I get the below issue: 

Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :MathWidgetSample.

Unable to resolve dependency for &#:app@debug/compileClasspath&#;: Could not resolve project :MathWidgetSample."

image

Dear Aoo Clock,

you must solve the issue: Can you please confirm you are not using the gradle from android studio 3.0?

Best regards,

Olivier

I am using android 3.0.1

image

so what can I do? is there any other API I need to implement to my app so the widget will be working?

Dear App Clock,

can you please try to use a 2.x version of Android Studio, and not upgrade the .gradle?

If this doesn't help, we would need your project, so that we can investigate further.

Best regards,

Olivier

I didn't resolve the issue, attached link for download my  project. you will run on emulator and see it doesn't write.


Dear App Clock,


I tried to download with Edge, Firefox and Chrome, but was not able to.


Can you please put it on another server?


Best regards,


Olivier


Login or Signup to post a comment