Merge pull request #138 from amnezia-vpn/feature/android_config_export_import

Export/import of configuration files on Android
This commit is contained in:
pokamest 2022-12-12 16:48:23 +01:00 committed by GitHub
commit 7345f464a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 568 additions and 147 deletions

View file

@ -112,7 +112,7 @@ New encryption keys pair will be generated.")
Layout.bottomMargin: 10
Layout.fillWidth: true
Layout.preferredHeight: 40
text: qsTr("Save to file")
text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file")
enabled: tfShareCode.textArea.length > 0
visible: tfShareCode.textArea.length > 0

View file

@ -94,7 +94,7 @@ PageShareProtocolBase {
Layout.fillWidth: true
Layout.preferredHeight: 40
text: qsTr("Save to file")
text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file")
enabled: tfShareCode.textArea.length > 0
visible: tfShareCode.textArea.length > 0

View file

@ -93,7 +93,7 @@ PageShareProtocolBase {
Layout.preferredHeight: 40
width: parent.width - 60
text: qsTr("Save to file")
text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file")
enabled: tfShareCode.textArea.length > 0
visible: tfShareCode.textArea.length > 0

View file

@ -91,7 +91,7 @@ PageShareProtocolBase {
Layout.preferredHeight: 40
Layout.fillWidth: true
text: qsTr("Save to file")
text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file")
enabled: tfShareCode.textArea.length > 0
visible: tfShareCode.textArea.length > 0

View file

@ -134,7 +134,7 @@ void UiLogic::initalizeUiLogic()
pageLogic<VpnLogic>()->onConnectionStateChanged(VpnProtocol::Connected);
}
});
if (!AndroidController::instance()->initialize()) {
if (!AndroidController::instance()->initialize(pageLogic<StartPageLogic>())) {
qCritical() << QString("Init failed") ;
emit VpnProtocol::Error;
return;
@ -593,8 +593,9 @@ void UiLogic::saveTextFile(const QString& desc, const QString& suggestedName, QS
if (fileName.isEmpty()) return;
if (!fileName.toString().endsWith(ext)) fileName = QUrl(fileName.toString() + ext);
#elif defined Q_OS_ANDROID
fileName = QFileDialog::getSaveFileUrl(nullptr, suggestedName,
QUrl::fromLocalFile(docDir), "*" + ext);
qDebug() << "UiLogic::shareConfig" << data;
AndroidController::instance()->shareConfig(data, suggestedName);
return;
#endif
if (fileName.isEmpty()) return;