Feature: Added Navigation hiding.
This commit is contained in:
@@ -213,6 +213,34 @@ class AppHelper @Inject constructor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showNavigationBar(window: Window) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
// For Android 11 (API 30) and above, use WindowInsetsController to show the navigation bar
|
||||||
|
window.insetsController?.show(WindowInsets.Type.navigationBars())
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION", "InlinedApi")
|
||||||
|
// For older versions, show the navigation bar using systemUiVisibility
|
||||||
|
window.decorView.apply {
|
||||||
|
systemUiVisibility =
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hideNavigationBar(window: Window) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
// For Android 11 (API 30) and above, use WindowInsetsController to hide the navigation bar
|
||||||
|
window.insetsController?.hide(WindowInsets.Type.navigationBars())
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
// For older versions, hide the navigation bar using systemUiVisibility
|
||||||
|
window.decorView.apply {
|
||||||
|
systemUiVisibility =
|
||||||
|
View.SYSTEM_UI_FLAG_IMMERSIVE or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun wordOfTheDay(resources: Resources): String {
|
fun wordOfTheDay(resources: Resources): String {
|
||||||
val dailyWordsArray =
|
val dailyWordsArray =
|
||||||
resources.getStringArray(R.array.settings_appearance_daily_word_default)
|
resources.getStringArray(R.array.settings_appearance_daily_word_default)
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
|
|||||||
get() = prefs.getBoolean(Constants.SHOW_STATUS_BAR, true)
|
get() = prefs.getBoolean(Constants.SHOW_STATUS_BAR, true)
|
||||||
set(value) = prefs.edit().putBoolean(Constants.SHOW_STATUS_BAR, value).apply()
|
set(value) = prefs.edit().putBoolean(Constants.SHOW_STATUS_BAR, value).apply()
|
||||||
|
|
||||||
|
var showNavigationBar: Boolean
|
||||||
|
get() = prefs.getBoolean(Constants.SHOW_NAVIGATION_BAR, true)
|
||||||
|
set(value) = prefs.edit().putBoolean(Constants.SHOW_NAVIGATION_BAR, value).apply()
|
||||||
|
|
||||||
var showTime: Boolean
|
var showTime: Boolean
|
||||||
get() = prefs.getBoolean(Constants.SHOW_TIME, true)
|
get() = prefs.getBoolean(Constants.SHOW_TIME, true)
|
||||||
set(value) = prefs.edit().putBoolean(Constants.SHOW_TIME, value).apply()
|
set(value) = prefs.edit().putBoolean(Constants.SHOW_TIME, value).apply()
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
setupNavController()
|
setupNavController()
|
||||||
setupOrientation()
|
setupOrientation()
|
||||||
setupLocationManager()
|
setupLocationManager()
|
||||||
setLanguage()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
@@ -110,6 +109,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private fun initializeDependencies() {
|
private fun initializeDependencies() {
|
||||||
setLocationPermissionDenied(false)
|
setLocationPermissionDenied(false)
|
||||||
preferenceViewModel.setShowStatusBar(preferenceHelper.showStatusBar)
|
preferenceViewModel.setShowStatusBar(preferenceHelper.showStatusBar)
|
||||||
|
preferenceViewModel.setShowNavigationBar(preferenceHelper.showNavigationBar)
|
||||||
preferenceViewModel.setFirstLaunch(preferenceHelper.firstLaunch)
|
preferenceViewModel.setFirstLaunch(preferenceHelper.firstLaunch)
|
||||||
|
|
||||||
window.addFlags(FLAG_LAYOUT_NO_LIMITS)
|
window.addFlags(FLAG_LAYOUT_NO_LIMITS)
|
||||||
@@ -214,6 +214,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (it) appHelper.showStatusBar(this.window)
|
if (it) appHelper.showStatusBar(this.window)
|
||||||
else appHelper.hideStatusBar(this.window)
|
else appHelper.hideStatusBar(this.window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
preferenceViewModel.setShowNavigationBar(preferenceHelper.showNavigationBar)
|
||||||
|
preferenceViewModel.showNavigationBarLiveData.observe(this) {
|
||||||
|
if (it) appHelper.showNavigationBar(this.window)
|
||||||
|
else appHelper.hideNavigationBar(this.window)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupNavController() {
|
private fun setupNavController() {
|
||||||
@@ -288,9 +294,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
when (navController.currentDestination?.id) {
|
when (navController.currentDestination?.id) {
|
||||||
R.id.SettingsFeaturesFragment,
|
R.id.SettingsFeaturesFragment,
|
||||||
R.id.SettingsLookFeelFragment,
|
R.id.SettingsLookFeelFragment,
|
||||||
|
R.id.SettingsWidgetFragment,
|
||||||
R.id.SettingsAdvancedFragment,
|
R.id.SettingsAdvancedFragment,
|
||||||
R.id.FavoriteFragment,
|
R.id.FavoriteFragment,
|
||||||
R.id.HiddenFragment -> {
|
R.id.HiddenFragment,
|
||||||
|
-> {
|
||||||
val actionTypeNavOptions: NavOptions? =
|
val actionTypeNavOptions: NavOptions? =
|
||||||
if (preferenceHelper.disableAnimations) null
|
if (preferenceHelper.disableAnimations) null
|
||||||
else appHelper.getActionType(Constants.Swipe.Up)
|
else appHelper.getActionType(Constants.Swipe.Up)
|
||||||
@@ -338,7 +346,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onRequestPermissionsResult(
|
override fun onRequestPermissionsResult(
|
||||||
requestCode: Int,
|
requestCode: Int,
|
||||||
permissions: Array<out String>,
|
permissions: Array<out String>,
|
||||||
grantResults: IntArray
|
grantResults: IntArray,
|
||||||
) {
|
) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
|
|||||||
@@ -537,8 +537,9 @@ class HomeFragment : Fragment(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
|
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
|
||||||
val actionTypeNavOptions: NavOptions =
|
val actionTypeNavOptions: NavOptions? =
|
||||||
appHelper.getActionType(Constants.Swipe.DoubleTap)
|
if (preferenceHelper.disableAnimations) null
|
||||||
|
else appHelper.getActionType(Constants.Swipe.DoubleTap)
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
R.id.SettingsFragment,
|
R.id.SettingsFragment,
|
||||||
null,
|
null,
|
||||||
@@ -554,8 +555,9 @@ class HomeFragment : Fragment(),
|
|||||||
if (preferenceHelper.settingsLock) {
|
if (preferenceHelper.settingsLock) {
|
||||||
fingerHelper.startBiometricSettingsAuth(R.id.SettingsFragment)
|
fingerHelper.startBiometricSettingsAuth(R.id.SettingsFragment)
|
||||||
} else {
|
} else {
|
||||||
val actionTypeNavOptions: NavOptions =
|
val actionTypeNavOptions: NavOptions? =
|
||||||
appHelper.getActionType(Constants.Swipe.DoubleTap)
|
if (preferenceHelper.disableAnimations) null
|
||||||
|
else appHelper.getActionType(Constants.Swipe.DoubleTap)
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
R.id.SettingsFragment,
|
R.id.SettingsFragment,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ class SettingsLookFeelFragment : Fragment(),
|
|||||||
private fun initializeInjectedDependencies() {
|
private fun initializeInjectedDependencies() {
|
||||||
// Set initial values and listeners for switches
|
// Set initial values and listeners for switches
|
||||||
binding.apply {
|
binding.apply {
|
||||||
statueBarSwitchCompat.isChecked = preferenceHelper.showStatusBar
|
statusBarSwitchCompat.isChecked = preferenceHelper.showStatusBar
|
||||||
|
navBarSwitchCompat.isChecked = preferenceHelper.showNavigationBar
|
||||||
timeSwitchCompat.isChecked = preferenceHelper.showTime
|
timeSwitchCompat.isChecked = preferenceHelper.showTime
|
||||||
dateSwitchCompat.isChecked = preferenceHelper.showDate
|
dateSwitchCompat.isChecked = preferenceHelper.showDate
|
||||||
batterySwitchCompat.isChecked = preferenceHelper.showBattery
|
batterySwitchCompat.isChecked = preferenceHelper.showBattery
|
||||||
@@ -142,12 +143,18 @@ class SettingsLookFeelFragment : Fragment(),
|
|||||||
@RequiresApi(Build.VERSION_CODES.Q)
|
@RequiresApi(Build.VERSION_CODES.Q)
|
||||||
private fun setupSwitchListeners() {
|
private fun setupSwitchListeners() {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
statueBarSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
statusBarSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
||||||
preferenceViewModel.setShowStatusBar(isChecked)
|
preferenceViewModel.setShowStatusBar(isChecked)
|
||||||
val feedbackType = if (isChecked) "on" else "off"
|
val feedbackType = if (isChecked) "on" else "off"
|
||||||
appHelper.triggerHapticFeedback(context, feedbackType)
|
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
navBarSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
||||||
|
preferenceViewModel.setShowNavigationBar(isChecked)
|
||||||
|
val feedbackType = if (isChecked) "on" else "off"
|
||||||
|
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||||
|
}
|
||||||
|
|
||||||
dateSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
dateSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
||||||
preferenceViewModel.setShowDate(isChecked)
|
preferenceViewModel.setShowDate(isChecked)
|
||||||
val feedbackType = if (isChecked) "on" else "off"
|
val feedbackType = if (isChecked) "on" else "off"
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ object Constants {
|
|||||||
const val SHOW_ALARM_CLOCK = "SHOW_ALARM_CLOCK"
|
const val SHOW_ALARM_CLOCK = "SHOW_ALARM_CLOCK"
|
||||||
const val SHOW_BATTERY = "SHOW_BATTERY"
|
const val SHOW_BATTERY = "SHOW_BATTERY"
|
||||||
const val SHOW_STATUS_BAR = "SHOW_STATUS_BAR"
|
const val SHOW_STATUS_BAR = "SHOW_STATUS_BAR"
|
||||||
|
const val SHOW_NAVIGATION_BAR = "SHOW_NAVIGATION_BAR"
|
||||||
|
|
||||||
|
|
||||||
const val SHOW_WEATHER_WIDGET = "SHOW_WEATHER_WIDGET"
|
const val SHOW_WEATHER_WIDGET = "SHOW_WEATHER_WIDGET"
|
||||||
const val SHOW_WEATHER_WIDGET_SUN_SET_RISE = "SHOW_WEATHER_WIDGET_SUN_SET_RISE"
|
const val SHOW_WEATHER_WIDGET_SUN_SET_RISE = "SHOW_WEATHER_WIDGET_SUN_SET_RISE"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class PreferenceViewModel @Inject constructor(
|
|||||||
|
|
||||||
private val firstLaunchLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
private val firstLaunchLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||||
val showStatusBarLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
val showStatusBarLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||||
|
val showNavigationBarLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||||
val showTimeLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
val showTimeLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||||
val showDateLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
val showDateLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||||
val showDailyWordLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
val showDailyWordLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||||
@@ -76,6 +77,11 @@ class PreferenceViewModel @Inject constructor(
|
|||||||
showStatusBarLiveData.postValue(preferenceHelper.showStatusBar)
|
showStatusBarLiveData.postValue(preferenceHelper.showStatusBar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setShowNavigationBar(showNavigationBar: Boolean) {
|
||||||
|
preferenceHelper.showNavigationBar = showNavigationBar
|
||||||
|
showNavigationBarLiveData.postValue(preferenceHelper.showNavigationBar)
|
||||||
|
}
|
||||||
|
|
||||||
fun setShowTime(showTime: Boolean) {
|
fun setShowTime(showTime: Boolean) {
|
||||||
preferenceHelper.showTime = showTime
|
preferenceHelper.showTime = showTime
|
||||||
showTimeLiveData.postValue(preferenceHelper.showTime)
|
showTimeLiveData.postValue(preferenceHelper.showTime)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
tools:ignore="MissingConstraints">
|
tools:ignore="MissingConstraints">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/statue_bar_text"
|
android:id="@+id/status_bar_text"
|
||||||
style="@style/TextDefaultStyle"
|
style="@style/TextDefaultStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -73,7 +73,38 @@
|
|||||||
tools:ignore="RtlHardcoded" />
|
tools:ignore="RtlHardcoded" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:id="@+id/statue_bar_switchCompat"
|
android:id="@+id/status_bar_switchCompat"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:scaleX="0.7"
|
||||||
|
android:scaleY="0.8"
|
||||||
|
android:thumb="@drawable/shape_switch_thumb"
|
||||||
|
app:track="@drawable/selector_switch"
|
||||||
|
tools:ignore="DuplicateSpeakableTextCheck,TouchTargetSizeCheck" />
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
tools:ignore="MissingConstraints">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/nav_bar_text"
|
||||||
|
style="@style/TextDefaultStyle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="left|center"
|
||||||
|
android:text="@string/settings_display_nav_bar"
|
||||||
|
android:textSize="@dimen/text_large"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:ignore="RtlHardcoded" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/nav_bar_switchCompat"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:scaleX="0.7"
|
android:scaleX="0.7"
|
||||||
|
|||||||
@@ -8,12 +8,6 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.widgets.WidgetFragment">
|
tools:context=".ui.widgets.WidgetFragment">
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/touchArea"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_marginVertical="20dp" />
|
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:id="@+id/nestedScrollView"
|
android:id="@+id/nestedScrollView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -95,6 +95,7 @@
|
|||||||
<string name="settings_title_others">Others</string>
|
<string name="settings_title_others">Others</string>
|
||||||
|
|
||||||
<string name="settings_display_status_bar">Show Status Bar</string>
|
<string name="settings_display_status_bar">Show Status Bar</string>
|
||||||
|
<string name="settings_display_nav_bar">Show Navigation Bar</string>
|
||||||
<string name="settings_display_date">Show Date</string>
|
<string name="settings_display_date">Show Date</string>
|
||||||
<string name="settings_display_time">Show Time</string>
|
<string name="settings_display_time">Show Time</string>
|
||||||
<string name="settings_display_battery">Show Battery</string>
|
<string name="settings_display_battery">Show Battery</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user