Oxidizer import issue

The new build is allowing me to compile and proceed. I ran into this new problem, and I’ll add others (if any) as I continue to import java code.

The java code I was trying to import (sans namespace):

import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.internal.view.menu.ActionMenuItemView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;

import java.util.ArrayList;

public class ColorizeTheToolBar
{
    static public void colorizeToolBarItem(AppCompatActivity myActivity, final String description, boolean bIsBlue)
    {   int theColor;
        if (bIsBlue)
            theColor = myActivity.getResources().getColor(R.color.colorAccent);
        else
            theColor = myActivity.getResources().getColor(R.color.colorGreyToolbarIcons);
        final ViewGroup decorView = (ViewGroup) myActivity.getWindow().getDecorView();
        final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
        final String myOverflowDescription = myActivity.getString(R.string.overflow_image);
        final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(theColor, PorterDuff.Mode.SRC_ATOP);
        viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
        {   @Override
            public void onGlobalLayout()
            {   final ArrayList<View> outViews = new ArrayList<>();
                decorView.findViewsWithText(outViews, description, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
                if (outViews.isEmpty())
                    return;
                if (description == myOverflowDescription)
                {   ImageView overflow = (ImageView) outViews.get(0);
                    overflow.setColorFilter(colorFilter);
                }
                else
                {   ActionMenuItemView overflow = (ActionMenuItemView) outViews.get(0);
                    overflow.getCompoundDrawables()[0].setColorFilter(colorFilter);
                }
                removeOnGlobalLayoutListener(decorView, this);
            }
        });
    }

    private static void removeOnGlobalLayoutListener(View myView, ViewTreeObserver.OnGlobalLayoutListener myListener)
    {   if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
            myView.getViewTreeObserver().removeGlobalOnLayoutListener(myListener);
        else
            myView.getViewTreeObserver().removeOnGlobalLayoutListener(myListener);
    }

}

The imported code (cleaned up a bit: removed ‘internal’, unsure why, and changed viewTreeObserver to myViewTreeObserver because of the case insensitivity on the Pascal side):

interface

uses
  android.graphics,
  android.os,
  android.support.v7.app,
  android.support.v7.view.menu,
  android.view,
  android.widget,
  java.util;

type
  ColorizeTheToolBar = public class
  private
    class method removeOnGlobalLayoutListener(myView: View; myListener: ViewTreeObserver.OnGlobalLayoutListener);
  public
    class method colorizeToolBarItem(myActivity: AppCompatActivity; description: String; bIsBlue: Boolean);
  end;

implementation

