Android: Support PasswordMaskDelay
It is only set if the "Show passwords" option in Android's security settings is enabled, the value is not updated at runtime as this option isn't likely to be changed frequently, if at all. The value of 1.5s is hardcoded in Android's PasswordTransformationMethod. [ChangeLog][Android] Show password while typing is now supported Task-number: QTBUG-48948 Change-Id: I9209b68c8684b825be196e8d0afd37cb0e0d141d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com> Reviewed-by: Jason Erb
This commit is contained in:
parent
08cd33a780
commit
2cba33901b
@ -80,6 +80,8 @@ Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::Pri
|
||||
|
||||
Qt::ApplicationState QAndroidPlatformIntegration::m_defaultApplicationState = Qt::ApplicationActive;
|
||||
|
||||
bool QAndroidPlatformIntegration::m_showPasswordEnabled = false;
|
||||
|
||||
void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteArray &resource)
|
||||
{
|
||||
if (resource=="JavaVM")
|
||||
@ -191,6 +193,12 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶
|
||||
}
|
||||
QWindowSystemInterface::registerTouchDevice(m_touchDevice);
|
||||
}
|
||||
|
||||
auto contentResolver = javaActivity.callObjectMethod("getContentResolver", "()Landroid/content/ContentResolver;");
|
||||
Q_ASSERT(contentResolver.isValid());
|
||||
m_showPasswordEnabled = QJNIObjectPrivate::callStaticMethod<jint>("android/provider/Settings$System", "getInt",
|
||||
"(Landroid/content/ContentResolver;Ljava/lang/String;)I", contentResolver.object(),
|
||||
QJNIObjectPrivate::getStaticObjectField("android/provider/Settings$System", "TEXT_SHOW_PASSWORD", "Ljava/lang/String;").object()) > 0;
|
||||
}
|
||||
|
||||
QGuiApplicationPrivate::instance()->setApplicationState(m_defaultApplicationState);
|
||||
@ -313,6 +321,9 @@ QPlatformServices *QAndroidPlatformIntegration::services() const
|
||||
QVariant QAndroidPlatformIntegration::styleHint(StyleHint hint) const
|
||||
{
|
||||
switch (hint) {
|
||||
case PasswordMaskDelay:
|
||||
// this number is from a hard-coded value in Android code (cf. PasswordTransformationMethod)
|
||||
return m_showPasswordEnabled ? 1500 : 0;
|
||||
case ShowIsMaximized:
|
||||
return true;
|
||||
default:
|
||||
|
@ -143,6 +143,8 @@ private:
|
||||
|
||||
static Qt::ApplicationState m_defaultApplicationState;
|
||||
|
||||
static bool m_showPasswordEnabled;
|
||||
|
||||
QPlatformFontDatabase *m_androidFDB;
|
||||
QAndroidPlatformNativeInterface *m_androidPlatformNativeInterface;
|
||||
QAndroidPlatformServices *m_androidPlatformServices;
|
||||
|
Loading…
Reference in New Issue
Block a user