diff --git a/imageviewer/src/main/java/com/stfalcon/imageviewer/StfalconImageViewer.java b/imageviewer/src/main/java/com/stfalcon/imageviewer/StfalconImageViewer.java index 61d8179a..3be8c4cc 100644 --- a/imageviewer/src/main/java/com/stfalcon/imageviewer/StfalconImageViewer.java +++ b/imageviewer/src/main/java/com/stfalcon/imageviewer/StfalconImageViewer.java @@ -17,6 +17,7 @@ package com.stfalcon.imageviewer; import android.content.Context; +import android.os.*; import android.util.Log; import android.view.View; import android.widget.ImageView; @@ -248,6 +249,28 @@ public Builder withHiddenStatusBar(boolean value) { return this; } + /** + * Sets alert dialog style. ImageViewerDialog.Default by default. + * + * @return This Builder object to allow calls chaining + */ + public Builder withDialogStyle(int value) { + this.data.setDialogStyle(value); + return this; + } + + /** + * Sets status bar transparency to allow drawing underneath it. False by default. + * Works only on API 21 and above. + * + * @return This Builder object to allow calls chaining + */ + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + public Builder shouldStatusBarTransparent(boolean value) { + this.data.setShouldStatusBarTransparent(value); + return this; + } + /** * Enables or disables zooming. True by default. * diff --git a/imageviewer/src/main/java/com/stfalcon/imageviewer/viewer/builder/BuilderData.kt b/imageviewer/src/main/java/com/stfalcon/imageviewer/viewer/builder/BuilderData.kt index 7153a95a..c9500200 100644 --- a/imageviewer/src/main/java/com/stfalcon/imageviewer/viewer/builder/BuilderData.kt +++ b/imageviewer/src/main/java/com/stfalcon/imageviewer/viewer/builder/BuilderData.kt @@ -19,6 +19,7 @@ package com.stfalcon.imageviewer.viewer.builder import android.graphics.Color import android.view.View import android.widget.ImageView +import com.stfalcon.imageviewer.R import com.stfalcon.imageviewer.listeners.OnDismissListener import com.stfalcon.imageviewer.listeners.OnImageChangeListener import com.stfalcon.imageviewer.loader.ImageLoader @@ -35,7 +36,9 @@ internal class BuilderData( var imageMarginPixels: Int = 0 var containerPaddingPixels = IntArray(4) var shouldStatusBarHide = true + var shouldStatusBarTransparent = false var isZoomingAllowed = true var isSwipeToDismissAllowed = true var transitionView: ImageView? = null -} \ No newline at end of file + var dialogStyle: Int = R.style.ImageViewerDialog_Default +} diff --git a/imageviewer/src/main/java/com/stfalcon/imageviewer/viewer/dialog/ImageViewerDialog.kt b/imageviewer/src/main/java/com/stfalcon/imageviewer/viewer/dialog/ImageViewerDialog.kt index bfb14f57..e2648285 100644 --- a/imageviewer/src/main/java/com/stfalcon/imageviewer/viewer/dialog/ImageViewerDialog.kt +++ b/imageviewer/src/main/java/com/stfalcon/imageviewer/viewer/dialog/ImageViewerDialog.kt @@ -17,7 +17,9 @@ package com.stfalcon.imageviewer.viewer.dialog import android.content.Context +import android.os.Build import android.view.KeyEvent +import android.view.WindowManager import android.widget.ImageView import androidx.appcompat.app.AlertDialog import com.stfalcon.imageviewer.R @@ -37,7 +39,7 @@ internal class ImageViewerDialog( get() = if (builderData.shouldStatusBarHide) R.style.ImageViewerDialog_NoStatusBar else - R.style.ImageViewerDialog_Default + builderData.dialogStyle init { setupViewerView() @@ -50,6 +52,11 @@ internal class ImageViewerDialog( setOnShowListener { viewerView.open(builderData.transitionView, animateOpen) } setOnDismissListener { builderData.onDismissListener?.onDismiss() } } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (builderData.shouldStatusBarTransparent) { + dialog.window?.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) + } + } } fun show(animate: Boolean) {