Skip to content

Commit 76afde8

Browse files
author
Maksim
authoredJul 21, 2020
Android: Fix ConfirmRegistration and PasswordChange input and scale size (#10182)
1 parent 82731d0 commit 76afde8

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed
 

‎src/gui/guiConfirmRegistration.cpp

+15-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ void GUIConfirmRegistration::regenerateGui(v2u32 screensize)
7373
/*
7474
Calculate new sizes and positions
7575
*/
76+
#ifdef __ANDROID__
77+
const float s = m_gui_scale * porting::getDisplayDensity() / 2;
78+
#else
7679
const float s = m_gui_scale;
80+
#endif
7781
DesiredRect = core::rect<s32>(
7882
screensize.X / 2 - 600 * s / 2,
7983
screensize.Y / 2 - 360 * s / 2,
@@ -257,12 +261,19 @@ bool GUIConfirmRegistration::getAndroidUIInput()
257261
if (!hasAndroidUIInput() || m_jni_field_name != "password")
258262
return false;
259263

260-
std::string text = porting::getInputDialogValue();
261-
gui::IGUIElement *e = getElementFromId(ID_confirmPassword);
262-
if (e)
263-
e->setText(utf8_to_wide(text).c_str());
264+
// still waiting
265+
if (porting::getInputDialogState() == -1)
266+
return true;
264267

265268
m_jni_field_name.clear();
269+
270+
gui::IGUIElement *e = getElementFromId(ID_confirmPassword);
271+
272+
if (!e || e->getType() != irr::gui::EGUIET_EDIT_BOX)
273+
return false;
274+
275+
std::string text = porting::getInputDialogValue();
276+
e->setText(utf8_to_wide(text).c_str());
266277
return false;
267278
}
268279
#endif

‎src/gui/guiPasswordChange.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
7979
/*
8080
Calculate new sizes and positions
8181
*/
82+
#ifdef __ANDROID__
83+
const float s = m_gui_scale * porting::getDisplayDensity() / 2;
84+
#else
8285
const float s = m_gui_scale;
86+
#endif
8387
DesiredRect = core::rect<s32>(
8488
screensize.X / 2 - 580 * s / 2,
8589
screensize.Y / 2 - 300 * s / 2,
@@ -289,19 +293,24 @@ bool GUIPasswordChange::getAndroidUIInput()
289293
if (!hasAndroidUIInput())
290294
return false;
291295

296+
// still waiting
297+
if (porting::getInputDialogState() == -1)
298+
return true;
299+
292300
gui::IGUIElement *e = nullptr;
293301
if (m_jni_field_name == "old_password")
294302
e = getElementFromId(ID_oldPassword);
295303
else if (m_jni_field_name == "new_password_1")
296304
e = getElementFromId(ID_newPassword1);
297305
else if (m_jni_field_name == "new_password_2")
298306
e = getElementFromId(ID_newPassword2);
299-
300-
if (e) {
301-
std::string text = porting::getInputDialogValue();
302-
e->setText(utf8_to_wide(text).c_str());
303-
}
304307
m_jni_field_name.clear();
308+
309+
if (!e || e->getType() != irr::gui::EGUIET_EDIT_BOX)
310+
return false;
311+
312+
std::string text = porting::getInputDialogValue();
313+
e->setText(utf8_to_wide(text).c_str());
305314
return false;
306315
}
307316
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.