Skip to content

Commit

Permalink
Merge branch 'git_contribution_workspace' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
fonkamloic authored Jul 15, 2024
2 parents 2f96502 + 77ee4a5 commit 0ce6a12
Show file tree
Hide file tree
Showing 23 changed files with 320 additions and 251 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
.buildlog/
.history
.svn/
.vscode/*
migrate_working_dir/

# fvm related
.fvmrc

# IntelliJ related
*.iml
*.ipr
Expand All @@ -28,3 +32,6 @@ migrate_working_dir/
.dart_tool/
.packages
build/

# FVM Version Cache
.fvm/
35 changes: 2 additions & 33 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,8 @@
{
"name": "no_screenshot",
"request": "launch",
"type": "dart"
},
{
"name": "no_screenshot (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "no_screenshot (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "example",
"cwd": "example",
"request": "launch",
"type": "dart"
},
{
"name": "example (profile mode)",
"cwd": "example",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "example (release mode)",
"cwd": "example",
"request": "launch",
"type": "dart",
"flutterMode": "release"
"type": "dart",
"program": "example/lib/main.dart"
}
]
}
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ Updated readme and added sample usage.

## 0.0.1+6

- Removed the non implemented override functions in android life-cycle
- Removed the non implemented override functions in android life-cycle

## 0.0.1+7

- Set the namespace for android
- Specify a more current version of ScreenProtectorKit. This resolves iOS17 issues.
46 changes: 23 additions & 23 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
Copyright (c) 2022, FlutterPlaza
All rights reserved.
Copyright (c) 2022, FlutterPlaza
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of FlutterPlaza nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of FlutterPlaza nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If you want to prevent user from taking screenshot or recording of your app. You

```dart
class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
final _noScreenshot = NoScreenshot();
final _noScreenshot = NoScreenshot.instance;
AppLifecycleState? _notification;
@override
Expand Down
1 change: 0 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {

namespace "com.flutterplaza.no_screenshot"
compileSdkVersion 31

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,89 @@ 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
import android.view.WindowManager.LayoutParams;
import android.view.WindowManager.LayoutParams
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding

const val SCREENSHOT_ON_CONST = "screenshotOn"
const val SCREENSHOT_OFF_CONST = "screenshotOff"
const val TOGGLE_SCREENSHOT_CONST = "toggleScreenshot"

/** NoScreenshotPlugin */
class NoScreenshotPlugin: FlutterPlugin, MethodCallHandler, ActivityAware {
/// 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 lateinit var context: Context
private lateinit var activity: Activity

override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "com.flutterplaza.no_screenshot")
channel.setMethodCallHandler(this)
context = flutterPluginBinding.applicationContext

}

override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) =
if (call.method == "screenshotOff") {
screenshotOff();
result.success(true);
}
else if(call.method == "screenshotOn"){
screenshotOn();
result.success(true);
}
else if(call.method == "toggleScreenshot"){
var flags: Int = activity.window.attributes.flags;
if( (flags and LayoutParams.FLAG_SECURE) != 0){
screenshotOn();
}else {
screenshotOff();
}
result.success(true);
class NoScreenshotPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
/// 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 lateinit var context: Context
private lateinit var activity: Activity

override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel =
MethodChannel(flutterPluginBinding.binaryMessenger, "com.flutterplaza.no_screenshot")
channel.setMethodCallHandler(this)
context = flutterPluginBinding.applicationContext

}
else {
result.notImplemented()

override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) =
when (call.method) {
SCREENSHOT_OFF_CONST -> {
val value: Boolean = screenshotOff()
result.success(value)
}
SCREENSHOT_ON_CONST -> {
val value = screenshotOn()

result.success(value)
}
TOGGLE_SCREENSHOT_CONST -> {
val flags: Int = activity.window.attributes.flags
if ((flags and LayoutParams.FLAG_SECURE) != 0) {
screenshotOn()
} else {
screenshotOff()
}
result.success(true)
}
else -> {
result.notImplemented()
}
}

private fun screenshotOff(): Boolean {
try {
activity.window.addFlags(LayoutParams.FLAG_SECURE)
return true
} catch (e: Exception) {
return false
}
}

private fun screenshotOff(){
activity.window.addFlags(LayoutParams.FLAG_SECURE);
}
private fun screenshotOn(){
activity.window.clearFlags(LayoutParams.FLAG_SECURE);
}
private fun screenshotOn() : Boolean{
try {
activity.window.clearFlags(LayoutParams.FLAG_SECURE)
return true
} catch (e: Exception) {
return false
}
}

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

override fun onAttachedToActivity(binding: ActivityPluginBinding) {
activity = binding.activity;
}
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
activity = binding.activity
}

override fun onDetachedFromActivityForConfigChanges() {}

override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
activity = binding.activity;
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
activity = binding.activity

}
}

override fun onDetachedFromActivity() {}
}
1 change: 0 additions & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.flutterplaza.no_screenshot_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
16 changes: 8 additions & 8 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- Flutter (1.0.0)
- no_screenshot (0.0.1):
- "no_screenshot (0.0.1+4)":
- Flutter
- ScreenProtectorKit (~> 1.2.0)
- ScreenProtectorKit (1.2.0)
- ScreenProtectorKit (~> 1.3.1)
- ScreenProtectorKit (1.3.1)

DEPENDENCIES:
- Flutter (from `Flutter`)
Expand All @@ -20,10 +20,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/no_screenshot/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
no_screenshot: 85ed02c4d27c344d72e3ae376c97cc85a18b06c6
ScreenProtectorKit: 823e5b0342eea5acd7e9b8d92956a5a7f9c2ce40
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
no_screenshot: 67d110f12466f4913b488803d4e498d03ef2889e
ScreenProtectorKit: 83a6281b02c7a5902ee6eac4f5045f674e902ae4

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.11.3
COCOAPODS: 1.15.2
Loading

0 comments on commit 0ce6a12

Please sign in to comment.