diff options
author | Roman Romanov <rromanov@65gb.net> | 2016-11-07 12:08:34 +0300 |
---|---|---|
committer | Roman Romanov <rromanov@65gb.net> | 2016-11-07 12:08:34 +0300 |
commit | 120bb3b6a0ab138d6ca3fa752a975991ec0e9cb2 (patch) | |
tree | 59cf486e981d9f158a4d45737a5258f3aba08bf3 /android | |
parent | 8187ba70d7398abe6806dd7a8bf090d088a7ca0b (diff) |
[android] added custom statusbar view.
Diffstat (limited to 'android')
-rw-r--r-- | android/res/values/themes-base.xml | 2 | ||||
-rw-r--r-- | android/res/values/themes.xml | 2 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java | 4 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/settings/SettingsActivity.java | 2 | ||||
-rw-r--r-- | android/src/com/mapswithme/util/UiUtils.java | 25 |
5 files changed, 33 insertions, 2 deletions
diff --git a/android/res/values/themes-base.xml b/android/res/values/themes-base.xml index e282fef1b3..e076f73959 100644 --- a/android/res/values/themes-base.xml +++ b/android/res/values/themes-base.xml @@ -14,6 +14,7 @@ <item name="android:fontFamily" tools:targetApi="jelly_bean">@string/robotoRegular</item> <item name="android:colorBackgroundCacheHint">@null</item> <item name="clickableBackground">?selectableItemBackground</item> + <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item> <item name="alertDialogTheme">@style/MwmTheme.DialogFragment</item> <item name="windowBackgroundForced">@color/bg_window</item> @@ -97,6 +98,7 @@ <item name="android:fontFamily" tools:targetApi="jelly_bean">@string/robotoRegular</item> <item name="android:colorBackgroundCacheHint">@null</item> <item name="clickableBackground">?selectableItemBackground</item> + <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item> <item name="alertDialogTheme">@style/MwmTheme.Night.DialogFragment</item> <item name="windowBackgroundForced">@color/bg_window_night</item> diff --git a/android/res/values/themes.xml b/android/res/values/themes.xml index 73a39873f8..0616d4e1d7 100644 --- a/android/res/values/themes.xml +++ b/android/res/values/themes.xml @@ -68,6 +68,7 @@ <item name="android:colorBackgroundCacheHint">@null</item> <item name="android:fontFamily" tools:targetApi="jelly_bean">@string/robotoRegular</item> <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item> + <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item> </style> <style name="MwmTheme.DialogFragment.Fullscreen.Night" parent="Theme.AppCompat"> @@ -82,6 +83,7 @@ <item name="android:colorBackgroundCacheHint">@null</item> <item name="android:fontFamily" tools:targetApi="jelly_bean">@string/robotoRegular</item> <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item> + <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item> </style> <style name="MwmTheme.DialogFragment.Fullscreen.Translucent"> diff --git a/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java b/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java index e160d7de46..84a2922e47 100644 --- a/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java +++ b/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java @@ -16,6 +16,7 @@ import android.view.WindowManager; import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.R; import com.mapswithme.util.ThemeUtils; +import com.mapswithme.util.UiUtils; import com.mapswithme.util.Utils; public class BaseMwmFragmentActivity extends AppCompatActivity @@ -50,8 +51,7 @@ public class BaseMwmFragmentActivity extends AppCompatActivity mBaseDelegate.onCreate(); super.onCreate(savedInstanceState); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) - getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + UiUtils.setupStatusBar(this); setVolumeControlStream(AudioManager.STREAM_MUSIC); final int layoutId = getContentLayoutResId(); if (layoutId != 0) diff --git a/android/src/com/mapswithme/maps/settings/SettingsActivity.java b/android/src/com/mapswithme/maps/settings/SettingsActivity.java index b34d93ad8b..08705f5fc1 100644 --- a/android/src/com/mapswithme/maps/settings/SettingsActivity.java +++ b/android/src/com/mapswithme/maps/settings/SettingsActivity.java @@ -128,12 +128,14 @@ public class SettingsActivity extends PreferenceActivity getAppDelegate().onCreate(savedInstanceState); super.onCreate(savedInstanceState); + UiUtils.setupStatusBar(this); setVolumeControlStream(AudioManager.STREAM_MUSIC); // Hack to attach Toolbar and make it work on native PreferenceActivity ViewGroup root = (ViewGroup)findViewById(android.R.id.list).getParent().getParent().getParent(); View toolbarHolder = LayoutInflater.from(this).inflate(R.layout.toolbar_default, root, false); Toolbar toolbar = (Toolbar) toolbarHolder.findViewById(R.id.toolbar); + UiUtils.extendViewWithStatusBar(toolbar); UiUtils.showHomeUpButton(toolbar); // First, add toolbar view to UI. diff --git a/android/src/com/mapswithme/util/UiUtils.java b/android/src/com/mapswithme/util/UiUtils.java index 12d3dd5242..4f051f09f0 100644 --- a/android/src/com/mapswithme/util/UiUtils.java +++ b/android/src/com/mapswithme/util/UiUtils.java @@ -7,6 +7,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Color; import android.graphics.Rect; import android.net.Uri; import android.os.Build; @@ -20,14 +21,17 @@ import android.support.design.widget.TextInputLayout; import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; import android.text.TextUtils; +import android.view.Gravity; import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; +import android.view.WindowManager; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.widget.Button; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; @@ -36,6 +40,7 @@ import com.mapswithme.maps.R; public final class UiUtils { + private static final int DEFAULT_TINT_COLOR = Color.parseColor("#20000000"); private static float sScreenDensity; public static class SimpleAnimationListener implements AnimationListener @@ -410,6 +415,26 @@ public final class UiUtils view.setLayoutParams(lp); } + public static void setupStatusBar(@NonNull Activity activity) + { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) + return; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + activity.getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + else + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + View statusBarTintView = new View(activity); + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity)); + params.gravity = Gravity.TOP; + statusBarTintView.setLayoutParams(params); + statusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR); + statusBarTintView.setVisibility(View.VISIBLE); + ViewGroup decorViewGroup = (ViewGroup) activity.getWindow().getDecorView(); + decorViewGroup.addView(statusBarTintView); + } + // utility class private UiUtils() {} } |