class method ColorizeTheToolBar.colorizeToolBarItem(myActivity: AppCompatActivity; description: String; bIsBlue: Boolean);
begin
  var theColor: Integer;
  if bIsBlue then begin
    theColor := myActivity.getResources().getColor(R.color.colorAccent);
  end
  else begin
    theColor := myActivity.getResources().getColor(R.color.colorGreyToolbarIcons);
  end;
  var decorView: ViewGroup := ViewGroup(myActivity.getWindow().getDecorView());
  var myViewTreeObserver: ViewTreeObserver := decorView.getViewTreeObserver();
  var myOverflowDescription: String := myActivity.getString(R.string.overflow_image);
  var colorFilter: PorterDuffColorFilter := new PorterDuffColorFilter(theColor, PorterDuff.Mode.SRC_ATOP);
  myViewTreeObserver.addOnGlobalLayoutListener(new class ViewTreeObserver.OnGlobalLayoutListener (onGlobalLayout := method  
		begin
			var outViews: ArrayList<View> := new ArrayList<View>();
			decorView.findViewsWithText(outViews, description, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
			if outViews.isEmpty() then 
			begin
				exit;
			end;
			if description = myOverflowDescription then 
			begin
				var overflow: ImageView := ImageView(outViews.get(0));
				overflow.setColorFilter(colorFilter);
			end
			else 
			begin
				var overflow: ActionMenuItemView := ActionMenuItemView(outViews.get(0));
				overflow.getCompoundDrawables()[0].setColorFilter(colorFilter);
			end;
			removeOnGlobalLayoutListener(decorView, self);
		end));
end;

class method ColorizeTheToolBar.removeOnGlobalLayoutListener(myView: View; myListener: ViewTreeObserver.OnGlobalLayoutListener);
begin
  if Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN then begin
    myView.getViewTreeObserver().removeGlobalOnLayoutListener(myListener);
  end
  else begin
    myView.getViewTreeObserver().removeOnGlobalLayoutListener(myListener);
  end;
end;

end.

The problem is the converted line:

removeOnGlobalLayoutListener(decorView, self);

on the 2nd parameter. In the Java version, the ‘self’ refers to the new ViewTreeObserver.OnGlobalLayoutListener() created in-line. But as best I can figure, after the Oxidizer conversion, the ‘self’ refers to something else, probably the ColorizeTheToolbar class itself. The error I get is:

Error (E486) Parameter 2 is "<type reference>", should be "ViewTreeObserver.OnGlobalLayoutListener", in call to class method ColorizeTheToolBar.removeOnGlobalLayoutListener(myView: View; myListener: ViewTreeObserver.OnGlobalLayoutListener)

I’m not sure if this is a bug in the Oxidizer process, a limitation of the syntax, or what. Any insight would be appreciated. I can comment this out and continue importing.

I’m also seeing that overrides are not coming through. Here’s another class:

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;

/**
 * Created by heave_000 on 4/27/2016.
 */
public class CustomStringSpinnerAdapter extends ArrayAdapter<String>
{
    String[] modelItems = null;
    Context mContext;
    boolean mbTransparent;
    boolean mbLeft;

    public CustomStringSpinnerAdapter(Context myContext, String[] resource, boolean bTransparent, boolean bLeft)
    {   super(myContext, R.layout.toolbar_spinner_item, resource);
        this.mContext = myContext;
        this.modelItems = resource;
        mbTransparent = bTransparent;
        mbLeft = bLeft;
    }

    @Override
    public View getView(final int position, final View convertView, final ViewGroup parent)
    {   int iPosition = position;
        if (parent instanceof AdapterView)
            iPosition = ((AdapterView) parent).getSelectedItemPosition();
        else if (parent instanceof Spinner)
            iPosition = ((Spinner) parent).getSelectedItemPosition();
        if (mbTransparent)
        {   if (mbLeft)
                return generateLayout(iPosition, convertView, parent, R.layout.content_spinner_item_transparent);
            else
                return generateLayout(iPosition, convertView, parent, R.layout.content_spinner_transparent_right);
        }
        else
            return generateLayout(iPosition, convertView, parent, R.layout.content_spinner_item);
    }

    @Override
    public View getDropDownView(final int position, final View convertView, final ViewGroup parent)
    {   return generateLayout(position, convertView, parent, R.layout.content_spinner_item);
    }

    private View generateLayout(final int position, final View convertView, final ViewGroup parent, final int layout)
    {   TextView tv;
        if (convertView != null)
            tv = (TextView) convertView;
        else
            tv = (TextView) LayoutInflater.from(mContext).inflate(layout, parent, false);
        tv.setText(modelItems[position]);
        return tv;
    }

}

that gets Oxidized as:

interface

uses
  android.content,
  android.view,
  android.widget;

type
  CustomStringSpinnerAdapter = public class(ArrayAdapter)
    var modelItems: array of String := nil;
    var mContext: Context;
    var mbTransparent: Boolean;
    var mbLeft: Boolean;
  private
    method generateLayout(position: Integer; convertView: View; parent: ViewGroup; layout: Integer): View;
  public
    constructor(myContext: Context; resource: array of String; bTransparent: Boolean; bLeft: Boolean);
    method getView(position: Integer; convertView: View; parent: ViewGroup): View;
    method getDropDownView(position: Integer; convertView: View; parent: ViewGroup): View;
  end;

implementation

constructor CustomStringSpinnerAdapter(myContext: Context; resource: array of String; bTransparent: Boolean; bLeft: Boolean);
begin
  (myContext, R.layout.toolbar_spinner_item, resource);
  self.mContext := myContext;
  self.modelItems := resource;
  mbTransparent := bTransparent;
  mbLeft := bLeft;
end;

method CustomStringSpinnerAdapter.getView(position: Integer; convertView: View; parent: ViewGroup): View;
begin
  var iPosition: Integer := position;
  if parent is AdapterView then begin
    iPosition := AdapterView(parent).getSelectedItemPosition();
  end
  else begin
    if parent is Spinner then begin
      iPosition := Spinner(parent).getSelectedItemPosition();
    end;
  end;
  if mbTransparent then begin
    if mbLeft then begin
      exit generateLayout(iPosition, convertView, parent, R.layout.content_spinner_item_transparent);
    end
    else begin
      exit generateLayout(iPosition, convertView, parent, R.layout.content_spinner_transparent_right);
    end;
  end
  else begin
    exit generateLayout(iPosition, convertView, parent, R.layout.content_spinner_item);
  end;
end;

method CustomStringSpinnerAdapter.getDropDownView(position: Integer; convertView: View; parent: ViewGroup): View;
begin
  exit generateLayout(position, convertView, parent, R.layout.content_spinner_item);
end;

method CustomStringSpinnerAdapter.generateLayout(position: Integer; convertView: View; parent: ViewGroup; layout: Integer): View;
begin
  var tv: TextView;
  if convertView ≠ nil then begin
    tv := TextView(convertView);
  end
  else begin
    tv := TextView(LayoutInflater.from(mContext).inflate(layout, parent, false));
  end;
  tv.setText(modelItems[position]);
  exit tv;
end;

end.

Problems:

  1. The two overrides getView and getDropDownView aren’t being converted as overrides, so they hide their parent. I saw (and fixed) this when importing another class, so it appears a general omission.

  2. The single constructor with parameters seemingly gets things confused. I get a ‘No matching or parameterless constructor in ancestor’. The java ‘super.’ call to the ArrayAdapter constructor gets nuked, and just the parameters survive, resulting in a ‘Statement expected’ error.

  3. The first ‘if’ in the last method gets converted oddly. The line:

if (convertView != null)

gets converted to:

if convertView ≠ nil then

the not equals I was expecting was ‘<>’, not ‘≠’ and I get a ‘“then” expected’ error.

Just as an FYI on each problem above:

  1. Adding ‘override;’ after the function declarations solved this.

  2. Changing the first line in the constructor to:

inherited constructor(myContext, R.layout.toolbar_spinner_item, resource);

solved this.

  1. Changing the if statement to:

if convertView <> nil then begin

solved this.

I’m hoping the Oxidizer can be improved to do these things automatically.

Another imported file, other issues. Hopefully I won’t need to include the whole file here.

This in java:

View mViewSpacer;
...
mViewSpacer = (View) myView.findViewById(R.id.view_spacer);

yielded this:

mViewSpacer := View(myView.findViewById(R.id.view_spacer));

which generated ‘property’ is used as a method.

Removing the (in this case unnecessary) cast:

mViewSpacer := myView.findViewById(R.id.view_spacer);

eliminates the error.

Then there is this function (java first):

public PopupWindow ListPopupWindow(Context myContext, int id, final String sBefore, final String sAfter)
{   String[] myArray = getResources().getStringArray(id);
    PopupWindow myPopupWindow = new PopupWindow(myContext);
    ListView myListView = new ListView(myContext);
    ArrayAdapter<String> myArrayAdapter = new ArrayAdapter<String>(this.getActivity(), R.layout.toolbar_spinner_item, myArray);
    myListView.setAdapter(myArrayAdapter);
    myListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {   @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id)
        {   if (myTagsPopupWindow.isShowing())
                myTagsPopupWindow.dismiss();
            if (myCommandsPopupWindow.isShowing())
                myCommandsPopupWindow.dismiss();
            String sItem = sBefore + ((TextView) view).getText().toString().toUpperCase() + sAfter;
            int start = Math.max(mSearchText.getSelectionStart(), 0);
            int end = Math.max(mSearchText.getSelectionEnd(), 0);
            mSearchText.getText().replace(Math.min(start, end), Math.max(start, end), sItem, 0, sItem.length());
        }
    });
    myPopupWindow.setFocusable(true);
    myPopupWindow.setWidth(250);
    myPopupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    myPopupWindow.setContentView(myListView);
    return myPopupWindow;
}

