Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wifi_basic): plugin added #201

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
44488d8
[wifi_basic] plugin created from flutter template
daadu Nov 21, 2021
52d10a3
[ci] `wifi_basic`: workflow file added
daadu Nov 21, 2021
5549592
- [pubspec] homepage link added
daadu Nov 21, 2021
b97974b
[ci,all_plugins] added `--no-select` option
daadu Nov 21, 2021
77a4d8f
proper org name as reverse domain name
daadu Nov 21, 2021
bb3f0fd
Merge branch 'master' into wifi_basic
daadu Nov 21, 2021
f911faa
Merge branch 'master' into wifi_basic
daadu Nov 21, 2021
15dadec
Merge branch 'master' into wifi_basic
daadu Nov 28, 2021
05ccf12
- [wifi_basic] class renamed to `WiFiBasic`, basic methods added
daadu Nov 28, 2021
c0298d6
formatting
daadu Nov 28, 2021
65b2bcd
- [android] handling methods - `hasCapability`, `isEnabled`, `setEnab…
daadu Nov 28, 2021
6a34081
formatting
daadu Nov 28, 2021
d76c381
- [wifi_basic,android] `WiFiBasic`, `WifiBasicPlugin`: `setEnabled` -…
daadu Nov 28, 2021
42581de
- [ios] `SwiftWifiBasicPlugin`: implemented `hasCapability`, `isEnabl…
daadu Nov 28, 2021
793c651
- [ios] formatting with Xcode - ctrl+I
daadu Nov 28, 2021
47349d7
[wifi_basic] renamed - `hasCapability` -> `isSupported`
daadu Dec 4, 2021
a38aef3
[android] making `context` non-nullable and lateinit
daadu Dec 4, 2021
02f1496
`WiFiBasic` as singleton - can be access by `WiFiBasic.instance`, made
daadu Dec 4, 2021
98b245b
`WiFiBasic`: minor re-arragne
daadu Dec 4, 2021
6043606
- [wifi_basic] `WiFiGenerations` enum added
daadu Dec 4, 2021
0edea8b
- [wifi_basic,pubspec] added `async` as dependency
daadu Dec 4, 2021
77cb7c9
[wifi_basic,pubspec] downgrade `async` because of conflict
daadu Dec 4, 2021
51ce1a8
- [wifi_basic] `WiFiInfo` class, `WiFiNetworkSecurity` enum and `WiFi…
daadu Dec 4, 2021
4899fea
[wifi_ios] fix
daadu Dec 4, 2021
2336752
[wifi_scan,android] removed unnecessary TODOs
daadu Dec 5, 2021
bb846dc
[wifi_scan,license] MIT license added
daadu Dec 5, 2021
a3736ca
[ios] dropped support for 8.0
daadu Dec 11, 2021
0eafba3
Merge branch 'master' into wifi_basic
daadu Jan 19, 2022
e7792e0
[pubspec] pointing homepage to `flutternetwork`
daadu Jan 19, 2022
92447f5
[license] minor - synced
daadu Jan 19, 2022
9c3d992
- [lint] removed `analysis_options` from wifi_basic package, using gl…
daadu Jan 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .github/workflows/wifi_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Build wifi_basic example
name: wifi_basic

on:
pull_request:
paths:
- "packages/wifi_basic/**"
- ".github/workflows/wifi_basic.yaml"

env:
PLUGIN_SCOPE: "*wifi_basic*"
PLUGIN_EXAMPLE_SCOPE: "*wifi_basic_example*"

jobs:
android:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: "Checkout repository"
uses: actions/checkout@v2
- name: "Install Flutter"
run: ./.github/workflows/scripts/install-flutter.sh stable
- name: "Install Tools"
run: ./.github/workflows/scripts/install-tools.sh
- name: "Build Example"
run: ./.github/workflows/scripts/build-examples.sh android ./lib/main.dart

ios:
runs-on: macos-latest
timeout-minutes: 30
steps:
- name: "Checkout repository"
uses: actions/checkout@v2
- name: "Install Flutter"
run: ./.github/workflows/scripts/install-flutter.sh stable
- name: "Install Tools"
run: ./.github/workflows/scripts/install-tools.sh
- name: "Build Example"
run: ./.github/workflows/scripts/build-examples.sh ios ./lib/main.dart

# macos:
# runs-on: macos-latest
# timeout-minutes: 30
# steps:
# - name: "Checkout repository"
# uses: actions/checkout@v2
# - name: "Install Flutter"
# run: ./.github/workflows/scripts/install-flutter.sh stable
# - name: "Install Tools"
# run: ./.github/workflows/scripts/install-tools.sh
# - name: "Build Example"
# run: ./.github/workflows/scripts/build-examples.sh macos ./lib/main.dart

# linux:
# runs-on: ubuntu-latest
# timeout-minutes: 30
# steps:
# - name: "Checkout repository"
# uses: actions/checkout@v2
# - name: "Install Flutter"
# run: ./.github/workflows/scripts/install-flutter.sh stable
# - name: "Install Tools"
# run: ./.github/workflows/scripts/install-tools.sh
# - name: "Build Example"
# run: ./.github/workflows/scripts/build-examples.sh linux ./lib/main.dart

# windows:
# runs-on: ubuntu-latest
# timeout-minutes: 30
# steps:
# - name: "Checkout repository"
# uses: actions/checkout@v2
# - name: "Install Flutter"
# run: ./.github/workflows/scripts/install-flutter.sh stable
# - name: "Install Tools"
# run: ./.github/workflows/scripts/install-tools.sh
# - name: "Build Example"
# run: ./.github/workflows/scripts/build-examples.sh windows ./lib/main.dart

# web:
# runs-on: ubuntu-latest
# timeout-minutes: 30
# steps:
# - name: "Checkout repository"
# uses: actions/checkout@v2
# - name: "Install Flutter"
# run: ./.github/workflows/scripts/install-flutter.sh stable
# - name: "Install Tools"
# run: ./.github/workflows/scripts/install-tools.sh
# - name: "Build Example"
# run: ./.github/workflows/scripts/build-examples.sh web ./lib/main.dart
7 changes: 7 additions & 0 deletions packages/wifi_basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.dart_tool/

.packages
.pub/

build/
10 changes: 10 additions & 0 deletions packages/wifi_basic/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 18116933e77adc82f80866c928266a5b4f1ed645
channel: stable

project_type: plugin
3 changes: 3 additions & 0 deletions packages/wifi_basic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

* TODO: Describe initial release.
1 change: 1 addition & 0 deletions packages/wifi_basic/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Add your license here.
15 changes: 15 additions & 0 deletions packages/wifi_basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# wifi_basic

Flutter plugin for basic WiFi information and functionalities.

## Getting Started

This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/developing-packages/),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

4 changes: 4 additions & 0 deletions packages/wifi_basic/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
8 changes: 8 additions & 0 deletions packages/wifi_basic/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
50 changes: 50 additions & 0 deletions packages/wifi_basic/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
group 'dev.flutternetwork.wifi.wifi_basic'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 30

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
minSdkVersion 16
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
3 changes: 3 additions & 0 deletions packages/wifi_basic/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
1 change: 1 addition & 0 deletions packages/wifi_basic/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'wifi_basic'
3 changes: 3 additions & 0 deletions packages/wifi_basic/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.flutternetwork.wifi.wifi_basic">
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package dev.flutternetwork.wifi.wifi_basic

import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.wifi.WifiManager
import android.os.Build
import android.provider.Settings
import androidx.annotation.NonNull

import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result

/** WifiBasicPlugin */
class WifiBasicPlugin : FlutterPlugin, MethodCallHandler {
/// The MethodChannel that will the communication between Flutter and native Android
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
/// when the Flutter Engine is detached from the Activity
private lateinit var channel: MethodChannel
private var context: Context? = null
daadu marked this conversation as resolved.
Show resolved Hide resolved
private var wifi: WifiManager? = null
daadu marked this conversation as resolved.
Show resolved Hide resolved

override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "wifi_basic")
channel.setMethodCallHandler(this)
context = flutterPluginBinding.applicationContext
wifi =
context!!.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
}

override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
when (call.method) {
"hasCapability" -> {
result.success(hasCapability())
}
"isEnabled" -> {
result.success(isEnabled())
}
"setEnabled" -> {
val enabled = call.argument<Boolean>("enabled")
?: return result.error("InvalidArg", "enabled argument is null", null)
result.success(setEnabled(enabled))
}
"openSettings" -> {
openSettings()
result.success(null)
}
else -> {
result.notImplemented()
}
}
}

override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
context = null
wifi = null
}

private fun hasCapability(): Boolean =
wifi != null && context!!.packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)

private fun isEnabled(): Boolean = wifi!!.isWifiEnabled

private fun setEnabled(enabled: Boolean): Boolean =
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
wifi!!.setWifiEnabled(enabled)
} else {
false;
}

private fun openSettings() {
val intent = Intent(Settings.ACTION_WIFI_SETTINGS)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context!!.startActivity(intent)
}
}
46 changes: 46 additions & 0 deletions packages/wifi_basic/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
10 changes: 10 additions & 0 deletions packages/wifi_basic/example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 18116933e77adc82f80866c928266a5b4f1ed645
channel: stable

project_type: app
16 changes: 16 additions & 0 deletions packages/wifi_basic/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# wifi_basic_example

Demonstrates how to use the wifi_basic plugin.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
Loading