mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2025-02-26 12:52:50 +08:00
Created statusbar version of plugin for Android
This commit is contained in:
parent
c94025e4dc
commit
9509848776
15
plugin.xml
15
plugin.xml
@ -14,12 +14,23 @@
|
|||||||
<engine name="cordova" version=">=3.0.0" />
|
<engine name="cordova" version=">=3.0.0" />
|
||||||
</engines>
|
</engines>
|
||||||
|
|
||||||
<!-- ios -->
|
|
||||||
<platform name="ios">
|
|
||||||
<js-module src="www/statusbar.js" name="statusbar">
|
<js-module src="www/statusbar.js" name="statusbar">
|
||||||
<clobbers target="window.StatusBar" />
|
<clobbers target="window.StatusBar" />
|
||||||
</js-module>
|
</js-module>
|
||||||
|
|
||||||
|
<platform name="android">
|
||||||
|
<source-file src="src/android/StatusBar.java" target-dir="src/org/apache/cordova/statusbar" />
|
||||||
|
|
||||||
|
<config-file target="res/xml/config.xml" parent="/*">
|
||||||
|
<feature name="StatusBar">
|
||||||
|
<param name="android-package" value="org.apache.cordova.statusbar.StatusBar" onload="true" />
|
||||||
|
</feature>
|
||||||
|
</config-file>
|
||||||
|
</platform>
|
||||||
|
|
||||||
|
<!-- ios -->
|
||||||
|
<platform name="ios">
|
||||||
|
|
||||||
<config-file target="config.xml" parent="/*">
|
<config-file target="config.xml" parent="/*">
|
||||||
<feature name="StatusBar">
|
<feature name="StatusBar">
|
||||||
<param name="ios-package" value="CDVStatusBar" onload="true" />
|
<param name="ios-package" value="CDVStatusBar" onload="true" />
|
||||||
|
90
src/android/StatusBar.java
Normal file
90
src/android/StatusBar.java
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.apache.cordova.statusbar;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import org.apache.cordova.CallbackContext;
|
||||||
|
import org.apache.cordova.CordovaArgs;
|
||||||
|
import org.apache.cordova.CordovaInterface;
|
||||||
|
import org.apache.cordova.CordovaPlugin;
|
||||||
|
import org.apache.cordova.CordovaWebView;
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
|
public class StatusBar extends CordovaPlugin {
|
||||||
|
private static final String TAG = "StatusBar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the context of the Command. This can then be used to do things like
|
||||||
|
* get file paths associated with the Activity.
|
||||||
|
*
|
||||||
|
* @param cordova The context of the main Activity.
|
||||||
|
* @param webView The CordovaWebView Cordova is running in.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||||
|
Log.v(TAG, "StatusBar: initialization");
|
||||||
|
super.initialize(cordova, webView);
|
||||||
|
|
||||||
|
// Clear flag FLAG_FORCE_NOT_FULLSCREEN which is set initially
|
||||||
|
// by the Cordova.
|
||||||
|
Window window = this.cordova.getActivity().getWindow();
|
||||||
|
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the request and returns PluginResult.
|
||||||
|
*
|
||||||
|
* @param action The action to execute.
|
||||||
|
* @param args JSONArry of arguments for the plugin.
|
||||||
|
* @param callbackContext The callback id used when calling back into JavaScript.
|
||||||
|
* @return True if the action was valid, false otherwise.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
|
||||||
|
Log.v(TAG, "Executing action: " + action);
|
||||||
|
final Activity activity = this.cordova.getActivity();
|
||||||
|
final Window window = activity.getWindow();
|
||||||
|
if ("show".equals(action)) {
|
||||||
|
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("hide".equals(action)) {
|
||||||
|
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user