Modifying the AltNotifier extension?

Could you please tell me the link to version 1.2?
I didn't understand where it should be :))

It is in the first post of the topic AltNotifier

2 Likes

Thanks for your interesting extension.
I am using your code as a tutorial for myself.
Please tell me, with what method can I call only the numeric keypad?
It could be in this line but I don't understand how to change it.....

        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

How to enable the "numbers only" keyboard?

Here is the code for the numbers only dialog. You set the inputType in the AlertDialog builder.

private void numberTextInputDialog(String message, String title, boolean cancelable) {

        AlertDialog.Builder alert = new AlertDialog.Builder(activity);

        alert.setTitle(title);
        alert.setMessage(message);
        alert.setCancelable(false);
        final EditText input = new EditText(activity);
        input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        input.setKeyListener(DigitsKeyListener.getInstance("0123456789,.-"));
        alert.setView(input);

        alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                HideKeyboard((View) input);
                AfterNumberTextInput(input.getText().toString());
            }
        });

        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                HideKeyboard((View) input);
                //TextInputCanceled();

                AfterTextInput("Cancel");
            }
        });

        alert.show();

        // Request focus after showing dialog
        input.requestFocus();
        // Show soft keyboard
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

    }
1 Like

Probably, here is the complete java for the current extension....

JAVA
/**
 * Alternative notifier extension with three methods not found in the standard
 * notifer in App Inventor, but based upon the original code.
 * Credits: @HalAbelson - MIT who wrote the original notifier code
 * Credits: @Shreyash for the Rush extension builder
 *
 * Created by: @TIMAI2 April 2021
 */


package metricrat.ai2.altnotifier;

import android.app.Activity;
import android.app.AlertDialog;
import android.text.*;
import android.text.method.*;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.LinearLayout;
import android.view.View;
import android.content.DialogInterface;
import android.view.inputmethod.InputMethodManager;
import android.content.Context;
import android.view.WindowManager.LayoutParams;

import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.errors.YailRuntimeError;
import com.google.appinventor.components.runtime.util.YailList;

public class AltNotifier extends AndroidNonvisibleComponent {

    private final Activity activity;

    public AltNotifier(ComponentContainer container) {
        super(container.$form());
        activity = container.$context();

    }

    /** ######################################################################################################
     *  QUESTION DIALOG
     */

    @SimpleFunction(description = "Shows a question dialog, set by the user, and allows a"
            + " positive response or cancel from the user. A response event is raised ")

    public void ShowQuestionDialog(String question, String title, String buttonText, boolean cancelable) {
        QuestionAlert(question, title, buttonText, cancelable);
    }

