Skip to content

Commit cac3c4a

Browse files
authored
Android: Change Status Bar Color with Navbar Color
1 parent 887f72f commit cac3c4a

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/android/InAppBrowser.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,20 @@ public void run() {
828828
dialog.setCancelable(true);
829829
dialog.setInAppBroswer(getInAppBrowser());
830830

831+
dialog.getWindow().clearFlags(0x04000000); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
832+
dialog.getWindow().addFlags(0x80000000); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
833+
834+
View decorView = dialog.getWindow().getDecorView();
835+
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
836+
837+
try {
838+
// Using reflection makes sure any 5.0+ device will work without having to compile with SDK level 21
839+
dialog.getWindow().getClass().getMethod("setStatusBarColor", int.class)
840+
.invoke(dialog.getWindow(), toolbarColor);
841+
} catch (Exception e) {
842+
e.printStackTrace();
843+
}
844+
831845
// Main container layout
832846
LinearLayout main = new LinearLayout(cordova.getActivity());
833847
main.setOrientation(LinearLayout.VERTICAL);
@@ -931,7 +945,7 @@ public void onClick(View v) {
931945
edittext.setTextSize(17);
932946
edittext.setTextColor(android.graphics.Color.argb(150, 255,255,255));
933947
edittext.setBackgroundColor(android.graphics.Color.argb(0,0,0,0));
934-
edittext.setPadding(10, this.dpToPixels(10), 10, this.dpToPixels(10));
948+
edittext.setPadding(20, this.dpToPixels(10), 20, this.dpToPixels(10));
935949
edittext.setOnKeyListener(new View.OnKeyListener() {
936950
public boolean onKey(View v, int keyCode, KeyEvent event) {
937951
// If the event is a key-down event on the "enter" button
@@ -982,17 +996,17 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
982996
int closeButtonId = 1;
983997
ImageButton closeButton = createImageButton(closeButtonId, "ic_action_remove_white");
984998
closeButton.setContentDescription("Close Button");
985-
closeButton.setPadding(15, this.dpToPixels(10), 15, this.dpToPixels(10));
999+
closeButton.setPadding(20, this.dpToPixels(10), 20, this.dpToPixels(10));
9861000
closeButton.setOnClickListener(new View.OnClickListener(){
9871001
public void onClick(View v){
9881002
closeDialog();
9891003
}
9901004
});
9911005

9921006
// Share button
993-
int shareButtonId=8;
1007+
int shareButtonId = 8;
9941008
ImageButton shareButton = createImageButton(shareButtonId, "ic_action_share");
995-
shareButton.setPadding(15, this.dpToPixels(10), 15, this.dpToPixels(10));
1009+
shareButton.setPadding(20, this.dpToPixels(10), 20, this.dpToPixels(10));
9961010
shareButton.setContentDescription("Share Button");
9971011
shareButton.setOnClickListener(new View.OnClickListener() {
9981012
public void onClick(View v) {
@@ -1615,4 +1629,3 @@ public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, Str
16151629
}
16161630
}
16171631
}
1618-

0 commit comments

Comments
 (0)