Android Question InputDialog - libray Dialogs v.4 and Dialogs2 v1 text entry problem

wes58

Active Member
Licensed User
Longtime User
I am using InputDialog from Dialogs V4 library. When I enter the text, the text is not visible probably because it is the same color as the background of the dialog.
Then, I tried Dialogs2 library, and the result is the same - entered text is not visible
The hint text and text color display OK.

Where does the text color come from?
How can I change the text color?

Edit:
All those issues happened after switching from B4A 7.8 to B4A 9.90 (and AndroidX SDK).
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
All those issues happened after switching from B4A 7.8 to B4A 9.90 (and AndroidX SDK).
It is not related to both. You probably used an old theme before.

The best solution is to switch to B4XDialog + B4XInputTemplate.
The second best solution is to set the theme properly. Maybe you need:
B4X:
CreateResourceFromFile(Macro, Themes.LightTheme)
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
It is not related to both. You probably used an old theme before.

The best solution is to switch to B4XDialog + B4XInputTemplate.
The second best solution is to set the theme properly. Maybe you need:
B4X:
CreateResourceFromFile(Macro, Themes.LightTheme)
I expected this to be a theme issue. It's a pity that dialog can't be configured
Well it must be related to AndoidX. I haven't changed anything in my application (or manifest) since I changed to B4A 9.9.
That's I tried to avoid switching to AndroidX, but I had to since I wanted to use xCLV.

I tried before using your second solution with setting theme in Manifest, but I had some errors.

I will try using B4XDialog.

Thanks for your help
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
I tried suggested solutions by Erel:
1. B4XDialog + B4XInputTemplate.
Top of the dialog (dialog title) is hidden behind the Toolbar

2. Using CreateResourceFromFile(Macro, Themes.LightTheme) in the Manifest
I get the following error:
B4X:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.homehub/com.homehub.main}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3555)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3707)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2220)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:8016)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:696)
    at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:659)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:543)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:166)
    at com.homehub.main.onCreate(main.java:73)
    at android.app.Activity.performCreate(Activity.java:7957)
    at android.app.Activity.performCreate(Activity.java:7946)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3530)
    ... 11 more
I saw some people had the same error message. Of course AndroidX changes are the problem!

3. In the end I fixed it in the following way.
I had in the Manifest theme defined like this:
B4X:
CreateResource(values, colors.xml,
<resources>
    <color name="actionbar">#2ACFE8</color>
   <color name="statusbar">#006666</color>
   <color name="textColorPrimary">#ffffffff</color>
   <color name="navigationBar">#ff006db3</color>
</resources>
)
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light">
       <item name="colorPrimary">@color/actionbar</item>
       <item name="colorPrimaryDark">@color/statusbar</item>
       <item name="android:textColorPrimary">@color/textColorPrimary</item>
       <item name="android:navigationBarColor">@color/navigationBar</item>
       <item name="windowNoTitle">true</item>
       <item name="windowActionBar">false</item>
       <item name="windowActionModeOverlay">true</item>
    </style>
</resources>
)
There was "android:textColorPrimary" defined as <color name="textColorPrimary">#ffffffff</color> (WHITE).
Prior to using AndroidX SDK this color didn't affect dialog, but only the Toolbar text color.
Now (after changing to AndroidX) it also affects dialog entry text color - that's why white text was not visible on white background
I removed this line from the Manifest (I could have changed it to different color) and it is fine now.

That's the beauty of Google changes/updates. Something worked for many years and now it doesn't - like many other things.
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
It is hidden automatically when there isn't enough space.
I am not sure what you mean by "not enough space". Unfortunately I can't show it, because I can't take a screenshot by swiping a screen (Samsung S10) because it doesn't work when the keyboard is shown.
So briefly describing it: there is a Toolbar, below is a small panel and below is the CLV. Is is because the dialog can't be displayed over a CLV?
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
I think that I misunderstood you. The dialog was partly hidden by the toolbar? You can take a screenshot from the IDE if connected with USB debug mode.
I didn't know that you could take a screenshot from the IDE.

I have attached the photo which shows two situations:
1. Dialog is initialized like this - dialog.Initialize(Activity). There is plenty of space between the bottom of the Toolbar and top of the keyboard.
2. Dialog is initialized like this - dialog.Initialize(pContent)
For the Toolbar I am using AppCompat v4 library, and it is defined as ACToolBarLight.

In the second case I can understand that the dialog doesn't have enough space because it is limited by the panel height
But the first case it should show below the toolbar
It is a pity that there is no option to position the Dialog.

With the Dialog2 library, when the dialog is shown it is positioned in the centre of the screen. And when you click in the edit text, the keyboard opens and the dialog is shifted above the keyboard.
And that's how I would expect the dialog to work.
But that's only my opinion. Maybe others like it the way B4X Dialogs are displayed.

With B4X Dialog you decided to position Dialog on top (what determines top position of the dialog?), and show the keyboard when the dialog is opened.
In my opinion this is not the best solution.
What if I want to read and copy something from the screen into the dialog? I can't do it because the keyboard is opened, covering the screen and the screen is dimmed.
 

Attachments

  • Capture.png
    Capture.png
    66.4 KB · Views: 194
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Dialog is initialized like this - dialog.Initialize(pContent)
Why are you checking this case? It is wrong.

You should use Activity or Root.

It is a pity that there is no option to position the Dialog.
Very simple to move it to wherever you like. Make some searches and you will find.
The dialog is pushed to the top, to make room for the keyboard.
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
Why are you checking this case? It is wrong.

You should use Activity or Root.
I just did it to see what the difference it will make.
You say it is wrong, but when you type "dialog.Initialze" you get hint in brackets "(Parent as B4XView)". There is nothing saying that it can't be any other B4XView?
Do we even need this if it has to be Activity? It could be just "dialog.Initialize"

Very simple to move it to wherever you like. Make some searches and you will find.
The dialog is pushed to the top, to make room for the keyboard.
Not as simple to find as you think (or as I would want).
Did a search on "b4x dialog position", which makes most sense to look for - got 7 pages but unless I go reading one by one, can't see anything.
Second search on "b4x dialog top" - again got 7 pages and only 1 thing that drew my attention was https://www.b4x.com/android/forum/threads/b4x-input-dialogs-with-xui-views.101197/#content
And there I saw this "If text input is expected then set Dialog.PutAtTop to true to make sure that the keyboard doesn't hide the dialog. "
If that's what you mean, I tried that before when I first tried b4x dialog. I had it set to both true and false and unfortunately, it didn't make a difference.
Was it this what I was supposed to find?

Simple would be, if you could position it like any other view - "dialog.top = 50dip, dialog.left = 20dip"
Anyway, as I wrote in post #4, I am using Dialogs2 library after I found out what was wrong with the text color.

Maybe when I start a new application I will go back to B4X dialogs - they do look good.
 
Upvote 0
Top