    private void QuestionAlert(String question, String title, String buttonText, boolean cancelable) {

        AlertDialog.Builder alert = new AlertDialog.Builder(activity);
        alert.setTitle(title);
        alert.setMessage(question);
        alert.setCancelable(false);

        alert.setPositiveButton(buttonText, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

                AfterQuestion(buttonText.toString());
            }
        });

        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

                AfterQuestion("Cancel");
            }
        });

        alert.show();

    }


    /**
     * Event raised after the user has responded to ShowQuestionDialog.
     * @param response is the button text selected
     */
    @SimpleEvent(
            description = "Event raised after the user has responded to ShowQuestionDialog.")
    public void AfterQuestion(String response) {
        EventDispatcher.dispatchEvent(this, "AfterQuestion", response);
    }

    /** ##############################################################################################################
     *  LOGIN/PASS ENTRY DIALOG
     */

    @SimpleFunction(description = "Shows a dialog box where the user can enter Login"
            + "and Password details. The user can also cancel")

    public void ShowLoginDialog(String message, String title, boolean cancelable) {
        loginInputDialog(message, title, cancelable);
    }

    private void loginInputDialog(String message, String title, boolean cancelable) {

        AlertDialog.Builder alert = new AlertDialog.Builder(activity);

        alert.setTitle(title);
        alert.setMessage(message);
        alert.setCancelable(false);

        LinearLayout layout = new LinearLayout(activity);
        layout.setOrientation(LinearLayout.VERTICAL);
        final EditText inputLogin = new EditText(activity);
        inputLogin.setHint("Login Name");
        layout.addView(inputLogin);
        final EditText inputPass = new EditText(activity);
        inputPass.setHint("Password");
        layout.addView(inputPass);
        alert.setView(layout);

        alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                HideKeyboard((View) layout);
                AfterLoginInput(inputLogin.getText().toString(), inputPass.getText().toString());
            }
        });

        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                HideKeyboard((View) layout);
                //LoginInputCanceled();
                AfterLoginInput("Cancel", "Cancel");
            }
        });

        alert.show();

        // Request focus after showing dialog
        inputLogin.requestFocus();
        // Show soft keyboard
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

    }

    /**
     * Event raised after the user has responded to loginInputDialog.
     * @param //response is the text that was entered
     */
    @SimpleEvent(description = "Event raised after the user has responded to ShowLoginDialog.")
    public void AfterLoginInput(String login, String password) {
        EventDispatcher.dispatchEvent(this, "AfterLoginInput", login, password);
    }

    /**
     * Event raised when the user canceled loginInputDialog.

    @SimpleEvent(description = "Event raised when the user canceled ShowLoginDialog.")
    public void LoginInputCanceled() {
        EventDispatcher.dispatchEvent(this, "LoginInputCanceled");
    }
     */


    /** ##############################################################################################################
     *  TEXT ENTRY WITH CONTENT DIALOG
     */

    @SimpleFunction(description = "Shows a dialog box where the user can enter text, after which the "
            + "AfterTextInput event will be raised.  If cancelable is true there will be an additional CANCEL button. "
            + "Entering text will raise the AfterTextInput event.  The \"response\" parameter to AfterTextInput "
            + "will be the text that was entered, or \"Cancel\" if the CANCEL button was pressed."
            + "A default text (content) can be added to the text entry box")

    public void ShowTextDialog(String message, String title, String content, boolean cancelable) {
        textInputDialog(message, title, content, cancelable);
    }

    private void textInputDialog(String message, String title, String content, boolean cancelable) {

        AlertDialog.Builder alert = new AlertDialog.Builder(activity);

        alert.setTitle(title);
        alert.setMessage(message);
        alert.setCancelable(false);
        final EditText input = new EditText(activity);
        input.setText(content);
        alert.setView(input);

        alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                HideKeyboard((View) input);
                AfterTextInput(input.getText().toString());
            }
        });

        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                HideKeyboard((View) input);
                //TextInputCanceled();

                AfterTextInput("Cancel");
            }
        });

        alert.show();

        // Request focus after showing dialog
        input.requestFocus();
        // Show soft keyboard
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

    }


    /**
     * Event raised after the user has responded to ShowTextDialog.
     * @param response is the text that was entered
     */
    @SimpleEvent(
            description = "Event raised after the user has responded to ShowTextDialog.")
    public void AfterTextInput(String response) {
        EventDispatcher.dispatchEvent(this, "AfterTextInput", response);
    }

    /**
     * Event raised when the user canceled ShowTextDialog.
    @SimpleEvent(
            description = "Event raised when the user canceled ShowTextDialog.")
    public void TextInputCanceled() {
        EventDispatcher.dispatchEvent(this, "TextInputCanceled");
    }
     */

    /** ##############################################################################################################
     *  NUMBER TEXT ENTRY DIALOG
     */

    @SimpleFunction(description = "Shows a dialog box where the user can enter number text, after which the "
            + "AfterNumberTextInput event will be raised.  If cancelable is true there will be an additional CANCEL button.")

    public void ShowNumberTextDialog(String message, String title, boolean cancelable) { numberTextInputDialog(message, title, cancelable); }

    private void numberTextInputDialog(String message, String title, boolean cancelable) {

        AlertDialog.Builder alert = new AlertDialog.Builder(activity);

        alert.setTitle(title);
        alert.setMessage(message);
        alert.setCancelable(false);
        final EditText input = new EditText(activity);
        input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        input.setKeyListener(DigitsKeyListener.getInstance("0123456789,.-"));
        alert.setView(input);

        alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                HideKeyboard((View) input);
                AfterNumberTextInput(input.getText().toString());
            }
        });

        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                HideKeyboard((View) input);
                //TextInputCanceled();

                AfterTextInput("Cancel");
            }
        });

        alert.show();

        // Request focus after showing dialog
        input.requestFocus();
        // Show soft keyboard
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

    }


    /**
     * Event raised after the user has responded to NumberTextDialog.
     * @param response is the text that was entered
     */
    @SimpleEvent(
            description = "Event raised after the user has responded to NumberTextDialog.")
    public void AfterNumberTextInput(String response) {
        EventDispatcher.dispatchEvent(this, "AfterNumberTextInput", response);
    }

    /**
     * Event raised when the user canceled ShowTextDialog.
     @SimpleEvent(
     description = "Event raised when the user canceled ShowTextDialog.")
     public void TextInputCanceled() {
     EventDispatcher.dispatchEvent(this, "TextInputCanceled");
     }
     */



    /** #########################################################################################################
     * Hide soft keyboard after user either enters text or cancels.
     */
    public void HideKeyboard(View view) {
        if (view != null) {
            InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    }

}

