Merge pull request #5929 from osmandapp/TelegramUiImprovements
Fix status bar transparent color
This commit is contained in:
commit
64131d0b16
8 changed files with 63 additions and 34 deletions
|
@ -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">
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package net.osmand.telegram.ui
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.DialogFragment
|
||||
import net.osmand.telegram.R
|
||||
import net.osmand.telegram.TelegramApplication
|
||||
|
||||
open class BaseDialogFragment : DialogFragment() {
|
||||
|
||||
val app: TelegramApplication
|
||||
get() = activity?.application as TelegramApplication
|
||||
|
||||
val telegramHelper get() = app.telegramHelper
|
||||
val settings get() = app.settings
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import android.graphics.Rect
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.annotation.StringRes
|
||||
import android.support.v4.app.DialogFragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v7.widget.AppCompatImageView
|
||||
|
@ -30,7 +29,7 @@ import net.osmand.telegram.utils.AndroidUtils
|
|||
import studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
|
||||
|
||||
class LoginDialogFragment : DialogFragment() {
|
||||
class LoginDialogFragment : BaseDialogFragment() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@ -118,10 +117,7 @@ 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
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
|
||||
requireActivity().window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.telegram.ui
|
|||
|
||||
import android.app.Dialog
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.BottomNavigationView
|
||||
import android.support.v4.app.DialogFragment
|
||||
|
@ -58,6 +59,12 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
AndroidUtils.enterToTransparentFullScreen(this)
|
||||
} else if (Build.VERSION.SDK_INT >= 19) {
|
||||
AndroidUtils.enterToTranslucentFullScreen(this)
|
||||
}
|
||||
|
||||
paused = false
|
||||
|
||||
val viewPager = findViewById<LockableViewPager>(R.id.view_pager).apply {
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.telegram.ui
|
|||
|
||||
import android.app.TimePickerDialog
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.DialogFragment
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
|
@ -15,7 +14,6 @@ import android.widget.TextView
|
|||
import net.osmand.Location
|
||||
import net.osmand.data.LatLon
|
||||
import net.osmand.telegram.R
|
||||
import net.osmand.telegram.TelegramApplication
|
||||
import net.osmand.telegram.TelegramLocationProvider.TelegramLocationListener
|
||||
import net.osmand.telegram.TelegramLocationProvider.TelegramCompassListener
|
||||
import net.osmand.telegram.helpers.ShareLocationHelper
|
||||
|
@ -29,13 +27,7 @@ import org.drinkless.td.libcore.telegram.TdApi
|
|||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, TelegramCompassListener {
|
||||
|
||||
private val app: TelegramApplication
|
||||
get() = activity?.application as TelegramApplication
|
||||
|
||||
private val telegramHelper get() = app.telegramHelper
|
||||
private val settings get() = app.settings
|
||||
class SetTimeDialogFragment : BaseDialogFragment(), TelegramLocationListener, TelegramCompassListener {
|
||||
|
||||
private lateinit var locationViewCache: UiUtils.UpdateLocationViewCache
|
||||
private val adapter = SetTimeListAdapter()
|
||||
|
@ -48,11 +40,6 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr
|
|||
private var location: Location? = null
|
||||
private var heading: Float? = null
|
||||
private var locationUiUpdateAllowed: Boolean = true
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.telegram.ui
|
|||
import android.os.Bundle
|
||||
import android.support.annotation.DrawableRes
|
||||
import android.support.annotation.StringRes
|
||||
import android.support.v4.app.DialogFragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.widget.ListPopupWindow
|
||||
import android.support.v7.widget.Toolbar
|
||||
|
@ -21,22 +20,12 @@ import net.osmand.telegram.helpers.TelegramUiHelper
|
|||
import net.osmand.telegram.utils.AndroidUtils
|
||||
import net.osmand.telegram.utils.OsmandFormatter
|
||||
|
||||
class SettingsDialogFragment : DialogFragment() {
|
||||
|
||||
private val app: TelegramApplication
|
||||
get() = activity?.application as TelegramApplication
|
||||
class SettingsDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private val uiUtils get() = app.uiUtils
|
||||
private val telegramHelper get() = app.telegramHelper
|
||||
private val settings get() = app.settings
|
||||
|
||||
private val gpsAndLocPrefs = listOf(SendMyLocPref(), StaleLocPref(), LocHistoryPref())
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(android.support.v4.app.DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
parent: ViewGroup?,
|
||||
|
@ -44,6 +33,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() }
|
||||
|
|
|
@ -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() }
|
||||
|
|
Loading…
Reference in a new issue