Android Question Disable edittext auto-fill

RB Smissaert

Well-Known Member
Licensed User
Longtime User
In a B4XPages project when an edittext is clicked the Auto-fill button will pop up.
Is there any way (Java code?) to avoid this?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
There is no relation between the project type and the behavior of views.

B4X:
EditText1.InputType = Bit.Or(EditText1.InputType, 0x00080000)
I didn't think there was any relation, but thought to mention it in case it was of any relevance.
I tried that already, but it made no difference and the reason for that is that I am using a custom keyboard
and should have mentioned that. Was hoping there was an other way to avoid the popups other than through
the InputType property.

As I have my own custom keyboard I have disabled the default custom keyboard:

B4X:
Sub SetEditTextInput_Type(bDoCustomKeyboard As Boolean, oEditText As  EditText, iKeyBoardType As Int, bHandleAction As Boolean)
    
    'Log("SetEditTextInput_Type, iKeyBoardType: " & iKeyBoardType)
    
    If NativeMe.IsInitialized = False Then
        NativeMe.InitializeContext
    End If
    
    If bDoCustomKeyboard Then
        NativeMe.RunMethod("disableSoftKeyboard", Array As Object(oEditText))
        'oEditText.InputType = Bit.Or(oEditText.InputType, 0x00080000)
    Else
        Select Case iKeyBoardType
            Case Enums.eKeyboardStates.LowerCase, Enums.eKeyboardStates.UpperCase, Enums.eKeyboardStates.UpperCaseFixed, _
                 Enums.eKeyboardStates.Symbols1, Enums.eKeyboardStates.Symbols2
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (1 + 524288)))
            Case Enums.eKeyboardStates.Numeric
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, 2))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789")
            Case Enums.eKeyboardStates.Decimals
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (2 + 8192)))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789.")
            Case Enums.eKeyboardStates.NumericWithMinus
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (2 + 4096)))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789-")
            Case Enums.eKeyboardStates.DecimalsWithMinus
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (2 + 4096 + 8192)))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789.-")
        End Select
        
        If bHandleAction Then
            'will show Next button to handle the action
            'will need to specify the action in ime_HandleAction
            ime.AddHandleActionEvent(oEditText)
        End If
    End If
    
End Sub

The strange thing is that when I go to a B4XPage and the edittext is clicked first time during the visit to that page then there is no popup.
Then when the keyboard is closed (via the bottom right back key) and then the edittext is clicked again then the popup appears.
I think the solution to this problem is finding out why first time all is OK and then after that not.

The above code (SetEditTextInput_Type) runs only once per edittext.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I didn't think there was any relation, but thought to mention it in case it was of any relevance.
I tried that already, but it made no difference and the reason for that is that I am using a custom keyboard
and should have mentioned that. Was hoping there was an other way to avoid the popups other than through
the InputType property.

As I have my own custom keyboard I have disabled the default custom keyboard:

B4X:
Sub SetEditTextInput_Type(bDoCustomKeyboard As Boolean, oEditText As  EditText, iKeyBoardType As Int, bHandleAction As Boolean)
   
    'Log("SetEditTextInput_Type, iKeyBoardType: " & iKeyBoardType)
   
    If NativeMe.IsInitialized = False Then
        NativeMe.InitializeContext
    End If
   
    If bDoCustomKeyboard Then
        NativeMe.RunMethod("disableSoftKeyboard", Array As Object(oEditText))
        'oEditText.InputType = Bit.Or(oEditText.InputType, 0x00080000)
    Else
        Select Case iKeyBoardType
            Case Enums.eKeyboardStates.LowerCase, Enums.eKeyboardStates.UpperCase, Enums.eKeyboardStates.UpperCaseFixed, _
                 Enums.eKeyboardStates.Symbols1, Enums.eKeyboardStates.Symbols2
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (1 + 524288)))
            Case Enums.eKeyboardStates.Numeric
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, 2))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789")
            Case Enums.eKeyboardStates.Decimals
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (2 + 8192)))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789.")
            Case Enums.eKeyboardStates.NumericWithMinus
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (2 + 4096)))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789-")
            Case Enums.eKeyboardStates.DecimalsWithMinus
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (2 + 4096 + 8192)))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789.-")
        End Select
       
        If bHandleAction Then
            'will show Next button to handle the action
            'will need to specify the action in ime_HandleAction
            ime.AddHandleActionEvent(oEditText)
        End If
    End If
   
End Sub

The strange thing is that when I go to a B4XPage and the edittext is clicked first time during the visit to that page then there is no popup.
Then when the keyboard is closed (via the bottom right back key) and then the edittext is clicked again then the popup appears.
I think the solution to this problem is finding out why first time all is OK and then after that not.

The above code (SetEditTextInput_Type) runs only once per edittext.

RBS
As the Auto-fill only pops up when the edittext is clicked when it has the focus (cursor is visible). There is a way round this by hiding the cursor
when the keyboard is closed and make the cursor visible when the edittext gets clicked, but there are some drawbacks to this. The main reason
to not make the popup not happen is that it takes one more click on the back button to make the keyboard disappear.

This is the code to manipulate the cursor:

