Compare commits

...

10 Commits

Author SHA1 Message Date
1f1ccb5e9d 改回来,如果沉浸式标题栏不好使,请使用cordova-android@^10.1.1 2023-05-17 11:23:48 +08:00
zher52
686b33113f 处理沉浸式状态栏背景不透明的问题 2023-05-16 22:30:39 +08:00
zher52
8fb34774c6 处理有虚拟按键的手机 app底部被遮盖的问题 2019-11-22 15:05:51 +08:00
zher52
022fa3bdad 启动时设置状态栏为沉浸式,避免某些机型沉浸式无效的问题 2019-11-07 13:26:23 +08:00
Tim Brust
217f792101 fix: remove deprecated platforms (#126)
* fix: remove deprecated platforms

* docs: use simply Windows

* fix: remove wp mentions from package.json

* fix: remove BlackBerry namespace
2019-10-24 07:54:45 +00:00
MrBullfinsh
13645b9f53 fix(iOS): Delay resizeWebView on viewWillAppear for correct statusbar height (#157) 2019-10-20 12:16:48 +02:00
i-need-to-tell-you-something
5f6614c3c1 docs(README): Clarify StatusBarStyle (#160) 2019-10-19 16:13:24 +02:00
Jan Piotrowski
eb9e106510 ci(appveyor): replace node 6 with node 12 2019-07-04 13:46:36 +02:00
Jan Piotrowski
9703774c6c ci(travis): upgrade to node 8 2019-07-03 10:28:03 +02:00
Jan Piotrowski
86d60a91b4 chore(release): 2.4.4-dev 2019-06-19 16:50:46 +02:00
10 changed files with 43 additions and 213 deletions

View File

@@ -15,9 +15,9 @@ environment:
PLATFORM: windows-10-store
JUST_BUILD: --justBuild
matrix:
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "10"
- nodejs_version: "12"
platform:
- x86

View File

@@ -12,12 +12,12 @@ addons:
env:
global:
- SAUCE_USERNAME=snay
- TRAVIS_NODE_VERSION=6
- TRAVIS_NODE_VERSION=8
- ANDROID_API_LEVEL=28
- ANDROID_BUILD_TOOLS_VERSION=28.0.3
language: node_js
node_js: 6
node_js: 8
# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027

View File

@@ -59,7 +59,7 @@ Preferences
<preference name="StatusBarBackgroundColor" value="#000000" />
- __StatusBarStyle__ (status bar style, defaults to lightcontent). Set the status bar style. Available options default, lightcontent, blacktranslucent, blackopaque.
- __StatusBarStyle__ (status bar style, defaults to lightcontent). Set the status bar style (e.g. text color). Available options: default, lightcontent, blacktranslucent, blackopaque.
<preference name="StatusBarStyle" value="lightcontent" />
@@ -168,9 +168,7 @@ Supported Platforms
- iOS
- Android 6+
- Windows Phone 7
- Windows Phone 8
- Windows Phone 8.1
- Windows
StatusBar.styleLightContent
=================
@@ -185,9 +183,7 @@ Supported Platforms
- iOS
- Android 6+
- Windows Phone 7
- Windows Phone 8
- Windows Phone 8.1
- Windows
StatusBar.styleBlackTranslucent
=================
@@ -202,9 +198,7 @@ Supported Platforms
- iOS
- Android 6+
- Windows Phone 7
- Windows Phone 8
- Windows Phone 8.1
- Windows
StatusBar.styleBlackOpaque
=================
@@ -219,9 +213,7 @@ Supported Platforms
- iOS
- Android 6+
- Windows Phone 7
- Windows Phone 8
- Windows Phone 8.1
- Windows
StatusBar.backgroundColorByName
@@ -241,9 +233,7 @@ Supported Platforms
- iOS
- Android 5+
- Windows Phone 7
- Windows Phone 8
- Windows Phone 8.1
- Windows
StatusBar.backgroundColorByHexString
=================
@@ -266,9 +256,7 @@ Supported Platforms
- iOS
- Android 5+
- Windows Phone 7
- Windows Phone 8
- Windows Phone 8.1
- Windows
StatusBar.hide
=================
@@ -283,9 +271,7 @@ Supported Platforms
- iOS
- Android
- Windows Phone 7
- Windows Phone 8
- Windows Phone 8.1
- Windows
StatusBar.show
=================
@@ -300,10 +286,7 @@ Supported Platforms
- iOS
- Android
- Windows Phone 7
- Windows Phone 8
- Windows Phone 8.1
- Windows
StatusBar.isVisible
=================
@@ -320,10 +303,7 @@ Supported Platforms
- iOS
- Android
- Windows Phone 7
- Windows Phone 8
- Windows Phone 8.1
- Windows
statusTap
=========

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-statusbar",
"version": "2.4.3",
"version": "2.4.4-dev",
"description": "Cordova StatusBar Plugin",
"types": "./types/index.d.ts",
"cordova": {
@@ -8,8 +8,6 @@
"platforms": [
"android",
"ios",
"wp7",
"wp8",
"windows"
]
},
@@ -26,8 +24,6 @@
"ecosystem:cordova",
"cordova-android",
"cordova-ios",
"cordova-wp7",
"cordova-wp8",
"cordova-windows"
],
"scripts": {

View File

@@ -19,10 +19,9 @@
-->
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:rim="http://www.blackberry.com/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-statusbar"
version="2.4.3">
version="2.4.4-dev">
<name>StatusBar</name>
<description>Cordova StatusBar Plugin</description>
<license>Apache 2.0</license>
@@ -53,9 +52,7 @@
</js-module>
</platform>
<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" />
@@ -67,30 +64,8 @@
<header-file src="src/ios/CDVStatusBar.h" />
<source-file src="src/ios/CDVStatusBar.m" />
</platform>
<!-- wp7 -->
<platform name="wp7">
<config-file target="config.xml" parent="/*">
<feature name="StatusBar">
<param name="wp-package" value="StatusBar"/>
</feature>
</config-file>
<source-file src="src/wp/StatusBar.cs" />
</platform>
<!-- wp8 -->
<platform name="wp8">
<config-file target="config.xml" parent="/*">
<feature name="StatusBar">
<param name="wp-package" value="StatusBar"/>
</feature>
</config-file>
<source-file src="src/wp/StatusBar.cs" />
</platform>
<!-- windows -->
<platform name="windows">
<js-module src="src/windows/StatusBarProxy.js" name="StatusBarProxy">
<runs />

View File

@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*
*/
*/
package org.apache.cordova.statusbar;
import android.app.Activity;
@@ -57,6 +57,20 @@ public class StatusBar extends CordovaPlugin {
// Clear flag FLAG_FORCE_NOT_FULLSCREEN which is set initially
// by the Cordova.
Window window = cordova.getActivity().getWindow();
// 添加的内容开始
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// window.addFlags(WindowManager.LayoutParams
// .FLAG_TRANSLUCENT_NAVIGATION);
window.addFlags(WindowManager.LayoutParams
.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(Color.TRANSPARENT);
window.setNavigationBarColor(Color.TRANSPARENT);
}
// window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN);
// 添加的内容结束
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
// Read 'StatusBarBackgroundColor' from config.xml, default is #000000.
@@ -230,12 +244,14 @@ public class StatusBar extends CordovaPlugin {
if (Build.VERSION.SDK_INT >= 21) {
final Window window = cordova.getActivity().getWindow();
if (transparent) {
// cordova.getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
window.setStatusBarColor(Color.TRANSPARENT);
}
else {
// cordova.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_VISIBLE);
@@ -250,13 +266,13 @@ public class StatusBar extends CordovaPlugin {
int uiOptions = decorView.getSystemUiVisibility();
String[] darkContentStyles = {
"default",
"default",
};
String[] lightContentStyles = {
"lightcontent",
"blacktranslucent",
"blackopaque",
"lightcontent",
"blacktranslucent",
"blackopaque",
};
if (Arrays.asList(darkContentStyles).contains(style.toLowerCase())) {

View File

@@ -92,7 +92,11 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
-(void)cordovaViewWillAppear:(NSNotification*)notification
{
[self resizeWebView];
//add a small delay ( 0.1 seconds ) or statusbar size will be wrong
__weak CDVStatusBar* weakSelf = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[weakSelf resizeWebView];
});
}
-(void)statusBarDidChangeFrame:(NSNotification*)notification

View File

@@ -1,141 +0,0 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using Microsoft.Phone.Shell;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Threading;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
/*
* http://www.idev101.com/code/User_Interface/StatusBar.html
* https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/Bars.html
* https://developer.apple.com/library/ios/documentation/uikit/reference/UIApplication_Class/Reference/Reference.html#//apple_ref/c/econst/UIStatusBarStyleDefault
* */
namespace WPCordovaClassLib.Cordova.Commands
{
public class StatusBar : BaseCommand
{
// returns an argb value, if the hex is only rgb, it will be full opacity
protected Color ColorFromHex(string hexString)
{
string cleanHex = hexString.Replace("#", "").Replace("0x", "");
// turn #FFF into #FFFFFF
if (cleanHex.Length == 3)
{
cleanHex = "" + cleanHex[0] + cleanHex[0] + cleanHex[1] + cleanHex[1] + cleanHex[2] + cleanHex[2];
}
// add an alpha 100% if it is missing
if (cleanHex.Length == 6)
{
cleanHex = "FF" + cleanHex;
}
int argb = Int32.Parse(cleanHex, NumberStyles.HexNumber);
Color clr = Color.FromArgb((byte)((argb & 0xff000000) >> 0x18),
(byte)((argb & 0xff0000) >> 0x10),
(byte)((argb & 0xff00) >> 8),
(byte)(argb & 0xff));
return clr;
}
public void _ready(string options)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
bool isVis = SystemTray.IsVisible;
// TODO: pass this to JS
//Debug.WriteLine("Result::" + res);
DispatchCommandResult(new PluginResult(PluginResult.Status.OK, isVis));
});
}
public void overlaysWebView(string options)
{ //exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
// string arg = JSON.JsonHelper.Deserialize<string[]>(options)[0];
}
public void styleDefault(string options)
{ //exec(null, null, "StatusBar", "styleDefault", []);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
SystemTray.ForegroundColor = Colors.Black;
});
}
public void styleLightContent(string options)
{ //exec(null, null, "StatusBar", "styleLightContent", []);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
SystemTray.ForegroundColor = Colors.White;
});
}
public void styleBlackTranslucent(string options)
{ //exec(null, null, "StatusBar", "styleBlackTranslucent", []);
styleLightContent(options);
}
public void styleBlackOpaque(string options)
{ //exec(null, null, "StatusBar", "styleBlackOpaque", []);
styleLightContent(options);
}
public void backgroundColorByName(string options)
{ //exec(null, null, "StatusBar", "backgroundColorByName", [colorname]);
// this should NOT be called, js should now be using/converting color names to hex
}
public void backgroundColorByHexString(string options)
{ //exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
string argb = JSON.JsonHelper.Deserialize<string[]>(options)[0];
Color clr = ColorFromHex(argb);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
SystemTray.Opacity = clr.A / 255.0d;
SystemTray.BackgroundColor = clr;
});
}
public void hide(string options)
{ //exec(null, null, "StatusBar", "hide", []);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
SystemTray.IsVisible = false;
});
}
public void show(string options)
{ //exec(null, null, "StatusBar", "show", []);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
SystemTray.IsVisible = true;
});
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-statusbar-tests",
"version": "2.4.3",
"version": "2.4.4-dev",
"description": "",
"cordova": {
"id": "cordova-plugin-statusbar-tests",

View File

@@ -22,7 +22,7 @@
xmlns:rim="http://www.blackberry.com/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-statusbar-tests"
version="2.4.3">
version="2.4.4-dev">
<name>Cordova StatusBar Plugin Tests</name>
<license>Apache 2.0</license>