Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix translucent navbar for Android 10 #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package com.stfalcon.imageviewer.viewer.dialog

import android.content.Context
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import com.stfalcon.imageviewer.R
Expand All @@ -39,6 +41,12 @@ internal class ImageViewerDialog<T>(
else
R.style.ImageViewerDialog_Default

private val dialogSystemUiVisibility: Int
get() = if (builderData.shouldStatusBarHide)
0
else
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

init {
setupViewerView()
dialog = AlertDialog
Expand All @@ -50,6 +58,7 @@ internal class ImageViewerDialog<T>(
setOnShowListener { viewerView.open(builderData.transitionView, animateOpen) }
setOnDismissListener { builderData.onDismissListener?.onDismiss() }
}
dialog.window?.decorView?.systemUiVisibility = dialogSystemUiVisibility
}

fun show(animate: Boolean) {
Expand Down
9 changes: 9 additions & 0 deletions imageviewer/src/main/res/values-v29/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="ImageViewerDialog.Default" parent="ImageViewerDialog.DefaultBaseTheme">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>

</resources>
5 changes: 4 additions & 1 deletion imageviewer/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

<style name="ImageViewerDialog.NoStatusBar" parent="android:Theme.Translucent.NoTitleBar.Fullscreen"/>

<style name="ImageViewerDialog.Default" parent="android:Theme.Translucent.NoTitleBar">
<style name="ImageViewerDialog.DefaultBaseTheme" parent="android:Theme.Translucent.NoTitleBar">
<item name="android:windowTranslucentStatus">true</item>
</style>

<style name="ImageViewerDialog.Default" parent="ImageViewerDialog.DefaultBaseTheme">
<item name="android:windowTranslucentNavigation">true</item>
</style>

Expand Down