B4X:
Sub SetCursorVisible(edt As EditText, Visible As Boolean)
    Dim jo = edt As JavaObject
    jo.RunMethod("setCursorVisible", Array As Object(Visible))
End Sub

I think I will just have to accept it as it is, unless some has some other solution.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
There is no relation between the project type and the behavior of views.

B4X:
EditText1.InputType = Bit.Or(EditText1.InputType, 0x00080000)
Reading this post:

Makes me think that the reason

B4X:
EditText1.InputType = Bit.Or(EditText1.InputType, 0x00080000)

didn't stop the popup has nothing to do with my custom keyboard, but has to do with the phone (I am now on a Samsung S24).
Will investigate further.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Reading this post:

Makes me think that the reason

B4X:
EditText1.InputType = Bit.Or(EditText1.InputType, 0x00080000)

didn't stop the popup has nothing to do with my custom keyboard, but has to do with the phone (I am now on a Samsung S24).
Will investigate further.

RBS
Confirmed now that it has nil to do with the custom keyboard as the popup is stopped nicely on a Samsung Tab S6 Lite tablet, using the line:

B4X:
EditText1.InputType = Bit.Or(EditText1.InputType, 0x00080000)

It looks I need to be able to manipulate that popup.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I didn't think there was any relation, but thought to mention it in case it was of any relevance.
I tried that already, but it made no difference and the reason for that is that I am using a custom keyboard
and should have mentioned that. Was hoping there was an other way to avoid the popups other than through
the InputType property.

As I have my own custom keyboard I have disabled the default custom keyboard:

B4X:
Sub SetEditTextInput_Type(bDoCustomKeyboard As Boolean, oEditText As  EditText, iKeyBoardType As Int, bHandleAction As Boolean)
   
    'Log("SetEditTextInput_Type, iKeyBoardType: " & iKeyBoardType)
   
    If NativeMe.IsInitialized = False Then
        NativeMe.InitializeContext
    End If
   
    If bDoCustomKeyboard Then
        NativeMe.RunMethod("disableSoftKeyboard", Array As Object(oEditText))
        'oEditText.InputType = Bit.Or(oEditText.InputType, 0x00080000)
    Else
        Select Case iKeyBoardType
            Case Enums.eKeyboardStates.LowerCase, Enums.eKeyboardStates.UpperCase, Enums.eKeyboardStates.UpperCaseFixed, _
                 Enums.eKeyboardStates.Symbols1, Enums.eKeyboardStates.Symbols2
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (1 + 524288)))
            Case Enums.eKeyboardStates.Numeric
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, 2))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789")
            Case Enums.eKeyboardStates.Decimals
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (2 + 8192)))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789.")
            Case Enums.eKeyboardStates.NumericWithMinus
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (2 + 4096)))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789-")
            Case Enums.eKeyboardStates.DecimalsWithMinus
                NativeMe.RunMethod("enableSoftKeyboard", Array As Object(oEditText, (2 + 4096 + 8192)))
                ime.SetCustomFilter(oEditText, oEditText.INPUT_TYPE_NUMBERS, "0123456789.-")
        End Select
       
        If bHandleAction Then
            'will show Next button to handle the action
            'will need to specify the action in ime_HandleAction
            ime.AddHandleActionEvent(oEditText)
        End If
    End If
   
End Sub

The strange thing is that when I go to a B4XPage and the edittext is clicked first time during the visit to that page then there is no popup.
Then when the keyboard is closed (via the bottom right back key) and then the edittext is clicked again then the popup appears.
I think the solution to this problem is finding out why first time all is OK and then after that not.

The above code (SetEditTextInput_Type) runs only once per edittext.

RBS
I forgot to post the Java code that does disableSoftKeyboard and enableSoftKeyboard. This is at the bottom of Main in the B4XPages project:

B4X:
#IF JAVA
    import android.widget.EditText;
    import android.os.Build;
    import android.text.InputType;

 public void disableSoftKeyboard(final EditText v) {
    if (Build.VERSION.SDK_INT >= 11) {
        v.setRawInputType(InputType.TYPE_CLASS_TEXT);
        v.setTextIsSelectable(true);
        v.setShowSoftInputOnFocus(false);
     } else {
        v.setRawInputType(InputType.TYPE_NULL);
        v.setFocusable(true);
     }
}

 public static void enableSoftKeyboard(final EditText v, int iKeyBoardType) {
    if (Build.VERSION.SDK_INT >= 11) {
        v.setRawInputType(iKeyBoardType);
        v.setTextIsSelectable(true);
        v.setShowSoftInputOnFocus(true);
     } else {
        v.setRawInputType(iKeyBoardType);
        v.setFocusable(true);
     }
                     
}
#END IF

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Confirmed now that it has nil to do with the custom keyboard as the popup is stopped nicely on a Samsung Tab S6 Lite tablet, using the line:

B4X:
EditText1.InputType = Bit.Or(EditText1.InputType, 0x00080000)

It looks I need to be able to manipulate that popup.

RBS
Actually on that Samsung Tab S6 Lite the popup wasn't there even without that line:

B4X:
EditText1.InputType = Bit.Or(EditText1.InputType, 0x00080000)

No idea what is going on here.
Autosuggest is turned on the tablet.
Will investigate further.

RBS
 
Upvote 0
Top