From 481a419c0028fe55041940bff95f619ddba665ca Mon Sep 17 00:00:00 2001 From: nefarius2001 Date: Tue, 12 Jan 2021 01:44:57 +0100 Subject: [PATCH 1/4] fix android back button for chat & settings --- src/chatdlg.cpp | 16 ++++++++++++++++ src/chatdlg.h | 3 +-- src/clientsettingsdlg.cpp | 11 +++++++++++ src/clientsettingsdlg.h | 2 ++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/chatdlg.cpp b/src/chatdlg.cpp index 9664794bbc..31b04ab1df 100755 --- a/src/chatdlg.cpp +++ b/src/chatdlg.cpp @@ -140,3 +140,19 @@ void CChatDlg::OnAnchorClicked ( const QUrl& Url ) } } } + +void CChatDlg::keyPressEvent ( QKeyEvent *e ) // block escape key & fix android back key +{ +#ifdef Q_OS_ANDROID + if ( e->key() == Qt::Key_Back ){ + this->close(); // otherwise, dialog does not show properly again + return; + } +#endif + if ( e->key() == Qt::Key_Escape ){ + ; // ignore escape key + }else{ + QDialog::keyPressEvent ( e ); + } +} + diff --git a/src/chatdlg.h b/src/chatdlg.h index 8ce46ff4e3..48315a9c08 100755 --- a/src/chatdlg.h +++ b/src/chatdlg.h @@ -54,8 +54,7 @@ public slots: void OnClearChatHistory(); void OnAnchorClicked ( const QUrl& Url ); - void keyPressEvent ( QKeyEvent *e ) // block escape key - { if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); } + void keyPressEvent ( QKeyEvent *e ); signals: void NewLocalInputText ( QString strNewText ); diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index c697682227..005007cf82 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -754,3 +754,14 @@ void CClientSettingsDlg::UpdateCustomCentralServerComboBox() } } } + +void CClientSettingsDlg::keyPressEvent ( QKeyEvent *e ) // block escape key & fix android back key +{ +#ifdef Q_OS_ANDROID + if ( e->key() == Qt::Key_Back ){ + this->close(); // otherwise, dialog does not show properly again + return; + } +#endif + QDialog::keyPressEvent ( e ); +} diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index 78f17b80ed..b355ae30ca 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -37,6 +37,7 @@ #include #include #include +#include #include "global.h" #include "client.h" #include "settings.h" @@ -107,6 +108,7 @@ public slots: void OnGUIDesignActivated ( int iDesignIdx ); void OnDriverSetupClicked(); void OnLanguageChanged ( QString strLanguage ) { pSettings->strLanguage = strLanguage; } + void keyPressEvent ( QKeyEvent *e ); signals: void GUIDesignChanged(); From e946189bc673ff23cf6337b067054324d3904535 Mon Sep 17 00:00:00 2001 From: nefarius2001 Date: Tue, 12 Jan 2021 02:57:27 +0100 Subject: [PATCH 2/4] replace ifdef condition with bool-type define for better readability --- Jamulus.pro | 4 ++++ src/chatdlg.cpp | 9 +++------ src/clientsettingsdlg.cpp | 7 +++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Jamulus.pro b/Jamulus.pro index 2bd65c001a..55c979364d 100755 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -47,6 +47,7 @@ DEFINES += APP_VERSION=\\\"$$VERSION\\\" \ USE_ALLOCA \ CUSTOM_MODES \ _REENTRANT +DEFINES += "BOOL_CLOSE_DIALOGS_ON_BACKBUTTON=0" # fixes android ui issue # some depreciated functions need to be kept for older versions to build # TODO as soon as we drop support for the old Qt version, remove the following line @@ -176,6 +177,9 @@ win32 { # enabled only for debugging on android devices DEFINES += ANDROIDDEBUG + DEFINES -= BOOL_CLOSE_DIALOGS_ON_BACKBUTTON=0 # fixes android ui issue + DEFINES += BOOL_CLOSE_DIALOGS_ON_BACKBUTTON=1 # fixes android ui issue + target.path = /tmp/your_executable # path on device INSTALLS += target diff --git a/src/chatdlg.cpp b/src/chatdlg.cpp index 31b04ab1df..e120388f8e 100755 --- a/src/chatdlg.cpp +++ b/src/chatdlg.cpp @@ -143,14 +143,11 @@ void CChatDlg::OnAnchorClicked ( const QUrl& Url ) void CChatDlg::keyPressEvent ( QKeyEvent *e ) // block escape key & fix android back key { -#ifdef Q_OS_ANDROID - if ( e->key() == Qt::Key_Back ){ - this->close(); // otherwise, dialog does not show properly again - return; - } -#endif if ( e->key() == Qt::Key_Escape ){ ; // ignore escape key + }else if (BOOL_CLOSE_DIALOGS_ON_BACKBUTTON && ( e->key() == Qt::Key_Back )){ + this->close(); // otherwise, dialog does not show properly again + return; }else{ QDialog::keyPressEvent ( e ); } diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 005007cf82..2d1a107adf 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -757,11 +757,10 @@ void CClientSettingsDlg::UpdateCustomCentralServerComboBox() void CClientSettingsDlg::keyPressEvent ( QKeyEvent *e ) // block escape key & fix android back key { -#ifdef Q_OS_ANDROID - if ( e->key() == Qt::Key_Back ){ + if (BOOL_CLOSE_DIALOGS_ON_BACKBUTTON && ( e->key() == Qt::Key_Back )){ this->close(); // otherwise, dialog does not show properly again return; + }else{ + QDialog::keyPressEvent ( e ); } -#endif - QDialog::keyPressEvent ( e ); } From 024ec6a8402048c13b03a31a13504feed1de3635 Mon Sep 17 00:00:00 2001 From: nefarius2001 Date: Tue, 12 Jan 2021 02:59:06 +0100 Subject: [PATCH 3/4] close-on-backbutton for all QDialogs --- src/analyzerconsole.cpp | 10 ++++++++++ src/analyzerconsole.h | 3 +++ src/chatdlg.cpp | 2 +- src/clientdlg.cpp | 12 ++++++++++++ src/clientdlg.h | 3 +-- src/clientsettingsdlg.cpp | 2 +- src/connectdlg.cpp | 10 ++++++++++ src/connectdlg.h | 3 +++ src/serverdlg.cpp | 12 ++++++++++++ src/serverdlg.h | 3 +-- src/util.cpp | 10 ++++++++++ src/util.h | 3 +++ 12 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/analyzerconsole.cpp b/src/analyzerconsole.cpp index 469ac9560a..12f912293c 100644 --- a/src/analyzerconsole.cpp +++ b/src/analyzerconsole.cpp @@ -220,3 +220,13 @@ int CAnalyzerConsole::CalcYPosInGraph ( const double dAxisMin, return GraphGridFrame.y() + static_cast ( static_cast ( GraphGridFrame.height() ) * ( 1 - dYValNorm ) ); } + +void CAnalyzerConsole::keyPressEvent ( QKeyEvent *e ) +{ + if (BOOL_CLOSE_DIALOGS_ON_BACKBUTTON && ( e->key() == Qt::Key_Back )){ + this->close(); // otherwise, dialog does not show properly again in android + return; + }else{ + QDialog::keyPressEvent ( e ); + } +} diff --git a/src/analyzerconsole.h b/src/analyzerconsole.h index f5770da2a4..5a6a12a704 100644 --- a/src/analyzerconsole.h +++ b/src/analyzerconsole.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "client.h" @@ -87,4 +88,6 @@ class CAnalyzerConsole : public QDialog public slots: void OnTimerErrRateUpdate(); + + void keyPressEvent ( QKeyEvent *e ); }; diff --git a/src/chatdlg.cpp b/src/chatdlg.cpp index e120388f8e..403a348a8a 100755 --- a/src/chatdlg.cpp +++ b/src/chatdlg.cpp @@ -146,7 +146,7 @@ void CChatDlg::keyPressEvent ( QKeyEvent *e ) // block escape key & fix android if ( e->key() == Qt::Key_Escape ){ ; // ignore escape key }else if (BOOL_CLOSE_DIALOGS_ON_BACKBUTTON && ( e->key() == Qt::Key_Back )){ - this->close(); // otherwise, dialog does not show properly again + this->close(); // otherwise, dialog does not show properly again in android return; }else{ QDialog::keyPressEvent ( e ); diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index df2468cf7f..b110ccae75 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -1354,3 +1354,15 @@ rbtReverbSelR->setStyleSheet ( "" ); // also apply GUI design to child GUI controls MainMixerBoard->SetGUIDesign ( eNewDesign ); } + +void CClientDlg::keyPressEvent ( QKeyEvent *e ) // block escape key & fix android back key +{ + if ( e->key() == Qt::Key_Escape ){ + ; // ignore escape key + }else if (BOOL_CLOSE_DIALOGS_ON_BACKBUTTON && ( e->key() == Qt::Key_Back )){ + this->close(); // otherwise, dialog does not show properly again in android + return; + }else{ + QDialog::keyPressEvent ( e ); + } +} diff --git a/src/clientdlg.h b/src/clientdlg.h index b58c1e967e..7d9c5c8421 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -238,6 +238,5 @@ public slots: void accept() { close(); } // introduced by pljones - void keyPressEvent ( QKeyEvent *e ) // block escape key - { if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); } + void keyPressEvent ( QKeyEvent *e ); }; diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 2d1a107adf..a8fe1095f9 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -758,7 +758,7 @@ void CClientSettingsDlg::UpdateCustomCentralServerComboBox() void CClientSettingsDlg::keyPressEvent ( QKeyEvent *e ) // block escape key & fix android back key { if (BOOL_CLOSE_DIALOGS_ON_BACKBUTTON && ( e->key() == Qt::Key_Back )){ - this->close(); // otherwise, dialog does not show properly again + this->close(); // otherwise, dialog does not show properly again in android return; }else{ QDialog::keyPressEvent ( e ); diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index b714f2f8cb..19575ce0fb 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -921,3 +921,13 @@ void CConnectDlg::DeleteAllListViewItemChilds ( QTreeWidgetItem* pItem ) delete pCurChildItem; } } + +void CConnectDlg::keyPressEvent ( QKeyEvent *e ) +{ + if (BOOL_CLOSE_DIALOGS_ON_BACKBUTTON && ( e->key() == Qt::Key_Back )){ + this->close(); // otherwise, dialog does not show properly again in android + return; + }else{ + QDialog::keyPressEvent ( e ); + } +} diff --git a/src/connectdlg.h b/src/connectdlg.h index 5c15f3011a..e6e9b9f854 100755 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "global.h" #include "settings.h" #include "multicolorled.h" @@ -109,6 +110,8 @@ public slots: void OnTimerPing(); void OnTimerReRequestServList(); + void keyPressEvent ( QKeyEvent *e ); + signals: void ReqServerListQuery ( CHostAddress InetAddr ); void CreateCLServerListPingMes ( CHostAddress InetAddr ); diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp index 22d86e0a06..fff43c65a5 100755 --- a/src/serverdlg.cpp +++ b/src/serverdlg.cpp @@ -834,3 +834,15 @@ void CServerDlg::changeEvent ( QEvent* pEvent ) } } } + +void CServerDlg::keyPressEvent ( QKeyEvent *e ) // block escape key & fix android back key +{ + if ( e->key() == Qt::Key_Escape ){ + ; // ignore escape key + }else if (BOOL_CLOSE_DIALOGS_ON_BACKBUTTON && ( e->key() == Qt::Key_Back )){ + this->close(); // otherwise, dialog does not show properly again in android + return; + }else{ + QDialog::keyPressEvent ( e ); + } +} diff --git a/src/serverdlg.h b/src/serverdlg.h index 399b4b98e9..463ac5b312 100755 --- a/src/serverdlg.h +++ b/src/serverdlg.h @@ -114,8 +114,7 @@ public slots: void OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReason ); void OnWelcomeMessageChanged() { pServer->SetWelcomeMessage ( tedWelcomeMessage->toPlainText() ); } - void keyPressEvent ( QKeyEvent *e ) // block escape key - { if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); } + void keyPressEvent ( QKeyEvent *e ); void OnLanguageChanged ( QString strLanguage ) { pSettings->strLanguage = strLanguage; } void OnNewRecordingClicked() { pServer->RequestNewRecording(); } diff --git a/src/util.cpp b/src/util.cpp index 89fd36a0a5..4e737e5c96 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -848,6 +848,16 @@ void CMusProfDlg::OnSkillActivated ( int iCntryListItem ) pClient->SetRemoteInfo(); } +void CMusProfDlg::keyPressEvent ( QKeyEvent *e ) +{ + if (BOOL_CLOSE_DIALOGS_ON_BACKBUTTON && ( e->key() == Qt::Key_Back )){ + this->close(); // otherwise, dialog does not show properly again in android + return; + }else{ + QDialog::keyPressEvent ( e ); + } +} + // Help menu ------------------------------------------------------------------- CHelpMenu::CHelpMenu ( const bool bIsClient, QWidget* parent ) : QMenu ( tr ( "&Help" ), parent ) diff --git a/src/util.h b/src/util.h index d8a7485dc2..8df9f95cbe 100755 --- a/src/util.h +++ b/src/util.h @@ -38,6 +38,7 @@ # include # include # include +# include # include "ui_aboutdlgbase.h" #endif #include @@ -420,6 +421,8 @@ public slots: void OnCountryActivated ( int iCntryListItem ); void OnCityTextChanged ( const QString& strNewName ); void OnSkillActivated ( int iCntryListItem ); + + void keyPressEvent ( QKeyEvent *e ); }; From d4091f2f7c355e632c0595c096854c0adaec7edc Mon Sep 17 00:00:00 2001 From: nefarius2001 Date: Wed, 13 Jan 2021 20:51:22 +0100 Subject: [PATCH 4/4] add job to build apk --- .github/workflows/android.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/android.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000000..af287cbebe --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,24 @@ +name: Android CI + +on: + push: + branches: [ feature/android ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Build with Gradle + run: ./gradlew build +