fix status bar transparent color

This commit is contained in:
Chumva 2018-08-23 15:03:59 +03:00
parent 945c71092f
commit cd1f6a58e5
7 changed files with 54 additions and 4 deletions

View file

@ -5,10 +5,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/card_bg_color">

View file

@ -25,7 +25,6 @@
<item name="primary_btn_bg">@drawable/primary_btn_bg_light</item>
<item name="primary_btn_text_color">@color/primary_btn_text_light</item>
<item name="secondary_btn_bg">@drawable/secondary_btn_bg_light</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="bottom_nav_shadow">@drawable/bg_bottom_bar_shadow_with_line_day</item>
@ -41,6 +40,11 @@
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="AppTheme.NoActionbar.Transparent">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="AppTheme.BottomSheet">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowBackground">@android:color/transparent</item>

View file

@ -118,9 +118,13 @@ class LoginDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar_Translucent)
val activity = requireActivity()
val window = activity.window
when {
Build.VERSION.SDK_INT >= 23 -> setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar_Transparent)
Build.VERSION.SDK_INT >= 19 -> setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar_Translucent)
else -> setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar)
}
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
}

View file

@ -75,6 +75,16 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
private var updateEnable: Boolean = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val activity = requireActivity()
if (Build.VERSION.SDK_INT >= 23) {
AndroidUtils.enterToTransparentFullScreen(activity)
} else if (Build.VERSION.SDK_INT >= 19) {
AndroidUtils.enterToTranslucentFullScreen(activity)
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,

View file

@ -1,6 +1,7 @@
package net.osmand.telegram.ui
import android.app.TimePickerDialog
import android.os.Build
import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.support.v4.app.Fragment
@ -51,7 +52,11 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar)
when {
Build.VERSION.SDK_INT >= 23 -> setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar_Transparent)
Build.VERSION.SDK_INT >= 19 -> setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar_Translucent)
else -> setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar)
}
}
override fun onCreateView(

View file

@ -1,5 +1,6 @@
package net.osmand.telegram.ui
import android.os.Build
import android.os.Bundle
import android.support.annotation.DrawableRes
import android.support.annotation.StringRes
@ -35,6 +36,11 @@ class SettingsDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(android.support.v4.app.DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar)
when {
Build.VERSION.SDK_INT >= 23 -> setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar_Transparent)
Build.VERSION.SDK_INT >= 19 -> setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar_Translucent)
else -> setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar)
}
}
override fun onCreateView(
@ -44,6 +50,9 @@ class SettingsDialogFragment : DialogFragment() {
): View {
val mainView = inflater.inflate(R.layout.fragement_settings_dialog, parent)
val appBarLayout = mainView.findViewById<View>(R.id.app_bar_layout)
AndroidUtils.addStatusBarPadding19v(context!!, appBarLayout)
mainView.findViewById<Toolbar>(R.id.toolbar).apply {
navigationIcon = uiUtils.getThemedIcon(R.drawable.ic_arrow_back)
setNavigationOnClickListener { dismiss() }

View file

@ -6,6 +6,7 @@ import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.graphics.Color
import android.graphics.Paint
import android.net.Uri
import android.os.Build
@ -16,6 +17,7 @@ import android.support.v4.content.FileProvider
import android.util.TypedValue
import android.util.TypedValue.COMPLEX_UNIT_DIP
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import net.osmand.telegram.R
import java.io.File
@ -85,6 +87,22 @@ object AndroidUtils {
}
}
fun enterToTransparentFullScreen(activity: Activity) {
if (Build.VERSION.SDK_INT >= 23) {
val window = activity.window
window.statusBarColor = Color.TRANSPARENT
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
}
}
fun enterToTranslucentFullScreen(activity: Activity) {
if (Build.VERSION.SDK_INT >= 19) {
activity.window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
}
}
fun getPopupMenuWidth(ctx: Context, titles: Collection<String>): Int {
val txtSize = ctx.resources.getDimensionPixelSize(R.dimen.list_item_title_text_size)
val paint = Paint().apply { textSize = txtSize.toFloat() }