which Oxidizes:

method AdvancedSearchDialogFragment.ListPopupWindow(myContext: Context; id: Integer; sBefore: String; sAfter: String): PopupWindow;
begin
  var myArray: array of String := getResources().getStringArray(id);
  var myPopupWindow: PopupWindow := new PopupWindow(myContext);
  var myListView: ListView := new ListView(myContext);
  var myArrayAdapter: ArrayAdapter<String> := new ArrayAdapter<String>(self.getActivity(), R.layout.toolbar_spinner_item, myArray);
  myListView.setAdapter(myArrayAdapter);
  myListView.setOnItemClickListener(new class AdapterView.OnItemClickListener (onItemClick := method (parent: AdapterView<>; myView: View; position: Integer; id: Int64) begin
    if myTagsPopupWindow.isShowing() then begin
      myTagsPopupWindow.dismiss();
    end;
    if myCommandsPopupWindow.isShowing() then begin
      myCommandsPopupWindow.dismiss();
    end;
    var sItem: String := sBefore + TextView(myView).getText().toString().toUpperCase() + sAfter;
    var start: Integer := Math.max(mSearchText.getSelectionStart(), 0);
    var &end: Integer := Math.max(mSearchText.getSelectionEnd(), 0);
    mSearchText.getText().replace(Math.min(start, &end), Math.max(start, &end), sItem, 0, sItem.length());
  end));
  myPopupWindow.setFocusable(true);
  myPopupWindow.setWidth(250);
  myPopupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
  myPopupWindow.setContentView(myListView);
  exit myPopupWindow;
