Skip to content

fix(android): backgroundColor in TextField #14222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public void processProperties(KrollDict d)
if (d.containsKey(TiC.PROPERTY_BACKGROUND_COLOR)) {
// Why transparent?
tv.setBackgroundColor(Color.TRANSPARENT);
textInputLayout.setBoxBackgroundColor(TiConvert.toColor(d.get(TiC.PROPERTY_BACKGROUND_COLOR),
TiApplication.getAppCurrentActivity()));
}

if (d.containsKey(TiC.PROPERTY_COLOR)) {
Expand Down Expand Up @@ -395,6 +397,7 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
this.inputFilterHandler.setMaxLength(TiConvert.toInt(newValue, -1));
} else if (key.equals(TiC.PROPERTY_BACKGROUND_COLOR)) {
tv.setBackgroundColor(Color.TRANSPARENT);
textInputLayout.setBoxBackgroundColor(TiConvert.toColor(newValue, TiApplication.getAppCurrentActivity()));
super.propertyChanged(key, oldValue, newValue, proxy);
} else if (key.equals(TiC.PROPERTY_COLOR)) {
// TODO: reset to default value when property is null
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/Resources/android/snapshots/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/Resources/android/snapshots/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions tests/Resources/ti.ui.textfield.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,39 @@ describe('Titanium.UI.TextField', () => {
win.open();
});

it.android('backgroundColor', function (finish) {
this.timeout(5000);
const textField = Ti.UI.createTextField({
value: 'test',
width: 100,
height: 40,
backgroundColor: '#f00',
color: 'black'
});
const bgView = Ti.UI.createView({
width: 200,
height: 40,
backgroundColor: '#ff0'
});
win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
bgView.add(textField);
win.add(bgView);

win.addEventListener('postlayout', function postlayout() { // FIXME: Support once!
win.removeEventListener('postlayout', postlayout); // only run once
try {
should(bgView).matchImage('snapshots/textfieldBackgroundColor.png');
} catch (err) {
return finish(err);
}
finish();
});

win.open();
});

describe('.hintText', () => {
let textField;
beforeEach(() => {
Expand Down
Loading