├── .gitignore ├── .metadata ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── android ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── io │ └── adaptant │ └── labs │ └── flutter_windowmanager │ └── FlutterWindowManagerPlugin.java ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── lib │ └── main.dart ├── pubspec.yaml └── test │ └── widget_test.dart ├── flutter_windowmanager.iml ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── FlutterWindowmanagerPlugin.h │ ├── FlutterWindowmanagerPlugin.m │ └── SwiftFlutterWindowmanagerPlugin.swift └── flutter_windowmanager.podspec ├── lib └── flutter_windowmanager.dart ├── overview.gif ├── pubspec.yaml └── test └── flutter_windowmanager_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .DS_Store 3 | .dart_tool/ 4 | .idea/ 5 | 6 | .packages 7 | .pub/ 8 | 9 | pubspec.lock 10 | 11 | build/ 12 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: cc949a8e8b9cf394b9290a8e80f87af3e207dce5 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: dart 2 | dart: 3 | - stable 4 | os: 5 | - linux 6 | sudo: false 7 | addons: 8 | # chrome: stable 9 | apt: 10 | sources: 11 | - ubuntu-toolchain-r-test # you need this source to get the right version of libstdc++6 12 | packages: 13 | - libstdc++6 14 | #- fonts-droid-fallback 15 | install: 16 | - echo 'Avoid default Travis CI install step' # this is to avoid an error with pub in Travis 17 | before_script: 18 | - cd .. 19 | - git clone https://github.com/flutter/flutter.git 20 | - export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH 21 | - flutter doctor 22 | # - pub global activate flutter_plugin_tools 23 | script: 24 | - cd $TRAVIS_BUILD_DIR 25 | - flutter packages get 26 | - flutter analyze --no-pub --no-current-package lib 27 | # - flutter test 28 | - flutter packages pub publish --dry-run 29 | cache: 30 | directories: 31 | - $HOME/.pub-cache 32 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.0 2 | 3 | * Finish flutter embedding v2 migration. #17 4 | 5 | ## 0.1.0 6 | 7 | * null-safety migration (@ValeteTech, PR#16) 8 | * Switch to version 2 of flutter embedding. 9 | * Add documentation 10 | 11 | ## 0.0.2 12 | 13 | * Update pubspec.yaml format for newer versions of Flutter, require 1.10. 14 | 15 | ## 0.0.1+1 16 | 17 | * Suppress deprecation warnings in build, all uses are safe. 18 | 19 | ## 0.0.1 20 | 21 | * Initial release. 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_windowmanager 2 | 3 | [![Build Status](https://travis-ci.com/adaptant-labs/flutter_windowmanager.svg?branch=master)](https://app.travis-ci.com/github/adaptant-labs/flutter_windowmanager) 4 | [![Pub](https://img.shields.io/pub/v/flutter_windowmanager.svg)](https://pub.dartlang.org/packages/flutter_windowmanager) 5 | 6 | A Flutter plugin for manipulating Android WindowManager LayoutParams 7 | dynamically at application run-time. 8 | 9 | Example App Use 10 | 11 | ## Motivation 12 | 13 | While Android natively supports a range of window modes, there was no 14 | good way to set these dynamically within a running Flutter application - 15 | instead requiring that these flags are set within the native 16 | `MainActivity` of the Flutter application itself. 17 | 18 | In our App, we only wished to disable screenshots for specific screens, 19 | rather than across the entire application lifecycle. This can now be 20 | accomplished by simply calling: 21 | 22 | ``` 23 | await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE); 24 | ``` 25 | 26 | for the relevant screen. 27 | 28 | This can further be toggled for a specific screen by either using a 29 | [RouteAware] mixin, or through direct toggling in `initState()` and 30 | `dispose()` methods in the case of stateful widgets. 31 | 32 | [RouteAware]: https://api.flutter.dev/flutter/widgets/RouteAware-class.html 33 | 34 | ## Flags 35 | 36 | The full range of [LayoutParams] flags are passed through. The plugin 37 | will carry out basic API level checking and throw an error on any 38 | unsupported flag specification. Flags are implemented using a bitmask, 39 | and may be specified individually or ORed together for setting/clearing 40 | multiple flags at once. 41 | 42 | The current list of flags is: 43 | 44 | ``` 45 | FLAG_ALLOW_LOCK_WHILE_SCREEN_ON 46 | FLAG_ALT_FOCUSABLE_IM 47 | FLAG_DIM_BEHIND 48 | FLAG_FORCE_NOT_FULLSCREEN 49 | FLAG_FULLSCREEN 50 | FLAG_HARDWARE_ACCELERATED 51 | FLAG_IGNORE_CHEEK_PRESSES 52 | FLAG_KEEP_SCREEN_ON 53 | FLAG_LAYOUT_INSET_DECOR 54 | FLAG_LAYOUT_IN_SCREEN 55 | FLAG_LAYOUT_NO_LIMITS 56 | FLAG_NOT_FOCUSABLE 57 | FLAG_NOT_TOUCHABLE 58 | FLAG_NOT_TOUCH_MODAL 59 | FLAG_SCALED 60 | FLAG_SECURE 61 | FLAG_SHOW_WALLPAPER 62 | FLAG_SPLIT_TOUCH 63 | FLAG_WATCH_OUTSIDE_TOUCH 64 | FLAG_BLUR_BEHIND 65 | FLAG_DISMISS_KEYGUARD 66 | FLAG_DITHER 67 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS 68 | FLAG_LAYOUT_ATTACHED_IN_DECOR 69 | FLAG_LAYOUT_IN_OVERSCAN 70 | FLAG_LOCAL_FOCUS_MODE 71 | FLAG_SHOW_WHEN_LOCKED 72 | FLAG_TOUCHABLE_WHEN_WAKING 73 | FLAG_TRANSLUCENT_NAVIGATION 74 | FLAG_TRANSLUCENT_STATUS 75 | FLAG_TURN_SCREEN_ON 76 | ``` 77 | 78 | In practice, this plugin was developed primarily for the toggling of 79 | `FLAG_SECURE`. Other flags have not been tested, and we make no 80 | guarantees that toggling with any of the other flags will interact well 81 | with Flutter - if you find specific problems with any particular flag, 82 | please let us know in the [issue tracker][tracker]. 83 | 84 | [LayoutParams]: https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html 85 | 86 | ## iOS Support 87 | 88 | As `flutter_windowmanager` only wraps and exposes an underlying Android-specific 89 | interface, there is no iOS support planned or possible. For those interested in 90 | cross-platform `FLAG_SECURE` functionality, this functionality has been re-created 91 | in the third-party [secure_application] package. Cross-platform `FLAG_KEEP_SCREEN_ON` 92 | functionality is provided by the third-party [keep_screen_on] package. 93 | 94 | [secure_application]: https://pub.dev/packages/secure_application 95 | [keep_screen_on]: https://pub.dev/packages/keep_screen_on 96 | 97 | ## Features and bugs 98 | 99 | Please file feature requests and bugs at the [issue tracker][tracker]. 100 | 101 | [tracker]: https://github.com/adaptant-labs/flutter_windowmanager/issues 102 | 103 | ## License 104 | 105 | Licensed under the terms of the Apache 2.0 license, the full version of which can be found in the 106 | [LICENSE] file included in the distribution. 107 | 108 | [LICENSE]: https://raw.githubusercontent.com/adaptant-labs/flutter_windowmanager/master/LICENSE -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'io.adaptant.labs.flutter_windowmanager' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.2.1' 12 | } 13 | } 14 | 15 | rootProject.allprojects { 16 | repositories { 17 | google() 18 | jcenter() 19 | } 20 | } 21 | 22 | apply plugin: 'com.android.library' 23 | 24 | android { 25 | compileSdkVersion 28 26 | 27 | defaultConfig { 28 | minSdkVersion 16 29 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 30 | } 31 | lintOptions { 32 | disable 'InvalidPackage' 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | 3 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_windowmanager' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/java/io/adaptant/labs/flutter_windowmanager/FlutterWindowManagerPlugin.java: -------------------------------------------------------------------------------- 1 | package io.adaptant.labs.flutter_windowmanager; 2 | 3 | import android.app.Activity; 4 | import android.os.Build; 5 | import android.view.WindowManager; 6 | 7 | import androidx.annotation.NonNull; 8 | 9 | import io.flutter.embedding.engine.plugins.FlutterPlugin; 10 | import io.flutter.embedding.engine.plugins.activity.ActivityAware; 11 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; 12 | import io.flutter.plugin.common.BinaryMessenger; 13 | import io.flutter.plugin.common.MethodCall; 14 | import io.flutter.plugin.common.MethodChannel; 15 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler; 16 | import io.flutter.plugin.common.MethodChannel.Result; 17 | import io.flutter.plugin.common.PluginRegistry.Registrar; 18 | 19 | /** FlutterWindowManagerPlugin */ 20 | public class FlutterWindowManagerPlugin implements MethodCallHandler, FlutterPlugin, ActivityAware { 21 | private Activity activity; 22 | 23 | @SuppressWarnings("unused") 24 | public FlutterWindowManagerPlugin() { } 25 | 26 | private FlutterWindowManagerPlugin(Activity activity) { 27 | this.activity = activity; 28 | } 29 | 30 | /** Plugin registration. */ 31 | @Deprecated 32 | public static void registerWith(Registrar registrar) { 33 | new FlutterWindowManagerPlugin(registrar.activity()).registerWith(registrar.messenger()); 34 | } 35 | 36 | private void registerWith(BinaryMessenger binaryMessenger) { 37 | final MethodChannel channel = new MethodChannel(binaryMessenger, "flutter_windowmanager"); 38 | channel.setMethodCallHandler(this); 39 | } 40 | 41 | 42 | @Override 43 | public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { 44 | registerWith(flutterPluginBinding.getBinaryMessenger()); 45 | } 46 | 47 | @Override 48 | public void onDetachedFromEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { 49 | 50 | } 51 | 52 | /** 53 | * Validate flag specification against WindowManager.LayoutParams and API levels, as per: 54 | * https://developer.android.com/reference/android/view/WindowManager.LayoutParams 55 | */ 56 | @SuppressWarnings("deprecation") 57 | private boolean validLayoutParam(int flag) { 58 | switch (flag) { 59 | case WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON: 60 | case WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM: 61 | case WindowManager.LayoutParams.FLAG_DIM_BEHIND: 62 | case WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN: 63 | case WindowManager.LayoutParams.FLAG_FULLSCREEN: 64 | case WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED: 65 | case WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES: 66 | case WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON: 67 | case WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR: 68 | case WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN: 69 | case WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS: 70 | case WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE: 71 | case WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE: 72 | case WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL: 73 | case WindowManager.LayoutParams.FLAG_SCALED: 74 | case WindowManager.LayoutParams.FLAG_SECURE: 75 | case WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER: 76 | case WindowManager.LayoutParams.FLAG_SPLIT_TOUCH: 77 | case WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH: 78 | return true; 79 | case WindowManager.LayoutParams.FLAG_BLUR_BEHIND: 80 | return !(Build.VERSION.SDK_INT >= 15); 81 | case WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD: 82 | return (Build.VERSION.SDK_INT >= 5 && Build.VERSION.SDK_INT < 26); 83 | case WindowManager.LayoutParams.FLAG_DITHER: 84 | return !(Build.VERSION.SDK_INT >= 17); 85 | case WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS: 86 | return (Build.VERSION.SDK_INT >= 21); 87 | case WindowManager.LayoutParams.FLAG_LAYOUT_ATTACHED_IN_DECOR: 88 | return (Build.VERSION.SDK_INT >= 22); 89 | case WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN: 90 | return (Build.VERSION.SDK_INT >= 18); 91 | case WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE: 92 | return (Build.VERSION.SDK_INT >= 19); 93 | case WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED: 94 | return !(Build.VERSION.SDK_INT >= 27); 95 | case WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING: 96 | return !(Build.VERSION.SDK_INT >= 20); 97 | case WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION: 98 | case WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS: 99 | return (Build.VERSION.SDK_INT >= 19); 100 | case WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON: 101 | return !(Build.VERSION.SDK_INT >= 27); 102 | default: 103 | return false; 104 | } 105 | } 106 | 107 | private boolean validLayoutParams(Result result, int flags) { 108 | for (int i = 0; i < Integer.SIZE; i++) { 109 | int flag = (1 << i); 110 | if ((flags & flag) == 1) { 111 | if (!validLayoutParam(flag)) { 112 | result.error("FlutterWindowManagerPlugin","FlutterWindowManagerPlugin: invalid flag specification: " + Integer.toHexString(flag), null); 113 | return false; 114 | } 115 | } 116 | } 117 | 118 | return true; 119 | } 120 | 121 | @Override 122 | public void onMethodCall(MethodCall call, Result result) { 123 | final int flags = call.argument("flags"); 124 | 125 | if (activity == null) { 126 | result.error("FlutterWindowManagerPlugin", "FlutterWindowManagerPlugin: ignored flag state change, current activity is null", null); 127 | } 128 | 129 | if (!validLayoutParams(result, flags)) { 130 | return; 131 | } 132 | 133 | switch (call.method) { 134 | case "addFlags": 135 | activity.getWindow().addFlags(flags); 136 | result.success(true); 137 | break; 138 | case "clearFlags": 139 | activity.getWindow().clearFlags(flags); 140 | result.success(true); 141 | break; 142 | default: 143 | result.notImplemented(); 144 | } 145 | } 146 | 147 | @Override 148 | public void onAttachedToActivity(@NonNull ActivityPluginBinding activityPluginBinding) { 149 | activity = activityPluginBinding.getActivity(); 150 | } 151 | 152 | @Override 153 | public void onDetachedFromActivityForConfigChanges() { 154 | activity = null; 155 | } 156 | 157 | @Override 158 | public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding activityPluginBinding) { 159 | onAttachedToActivity(activityPluginBinding); 160 | } 161 | 162 | @Override 163 | public void onDetachedFromActivity() { 164 | activity = null; 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Generated.xcconfig 62 | **/ios/Flutter/app.flx 63 | **/ios/Flutter/app.zip 64 | **/ios/Flutter/flutter_assets/ 65 | **/ios/Flutter/flutter_export_environment.sh 66 | **/ios/ServiceDefinitions.json 67 | **/ios/Runner/GeneratedPluginRegistrant.* 68 | 69 | # Exceptions to above rules. 70 | !**/ios/**/default.mode1v3 71 | !**/ios/**/default.mode2v3 72 | !**/ios/**/default.pbxuser 73 | !**/ios/**/default.perspectivev3 74 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 75 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: cc949a8e8b9cf394b9290a8e80f87af3e207dce5 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_windowmanager_example 2 | 3 | Demonstrates how to use the flutter_windowmanager plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | lintOptions { 31 | disable 'InvalidPackage' 32 | } 33 | 34 | defaultConfig { 35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 36 | applicationId "io.adaptant.labs.flutter_windowmanager_example" 37 | minSdkVersion 16 38 | targetSdkVersion 28 39 | versionCode flutterVersionCode.toInteger() 40 | versionName flutterVersionName 41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | testImplementation 'junit:junit:4.12' 59 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 60 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 61 | } 62 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 9 | 16 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adaptant-labs/flutter_windowmanager/17810c502e067c2811c2e180950ab2a59df5d2f8/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adaptant-labs/flutter_windowmanager/17810c502e067c2811c2e180950ab2a59df5d2f8/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adaptant-labs/flutter_windowmanager/17810c502e067c2811c2e180950ab2a59df5d2f8/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adaptant-labs/flutter_windowmanager/17810c502e067c2811c2e180950ab2a59df5d2f8/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adaptant-labs/flutter_windowmanager/17810c502e067c2811c2e180950ab2a59df5d2f8/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.2.1' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | 3 | android.enableR8=true 4 | android.useAndroidX=true 5 | android.enableJetifier=true 6 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_windowmanager/flutter_windowmanager.dart'; 3 | 4 | void main() => runApp(MyApp()); 5 | 6 | class MyApp extends StatefulWidget { 7 | @override 8 | _MyAppState createState() => _MyAppState(); 9 | } 10 | 11 | class _MyAppState extends State { 12 | bool _secureMode = false; 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return MaterialApp( 17 | home: Scaffold( 18 | appBar: AppBar( 19 | title: const Text('Plugin example app'), 20 | ), 21 | body: Center( 22 | child: Column( 23 | mainAxisAlignment: MainAxisAlignment.center, 24 | crossAxisAlignment: CrossAxisAlignment.center, 25 | children: [ 26 | Text('Secure Mode: ${_secureMode.toString()}\n'), 27 | ElevatedButton( 28 | onPressed: () async { 29 | final secureModeToggle = !_secureMode; 30 | 31 | if (secureModeToggle == true) { 32 | await FlutterWindowManager.addFlags( 33 | FlutterWindowManager.FLAG_SECURE); 34 | } else { 35 | await FlutterWindowManager.clearFlags( 36 | FlutterWindowManager.FLAG_SECURE); 37 | } 38 | 39 | setState(() { 40 | _secureMode = !_secureMode; 41 | }); 42 | }, 43 | child: const Text("Toggle Secure Mode")), 44 | ], 45 | ), 46 | ), 47 | ), 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_windowmanager_example 2 | description: Demonstrates how to use the flutter_windowmanager plugin. 3 | publish_to: 'none' 4 | 5 | environment: 6 | sdk: ">=2.1.0 <3.0.0" 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | 12 | dev_dependencies: 13 | flutter_test: 14 | sdk: flutter 15 | 16 | flutter_windowmanager: 17 | path: ../ 18 | 19 | # For information on the generic Dart part of this file, see the 20 | # following page: https://dart.dev/tools/pub/pubspec 21 | 22 | # The following section is specific to Flutter. 23 | flutter: 24 | 25 | # The following line ensures that the Material Icons font is 26 | # included with your application, so that you can use the icons in 27 | # the material Icons class. 28 | uses-material-design: true 29 | 30 | # To add assets to your application, add an assets section, like this: 31 | # assets: 32 | # - images/a_dot_burr.jpeg 33 | # - images/a_dot_ham.jpeg 34 | 35 | # An image asset can refer to one or more resolution-specific "variants", see 36 | # https://flutter.dev/assets-and-images/#resolution-aware. 37 | 38 | # For details regarding adding assets from package dependencies, see 39 | # https://flutter.dev/assets-and-images/#from-packages 40 | 41 | # To add custom fonts to your application, add a fonts section here, 42 | # in this "flutter" section. Each entry in this list should have a 43 | # "family" key with the font family name, and a "fonts" key with a 44 | # list giving the asset and other descriptors for the font. For 45 | # example: 46 | # fonts: 47 | # - family: Schyler 48 | # fonts: 49 | # - asset: fonts/Schyler-Regular.ttf 50 | # - asset: fonts/Schyler-Italic.ttf 51 | # style: italic 52 | # - family: Trajan Pro 53 | # fonts: 54 | # - asset: fonts/TrajanPro.ttf 55 | # - asset: fonts/TrajanPro_Bold.ttf 56 | # weight: 700 57 | # 58 | # For details regarding fonts from package dependencies, 59 | # see https://flutter.dev/custom-fonts/#from-packages 60 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:flutter_windowmanager_example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Verify Secure Mode', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MyApp()); 17 | 18 | // Verify that platform version is retrieved. 19 | expect( 20 | find.byWidgetPredicate( 21 | (Widget widget) => 22 | widget is Text && widget.data.startsWith('Secure Mode:'), 23 | ), 24 | findsOneWidget, 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /flutter_windowmanager.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adaptant-labs/flutter_windowmanager/17810c502e067c2811c2e180950ab2a59df5d2f8/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/FlutterWindowmanagerPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface FlutterWindowmanagerPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /ios/Classes/FlutterWindowmanagerPlugin.m: -------------------------------------------------------------------------------- 1 | #import "FlutterWindowmanagerPlugin.h" 2 | #if __has_include() 3 | #import 4 | #else 5 | // Support project import fallback if the generated compatibility header 6 | // is not copied when this plugin is created as a library. 7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 8 | #import "flutter_windowmanager-Swift.h" 9 | #endif 10 | 11 | @implementation FlutterWindowmanagerPlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftFlutterWindowmanagerPlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Classes/SwiftFlutterWindowmanagerPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | public class SwiftFlutterWindowmanagerPlugin: NSObject, FlutterPlugin { 5 | public static func register(with registrar: FlutterPluginRegistrar) { 6 | let channel = FlutterMethodChannel(name: "flutter_windowmanager", binaryMessenger: registrar.messenger()) 7 | let instance = SwiftFlutterWindowmanagerPlugin() 8 | registrar.addMethodCallDelegate(instance, channel: channel) 9 | } 10 | 11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 12 | result("iOS " + UIDevice.current.systemVersion) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ios/flutter_windowmanager.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint flutter_windowmanager.podspec' to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'flutter_windowmanager' 7 | s.version = '0.0.1' 8 | s.summary = 'A new flutter plugin project.' 9 | s.description = <<-DESC 10 | A new flutter plugin project. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | s.platform = :ios, '8.0' 19 | 20 | # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. 21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } 22 | s.swift_version = '5.0' 23 | end 24 | -------------------------------------------------------------------------------- /lib/flutter_windowmanager.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/services.dart'; 4 | 5 | /// A base class for manipulating Android WindowManager.LayoutParams. 6 | /// 7 | /// The class does not need to be instantiated directly, as it provides all 8 | /// static flags and methods. 9 | class FlutterWindowManager { 10 | // Flags for WindowManager.LayoutParams, as per 11 | // https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html 12 | 13 | /// Window flag: as long as this window is visible to the user, allow the lock screen to activate while the screen is on. 14 | static const int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; 15 | 16 | /// Window flag: when set, inverts the input method focusability of the window. 17 | static const int FLAG_ALT_FOCUSABLE_IM = 0x00020000; 18 | 19 | /// Window flag: everything behind this window will be dimmed. 20 | static const int FLAG_DIM_BEHIND = 0x00000002; 21 | 22 | /// This constant was deprecated in API level 30. This value became API "by accident", and shouldn't be used by 3rd party applications. 23 | static const int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; 24 | 25 | /// This constant was deprecated in API level 30. Use WindowInsetsController#hide(int) with Type#statusBars() instead. 26 | static const int FLAG_FULLSCREEN = 0x00000400; 27 | 28 | /// Indicates whether this window should be hardware accelerated. 29 | static const int FLAG_HARDWARE_ACCELERATED = 0x01000000; 30 | 31 | /// Window flag: intended for windows that will often be used when the user is holding the screen against their face, it will aggressively filter the event stream to prevent unintended presses in this situation that may not be desired for a particular window, when such an event stream is detected, the application will receive a CANCEL motion event to indicate this so applications can handle this accordingly by taking no action on the event until the finger is released. 32 | static const int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; 33 | 34 | /// Window flag: as long as this window is visible to the user, keep the device's screen turned on and bright. 35 | static const int FLAG_KEEP_SCREEN_ON = 0x00000080; 36 | 37 | /// This constant was deprecated in API level 30. Insets will always be delivered to your application. 38 | static const int FLAG_LAYOUT_INSET_DECOR = 0x00010000; 39 | 40 | /// Window flag for attached windows: Place the window within the entire screen, ignoring any constraints from the parent window. 41 | static const int FLAG_LAYOUT_IN_SCREEN = 0x00000100; 42 | 43 | /// Window flag: allow window to extend outside of the screen. 44 | static const int FLAG_LAYOUT_NO_LIMITS = 0x00000200; 45 | 46 | /// Window flag: this window won't ever get key input focus, so the user can not send key or other button events to it. 47 | static const int FLAG_NOT_FOCUSABLE = 0x00000008; 48 | 49 | /// Window flag: this window can never receive touch events. 50 | static const int FLAG_NOT_TOUCHABLE = 0x00000010; 51 | 52 | /// Window flag: even when this window is focusable (its FLAG_NOT_FOCUSABLE is not set), allow any pointer events outside of the window to be sent to the windows behind it. 53 | static const int FLAG_NOT_TOUCH_MODAL = 0x00000020; 54 | 55 | /// Window flag: a special mode where the layout parameters are used to perform scaling of the surface when it is composited to the screen. 56 | static const int FLAG_SCALED = 0x00004000; 57 | 58 | /// Window flag: treat the content of the window as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays. 59 | static const int FLAG_SECURE = 0x00002000; 60 | 61 | /// Window flag: ask that the system wallpaper be shown behind your window. 62 | static const int FLAG_SHOW_WALLPAPER = 0x00100000; 63 | 64 | /// Window flag: when set the window will accept for touch events outside of its bounds to be sent to other windows that also support split touch. 65 | static const int FLAG_SPLIT_TOUCH = 0x00800000; 66 | 67 | /// Window flag: if you have set FLAG_NOT_TOUCH_MODAL, you can set this flag to receive a single special MotionEvent with the action MotionEvent.ACTION_OUTSIDE for touches that occur outside of your window. 68 | static const int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; 69 | 70 | /// Window flag: enable blur behind for this window. 71 | static const int FLAG_BLUR_BEHIND = 0x00000004; 72 | 73 | /// This constant was deprecated in API level 26. Use FLAG_SHOW_WHEN_LOCKED or KeyguardManager#requestDismissKeyguard instead. Since keyguard was dismissed all the time as long as an activity with this flag on its window was focused, keyguard couldn't guard against unintentional touches on the screen, which isn't desired. 74 | static const int FLAG_DISMISS_KEYGUARD = 0x00400000; 75 | 76 | /// This constant was deprecated in API level 17. This flag is no longer used. 77 | static const int FLAG_DITHER = 0x00001000; 78 | 79 | /// Flag indicating that this Window is responsible for drawing the background for the system bars. 80 | static const int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000; 81 | 82 | /// Window flag: When requesting layout with an attached window, the attached window may overlap with the screen decorations of the parent window such as the navigation bar. By including this flag, the window manager will layout the attached window within the decor frame of the parent window such that it doesn't overlap with screen decorations. 83 | static const int FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000; 84 | 85 | /// Window flag: allow window contents to extend in to the screen's overscan area, if there is one. The window should still correctly position its contents to take the overscan area into account. 86 | static const int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000; 87 | 88 | /// Flag for a window in local focus mode. 89 | static const int FLAG_LOCAL_FOCUS_MODE = 0x10000000; 90 | 91 | /// Window flag: special flag to let windows be shown when the screen is locked. This will let application windows take precedence over key guard or any other lock screens. Can be used with FLAG_KEEP_SCREEN_ON to turn screen on and display windows directly before showing the key guard window. Can be used with FLAG_DISMISS_KEYGUARD to automatically fully dismisss non-secure keyguards. This flag only applies to the top-most full-screen window. 92 | static const int FLAG_SHOW_WHEN_LOCKED = 0x00080000; 93 | 94 | /// Window flag: when set, if the device is asleep when the touch screen is pressed, you will receive this first touch event. Usually the first touch event is consumed by the system since the user can not see what they are pressing on. 95 | static const int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; 96 | 97 | /// Window flag: request a translucent navigation bar with minimal system-provided background protection. 98 | static const int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000; 99 | 100 | /// Window flag: request a translucent status bar with minimal system-provided background protection. 101 | static const int FLAG_TRANSLUCENT_STATUS = 0x04000000; 102 | 103 | /// Window flag: when set as a window is being added or made visible, once the window has been shown then the system will poke the power manager's user activity (as if the user had woken up the device) to turn the screen on. 104 | static const int FLAG_TURN_SCREEN_ON = 0x00200000; 105 | 106 | static const MethodChannel _channel = 107 | const MethodChannel('flutter_windowmanager'); 108 | 109 | /// Adds flags [flags] to the WindowManager.LayoutParams 110 | static Future addFlags(int flags) async { 111 | return await _channel.invokeMethod("addFlags", { 112 | "flags": flags, 113 | }); 114 | } 115 | 116 | /// Clears flags [flags] from the WindowManager.LayoutParams 117 | static Future clearFlags(int flags) async { 118 | return await _channel.invokeMethod("clearFlags", { 119 | "flags": flags, 120 | }); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /overview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adaptant-labs/flutter_windowmanager/17810c502e067c2811c2e180950ab2a59df5d2f8/overview.gif -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_windowmanager 2 | description: A Flutter plugin for manipulating Android WindowManager LayoutParams. 3 | version: 0.2.0 4 | homepage: https://github.com/adaptant-labs/flutter_windowmanager 5 | repository: https://github.com/adaptant-labs/flutter_windowmanager 6 | issue_tracker: https://github.com/adaptant-labs/flutter_windowmanager/issues 7 | 8 | environment: 9 | sdk: ">=2.12.0 <3.0.0" 10 | # Flutter versions prior to 1.10 did not support 11 | # the flutter.plugin.platforms map. 12 | flutter: ">=1.10.0" 13 | 14 | dependencies: 15 | flutter: 16 | sdk: flutter 17 | 18 | dev_dependencies: 19 | flutter_test: 20 | sdk: flutter 21 | 22 | flutter: 23 | plugin: 24 | platforms: 25 | android: 26 | package: io.adaptant.labs.flutter_windowmanager 27 | pluginClass: FlutterWindowManagerPlugin 28 | -------------------------------------------------------------------------------- /test/flutter_windowmanager_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:flutter_windowmanager/flutter_windowmanager.dart'; 4 | 5 | void main() { 6 | TestWidgetsFlutterBinding.ensureInitialized(); 7 | const MethodChannel channel = MethodChannel('flutter_windowmanager'); 8 | final List log = []; 9 | 10 | setUp(() { 11 | channel.setMockMethodCallHandler((MethodCall methodCall) async { 12 | log.add(methodCall); 13 | return true; 14 | }); 15 | }); 16 | 17 | tearDown(() { 18 | channel.setMockMethodCallHandler(null); 19 | log.clear(); 20 | }); 21 | 22 | test('addFlags', () async { 23 | await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE); 24 | expect( 25 | log, 26 | [ 27 | isMethodCall('addFlags', arguments: { 28 | 'flags': FlutterWindowManager.FLAG_SECURE, 29 | }) 30 | ], 31 | ); 32 | }); 33 | 34 | test('clearFlags', () async { 35 | await FlutterWindowManager.clearFlags(FlutterWindowManager.FLAG_SECURE); 36 | expect( 37 | log, 38 | [ 39 | isMethodCall('clearFlags', arguments: { 40 | 'flags': FlutterWindowManager.FLAG_SECURE, 41 | }) 42 | ], 43 | ); 44 | }); 45 | } 46 | --------------------------------------------------------------------------------