diff --git a/app/src/main/java/com/simplified/wsstatussaver/activities/StatusesActivity.kt b/app/src/main/java/com/simplified/wsstatussaver/activities/StatusesActivity.kt index 0a3eee2..ee0305e 100644 --- a/app/src/main/java/com/simplified/wsstatussaver/activities/StatusesActivity.kt +++ b/app/src/main/java/com/simplified/wsstatussaver/activities/StatusesActivity.kt @@ -31,6 +31,7 @@ import com.simplified.wsstatussaver.R import com.simplified.wsstatussaver.WhatSaveViewModel import com.simplified.wsstatussaver.activities.base.BaseActivity import com.simplified.wsstatussaver.dialogs.UpdateDialog +import com.simplified.wsstatussaver.extensions.applyLandscapeInsetter import com.simplified.wsstatussaver.extensions.currentFragment import com.simplified.wsstatussaver.extensions.getBottomInsets import com.simplified.wsstatussaver.extensions.getPreferredClient @@ -58,6 +59,11 @@ class StatusesActivity : BaseActivity(), NavigationBarView.OnItemReselectedListe super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) contentView = findViewById(R.id.main_container) + contentView.applyLandscapeInsetter { + type(navigationBars = true, displayCutout = true) { + padding(horizontal = true) + } + } navigationView = findViewById(R.id.navigation_view) navigationView.setOnItemReselectedListener(this) if (navigationView is BottomNavigationView) { diff --git a/app/src/main/java/com/simplified/wsstatussaver/extensions/InsetsExt.kt b/app/src/main/java/com/simplified/wsstatussaver/extensions/InsetsExt.kt index 433efc7..4984cb3 100644 --- a/app/src/main/java/com/simplified/wsstatussaver/extensions/InsetsExt.kt +++ b/app/src/main/java/com/simplified/wsstatussaver/extensions/InsetsExt.kt @@ -17,6 +17,7 @@ import android.annotation.SuppressLint import android.view.View import androidx.core.view.WindowInsetsCompat import com.simplified.wsstatussaver.getApp +import dev.chrisbanes.insetter.InsetterDsl import dev.chrisbanes.insetter.applyInsetter @SuppressLint("DiscouragedApi", "InternalInsetResource") @@ -31,25 +32,14 @@ fun WindowInsetsCompat?.getBottomInsets(): Int { return bottomInsets ?: 0 } -/** - * This will draw our view above the navigation bar instead of behind it by adding margins. - */ -fun View.drawAboveSystemBars(onlyPortrait: Boolean = true) { - if (onlyPortrait && isLandscape()) return - applyInsetter { - type(navigationBars = true) { - margin() - } +fun View.applyPortraitInsetter(build: InsetterDsl.() -> Unit) { + if (!isLandscape()) { + applyInsetter(build) } } -/** - * This will draw our view above the navigation bar instead of behind it by adding padding. - */ -fun View.drawAboveSystemBarsWithPadding() { - applyInsetter { - type(navigationBars = true) { - padding() - } +fun View.applyLandscapeInsetter(build: InsetterDsl.() -> Unit) { + if (isLandscape()) { + applyInsetter(build) } } \ No newline at end of file diff --git a/app/src/main/java/com/simplified/wsstatussaver/fragments/SettingsFragment.kt b/app/src/main/java/com/simplified/wsstatussaver/fragments/SettingsFragment.kt index 98df100..eab1396 100644 --- a/app/src/main/java/com/simplified/wsstatussaver/fragments/SettingsFragment.kt +++ b/app/src/main/java/com/simplified/wsstatussaver/fragments/SettingsFragment.kt @@ -38,6 +38,7 @@ import com.simplified.wsstatussaver.extensions.PREFERENCE_QUICK_DELETION import com.simplified.wsstatussaver.extensions.PREFERENCE_STATUSES_LOCATION import com.simplified.wsstatussaver.extensions.PREFERENCE_THEME_MODE import com.simplified.wsstatussaver.extensions.PREFERENCE_USE_CUSTOM_FONT +import com.simplified.wsstatussaver.extensions.applyPortraitInsetter import com.simplified.wsstatussaver.extensions.findActivityNavController import com.simplified.wsstatussaver.extensions.getDefaultDayNightMode import com.simplified.wsstatussaver.extensions.isNightModeEnabled @@ -52,7 +53,6 @@ import com.simplified.wsstatussaver.preferences.SaveLocationPreferenceDialog import com.simplified.wsstatussaver.preferences.StoragePreference import com.simplified.wsstatussaver.preferences.StoragePreferenceDialog import com.simplified.wsstatussaver.setAnalyticsEnabled -import dev.chrisbanes.insetter.applyInsetter /** * @author Christians Martínez Alvarado (mardous) @@ -92,7 +92,7 @@ class SettingsFragment : BaseFragment(R.layout.fragment_settings) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - listView.applyInsetter { + listView.applyPortraitInsetter { type(navigationBars = true) { padding(vertical = true) } diff --git a/app/src/main/java/com/simplified/wsstatussaver/fragments/messageview/ConversationDetailFragment.kt b/app/src/main/java/com/simplified/wsstatussaver/fragments/messageview/ConversationDetailFragment.kt index 2378bcd..a9c5ba2 100644 --- a/app/src/main/java/com/simplified/wsstatussaver/fragments/messageview/ConversationDetailFragment.kt +++ b/app/src/main/java/com/simplified/wsstatussaver/fragments/messageview/ConversationDetailFragment.kt @@ -34,7 +34,7 @@ import com.simplified.wsstatussaver.adapter.MessageAdapter import com.simplified.wsstatussaver.database.Conversation import com.simplified.wsstatussaver.database.MessageEntity import com.simplified.wsstatussaver.databinding.FragmentMessagesBinding -import com.simplified.wsstatussaver.extensions.drawAboveSystemBarsWithPadding +import com.simplified.wsstatussaver.extensions.applyPortraitInsetter import com.simplified.wsstatussaver.extensions.startActivitySafe import com.simplified.wsstatussaver.fragments.base.BaseFragment import com.simplified.wsstatussaver.interfaces.IMessageCallback @@ -57,7 +57,11 @@ class ConversationDetailFragment : BaseFragment(R.layout.fragment_messages), IMe override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) _binding = FragmentMessagesBinding.bind(view) - binding.recyclerView.drawAboveSystemBarsWithPadding() + binding.recyclerView.applyPortraitInsetter { + type(navigationBars = true) { + padding() + } + } postponeEnterTransition() view.doOnPreDraw { startPostponedEnterTransition() } diff --git a/app/src/main/java/com/simplified/wsstatussaver/fragments/onboard/OnboardFragment.kt b/app/src/main/java/com/simplified/wsstatussaver/fragments/onboard/OnboardFragment.kt index 9735269..5bad304 100644 --- a/app/src/main/java/com/simplified/wsstatussaver/fragments/onboard/OnboardFragment.kt +++ b/app/src/main/java/com/simplified/wsstatussaver/fragments/onboard/OnboardFragment.kt @@ -34,7 +34,7 @@ import com.simplified.wsstatussaver.R import com.simplified.wsstatussaver.WhatSaveViewModel import com.simplified.wsstatussaver.adapter.ClientAdapter import com.simplified.wsstatussaver.databinding.FragmentOnboardBinding -import com.simplified.wsstatussaver.extensions.drawAboveSystemBars +import com.simplified.wsstatussaver.extensions.applyPortraitInsetter import com.simplified.wsstatussaver.extensions.formattedAsHtml import com.simplified.wsstatussaver.extensions.getClientSAFIntent import com.simplified.wsstatussaver.extensions.getOnBackPressedDispatcher @@ -82,7 +82,11 @@ class OnboardFragment : BaseFragment(R.layout.fragment_onboard), View.OnClickLis override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) _binding = OnboardBinding(FragmentOnboardBinding.bind(view)) - binding.agreementText.drawAboveSystemBars() + binding.agreementText.applyPortraitInsetter { + type(navigationBars = true) { + margin() + } + } postponeEnterTransition() enterTransition = MaterialFadeThrough().addTarget(view) diff --git a/app/src/main/java/com/simplified/wsstatussaver/views/InsetsConstraintLayout.kt b/app/src/main/java/com/simplified/wsstatussaver/views/InsetsConstraintLayout.kt index 200fa18..b8f6971 100644 --- a/app/src/main/java/com/simplified/wsstatussaver/views/InsetsConstraintLayout.kt +++ b/app/src/main/java/com/simplified/wsstatussaver/views/InsetsConstraintLayout.kt @@ -16,7 +16,7 @@ package com.simplified.wsstatussaver.views import android.content.Context import android.util.AttributeSet import androidx.constraintlayout.widget.ConstraintLayout -import dev.chrisbanes.insetter.applyInsetter +import com.simplified.wsstatussaver.extensions.applyPortraitInsetter /** * @author Christians M. A. (mardous) @@ -39,7 +39,7 @@ class InsetsConstraintLayout @JvmOverloads constructor( parent = parent.parent } if (!hasInsetsParent) { - applyInsetter { + applyPortraitInsetter { type(navigationBars = true) { padding() } diff --git a/app/src/main/java/com/simplified/wsstatussaver/views/InsetsNestedScrollView.kt b/app/src/main/java/com/simplified/wsstatussaver/views/InsetsNestedScrollView.kt index 7fe3d02..ebecd48 100644 --- a/app/src/main/java/com/simplified/wsstatussaver/views/InsetsNestedScrollView.kt +++ b/app/src/main/java/com/simplified/wsstatussaver/views/InsetsNestedScrollView.kt @@ -16,7 +16,7 @@ package com.simplified.wsstatussaver.views import android.content.Context import android.util.AttributeSet import androidx.core.widget.NestedScrollView -import dev.chrisbanes.insetter.applyInsetter +import com.simplified.wsstatussaver.extensions.applyPortraitInsetter /** * @author Christians M. A. (mardous) @@ -28,7 +28,7 @@ class InsetsNestedScrollView @JvmOverloads constructor( ) : NestedScrollView(context, attrs, defStyleAttr) { init { - applyInsetter { + applyPortraitInsetter { type(navigationBars = true) { padding() }