Skip to content

Commit

Permalink
[fix]: navbar on huawei devices
Browse files Browse the repository at this point in the history
  • Loading branch information
F0x1d committed Dec 17, 2023
1 parent 892b113 commit 4481990
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.os.Build
val isAtLeastAndroid13 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU

val gesturesAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
val contrastedNavBarAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
val contrastedNavBarAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 || isHuawei

val notificationsDynamicColorAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
val notificationsChannelsAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
Expand Down
15 changes: 6 additions & 9 deletions app/src/main/java/com/f0x1d/logfox/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.f0x1d.logfox.extensions.context.hasNotificationsPermission
import com.f0x1d.logfox.extensions.context.isHorizontalOrientation
import com.f0x1d.logfox.extensions.contrastedNavBarAvailable
import com.f0x1d.logfox.extensions.gesturesAvailable
import com.f0x1d.logfox.extensions.isHuawei
import com.f0x1d.logfox.ui.activity.base.BaseViewModelActivity
import com.f0x1d.logfox.utils.event.Event
import com.f0x1d.logfox.viewmodel.MainViewModel
Expand Down Expand Up @@ -136,16 +135,14 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),
else -> true
}

if (!isHuawei) {
if (!gesturesAvailable && contrastedNavBarAvailable) {
window.navigationBarColor = when {
barShown && !isHorizontalOrientation -> Color.TRANSPARENT
if (!gesturesAvailable && contrastedNavBarAvailable) {
window.navigationBarColor = when {
barShown && !isHorizontalOrientation -> Color.TRANSPARENT

else -> getColor(R.color.navbar_transparent_background)
}
} else if (gesturesAvailable) {
window.isNavigationBarContrastEnforced = !(barShown && !isHorizontalOrientation)
else -> getColor(R.color.navbar_transparent_background)
}
} else if (gesturesAvailable) {
window.isNavigationBarContrastEnforced = !(barShown && !isHorizontalOrientation)
}

if (this.barShown != barShown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.f0x1d.logfox.R
import com.f0x1d.logfox.extensions.context.viewPump
import com.f0x1d.logfox.extensions.contrastedNavBarAvailable
import com.f0x1d.logfox.extensions.gesturesAvailable
import com.f0x1d.logfox.extensions.isHuawei
import com.f0x1d.logfox.extensions.views.snackbar
import dev.chrisbanes.insetter.applyInsetter
import io.github.inflationx.viewpump.ViewPumpContextWrapper
Expand All @@ -24,7 +23,7 @@ abstract class BaseActivity<T : ViewBinding>: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)

if (!isHuawei) window.navigationBarColor = when {
window.navigationBarColor = when {
!contrastedNavBarAvailable -> getColor(
R.color.transparent_black
)
Expand Down

0 comments on commit 4481990

Please sign in to comment.