Java Question [solved] WebView

Johan Schoeman

Expert
Licensed User
Longtime User
I am trying to wrap this Github project:
https://github.com/lingarajsankarav...nal.com&utm_medium=referral&utm_campaign=5577

I have done a similar project before when the original project makes use of a WebView.

The previous project had this in class MathView:
B4X:
package main.java.io.github.kexanie.library;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.x5.template.Chunk;
import com.x5.template.Theme;
import com.x5.template.providers.AndroidTemplates;

import main.java.io.github.kexanie.library.R;

public class MathView extends WebView {

And in its wrapper I had:
B4X:
package mathviewwrapper;


import main.java.io.github.kexanie.library.MathView;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.view.ViewGroup;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.Hide;
import anywheresoftware.b4a.BA.Pixel;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.keywords.Common.DesignerCustomView;
import anywheresoftware.b4a.objects.LabelWrapper;
import anywheresoftware.b4a.objects.PanelWrapper;
import anywheresoftware.b4a.objects.ViewWrapper;
import anywheresoftware.b4a.objects.WebViewWrapper;
import anywheresoftware.b4a.objects.TextViewWrapper;
import anywheresoftware.b4a.BA.Events;
import android.view.Gravity;

import android.graphics.Color;
import android.graphics.Typeface;

import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewParent;
import android.support.annotation.NonNull;
import android.widget.ImageView;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;


import android.graphics.BitmapShader;
import android.graphics.Shader;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;

import java.util.ArrayList;
import java.util.List;



//@Events(values={"like_toggled"})
@Author("Github: Brian Lee, Wrapped by: Johan Schoeman")
@Version(1.00f)
@ShortName("MathView")
//@DependsOn(values={"android-support-v7-appcompat", "chunk-templates-3.0.1"})
public class mathViewWrapper extends WebViewWrapper implements DesignerCustomView {

    private BA ba;
    private String eventName;
    private MathView cv;

    public void Initialize(BA ba, String EventName) {
        _initialize(ba, null, EventName);
    }

    @Hide
    public void _initialize(BA ba, Object activityClass, String EventName) {
        this.eventName = EventName.toLowerCase(BA.cul);
        this.ba = ba;
        cv = new MathView(ba.context, null);
                this.setObject(cv);
//              setEngine(1);
//              addImage();
//              addListener();
//              addListener2();
     }

It compiled 100% and I could add the MathView as a CustomView in the B4A designer.

The new project that I am working on has this in class MathView:
B4X:
package katex.hourglass.in.mathlib;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;


/**
* Created by lingaraj on 3/15/17.
*/

public class MathView extends WebView {

And in the wrapper I have:

B4X:
package katexmathviewwrapper;

import katex.hourglass.in.mathlib.MathView;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.view.ViewGroup;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.Hide;
import anywheresoftware.b4a.BA.Pixel;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.keywords.Common.DesignerCustomView;
import anywheresoftware.b4a.objects.LabelWrapper;
import anywheresoftware.b4a.objects.PanelWrapper;
import anywheresoftware.b4a.objects.ViewWrapper;
import anywheresoftware.b4a.objects.WebViewWrapper;
import anywheresoftware.b4a.objects.TextViewWrapper;
import anywheresoftware.b4a.BA.Events;
import android.view.Gravity;

import android.graphics.Color;
import android.graphics.Typeface;

import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewParent;
import android.support.annotation.NonNull;
import android.widget.ImageView;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;


import android.graphics.BitmapShader;
import android.graphics.Shader;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;

import java.util.ArrayList;
import java.util.List;

import anywheresoftware.b4a.AbsObjectWrapper;
import anywheresoftware.b4a.BA.ActivityObject;


//@ActivityObject
//@Events(values={"like_toggled"})
@Author("Github: lingarajsankaravelu, Wrapped by: Johan Schoeman")
@Version(1.00f)
@ShortName("KatexMathView")
@DependsOn(values={"android-support-v7-appcompat", "android-support-v4"})
public class katexmathviewWrapper extends WebViewWrapper implements DesignerCustomView {

    private BA ba;
    private String eventName;
    private MathView cv;

    public void Initialize(BA ba, String EventName) {
        _initialize(ba, null, EventName);
    }

    @Hide
    public void _initialize(BA ba, Object activityClass, String EventName) {
        this.eventName = EventName.toLowerCase(BA.cul);
        this.ba = ba;
        cv = new MathView(ba.context, null);
                this.setObject(cv);
//              setEngine(1);
//              addImage();
//              addListener();
//              addListener2();
     }

In other words, just about the same approach. The new library compiles 100% but in the B4A designer the CustomView is not available to select. In the designer CustomView is not even enabled to select from....?

What am I doing wrong or what am I missing here?

Thanks

JS
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…