end;

and has these problems:

The line:

myListView.setOnItemClickListener(new class AdapterView.OnItemClickListener (onItemClick := method (parent: AdapterView<>; myView: View; position: Integer; id: Int64) begin

has five errors:
semicolon ( ; ) or close parenthesis expected, got not equals (<>)
“begin” expected, got close parenthesis
semicolon ( ; ) expected, got "begin"
comma ( , ) or close parenthesis expected, got “begin”
semicolon ( ; ) expected, got close parenthesis

most of which descend, I think, from a lack of the translation of the ‘?’ in the java lines:

myListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
        {   @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id)

and maybe something else. I’m not entirely clear on how to fix this one.

Further, on this converted line:

var sItem: String := sBefore + TextView(myView).getText().toString().toUpperCase() + sAfter;

I get ‘Unknown identifier’ on ‘myView’, which would seem to be a scope problem.

and then there is some messiness with the end of that function, which probably arises from earlier issues.

More… Another java file:

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class EasyInstallActivity extends AppCompatActivity {

    String[] items = {"ISBE", "Nave's Topical Bible", "Smith's Bible Dictionary", "Eerdmans Dictionary", "New Dict. of Theology"};
    int[] checks = {0,1,0,1,0};
    Model[] mModelItems;
    Menu mMenu;
    ListView mListView;
    CustomAdapter mCustomAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {   super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_easy_install);
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.colorAccentDarker));
        Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(myToolbar);
        android.support.v7.app.ActionBar myActionBar = getSupportActionBar();
        if (myActionBar != null)
        {   myActionBar.setDisplayShowHomeEnabled(true);
            myActionBar.setIcon(R.drawable.accordanceicon);
        }
        mListView = (ListView) findViewById(R.id.easy_install_listview);
        mModelItems = new Model[items.length];
        for (int iCntr = 0; iCntr < items.length; iCntr++)
            mModelItems[iCntr] = new Model(items[iCntr], checks[iCntr]);
        mCustomAdapter = new CustomAdapter(this, mModelItems);
        ColorizeTheToolBar.colorizeToolBarItem(this, getResources().getString(R.string.action_download), false);
        ColorizeTheToolBar.colorizeToolBarItem(this, getResources().getString(R.string.action_download_all), false);
        ColorizeTheToolBar.colorizeToolBarItem(this, getResources().getString(R.string.action_store), false);
        ColorizeTheToolBar.colorizeToolBarItem(this, getResources().getString(R.string.action_help), false);
        mListView.setAdapter(mCustomAdapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu myMenu)
    {   getMenuInflater().inflate(R.menu.menu_easy_install_activity, myMenu);
        mMenu = myMenu;
        boolean bIsChecked = false;
        for (int iCntr = 0; iCntr < mCustomAdapter.getCount(); iCntr++)
            if (mCustomAdapter.getItem(iCntr).getValue() > 0)
            {   bIsChecked = true;
                break;
            }
        mMenu.findItem(R.id.action_download).setEnabled(bIsChecked);
        mMenu.findItem(R.id.action_download).setVisible(bIsChecked);
        //Toast.makeText(this, "aha!", Toast.LENGTH_SHORT).show();
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {   int id = item.getItemId();
        if (id == R.id.action_store)
        {   Toast.makeText(this, "Apologies. Store is not yet implemented.", Toast.LENGTH_SHORT).show();
            return true;
        }
        else if (id == R.id.action_download)
        {   Toast.makeText(this, "Apologies. Download is not currently working.", Toast.LENGTH_SHORT).show();
            return true;
        }
        else if (id == R.id.action_download_all)
        {   Toast.makeText(this, "Apologies. Download all is not currently working.", Toast.LENGTH_SHORT).show();
            return true;
        }
        else if (id == R.id.action_help)
        {   Intent myIntent = new Intent(this, ActivityHelp.class);
            startActivity(myIntent);
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public class Model
    {   String name;
        int value; /* 0 -&gt; checkbox disable, 1 -&gt; checkbox enable */

        Model(String name, int value)
        {   this.name = name;
            this.value = value;
        }

        public String getName()
        {   return this.name; }

        public int getValue()
        {   return this.value; }
    }

    public class CustomAdapter extends ArrayAdapter<Model>
    {   Model[] modelItems = null;
        Context mContext;

        public CustomAdapter(Context myContext, Model[] resource)
        {   super(myContext, R.layout.easy_install_row, resource);
            this.mContext = myContext;
            this.modelItems = resource;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent)
        {   LayoutInflater MyLayoutInflater = ((Activity) mContext).getLayoutInflater();
            convertView = MyLayoutInflater.inflate(R.layout.easy_install_row, parent, false);
            TextView myTextView = (TextView) convertView.findViewById(R.id.easy_install_row_textview);
            CheckBox myCheckBox = (CheckBox) convertView.findViewById(R.id.easy_install_row_checkbox);
            myTextView.setText(modelItems[position].getName());
            if (modelItems[position].getValue() == 1)
                myCheckBox.setChecked(true);
            else
                myCheckBox.setChecked(false);
            myCheckBox.setTag(position);
            myCheckBox.setOnClickListener(new View.OnClickListener()
            {   @Override
                public void onClick(View v)
                {   Object iObject = v.getTag();
                    int iTag = (int) iObject;
                    if (modelItems[iTag].value > 0)
                        modelItems[iTag].value = 0;
                    else
                        modelItems[iTag].value = 1;
                    supportInvalidateOptionsMenu();
                }
            });
            return convertView;
        }
    }

    private void setListItemStyles(TextView myTextView)
    {   myTextView.setTextColor(getResources().getColor(R.color.colorDarkGreyText));
        myTextView.setPadding(8, 8, 8, 8);
    }

}

yields these problems (only a portion rendered here, I can provide more if you like):

interface

uses
  android.app,
  android.content,
  android.os,
  android.support.v7.app,
  android.support.v7.widget,
  android.view,
  android.widget;

type
  EasyInstallActivity = public class(AppCompatActivity)
    var items: array of String := ['ISBE', 'Nave''s Topical Bible', 'Smith''s Bible Dictionary', 'Eerdmans Dictionary', 'New Dict. of Theology'];
    var checks: array of Integer := [0, 1, 0, 1, 0];
    var mModelItems: array of Model;
    var mMenu: Menu;
    var mListView: ListView;
    var mCustomAdapter: CustomAdapter;
  private
    method setListItemStyles(myTextView: TextView);
  protected
    method onCreate(savedInstanceState: Bundle);
  public
    method onCreateOptionsMenu(myMenu: Menu): Boolean;
    method onOptionsItemSelected(item: MenuItem): Boolean;
  end;

  Model nested in EasyInstallActivity = public class
    var name: String;
    var value: Integer;
    constructor(name: String; value: Integer);
  public
    method getName: String;
    method getValue: Integer;
  end;

  CustomAdapter nested in EasyInstallActivity = public class(ArrayAdapter)
    var modelItems: array of Model := nil;
    var mContext: Context;
  public
    constructor(myContext: Context; resource: array of Model);
    method getView(position: Integer; convertView: View; parent: ViewGroup): View;
  end;

implementation

method EasyInstallActivity.onCreate(savedInstanceState: Bundle);
begin
  inherited onCreate(savedInstanceState);
  setContentView(R.layout.activity_easy_install);
  if android.os.Build.VERSION.SDK_INT ≥ Build.VERSION_CODES.LOLLIPOP then begin
    getWindow().setNavigationBarColor(getResources().getColor(R.color.colorAccentDarker));
  end;
  var myToolbar: Toolbar := Toolbar(findViewById(R.id.toolbar));
  setSupportActionBar(myToolbar);
  var myActionBar: android.support.v7.app.ActionBar := getSupportActionBar();
  if myActionBar ≠ nil then begin
    myActionBar.setDisplayShowHomeEnabled(true);
    myActionBar.setIcon(R.drawable.accordanceicon);
  end;
  mListView := ListView(findViewById(R.id.easy_install_listview));
  mModelItems := new Model[items.length];
  for iCntr: Integer := 0 to items.length - 1 do
    mModelItems[iCntr] := new Model(items[iCntr], checks[iCntr]);
  mCustomAdapter := new CustomAdapter(self, mModelItems);
  ColorizeTheToolBar.colorizeToolBarItem(self, getResources().getString(R.string.action_download), false);
  ColorizeTheToolBar.colorizeToolBarItem(self, getResources().getString(R.string.action_download_all), false);
  ColorizeTheToolBar.colorizeToolBarItem(self, getResources().getString(R.string.action_store), false);
  ColorizeTheToolBar.colorizeToolBarItem(self, getResources().getString(R.string.action_help), false);
  mListView.setAdapter(mCustomAdapter);
end;

so in the type section I get ‘implementation missing’ on nearly every method. (Except onCreate gets the ‘hide’ issue because the override didn’t convert.) Probably because of the ‘nested in’-ness of the classes, I’m not sure.

Down in implementation, the >= in

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)

gets converted to:

if android.os.Build.VERSION.SDK_INT ≥ Build.VERSION_CODES.LOLLIPOP then begin

so that conversion seems odd like the != conversion earlier. Gives me a ‘“then” expected’.

Some similar deja vu with:

Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);

to

var myToolbar: Toolbar := Toolbar(findViewById(R.id.toolbar));

where I get ‘Unknown identifier’ but here the cast is required. Not sure what to do there.

And then I get several errors that I think descend from the ‘Unknown identifier’.

So I fixed the >= and another <> which helped.

Also fixed some variable names to account for a lack of case-sensitivity.

Then got an error on:

supportInvalidateOptionsMenu();

and if I changed it to:

AppCompatActivity(self.mContext).supportInvalidateOptionsMenu();

it worked, though the cast was necessary, and none of it necessary in java. (Fortunately, the context was already there.)

All the Toolbar references (even though I have the using) requires pre-fixing. To wit:

var myToolbar: Toolbar := Toolbar(findViewById(R.id.toolbar));

has to be

var myToolbar: android.support.v7.widget.Toolbar := android.support.v7.widget.Toolbar(findViewById(R.id.toolbar));

again un-needful in java.

And this line:

if mCustomAdapter.getItem(iCntr).getValue() > 0 then begin

gave me 'No member getValue on type “T”’, which if I cast:

if Model(mCustomAdapter.getItem(iCntr)).getValue() > 0 then begin

then it compiled. Seems unnecessary to me, or if necessary, perhaps part of Oxidizer?

Another file. Issues:

The java:

import android.view.ViewGroup;

converted to the uses section as:

android.view.ViewGroup;

and gives me an Unknown namespace error. Accordingly, my LayoutParams aren’t going over so well either. That would be nice if it worked.

These ‘nested in’ classes are giving me a headache. Is the only way to talk to the class above the nested class is to pass in a constructor with reference to that outside class?

yes.

Do remember that Oxidizer is meant as a tool to aid in converting code from 1 language to another. It’s not a perfect translator. We’ll look into the issues you report to see which are practical to fix.

1 Like

bugs://75487 got closed with status fixed.

bugs://75490 got closed with status fixed.

bugs://75493 got closed with status fixed.

OK, I’ll just report a few more issues as I find them, and then swing back to the ones that I’m not sure how to fix.

Small issues:

Sections like this:

private static final int MAX_CLICK_DURATION = 200, NUM_IMAGE_BUTTONS = 2,
        IB_TOOLBAR_NAVIGATE_BUTTON = 0, IB_HIDE_SEARCH_ONLY = 1;

only translate (to a const) the first of the series, leaving the others undefined.

Similarly, in this:

myTextView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View myView, MotionEvent myMotionEvent)
            {
                int iPointers = myMotionEvent.getPointerCount(), iEvent = myMotionEvent.getAction();
                if (myView == myTextView)

the iEvent line was dropped out.

Back on the ViewGroup / LayoutParams, I can’t seem to include in the uses a reference to android.view.viewgroup in the uses. But this fixes the problem, which seems odd to me:

var myParams: android.view.ViewGroup.LayoutParams := new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT);

