Build fixes and some refactoring
This commit is contained in:
parent
e0c2f873f5
commit
4a4c9cd63f
9 changed files with 22 additions and 94 deletions
|
@ -169,10 +169,7 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface {
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
// Log.v(tag, "Aman: onCreate....................")
|
NotificationUtil.show(this) // Go foreground
|
||||||
// Log.v(tag, "Aman: onCreate....................")
|
|
||||||
// Log.v(tag, "Aman: onCreate....................")
|
|
||||||
// NotificationUtil.show(this) // Go foreground
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUnbind(intent: Intent?): Boolean {
|
override fun onUnbind(intent: Intent?): Boolean {
|
||||||
|
|
|
@ -196,6 +196,7 @@ class VPNServiceBinder(service: VPNService) : Binder() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The codes we Are Using in case of [dispatchEvent]
|
* The codes we Are Using in case of [dispatchEvent]
|
||||||
|
* Qt codes in the androidvpnactivity.h
|
||||||
*/
|
*/
|
||||||
object EVENTS {
|
object EVENTS {
|
||||||
const val init = 0
|
const val init = 0
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package org.ftylitak.qzxing;
|
|
||||||
|
|
||||||
public class NativeFunctions {
|
|
||||||
public static native void onPermissionsGranted();
|
|
||||||
public static native void onPermissionsDenied();
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package org.ftylitak.qzxing;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import org.qtproject.qt.android.bindings.QtActivity;
|
|
||||||
import static org.ftylitak.qzxing.Utilities.REQUEST_CAMERA;
|
|
||||||
|
|
||||||
public class QZXingLiveActivity extends QtActivity {
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode,
|
|
||||||
String permissions[], int[] grantResults) {
|
|
||||||
switch (requestCode) {
|
|
||||||
case REQUEST_CAMERA: {
|
|
||||||
// If request is cancelled, the result arrays are empty.
|
|
||||||
if (grantResults.length > 0
|
|
||||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
NativeFunctions.onPermissionsGranted();
|
|
||||||
} else {
|
|
||||||
NativeFunctions.onPermissionsDenied();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
package org.ftylitak.qzxing;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Utilities {
|
|
||||||
|
|
||||||
public static final int REQUEST_CAMERA = 0;
|
|
||||||
|
|
||||||
public static final String[] requiredPermissionsModifyPhoneState = {
|
|
||||||
Manifest.permission.CAMERA,
|
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
|
||||||
};
|
|
||||||
|
|
||||||
public static void checkAndRequestPermissionList(Activity activity, String[] permissions) {
|
|
||||||
ArrayList<String> permissionsToRequest = new ArrayList<>();
|
|
||||||
for (int i = 0; i < permissions.length; i++) {
|
|
||||||
if (ContextCompat.checkSelfPermission(activity, permissions[i])
|
|
||||||
!= PackageManager.PERMISSION_GRANTED)
|
|
||||||
permissionsToRequest.add(permissions[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (permissionsToRequest.size() != 0)
|
|
||||||
ActivityCompat.requestPermissions(activity,
|
|
||||||
permissionsToRequest.toArray(new String[0]),
|
|
||||||
REQUEST_CAMERA);
|
|
||||||
else
|
|
||||||
NativeFunctions.onPermissionsGranted();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void requestQZXingPermissions(Activity activity) {
|
|
||||||
checkAndRequestPermissionList(activity, requiredPermissionsModifyPhoneState);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "amnezia_application.h"
|
#include "amnezia_application.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
|
@ -91,7 +91,6 @@ AndroidController::AndroidController() : QObject()
|
||||||
|
|
||||||
connect(activity, &AndroidVPNActivity::eventStatisticUpdate, this,
|
connect(activity, &AndroidVPNActivity::eventStatisticUpdate, this,
|
||||||
[this](const QString& parcelBody) {
|
[this](const QString& parcelBody) {
|
||||||
qDebug() << "Transact: update";
|
|
||||||
auto doc = QJsonDocument::fromJson(parcelBody.toUtf8());
|
auto doc = QJsonDocument::fromJson(parcelBody.toUtf8());
|
||||||
|
|
||||||
QString rx = doc.object()["rx_bytes"].toString();
|
QString rx = doc.object()["rx_bytes"].toString();
|
||||||
|
@ -229,8 +228,6 @@ void AndroidController::setFallbackConnectedNotification() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidController::checkStatus() {
|
void AndroidController::checkStatus() {
|
||||||
qDebug() << "check status";
|
|
||||||
|
|
||||||
AndroidVPNActivity::sendToService(ServiceAction::ACTION_REQUEST_STATISTIC, QString());
|
AndroidVPNActivity::sendToService(ServiceAction::ACTION_REQUEST_STATISTIC, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ enum ServiceAction {
|
||||||
typedef enum ServiceAction ServiceAction;
|
typedef enum ServiceAction ServiceAction;
|
||||||
|
|
||||||
// Event Types that will be Dispatched after registration
|
// Event Types that will be Dispatched after registration
|
||||||
|
// Kotlin codes in the VPNServiceBinder.kt
|
||||||
enum ServiceEvents {
|
enum ServiceEvents {
|
||||||
// The Service has Accepted our Binder
|
// The Service has Accepted our Binder
|
||||||
// Responds with the current status of the vpn.
|
// Responds with the current status of the vpn.
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
|
import QtCore
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Window
|
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Controls.Basic
|
||||||
|
import QtQuick.Dialogs
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Window
|
||||||
|
|
||||||
|
import Qt.labs.platform as LabsPlatform
|
||||||
|
import Qt.labs.folderlistmodel as LabsFolderlistmodel
|
||||||
|
|
||||||
import PageEnum 1.0
|
import PageEnum 1.0
|
||||||
import PageType 1.0
|
import PageType 1.0
|
||||||
import Qt.labs.platform
|
|
||||||
import Qt.labs.folderlistmodel
|
|
||||||
import QtQuick.Dialogs
|
|
||||||
import QtQuick.Controls.Basic
|
|
||||||
import "Controls"
|
import "Controls"
|
||||||
import "Pages"
|
import "Pages"
|
||||||
import "Pages/Protocols"
|
import "Pages/Protocols"
|
||||||
|
@ -117,13 +121,13 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderListModel {
|
LabsFolderlistmodel.FolderListModel {
|
||||||
id: folderModelPages
|
id: folderModelPages
|
||||||
folder: "qrc:/ui/qml/Pages/"
|
folder: "qrc:/ui/qml/Pages/"
|
||||||
nameFilters: ["*.qml"]
|
nameFilters: ["*.qml"]
|
||||||
showDirs: false
|
showDirs: false
|
||||||
|
|
||||||
onStatusChanged: if (status == FolderListModel.Ready) {
|
onStatusChanged: if (status == LabsFolderlistmodel.FolderListModel.Ready) {
|
||||||
for (var i=0; i<folderModelPages.count; i++) {
|
for (var i=0; i<folderModelPages.count; i++) {
|
||||||
createPagesObjects(folderModelPages.get(i, "filePath"), PageType.Basic);
|
createPagesObjects(folderModelPages.get(i, "filePath"), PageType.Basic);
|
||||||
}
|
}
|
||||||
|
@ -131,39 +135,39 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderListModel {
|
LabsFolderlistmodel.FolderListModel {
|
||||||
id: folderModelProtocols
|
id: folderModelProtocols
|
||||||
folder: "qrc:/ui/qml/Pages/Protocols/"
|
folder: "qrc:/ui/qml/Pages/Protocols/"
|
||||||
nameFilters: ["*.qml"]
|
nameFilters: ["*.qml"]
|
||||||
showDirs: false
|
showDirs: false
|
||||||
|
|
||||||
onStatusChanged: if (status == FolderListModel.Ready) {
|
onStatusChanged: if (status == LabsFolderlistmodel.FolderListModel.Ready) {
|
||||||
for (var i=0; i<folderModelProtocols.count; i++) {
|
for (var i=0; i<folderModelProtocols.count; i++) {
|
||||||
createPagesObjects(folderModelProtocols.get(i, "filePath"), PageType.Proto);
|
createPagesObjects(folderModelProtocols.get(i, "filePath"), PageType.Proto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderListModel {
|
LabsFolderlistmodel.FolderListModel {
|
||||||
id: folderModelShareProtocols
|
id: folderModelShareProtocols
|
||||||
folder: "qrc:/ui/qml/Pages/Share/"
|
folder: "qrc:/ui/qml/Pages/Share/"
|
||||||
nameFilters: ["*.qml"]
|
nameFilters: ["*.qml"]
|
||||||
showDirs: false
|
showDirs: false
|
||||||
|
|
||||||
onStatusChanged: if (status == FolderListModel.Ready) {
|
onStatusChanged: if (status == LabsFolderlistmodel.FolderListModel.Ready) {
|
||||||
for (var i=0; i<folderModelShareProtocols.count; i++) {
|
for (var i=0; i<folderModelShareProtocols.count; i++) {
|
||||||
createPagesObjects(folderModelShareProtocols.get(i, "filePath"), PageType.ShareProto);
|
createPagesObjects(folderModelShareProtocols.get(i, "filePath"), PageType.ShareProto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderListModel {
|
LabsFolderlistmodel.FolderListModel {
|
||||||
id: folderModelClientInfo
|
id: folderModelClientInfo
|
||||||
folder: "qrc:/ui/qml/Pages/ClientInfo/"
|
folder: "qrc:/ui/qml/Pages/ClientInfo/"
|
||||||
nameFilters: ["*.qml"]
|
nameFilters: ["*.qml"]
|
||||||
showDirs: false
|
showDirs: false
|
||||||
|
|
||||||
onStatusChanged: if (status == FolderListModel.Ready) {
|
onStatusChanged: if (status == LabsFolderlistmodel.FolderListModel.Ready) {
|
||||||
for (var i=0; i<folderModelClientInfo.count; i++) {
|
for (var i=0; i<folderModelClientInfo.count; i++) {
|
||||||
createPagesObjects(folderModelClientInfo.get(i, "filePath"), PageType.ClientInfo);
|
createPagesObjects(folderModelClientInfo.get(i, "filePath"), PageType.ClientInfo);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue