From 73e551c0d3b1a7f37fa19595b5cdfd52358ae5c9 Mon Sep 17 00:00:00 2001 From: Kamal Date: Thu, 15 Aug 2019 11:28:55 +0700 Subject: [PATCH 1/3] Checking Navigation bar is exist on device --- .../blurdialogfragment/BlurDialogEngine.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java index ee77397..ae01a5d 100644 --- a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java +++ b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java @@ -5,6 +5,7 @@ import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; +import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; @@ -23,7 +24,10 @@ import android.util.Log; import android.util.TypedValue; import android.view.Gravity; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; import android.view.View; +import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.WindowManager; @@ -363,7 +367,13 @@ && isStatusBarTranslucent()) { // evaluate bottom or right offset due to navigation bar. int bottomOffset = 0; int rightOffset = 0; - final int navBarSize = getNavigationBarOffset(); + int navBarSize = 0; + + if (hasNavigationBar(mHoldingActivity)) { + navBarSize = getNavigationBarOffset(); + } else { + navBarSize = 0; + } if (mHoldingActivity.getResources().getBoolean(R.bool.blur_dialog_has_bottom_navigation_bar)) { bottomOffset = navBarSize; @@ -516,6 +526,23 @@ private int getNavigationBarOffset() { return result; } + /** + * Check the device has navigation bar + * @param context + * @return boolean has navigation bar + */ + boolean hasNavigationBar(Context context) { + Resources resources = context.getResources(); + int id = resources.getIdentifier("config_showNavigationBar", "bool", "android"); + if (id > 0) { + return resources.getBoolean(id); + } else { // Check for keys + boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey(); + boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); + return !hasMenuKey && !hasBackKey; + } + } + /** * Used to check if the status bar is translucent. * From bf0c2dcf9baa1f9f1c5a6b9cbd59f6b3c5d3ff83 Mon Sep 17 00:00:00 2001 From: Kamal Date: Tue, 27 Aug 2019 14:28:05 +0700 Subject: [PATCH 2/3] Add handler before addingContentView --- .../fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java index ae01a5d..c106958 100644 --- a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java +++ b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java @@ -633,7 +633,7 @@ protected void onPostExecute(Void aVoid) { mBackgroundView.destroyDrawingCache(); mBackgroundView.setDrawingCacheEnabled(false); - + removeBlurredView(); mHoldingActivity.getWindow().addContentView( mBlurredBackgroundView, mBlurredBackgroundLayoutParams From 25a7de63cbe28f2141b9217e57c81abd6f1086bd Mon Sep 17 00:00:00 2001 From: Kamal Date: Tue, 27 Aug 2019 16:52:48 +0700 Subject: [PATCH 3/3] Add handler to fix duplicate view --- .../lib/blurdialogfragment/BlurDialogEngine.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java index c106958..acbe34a 100644 --- a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java +++ b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java @@ -571,6 +571,18 @@ private void removeBlurredView() { } } + /** + * Removed the duplicated blurred view from the view hierarchy. + */ + private void removedDuplicateBlurredView() { + if (mBlurredBackgroundView != null) { + ViewGroup parent = (ViewGroup) mBlurredBackgroundView.getParent(); + if (parent != null) { + parent.removeView(mBlurredBackgroundView); + } + } + } + /** * Async task used to process blur out of ui thread */ @@ -633,7 +645,7 @@ protected void onPostExecute(Void aVoid) { mBackgroundView.destroyDrawingCache(); mBackgroundView.setDrawingCacheEnabled(false); - removeBlurredView(); + removedDuplicateBlurredView(); mHoldingActivity.getWindow().addContentView( mBlurredBackgroundView, mBlurredBackgroundLayoutParams