And it’s obviously a bit verbose.

But I can use ViewGroup without including it in the uses, for example:

method getGroupView(groupPosition: Integer; isExpanded: Boolean; convertView: View; parent: **ViewGroup**): View; override;

Probably more later.

Rather than repeat the entire file here, I’ve posted it to my Dropbox link sent earlier. I tried importing this file, ScrollingActivityDual.java, and I get:

Value cannot be null.
Parameter name: value

I don’t think the file is damaged, but something odd is going on, because I’ve been able to import about 12 other files without hitting this.

bugs://75496 got closed with status fixed.

On the Value cannot be null import, this function does it:

public void onClickFoldUnfold(View myView)
{   LinearLayoutCompat.LayoutParams myLayoutParams;
    if (mIsToolbarHidden)
    {   myImageButtonArray[IB_HIDE_SEARCH_ONLY].setImageResource(R.drawable.hide_action_bar_icon_48);
        myMainAppBarLayout.setVisibility(View.VISIBLE);
        ViewGroup.MarginLayoutParams myParams = (ViewGroup.MarginLayoutParams) myLinearLayoutCompat.getLayoutParams();
        myParams.setMargins(0, getResources().getDimensionPixelSize(R.dimen.layout_margin_for_toolbar_top), 0 , 0);
        myLinearLayoutCompat.setLayoutParams(myParams);
        myLayoutParams = (LinearLayoutCompat.LayoutParams) myLinearLayoutUpper.getLayoutParams();
        myLayoutParams.weight = 50;
        myLinearLayoutUpper.setLayoutParams(myLayoutParams);
    }
    else
    {   myImageButtonArray[IB_HIDE_SEARCH_ONLY].setImageResource(R.drawable.show_action_bar_icon_48);
        myMainAppBarLayout.setVisibility(View.GONE);
        ViewGroup.MarginLayoutParams myParams = (ViewGroup.MarginLayoutParams) myLinearLayoutCompat.getLayoutParams();
        myParams.setMargins(0, 0, 0, 0);
        myLinearLayoutCompat.setLayoutParams(myParams);
        int iHeight = myLinearLayoutCompat.getHeight();
        int iChange = getResources().getDimensionPixelSize(R.dimen.layout_margin_for_toolbar_top);
        float fPercent = 2 * ((float) iChange) / ((float) iHeight) + 1;
        myLayoutParams = (LinearLayoutCompat.LayoutParams) myLinearLayoutUpper.getLayoutParams();
        myLayoutParams.weight = (int) (50 * fPercent);
        myLinearLayoutUpper.setLayoutParams(myLayoutParams);
    }
    mIsToolbarHidden = !mIsToolbarHidden;
}

There might be more, but that one causes it when you paste java as oxygene.

bugs://75498 got closed with status fixed.

bugs://75500 got closed with status fixed.

bugs://75501 got closed with status fixed.

Logged as bugs://i63457.

bugs://i63457 was closed as fixed.