fix: Récupérer l'opération active depuis la table operations

- Corrige l'erreur SQL 'Unknown column fk_operation in users'
- L'opération active est récupérée depuis operations.chk_active = 1
- Jointure avec users pour filtrer par entité de l'admin créateur
- Query: SELECT o.id FROM operations o INNER JOIN users u ON u.fk_entite = o.fk_entite WHERE u.id = ? AND o.chk_active = 1
This commit is contained in:
2026-01-26 16:57:08 +01:00
parent c24a3afe6a
commit 0687900564
3040 changed files with 77204 additions and 1578 deletions

View File

@@ -0,0 +1,41 @@
group 'dev.fluttercommunity.plus.connectivity'
version '1.0-SNAPSHOT'
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.3.1'
}
}
rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}
apply plugin: 'com.android.library'
android {
compileSdk 34
namespace 'dev.fluttercommunity.plus.connectivity'
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
defaultConfig {
minSdk 19
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
}

View File

@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx1536M

View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

View File

@@ -0,0 +1 @@
rootProject.name = 'connectivity'

View File

@@ -0,0 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.fluttercommunity.plus.connectivity">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>

View File

@@ -0,0 +1,121 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package dev.fluttercommunity.plus.connectivity;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import java.util.ArrayList;
import java.util.List;
/** Reports connectivity related information such as connectivity type and wifi information. */
public class Connectivity {
static final String CONNECTIVITY_NONE = "none";
static final String CONNECTIVITY_WIFI = "wifi";
static final String CONNECTIVITY_MOBILE = "mobile";
static final String CONNECTIVITY_ETHERNET = "ethernet";
static final String CONNECTIVITY_BLUETOOTH = "bluetooth";
static final String CONNECTIVITY_VPN = "vpn";
static final String CONNECTIVITY_OTHER = "other";
private final ConnectivityManager connectivityManager;
public Connectivity(ConnectivityManager connectivityManager) {
this.connectivityManager = connectivityManager;
}
List<String> getNetworkTypes() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Network network = connectivityManager.getActiveNetwork();
return getCapabilitiesFromNetwork(network);
} else {
// For legacy versions, return a single type as before or adapt similarly if multiple types
// need to be supported
return getNetworkTypesLegacy();
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
List<String> getCapabilitiesFromNetwork(Network network) {
NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network);
return getCapabilitiesList(capabilities);
}
@NonNull
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
List<String> getCapabilitiesList(NetworkCapabilities capabilities) {
List<String> types = new ArrayList<>();
if (capabilities == null
|| !capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
types.add(CONNECTIVITY_NONE);
return types;
}
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
|| capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI_AWARE)) {
types.add(CONNECTIVITY_WIFI);
}
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) {
types.add(CONNECTIVITY_ETHERNET);
}
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) {
types.add(CONNECTIVITY_VPN);
}
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
types.add(CONNECTIVITY_MOBILE);
}
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH)) {
types.add(CONNECTIVITY_BLUETOOTH);
}
if (types.isEmpty()
&& capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
types.add(CONNECTIVITY_OTHER);
}
if (types.isEmpty()) {
types.add(CONNECTIVITY_NONE);
}
return types;
}
@SuppressWarnings("deprecation")
private List<String> getNetworkTypesLegacy() {
// handle type for Android versions less than Android 6
android.net.NetworkInfo info = connectivityManager.getActiveNetworkInfo();
List<String> types = new ArrayList<>();
if (info == null || !info.isConnected()) {
types.add(CONNECTIVITY_NONE);
return types;
}
int type = info.getType();
switch (type) {
case ConnectivityManager.TYPE_BLUETOOTH:
types.add(CONNECTIVITY_BLUETOOTH);
break;
case ConnectivityManager.TYPE_ETHERNET:
types.add(CONNECTIVITY_ETHERNET);
break;
case ConnectivityManager.TYPE_WIFI:
case ConnectivityManager.TYPE_WIMAX:
types.add(CONNECTIVITY_WIFI);
break;
case ConnectivityManager.TYPE_VPN:
types.add(CONNECTIVITY_VPN);
break;
case ConnectivityManager.TYPE_MOBILE:
case ConnectivityManager.TYPE_MOBILE_DUN:
case ConnectivityManager.TYPE_MOBILE_HIPRI:
types.add(CONNECTIVITY_MOBILE);
break;
default:
types.add(CONNECTIVITY_OTHER);
}
return types;
}
public ConnectivityManager getConnectivityManager() {
return connectivityManager;
}
}

View File

