Skip to content

Commit 0a3e2ca

Browse files
committed
Update flutter embedding to v2, add dartdoc documentation
1 parent c37bfc4 commit 0a3e2ca

File tree

7 files changed

+86
-19
lines changed

7 files changed

+86
-19
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.1.0
2+
3+
* null-safety migration (@ValeteTech, PR#16)
4+
* Switch to version 2 of flutter embedding.
5+
* Add documentation
6+
17
## 0.0.2
28

39
* Update pubspec.yaml format for newer versions of Flutter, require 1.10.

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
A Flutter plugin for manipulating Android WindowManager LayoutParams
77
dynamically at application run-time.
88

9-
![Example App Use](screenshot.jpg)
9+
<img alt="Example App Use" src="https://raw.githubusercontent.com/adaptant-labs/flutter_windowmanager/master/overview.gif" width="270"/>
1010

1111
## Motivation
1212

@@ -88,9 +88,11 @@ please let us know in the [issue tracker][tracker].
8888
As `flutter_windowmanager` only wraps and exposes an underlying Android-specific
8989
interface, there is no iOS support planned or possible. For those interested in
9090
cross-platform `FLAG_SECURE` functionality, this functionality has been re-created
91-
in the third-party [secure_application] plugin.
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.
9293

9394
[secure_application]: https://pub.dev/packages/secure_application
95+
[keep_screen_on]: https://pub.dev/packages/keep_screen_on
9496

9597
## Features and bugs
9698

@@ -101,4 +103,6 @@ Please file feature requests and bugs at the [issue tracker][tracker].
101103
## License
102104

103105
Licensed under the terms of the Apache 2.0 license, the full version of which can be found in the
104-
[LICENSE](LICENSE) file included in the distribution.
106+
[LICENSE] file included in the distribution.
107+
108+
[LICENSE]: https://raw.githubusercontent.com/adaptant-labs/flutter_windowmanager/master/LICENSE

example/android/app/src/main/AndroidManifest.xml

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="io.adaptant.labs.flutter_windowmanager_example">
3-
4-
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
5-
calls FlutterMain.startInitialization(this); in its onCreate method.
6-
In most cases you can leave this as-is, but you if you want to provide
7-
additional functionality it is fine to subclass or reimplement
8-
FlutterApplication and put your custom class here. -->
93
<application
10-
android:name="io.flutter.app.FlutterApplication"
114
android:label="flutter_windowmanager_example"
125
android:icon="@mipmap/ic_launcher">
6+
<meta-data
7+
android:name="flutterEmbedding"
8+
android:value="2"/>
139
<activity
1410
android:name=".MainActivity"
1511
android:launchMode="singleTop"
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
package io.adaptant.labs.flutter_windowmanager_example;
22

3-
import android.os.Bundle;
4-
import io.flutter.app.FlutterActivity;
5-
import io.flutter.plugins.GeneratedPluginRegistrant;
3+
import io.flutter.embedding.android.FlutterActivity;
64

75
public class MainActivity extends FlutterActivity {
8-
@Override
9-
protected void onCreate(Bundle savedInstanceState) {
10-
super.onCreate(savedInstanceState);
11-
GeneratedPluginRegistrant.registerWith(this);
12-
}
136
}

lib/flutter_windowmanager.dart

+68
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,118 @@ import 'dart:async';
22

33
import 'package:flutter/services.dart';
44

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.
59
class FlutterWindowManager {
610
// Flags for WindowManager.LayoutParams, as per
711
// 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.
814
static const int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001;
15+
16+
/// Window flag: when set, inverts the input method focusability of the window.
917
static const int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
18+
19+
/// Window flag: everything behind this window will be dimmed.
1020
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.
1123
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.
1226
static const int FLAG_FULLSCREEN = 0x00000400;
27+
28+
/// Indicates whether this window should be hardware accelerated.
1329
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.
1432
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.
1535
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.
1638
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.
1741
static const int FLAG_LAYOUT_IN_SCREEN = 0x00000100;
42+
43+
/// Window flag: allow window to extend outside of the screen.
1844
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.
1947
static const int FLAG_NOT_FOCUSABLE = 0x00000008;
48+
49+
/// Window flag: this window can never receive touch events.
2050
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.
2153
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.
2256
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.
2359
static const int FLAG_SECURE = 0x00002000;
60+
61+
/// Window flag: ask that the system wallpaper be shown behind your window.
2462
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.
2565
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.
2668
static const int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
69+
70+
/// Window flag: enable blur behind for this window.
2771
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.
2874
static const int FLAG_DISMISS_KEYGUARD = 0x00400000;
75+
76+
/// This constant was deprecated in API level 17. This flag is no longer used.
2977
static const int FLAG_DITHER = 0x00001000;
78+
79+
/// Flag indicating that this Window is responsible for drawing the background for the system bars.
3080
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.
3183
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.
3286
static const int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000;
87+
88+
/// Flag for a window in local focus mode.
3389
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.
3492
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.
3595
static const int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
96+
97+
/// Window flag: request a translucent navigation bar with minimal system-provided background protection.
3698
static const int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000;
99+
100+
/// Window flag: request a translucent status bar with minimal system-provided background protection.
37101
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.
38104
static const int FLAG_TURN_SCREEN_ON = 0x00200000;
39105

40106
static const MethodChannel _channel =
41107
const MethodChannel('flutter_windowmanager');
42108

109+
/// Adds flags [flags] to the WindowManager.LayoutParams
43110
static Future<bool> addFlags(int flags) async {
44111
return await _channel.invokeMethod("addFlags", {
45112
"flags": flags,
46113
});
47114
}
48115

116+
/// Clears flags [flags] from the WindowManager.LayoutParams
49117
static Future<bool> clearFlags(int flags) async {
50118
return await _channel.invokeMethod("clearFlags", {
51119
"flags": flags,

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_windowmanager
22
description: A Flutter plugin for manipulating Android WindowManager LayoutParams.
3-
version: 0.0.2
3+
version: 0.1.0
44
homepage: https://github.com/adaptant-labs/flutter_windowmanager
55
repository: https://github.com/adaptant-labs/flutter_windowmanager
66
issue_tracker: https://github.com/adaptant-labs/flutter_windowmanager/issues

screenshot.jpg

-5.25 KB
Binary file not shown.

0 commit comments

Comments
 (0)