* correct behavior of back button on Android

* removing of annoying debug logs on Android
This commit is contained in:
Dmitriy Karpushin 2023-03-14 16:49:06 +03:00
parent fe7c66cf1d
commit 20846c8eff
4 changed files with 15 additions and 15 deletions

View file

@ -196,7 +196,6 @@ class VPNServiceBinder(service: VPNService) : Binder() {
try {
mListener?.let {
if (it.isBinderAlive) {
Log.i(tag, "Dispatching event: binder alive")
val data = Parcel.obtain()
data.writeByteArray(payload?.toByteArray(charset("UTF-8")))
it.transact(code, data, Parcel.obtain(), 0)

View file

@ -99,8 +99,6 @@ class VPNActivity : org.qtproject.qt.android.bindings.QtActivity() {
if (!isBound) {
Log.d(TAG, "dispatchParcel: not bound")
return
} else {
Log.d(TAG, "dispatchParcel: bound")
}
val out: Parcel = Parcel.obtain()
@ -331,12 +329,4 @@ class VPNActivity : org.qtproject.qt.android.bindings.QtActivity() {
onActivityMessage(UI_EVENT_QR_CODE_RECEIVED, extra)
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK && event.repeatCount == 0) {
onBackPressed()
return true
}
return super.onKeyDown(keyCode, event)
}
}

View file

@ -61,8 +61,12 @@ Window {
function close_page() {
if (pageLoader.depth <= 1) {
if (GC.isMobile()) {
root.close()
}
return
}
pageLoader.currentItem.deactivated()
pageLoader.pop()
}

View file

@ -224,9 +224,10 @@ void UiLogic::keyPressEvent(Qt::Key key)
m_configurator->sshConfigurator->openSshTerminal(m_settings->serverCredentials(m_settings->defaultServerIndex()));
break;
case Qt::Key_Escape:
case Qt::Key_Back:
if (currentPage() == Page::Vpn) break;
if (currentPage() == Page::ServerConfiguringProgress) break;
case Qt::Key_Back:
// if (currentPage() == Page::Start && pagesStack.size() < 2) break;
// if (currentPage() == Page::Sites &&
// ui->tableView_sites->selectionModel()->selection().indexes().size() > 0) {
@ -243,10 +244,16 @@ void UiLogic::keyPressEvent(Qt::Key key)
void UiLogic::onCloseWindow()
{
if (m_settings->serversCount() == 0) qApp->quit();
else {
hide();
#ifdef Q_OS_ANDROID
qApp->quit();
#else
if (m_settings->serversCount() == 0)
{
qApp->quit();
} else {
emit hide();
}
#endif
}
QString UiLogic::containerName(int container)