mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2025-02-22 02:29:33 +08:00
refactor!: remove deprecated methods (#229)
This commit is contained in:
parent
49b94aed6a
commit
fbe33eb327
39
README.md
39
README.md
@ -55,7 +55,7 @@ Preferences
|
||||
|
||||
<preference name="StatusBarBackgroundColor" value="#000000" />
|
||||
|
||||
- __StatusBarStyle__ (status bar style, defaults to lightcontent). Set the status bar style (e.g. text color). Available options: `default`, `lightcontent`. `blacktranslucent` and `blackopaque` are also available, but __deprecated__, will be removed in next major release, use `lightcontent` instead.
|
||||
- __StatusBarStyle__ (status bar style, defaults to lightcontent). Set the status bar style (e.g. text color). Available options: `default`, `lightcontent`.
|
||||
|
||||
<preference name="StatusBarStyle" value="lightcontent" />
|
||||
|
||||
@ -118,8 +118,6 @@ Although in the global scope, it is not available until after the `deviceready`
|
||||
- StatusBar.overlaysWebView
|
||||
- StatusBar.styleDefault
|
||||
- StatusBar.styleLightContent
|
||||
- StatusBar.styleBlackTranslucent
|
||||
- StatusBar.styleBlackOpaque
|
||||
- StatusBar.backgroundColorByName
|
||||
- StatusBar.backgroundColorByHexString
|
||||
- StatusBar.hide
|
||||
@ -190,41 +188,6 @@ Supported Platforms
|
||||
- Android 6+
|
||||
- Windows
|
||||
|
||||
StatusBar.styleBlackTranslucent
|
||||
=================
|
||||
|
||||
Note: `styleBlackTranslucent` is __deprecated__ and will be removed in next major release, use `styleLightContent` instead.
|
||||
|
||||
Use the blackTranslucent statusbar (light text, for dark backgrounds).
|
||||
|
||||
StatusBar.styleBlackTranslucent();
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows
|
||||
|
||||
StatusBar.styleBlackOpaque
|
||||
=================
|
||||
|
||||
Note: `styleBlackOpaque` is __deprecated__ and will be removed in next major release, use `styleLightContent` instead.
|
||||
|
||||
Use the blackOpaque statusbar (light text, for dark backgrounds).
|
||||
|
||||
StatusBar.styleBlackOpaque();
|
||||
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- iOS
|
||||
- Android 6+
|
||||
- Windows
|
||||
|
||||
|
||||
StatusBar.backgroundColorByName
|
||||
=================
|
||||
|
||||
|
@ -70,9 +70,6 @@ public class StatusBar extends CordovaPlugin {
|
||||
|
||||
// Read 'StatusBarStyle' from config.xml, default is 'lightcontent'.
|
||||
String styleSetting = preferences.getString("StatusBarStyle", "lightcontent");
|
||||
if (styleSetting.equalsIgnoreCase("blacktranslucent") || styleSetting.equalsIgnoreCase("blackopaque")) {
|
||||
LOG.w(TAG, styleSetting +" is deprecated and will be removed in next major release, use lightcontent");
|
||||
}
|
||||
setStatusBarStyle(styleSetting);
|
||||
}
|
||||
});
|
||||
@ -193,26 +190,6 @@ public class StatusBar extends CordovaPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("styleBlackTranslucent".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setStatusBarStyle("blacktranslucent");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("styleBlackOpaque".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setStatusBarStyle("blackopaque");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -266,8 +243,6 @@ public class StatusBar extends CordovaPlugin {
|
||||
|
||||
String[] lightContentStyles = {
|
||||
"lightcontent",
|
||||
"blacktranslucent",
|
||||
"blackopaque",
|
||||
};
|
||||
|
||||
if (Arrays.asList(darkContentStyles).contains(style.toLowerCase())) {
|
||||
@ -280,7 +255,7 @@ public class StatusBar extends CordovaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG.e(TAG, "Invalid style, must be either 'default', 'lightcontent' or the deprecated 'blacktranslucent' and 'blackopaque'");
|
||||
LOG.e(TAG, "Invalid style, must be either 'default' or 'lightcontent'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,8 @@ function notSupported (win, fail) {
|
||||
|
||||
module.exports = {
|
||||
isVisible: false,
|
||||
styleBlackTranslucent: notSupported,
|
||||
styleDefault: notSupported,
|
||||
styleLightContent: notSupported,
|
||||
styleBlackOpaque: notSupported,
|
||||
overlaysWebView: notSupported,
|
||||
backgroundColorByName: notSupported,
|
||||
backgroundColorByHexString: notSupported,
|
||||
|
@ -36,8 +36,6 @@
|
||||
|
||||
- (void) styleDefault:(CDVInvokedUrlCommand*)command;
|
||||
- (void) styleLightContent:(CDVInvokedUrlCommand*)command;
|
||||
- (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command;
|
||||
- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
- (void) backgroundColorByName:(CDVInvokedUrlCommand*)command;
|
||||
- (void) backgroundColorByHexString:(CDVInvokedUrlCommand*)command;
|
||||
|
@ -138,9 +138,6 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
setting = @"StatusBarStyle";
|
||||
if ([self settingForKey:setting]) {
|
||||
NSString * styleSetting = [self settingForKey:setting];
|
||||
if ([styleSetting isEqualToString:@"blacktranslucent"] || [styleSetting isEqualToString:@"blackopaque"]) {
|
||||
NSLog(@"%@ is deprecated and will be removed in next major release, use lightcontent", styleSetting);
|
||||
}
|
||||
[self setStatusBarStyle:styleSetting];
|
||||
}
|
||||
|
||||
@ -282,17 +279,13 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
|
||||
- (void) setStatusBarStyle:(NSString*)statusBarStyle
|
||||
{
|
||||
// default, lightContent, blackTranslucent, blackOpaque
|
||||
// default, lightContent
|
||||
NSString* lcStatusBarStyle = [statusBarStyle lowercaseString];
|
||||
|
||||
if ([lcStatusBarStyle isEqualToString:@"default"]) {
|
||||
[self styleDefault:nil];
|
||||
} else if ([lcStatusBarStyle isEqualToString:@"lightcontent"]) {
|
||||
[self styleLightContent:nil];
|
||||
} else if ([lcStatusBarStyle isEqualToString:@"blacktranslucent"]) {
|
||||
[self styleBlackTranslucent:nil];
|
||||
} else if ([lcStatusBarStyle isEqualToString:@"blackopaque"]) {
|
||||
[self styleBlackOpaque:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,16 +304,6 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
||||
[self setStyleForStatusBar:UIStatusBarStyleLightContent];
|
||||
}
|
||||
|
||||
- (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
[self setStyleForStatusBar:UIStatusBarStyleLightContent];
|
||||
}
|
||||
|
||||
- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
[self setStyleForStatusBar:UIStatusBarStyleLightContent];
|
||||
}
|
||||
|
||||
- (void) backgroundColorByName:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
id value = [command argumentAtIndex:0];
|
||||
|
@ -80,16 +80,6 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
styleBlackTranslucent: function () {
|
||||
// #88000000 ? Apple says to use lightContent instead
|
||||
return module.exports.styleLightContent();
|
||||
},
|
||||
|
||||
styleBlackOpaque: function () {
|
||||
// #FF000000 ? Apple says to use lightContent instead
|
||||
return module.exports.styleLightContent();
|
||||
},
|
||||
|
||||
backgroundColorByHexString: function (win, fail, args) {
|
||||
var rgb = hexToRgb(args[0]);
|
||||
if (isSupported()) {
|
||||
|
@ -44,18 +44,12 @@ exports.defineAutoTests = function () {
|
||||
});
|
||||
|
||||
it('statusbar.spec.4 should have set style methods', function () {
|
||||
expect(window.StatusBar.styleBlackTranslucent).toBeDefined();
|
||||
expect(typeof window.StatusBar.styleBlackTranslucent).toBe('function');
|
||||
|
||||
expect(window.StatusBar.styleDefault).toBeDefined();
|
||||
expect(typeof window.StatusBar.styleDefault).toBe('function');
|
||||
|
||||
expect(window.StatusBar.styleLightContent).toBeDefined();
|
||||
expect(typeof window.StatusBar.styleLightContent).toBe('function');
|
||||
|
||||
expect(window.StatusBar.styleBlackOpaque).toBeDefined();
|
||||
expect(typeof window.StatusBar.styleBlackOpaque).toBe('function');
|
||||
|
||||
expect(window.StatusBar.overlaysWebView).toBeDefined();
|
||||
expect(typeof window.StatusBar.overlaysWebView).toBe('function');
|
||||
});
|
||||
@ -85,11 +79,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
StatusBar.backgroundColorByName('red');
|
||||
}
|
||||
|
||||
function doColor2 () {
|
||||
log('set style=translucent black');
|
||||
StatusBar.styleBlackTranslucent();
|
||||
}
|
||||
|
||||
function doColor3 () {
|
||||
log('set style=default');
|
||||
StatusBar.styleDefault();
|
||||
@ -153,14 +142,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'action-color1'
|
||||
);
|
||||
|
||||
createActionButton(
|
||||
'Style=translucent black',
|
||||
function () {
|
||||
doColor2();
|
||||
},
|
||||
'action-color2'
|
||||
);
|
||||
|
||||
createActionButton(
|
||||
'Style=default',
|
||||
function () {
|
||||
|
10
types/index.d.ts
vendored
10
types/index.d.ts
vendored
@ -34,16 +34,6 @@ interface StatusBar {
|
||||
*/
|
||||
styleLightContent(): void;
|
||||
|
||||
/**
|
||||
* Use the blackTranslucent statusbar (light text, for dark backgrounds).
|
||||
*/
|
||||
styleBlackTranslucent(): void;
|
||||
|
||||
/**
|
||||
* Use the blackOpaque statusbar (light text, for dark backgrounds).
|
||||
*/
|
||||
styleBlackOpaque(): void;
|
||||
|
||||
/**
|
||||
* On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false,
|
||||
* you can set the background color of the statusbar by color name.
|
||||
|
@ -57,16 +57,6 @@ var StatusBar = {
|
||||
exec(null, null, 'StatusBar', 'styleLightContent', []);
|
||||
},
|
||||
|
||||
styleBlackTranslucent: function () {
|
||||
console.warn('styleBlackTranslucent is deprecated and will be removed in next major release, use styleLightContent');
|
||||
exec(null, null, 'StatusBar', 'styleBlackTranslucent', []);
|
||||
},
|
||||
|
||||
styleBlackOpaque: function () {
|
||||
console.warn('styleBlackOpaque is deprecated and will be removed in next major release, use styleLightContent');
|
||||
exec(null, null, 'StatusBar', 'styleBlackOpaque', []);
|
||||
},
|
||||
|
||||
backgroundColorByName: function (colorname) {
|
||||
return StatusBar.backgroundColorByHexString(namedColors[colorname]);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user