@@ -0,0 +1,121 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package dev.fluttercommunity.plus.connectivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import io.flutter.plugin.common.EventChannel;
import java.util.List;
/**
* The ConnectivityBroadcastReceiver receives the connectivity updates and send them to the UIThread
* through an {@link EventChannel.EventSink}
*
* <p>Use {@link
* io.flutter.plugin.common.EventChannel#setStreamHandler(io.flutter.plugin.common.EventChannel.StreamHandler)}
* to set up the receiver.
*/
public class ConnectivityBroadcastReceiver extends BroadcastReceiver
implements EventChannel.StreamHandler {
private final Context context;
private final Connectivity connectivity;
private EventChannel.EventSink events;
private final Handler mainHandler = new Handler(Looper.getMainLooper());
private ConnectivityManager.NetworkCallback networkCallback;
public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
public ConnectivityBroadcastReceiver(Context context, Connectivity connectivity) {
this.context = context;
this.connectivity = connectivity;
}
@Override
public void onListen(Object arguments, EventChannel.EventSink events) {
this.events = events;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
networkCallback =
new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
// onAvailable is called when the phone switches to a new network
// e.g. the phone was offline and gets wifi connection
// or the phone was on wifi and now switches to mobile.
// The plugin sends the current capability connection to the users.
sendEvent(connectivity.getCapabilitiesFromNetwork(network));
}
@Override
public void onCapabilitiesChanged(
Network network, NetworkCapabilities networkCapabilities) {
// This callback is called multiple times after a call to onAvailable
// this also causes multiple callbacks to the Flutter layer.
sendEvent(connectivity.getCapabilitiesList(networkCapabilities));
}
@Override
public void onLost(Network network) {
// This callback is called when a capability is lost.
//
// The provided Network object contains information about the
// network capability that has been lost, so we cannot use it.
//
// Instead, post the current network but with a delay long enough
// that we avoid a race condition.
sendCurrentStatusWithDelay();
}
};
connectivity.getConnectivityManager().registerDefaultNetworkCallback(networkCallback);
} else {
context.registerReceiver(this, new IntentFilter(CONNECTIVITY_ACTION));
}
// Need to emit first event with connectivity types without waiting for first change in system
// that might happen much later
sendEvent(connectivity.getNetworkTypes());
}
@Override
public void onCancel(Object arguments) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (networkCallback != null) {
connectivity.getConnectivityManager().unregisterNetworkCallback(networkCallback);
networkCallback = null;
}
} else {
try {
context.unregisterReceiver(this);
} catch (Exception e) {
// listen never called, ignore the error
}
}
}
@Override
public void onReceive(Context context, Intent intent) {
if (events != null) {
events.success(connectivity.getNetworkTypes());
}
}
private void sendEvent(List<String> networkTypes) {
Runnable runnable = () -> events.success(networkTypes);
// Emit events on main thread
mainHandler.post(runnable);
}
private void sendCurrentStatusWithDelay() {
Runnable runnable = () -> events.success(connectivity.getNetworkTypes());
// Emit events on main thread
// 500 milliseconds to avoid race conditions
mainHandler.postDelayed(runnable, 500);
}
}

View File

@@ -0,0 +1,37 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package dev.fluttercommunity.plus.connectivity;
import androidx.annotation.NonNull;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
/**
* The handler receives {@link MethodCall}s from the UIThread, gets the related information from
* a @{@link Connectivity}, and then send the result back to the UIThread through the {@link
* MethodChannel.Result}.
*/
class ConnectivityMethodChannelHandler implements MethodChannel.MethodCallHandler {
private final Connectivity connectivity;
/**
* Construct the ConnectivityMethodChannelHandler with a {@code connectivity}. The {@code
* connectivity} must not be null.
*/
ConnectivityMethodChannelHandler(Connectivity connectivity) {
assert (connectivity != null);
this.connectivity = connectivity;
}
@Override
public void onMethodCall(MethodCall call, @NonNull MethodChannel.Result result) {
if ("check".equals(call.method)) {
result.success(connectivity.getNetworkTypes());
} else {
result.notImplemented();
}
}
}

View File

@@ -0,0 +1,56 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package dev.fluttercommunity.plus.connectivity;
import android.content.Context;
import android.net.ConnectivityManager;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodChannel;
/** ConnectivityPlugin */
public class ConnectivityPlugin implements FlutterPlugin {
private MethodChannel methodChannel;
private EventChannel eventChannel;
private ConnectivityBroadcastReceiver receiver;
@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
setupChannels(binding.getBinaryMessenger(), binding.getApplicationContext());
}
@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
teardownChannels();
}
private void setupChannels(BinaryMessenger messenger, Context context) {
methodChannel = new MethodChannel(messenger, "dev.fluttercommunity.plus/connectivity");
eventChannel = new EventChannel(messenger, "dev.fluttercommunity.plus/connectivity_status");
ConnectivityManager connectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Connectivity connectivity = new Connectivity(connectivityManager);
ConnectivityMethodChannelHandler methodChannelHandler =
new ConnectivityMethodChannelHandler(connectivity);
receiver = new ConnectivityBroadcastReceiver(context, connectivity);
methodChannel.setMethodCallHandler(methodChannelHandler);
eventChannel.setStreamHandler(receiver);
}
private void teardownChannels() {
methodChannel.setMethodCallHandler(null);
eventChannel.setStreamHandler(null);
receiver.onCancel(null);
methodChannel = null;
eventChannel = null;
receiver = null;
}
}