1 Like

I managed to compile V1.0.
So in it, I'm carefully trying to make changes.
Unfortunately with V1.2 the same method doesn't work,
I have V1.2 giving an error.

Maybe I have the wrong version of Java assembly?.
This is the version of Java I have now.
2023-01-13 19 54 59

I can compile V1.0 source.
In the V1.2 source I don't see any syntactic differences,
but it throws an error...
Can you please give me a hint why I am getting a negative result?

Rename your file from "Altnotifier.java" to "AltNotifier.java", make sure the class name and the file names match.

1 Like

What do you mean change?
I made a screenshot with the numbers.
All names are spelled correctly.
Any change in the names causes the project to malfunction.
(sorry for the poorly composed text, I'm talking through google translator :-))

The name of your file is wrong. This is case sensitive. Use AltNotifier.java, not Altnotifier.java.

2 Likes

Look at the letter "n" in "Altnotifier", it must be capital -> "AltNotifier".

2 Likes

Thank you very much!!
Everything is working correctly now.:smiley:

1 Like

Дякую @TIMAI2 за ваш вихідний проект.
Мені тут багато що вдалося, і я змінив кілька речей у вашому проекті.
Це було дуже цікаво редагувати та створювати такі модулі.
На жаль, через мовний бар'єр мені важко описати всі зміни, що тут зроблені мною.

  • Але до свого повідомлення я прикладаю скрін блоків, мій вихідний проект та готовий файл .aix.*
    можливо, кому це також буде цікавим.
    ------------------------------------------------
    Особливо зараз мені подобається що у всіх блоків, тепер є індифікатор (побачив таке у @gordonlu310, також дяка йому велика). З цімі дуже зрусно обробляти пришедшу інформацію.
    ----------------------------------------------------------------------------
    З нереалізованого, є ще мрія зробити "NumberPicker".
    Я такий бачив у @ Gordon Lu, на жаль, я без зрозумілого прикладу таке не зможу зробити.
  • Дякую всім, я дуже задоволений виконаною роботою.*
    =============================================emphasized text

Many thanks to @TIMAI2 for your initial project. :+1:
I succeeded and I changed a few things in your project.
It was very interesting to edit such modules.
Unfortunately, due to the language barrier, it is difficult for me to describe all the changes that I have made.
But I'm attaching a block screen, my original project, and a finished .aix file to my post.
maybe someone else will find it interesting too.

I especially like that all blocks now have an indicator (I spied on the @gordonlu310, also thank you very much).

From unrealized there is still a dream to make "NumberPicker".
I saw this at the @gordonlu310, unfortunately I can’t do this without a clear example.
Thank you all, I am very pleased with the work done.
[Placeholder for extension]
[Placeholder for java text file]

1 Like

You should rename your extension to something else (different package name and extension name) to avoid confusion with the original (my) extension (and Jarlison's extension). You should also give credit to Jarlison.

I have removed your uploads for the time being

2 Likes

Thank you. I understood everything about the confusion, except for the phrase
"You should also give credit to Jarlison."
explain again what it means
or give a link to this action.

In your java file NotificationStyle.txt your package is named:
package com.jdl.notificationstyle;

If you used some of his work, then you should give credit (acknowledge their work)

Is it implied?
2023-01-17 14 35 00

Moving all this to a new topic

My version of the notifier upgrade.
The goal was to simplify the change of integers and text, with subsequent processing and saving.
Main addition:

  1. this is a built-in indicator in each block.
  2. when calling the block, it is possible to set the initial values of digital and text values.

/**
 * Optional upgrade, to extend the notifier, with a little variety to change the variables.
 * notifer in App Inventor, but based upon the original code.
 * Credits: @HalAbelson - MIT who wrote the original notifier code
 * Credits: @Shreyash for the Rush extension builder
 * Credits: @TIMAI2 available source was the basis of the upgrade
 * Credits: @Gordon_Lu available source
 *
 * Additions: @DIY_channel, 18-01-2023(Ukraine)
 */

package sxem.org.metodnotifier;

import android.app.Activity;
import android.app.AlertDialog;
import android.text.*;
import android.text.method.*;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.LinearLayout;
import android.view.View;
import android.content.DialogInterface;
import android.view.inputmethod.InputMethodManager;
import android.content.Context;
import android.view.WindowManager.LayoutParams;
import android.widget.NumberPicker;
import android.graphics.Typeface;

import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.errors.YailRuntimeError;
import com.google.appinventor.components.runtime.util.YailList;


public class MetodNotifier extends AndroidNonvisibleComponent {

    private final Context context;
    private Activity activity;

    public MetodNotifier(ComponentContainer container){
        super(container.$form());
        activity = container.$context();
        this.context = container.$context();
    }

    /** ###################################################################################################### 
     *    ДІАЛОГ ЗАПИТАНня      QUESTION DIALOG 
     */

    @SimpleFunction(description = "Показує діалогове вікно запитань, яке встановлює користувач, і дозволяє "
            + " позитивну відповідь або скасування від користувача. Викликається відповідна подія          \n "		
            + " variant=0 Left,Right,Cancel         \n "		
            + " variant=1 Left,Right                \n "		
            + " variant=2 Left,Cancel               \n "		
            + " variant>=3 Left,Right,Cancel")

    public void InfoChoiceDialog(final int identify, String message, String title, String buttonTextLeft, String buttonTextRight, final int variant) {
        InfoChoiceAlert(identify, message, title, buttonTextLeft, buttonTextRight,  variant);
    }

    private void InfoChoiceAlert(final int identify, String message, String title, String buttonTextLeft, String buttonTextRight, final int variant) {

        AlertDialog.Builder alert = new AlertDialog.Builder(activity);
        alert.setTitle(title);
        alert.setMessage(message);
        

        alert.setPositiveButton(buttonTextLeft, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

                InfoChoicelnput(identify, buttonTextLeft.toString());
            }
        });
		
        if (variant <= 1 || variant > 3) {
        alert.setNeutralButton( buttonTextRight, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

                InfoChoicelnput(identify, buttonTextRight.toString());
            }
        });
		}

		
        if (variant < 1 || variant == 2) {
        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                   InfoChoiceCanceled(identify);
                //AfterQuestion("Cancel");
            }
        });
       }
        alert.show();
    }
	
	
    /**
     * Подія виникає після відповіді користувача на ПоказатДіалогЗапитання.
     * @param відповідь — це вибраний текст кнопки
     */
    @SimpleEvent(
            description = "Event raised after the user has responded to ShowQuestionDialog.")
    public void InfoChoicelnput(final int identify, String response) {
        EventDispatcher.dispatchEvent(this, "InfoChoicelnput", identify, response);
    }
	
    /**
       * Подія, викликана, коли користувач скасував ПоказатиТекстДіалог. 
	*/
    @SimpleEvent(
            description = "Event raised when the user canceled ПоказатиТекстДіалог.")
    public void InfoChoiceCanceled(final int identify) {
        EventDispatcher.dispatchEvent(this, "InfoChoiceCanceled", identify);
    }

    /** ##############################################################################################################
     *    ДІАЛОГ ЛОГІН/ПАРОЛЬ ВХІДУ        LOGIN/PASS ENTRY DIALOG  , String backgrup, String backgrdw
     */

    @SimpleFunction(description = "Показує діалогове вікно, де користувач може ввести логін"
            + "і деталі пароля. Користувач також може скасувати")

    public void DubliViknaDialog(final int identify, String message, String title, String hintUp, String hintDown, String textUp, String textDown, boolean cancelable) {
        ViknoDubliViknaTekst( identify, message, title, hintUp, hintDown, textUp, textDown, cancelable);
    }

      private void ViknoDubliViknaTekst(final int identify, String message, String title, String hintUp, String hintDown, String textUp, String textDown, boolean cancelable) {

        AlertDialog.Builder alert = new AlertDialog.Builder(activity);

        alert.setTitle(title);
        alert.setMessage(message);
        alert.setCancelable(false);
        LinearLayout layout = new LinearLayout(activity);
        layout.setOrientation(LinearLayout.VERTICAL);
        final EditText inputLogin = new EditText(activity);
        inputLogin.setHint(hintUp);
		inputLogin.setText(textUp);
        layout.addView(inputLogin);
        final EditText inputPass = new EditText(activity);
        inputPass.setHint(hintDown);
		inputPass.setText(textDown);
		layout.addView(inputPass);
        alert.setView(layout);
		
		
		

        alert.setPositiveButton("OK!", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                HideKeyboard((View) layout);
                DubliViknaTextlnput(identify, inputLogin.getText().toString(), inputPass.getText().toString());
            }
        });
       
	    if (cancelable) {
        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                DubliViknaCanceled(identify);
                HideKeyboard((View) layout);
                //DubliViknaTextlnput("Cancel", "Cancel");
            }
        });
      }
        alert.show();
        // Request focus after showing dialog Запитати фокус після показу діалогу
        inputLogin.requestFocus();
        // Show soft keyboard Показати програмну клавіатуру
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
     }

    /**
     * Подія виникає після відповіді користувача на ВікноВведення2текст.
     * @param відповідь – це введений текст
     */
    @SimpleEvent(description = "Подія, що виникає після того, як користувач відповів на ДубльВікнаТекст.")
    public void DubliViknaTextlnput(final int identify, String textup, String textdown) {
        EventDispatcher.dispatchEvent(this, "DubliViknaTextlnput", identify, textup, textdown);
    }

    /**
     * Подія виникає, коли користувач скасував ВікноВведення2текст.
     */
    @SimpleEvent(description = "Event raised when the user canceled ДубльВікнаТекст.")
    public void DubliViknaCanceled(final int identify) {
        EventDispatcher.dispatchEvent(this, "DubliViknaCanceled", identify);
    }
     
    /** ##############################################################################################################
     * 
     */
	
    @SimpleFunction(description = "Displays a number picker dialog that enables the user to select a number from a predefined range.")
       public void NumberPickerDialog(final int identify, String message, String title, String buttonText,
	int defaultValue, int minValue, int maxValue, boolean cancelable) {
        TextNumberPickerDialog(identify, message, title, buttonText, defaultValue, minValue, maxValue, cancelable);
    }
    private void TextNumberPickerDialog(final int identify, String message, String title, String buttonText,
	int defaultValue, int minValue, int maxValue, boolean cancelable) {
		
		 AlertDialog.Builder alert = new AlertDialog.Builder(this.context);
        final NumberPicker numberPicker = new NumberPicker(this.context);
        numberPicker.setMaxValue(maxValue);
        numberPicker.setMinValue(minValue);
		numberPicker.setValue(defaultValue);

        alert.setView(numberPicker); 
        alert.setCancelable(false);
		 alert.setTitle(title);
         alert.setMessage(message);
        alert.setPositiveButton(buttonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        NumberPickerInput(identify, numberPicker.getValue());
      }
      });
        if (cancelable) {
        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        NumberPickerCanceled(identify);
      }
    });
       }
        alert.show();
    }

    @SimpleEvent(description = "This event is fired when the user has pressed the OK button in a number picker dialog.")
    public void NumberPickerInput(int identify, int number) {
        EventDispatcher.dispatchEvent(this, "NumberPickerInput", identify, number);
    }
    @SimpleEvent(description = "This event is fired when the user has pressed the cancel button in a number picker dialog.")
    public void NumberPickerCanceled(int identify) {
        EventDispatcher.dispatchEvent(this, "NumberPickerCanceled", identify);
    }
	
    /** ##############################################################################################################
     * 
     */
   
     @SimpleFunction(description = "Shows a text input dialog. \n "
          + "0 без спілкування.           \n "
          + "1 звич. текст.               \n "
          + "2 тільки цифри.              \n "
          + "3 номер телефона.            \n "
          + "4 дата/час.                  \n "
          + "32 адреса электроной пошти. ") 
	 

    public void ShowTextInputDialog(final int identify, String message, String title, String textDefault, String hintText,
    int hintColor, int inputColor, String buttonText, String cancelButtonText, boolean cancelable, int inputType) {
        TextInputDialog( identify, message, title, textDefault, hintText, hintColor, inputColor, buttonText, cancelButtonText, cancelable, inputType);
    }
    private void TextInputDialog(final int identify, String message, String title, String textDefault, String hintText,
    int hintColor, int inputColor, String buttonText, String cancelButtonText, boolean cancelable, int inputType) {
		
        AlertDialog.Builder alert = new AlertDialog.Builder(this.context);
        alert.setTitle(title);

            alert.setMessage(message);

        alert.setCancelable(false);
        final EditText edit = new EditText(this.context);
        edit.setText(textDefault);
        edit.setHintTextColor(hintColor);
        edit.setTextColor(inputColor);
        edit.setHint(hintText);
        edit.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
        edit.setInputType(inputType);
        alert.setView(edit);
		
        alert.setPositiveButton(buttonText, new DialogInterface.OnClickListener() { 
        @Override
        public void onClick(DialogInterface dialog, int which) {
        TextDialogInput(identify, edit.getText().toString());
        InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(edit.getWindowToken(), 0);
        }
    });
        if (cancelable) {
        alert.setNegativeButton(cancelButtonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        TextDialogCanceled(identify);
        InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(edit.getWindowToken(), 0);
    }
});
        }
        alert.show();
 }  
   

    @SimpleEvent(description = "This event is fired when the user has pressed the OK button in a text response dialog.")
    public void TextDialogInput(final int identify, String response) {
        EventDispatcher.dispatchEvent(this, "TextDialogInput", identify, response);
    }

    @SimpleEvent(description = "This event is fired when the user has pressed the cancel button in a text response dialog.")
    public void TextDialogCanceled(final int identify) {
        EventDispatcher.dispatchEvent(this, "TextDialogCanceled", identify);
   }
   
    /** #########################################################################################################
     *  Приховати програмну клавіатуру після того, як користувач введе текст або скасує введення.
     */
    public void HideKeyboard(View view) {
        if (view != null) {
            InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    }

}


MetodNotifierV1_0.aia (125.6 KB)
sxem.org.metodnotifier.aix (29.4 KB)

1 Like

In the code above, the PickerDialog currently changes the number in 1 step. (And that's fine).
But I have an interest to change this number in increments of 2.3 or 5...
Please tell me the method (code), how can this be implemented here?
(the text of the message was written through google translator :)))

For me, Java is a difficult language.
I am good at making programs in C++.
If I had to complete an action,
to change the number with step width.
For me in C it's not difficult, I would do it like this

#define step 5 // set step width
#define minValue 0
#define maxValue 59
unsigned int context =0; //declare an integer
// = = =
while (1)
{
if( ! plusButton && context < maxValue )
{
context = context + step;
}

    if( ! minusButton && context > minValue) 
    { 
     context =  context - step;
    }

}

Probably for those who work with Java
It's also not a problem to make such a mathematical calculation.
Please suggest a solution for this problem.