cancel
Showing results for 
Search instead for 
Did you mean: 

OpenUI - my class.

former_member193863
Participant
0 Kudos

Hello experts,

I have a question, if I wanted to change just one field in the image is a class which I should edit? I would like to ensure that the data were read using an external library, to read RFID tags.

BR

Lukas

Tags edited by: Michael Appleby

Accepted Solutions (1)

Accepted Solutions (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Lukas,

Guessing from your message about using RFID, I would probably create a new class extending the StringEditAdapter to interface with the RFID reader and return the read value back to Agentry in a field as a String.

--Bill

former_member193863
Participant
0 Kudos

Bill, thank you, I try and I give you feedback.

BR

Lukas

former_member193863
Participant
0 Kudos

Hi Bill, for test I change the color of the text:

_textView.setTextColor(Color.RED);

In MyStringEditAdapter, this class extends StrindEditAdater and I setup new class on Agentry side, but I dont see any change after deploy new apk on this fild.

Why?

BR

Lukas

/*

* MyStringEditAdapter.java

*/

package com.sap.mobile.platform.client.openui.extensions;

import android.content.Context;

import android.graphics.Color;

import android.view.Gravity;

import android.view.View;

import android.widget.EditText;

import com.sap.mobile.platform.client.openui.adapters.StringEditAdapter;

import com.sap.mobile.platform.client.openui.models.StringEditModel;

import com.sap.mobile.platform.client.openui.utils.Helpers;

import com.sap.mobile.platform.core.openui.AutosizeBehavior;

public class MyStringEditAdapter extends StringEditAdapter

{

    /** Core model */

    StringEditModel _model;

    /** App context */

    Context _context;

    /** Text view */

    EditText _textView;

    /** Allows auto height */

    boolean _autoHeight;

    /** Carriage return */

    boolean _carriageReturn;

    /** Word Wrapt */

    boolean _wordWrap;

    /*

     * (non-Javadoc)

     *

     * @see

     * com.sap.mobile.platform.client.openui.adapters.StringDisplayAdapter#initialize(com.sap.mobile.platform.client

     * .openui.models.StringDisplayModel, android.content.Context)

     */

    @Override

    public void initialize(StringEditModel model, Context context)

    {

        _model = model;

        _context = context;

        _carriageReturn = _model.isCarriageReturnAllowed();

        _wordWrap = _model.isWordWrapAllowed();

        _autoHeight = _model.isAutosizeSupported();

    }

    /*

     * (non-Javadoc)

     *

     * @see com.sap.mobile.platform.client.openui.adapters.FieldAdapter#getView()

     */

    @Override

    public View getView()

    {

        _textView = new EditText(_context);

        _textView.setText(_model.getValue());


        _textView.setTextColor(Color.RED); //LR

        _textView.setGravity(Gravity.CENTER_VERTICAL);

        if (!canHandleAutosizing())

        {

            _textView.setSingleLine();

        }

        _textView.setOnFocusChangeListener(new View.OnFocusChangeListener()

        {

            @Override

            public void onFocusChange(View v, boolean hasFocus)

            {

                if (!hasFocus)

                {

                    _model.processInput(_textView.getText().toString());

                }

            }// end onFocuschange

        });// end setOnFocusChangeListener

        return _textView;

    }

    /**

     * Can we handle autosizing?

     *

     * @return if we can handle autosizing

     */

    public boolean canHandleAutosizing()

    {

        if (_autoHeight && (_wordWrap || _carriageReturn))

        {

            return true;

        }

        return false;

    }

    @Override

    public AutosizeBehavior getAutosizeBehavior()

    {

        if (canHandleAutosizing())

        {

            return AutosizeBehavior.Autosize_FillVisible;

        }

        return AutosizeBehavior.Autosize_None;

    }

    @Override

    public void valueChanged(String value)

    {

        _textView.setText(_model.getValue());

    }

    @Override

    public boolean isAgentryDisplayingLabel()

    {

        return true;

    }

    @Override

    public int getContentHeightForAutosizing(int width)

    {

        int height = Helpers.AutosizeUtils.heightForMultiLineText(_textView, width, _carriageReturn, _wordWrap);

        return height;

    }

}

former_member193863
Participant
0 Kudos

Bill, and one more question, to WM I have the same list of the class like in Samples? So I can use this class from Samples to change WM client?

BR

Lukas

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

With Open UI you are adding additional classes to the Agentry client.  All of the products utilize an Agentry client so yes it can be used with Work Manager.

Also, you need to make sure the field on the screen you are looking at is configured to use your Open UI class.  It doesn't automatically change every field in your application you still need to configure it in the editor to use your new class.  This gives you the flexibility to control exactly when it is used.

--Bill

former_member193863
Participant
0 Kudos

Hi Bill, I change in field, external field, the class Name and I publish then Agentry application to server. And I do not see my change.

BR

Lukas

former_member193863
Participant
0 Kudos

Bill, Maybe you have a small example that could steer me on track?

BR

Lukas

former_member193863
Participant
0 Kudos

Hi, I fix this, solution is setting the default style on the field.

BR

Lukas

agentry_src
Active Contributor
0 Kudos

Hi Lukas,

Please mark this Discussion with a Correct Answer and Helpful Answer where appropriate.  See http://scn.sap.com/community/support/blog/2013/04/03/how-to-close-a-discussion-and-why   Even if you discovered the solution without any outside contributions, it helps others to understand what the solution turned out to be.

Regards, Mike
SAP Customer Experience Group - CEG

former_member193863
Participant
0 Kudos

Hi Michael, I will be remember on this, done.

BR

Lukas

Answers (0)