Change status bar color

This commit is contained in:
PavelRatushny 2017-10-30 10:41:28 +02:00
parent ef4a371eb9
commit 4cc7757bba
2 changed files with 16 additions and 1 deletions

View file

@ -269,4 +269,6 @@
<color name="keyboard_text_color_dark">#ffffff</color> <color name="keyboard_text_color_dark">#ffffff</color>
<color name="coordinate_input_status_bar_color">#4257c9</color>
</resources> </resources>

View file

@ -4,11 +4,13 @@ import android.app.Dialog;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.TextViewCompat; import android.support.v4.widget.TextViewCompat;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
@ -24,6 +26,8 @@ import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.EditText; import android.widget.EditText;
@ -117,13 +121,22 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
return new Dialog(getContext(), getTheme()) { Dialog dialog = new Dialog(getContext(), getTheme()) {
@Override @Override
public void onBackPressed() { public void onBackPressed() {
saveMarkers(); saveMarkers();
super.onBackPressed(); super.onBackPressed();
} }
}; };
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = dialog.getWindow();
if (window != null) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(getContext(), R.color.coordinate_input_status_bar_color));
}
}
return dialog;
} }
@Nullable @Nullable