Remove bottom navigation bar, improve E2E support
This commit is contained in:
parent
d96a91b46e
commit
46a6c0e875
17 changed files with 157 additions and 55 deletions
|
|
@ -1,8 +1,10 @@
|
|||
package icu.nullptr.hidemyapplist.ui.fragment
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.activity.addCallback
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.fragment.app.Fragment
|
||||
|
|
@ -120,5 +122,24 @@ abstract class AppSelectFragment : Fragment(R.layout.fragment_app_select) {
|
|||
}
|
||||
|
||||
sortList()
|
||||
|
||||
val insets = binding.root.rootWindowInsets
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val barInsets = insets.getInsets(WindowInsets.Type.systemBars())
|
||||
binding.root.setPadding(
|
||||
barInsets.left,
|
||||
barInsets.top,
|
||||
barInsets.right,
|
||||
barInsets.bottom,
|
||||
)
|
||||
} else {
|
||||
@Suppress("deprecation")
|
||||
binding.root.setPadding(
|
||||
insets.systemWindowInsetLeft,
|
||||
insets.systemWindowInsetTop,
|
||||
insets.systemWindowInsetRight,
|
||||
insets.systemWindowInsetBottom,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package icu.nullptr.hidemyapplist.ui.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.activity.addCallback
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import androidx.fragment.app.Fragment
|
||||
|
|
@ -73,6 +75,25 @@ class AppSettingsFragment : Fragment(R.layout.fragment_settings) {
|
|||
.replace(R.id.settings_container, AppPreferenceFragment())
|
||||
.commit()
|
||||
}
|
||||
|
||||
val insets = binding.root.rootWindowInsets
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val barInsets = insets.getInsets(WindowInsets.Type.systemBars())
|
||||
binding.root.setPadding(
|
||||
barInsets.left,
|
||||
barInsets.top,
|
||||
barInsets.right,
|
||||
barInsets.bottom,
|
||||
)
|
||||
} else {
|
||||
@Suppress("deprecation")
|
||||
binding.root.setPadding(
|
||||
insets.systemWindowInsetLeft,
|
||||
insets.systemWindowInsetTop,
|
||||
insets.systemWindowInsetRight,
|
||||
insets.systemWindowInsetBottom,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class AppPreferenceDataStore(private val pack: AppSettingsViewModel.Pack) : PreferenceDataStore() {
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class LogsFragment : Fragment(R.layout.fragment_logs) {
|
|||
)
|
||||
setNavigationIcon(R.drawable.baseline_arrow_back_24)
|
||||
setNavigationOnClickListener { navController.popBackStack() }
|
||||
isTitleCentered = true
|
||||
// isTitleCentered = true
|
||||
}
|
||||
|
||||
with(binding.toolbar.menu) {
|
||||
|
|
@ -150,7 +150,7 @@ class LogsFragment : Fragment(R.layout.fragment_logs) {
|
|||
barInsets.left,
|
||||
barInsets.top,
|
||||
barInsets.right,
|
||||
0,
|
||||
barInsets.bottom,
|
||||
)
|
||||
} else {
|
||||
@Suppress("deprecation")
|
||||
|
|
@ -158,7 +158,7 @@ class LogsFragment : Fragment(R.layout.fragment_logs) {
|
|||
insets.systemWindowInsetLeft,
|
||||
insets.systemWindowInsetTop,
|
||||
insets.systemWindowInsetRight,
|
||||
0,
|
||||
insets.systemWindowInsetBottom,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.os.Build
|
|||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.preference.ListPreference
|
||||
|
|
@ -22,6 +23,7 @@ import icu.nullptr.hidemyapplist.service.PrefManager
|
|||
import icu.nullptr.hidemyapplist.service.ServiceClient
|
||||
import icu.nullptr.hidemyapplist.ui.activity.AboutActivity
|
||||
import icu.nullptr.hidemyapplist.ui.util.makeToast
|
||||
import icu.nullptr.hidemyapplist.ui.util.navController
|
||||
import icu.nullptr.hidemyapplist.ui.util.setupToolbar
|
||||
import icu.nullptr.hidemyapplist.util.ConfigUtils.Companion.getLocale
|
||||
import icu.nullptr.hidemyapplist.util.LangList
|
||||
|
|
@ -42,9 +44,11 @@ class SettingsFragment : Fragment(R.layout.fragment_settings), PreferenceFragmen
|
|||
menuRes = R.menu.menu_about,
|
||||
onMenuOptionSelected = {
|
||||
startActivity(Intent(requireContext(), AboutActivity::class.java))
|
||||
}
|
||||
},
|
||||
navigationIcon = R.drawable.baseline_arrow_back_24,
|
||||
navigationOnClick = { navController.navigateUp() }
|
||||
)
|
||||
isTitleCentered = true
|
||||
// isTitleCentered = true
|
||||
}
|
||||
|
||||
if (childFragmentManager.findFragmentById(R.id.settings_container) == null) {
|
||||
|
|
@ -52,6 +56,25 @@ class SettingsFragment : Fragment(R.layout.fragment_settings), PreferenceFragmen
|
|||
.replace(R.id.settings_container, SettingsPreferenceFragment())
|
||||
.commit()
|
||||
}
|
||||
|
||||
val insets = binding.root.rootWindowInsets
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val barInsets = insets.getInsets(WindowInsets.Type.systemBars())
|
||||
binding.root.setPadding(
|
||||
barInsets.left,
|
||||
barInsets.top,
|
||||
barInsets.right,
|
||||
barInsets.bottom,
|
||||
)
|
||||
} else {
|
||||
@Suppress("deprecation")
|
||||
binding.root.setPadding(
|
||||
insets.systemWindowInsetLeft,
|
||||
insets.systemWindowInsetTop,
|
||||
insets.systemWindowInsetRight,
|
||||
insets.systemWindowInsetBottom,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPreferenceStartFragment(caller: PreferenceFragmentCompat, pref: Preference): Boolean {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package icu.nullptr.hidemyapplist.ui.fragment
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.clearFragmentResultListener
|
||||
|
|
@ -50,6 +52,25 @@ class TemplateManageFragment : Fragment(R.layout.fragment_template_manage) {
|
|||
}
|
||||
binding.templateList.layoutManager = LinearLayoutManager(context)
|
||||
binding.templateList.adapter = adapter
|
||||
|
||||
val insets = binding.root.rootWindowInsets
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val barInsets = insets.getInsets(WindowInsets.Type.systemBars())
|
||||
binding.root.setPadding(
|
||||
barInsets.left,
|
||||
barInsets.top,
|
||||
barInsets.right,
|
||||
barInsets.bottom,
|
||||
)
|
||||
} else {
|
||||
@Suppress("deprecation")
|
||||
binding.root.setPadding(
|
||||
insets.systemWindowInsetLeft,
|
||||
insets.systemWindowInsetTop,
|
||||
insets.systemWindowInsetRight,
|
||||
insets.systemWindowInsetBottom,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun navigateToSettings(info: ConfigManager.TemplateInfo) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package icu.nullptr.hidemyapplist.ui.fragment
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.activity.addCallback
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
import androidx.fragment.app.Fragment
|
||||
|
|
@ -116,5 +118,24 @@ class TemplateSettingsFragment : Fragment(R.layout.fragment_template_settings) {
|
|||
binding.appliedApps.text = String.format(getString(R.string.template_applied_count), it.size)
|
||||
}
|
||||
}
|
||||
|
||||
val insets = binding.root.rootWindowInsets
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val barInsets = insets.getInsets(WindowInsets.Type.systemBars())
|
||||
binding.root.setPadding(
|
||||
barInsets.left,
|
||||
barInsets.top,
|
||||
barInsets.right,
|
||||
barInsets.bottom,
|
||||
)
|
||||
} else {
|
||||
@Suppress("deprecation")
|
||||
binding.root.setPadding(
|
||||
insets.systemWindowInsetLeft,
|
||||
insets.systemWindowInsetTop,
|
||||
insets.systemWindowInsetRight,
|
||||
insets.systemWindowInsetBottom,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import android.os.Bundle
|
|||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.ui.NavigationUI.setupWithNavController
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import icu.nullptr.hidemyapplist.hmaApp
|
||||
import icu.nullptr.hidemyapplist.ui.util.ThemeUtils
|
||||
|
|
@ -25,9 +23,6 @@ class MainActivity : AppCompatActivity() {
|
|||
setContentView(binding.root)
|
||||
|
||||
DynamicColors.applyToActivityIfAvailable(this)
|
||||
val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
|
||||
val navController = navHostFragment.navController
|
||||
setupWithNavController(binding.bottomNav, navController)
|
||||
}
|
||||
|
||||
override fun onApplyThemeResource(theme: Resources.Theme, resid: Int, first: Boolean) {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@ package org.frknkrc44.hma_oss.ui.fragment
|
|||
import android.annotation.SuppressLint
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowInsets
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
|
|
@ -82,7 +84,29 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
|
|||
toolbar = binding.toolbar,
|
||||
title = getString(R.string.app_name),
|
||||
)
|
||||
isTitleCentered = true
|
||||
// isTitleCentered = true
|
||||
}
|
||||
|
||||
binding.root.setOnApplyWindowInsetsListener { v, insets ->
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val barInsets = insets.getInsets(WindowInsets.Type.systemBars())
|
||||
binding.root.setPadding(
|
||||
barInsets.left,
|
||||
barInsets.top,
|
||||
barInsets.right,
|
||||
barInsets.bottom,
|
||||
)
|
||||
} else {
|
||||
@Suppress("deprecation")
|
||||
binding.root.setPadding(
|
||||
insets.systemWindowInsetLeft,
|
||||
insets.systemWindowInsetTop,
|
||||
insets.systemWindowInsetRight,
|
||||
insets.systemWindowInsetBottom,
|
||||
)
|
||||
}
|
||||
|
||||
insets
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -153,13 +177,7 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
|
|||
}
|
||||
|
||||
(layoutParams as LinearLayout.LayoutParams).apply {
|
||||
if (i == 0) {
|
||||
setMargins(pad, pad, pad, 0)
|
||||
} else if (i == childCount - 1) {
|
||||
setMargins(pad, 0, pad, pad)
|
||||
} else {
|
||||
setMargins(pad, 0, pad, 0)
|
||||
}
|
||||
setMargins(pad, 0, pad, 0)
|
||||
}
|
||||
|
||||
val backgroundDrawable = GradientDrawable()
|
||||
|
|
@ -258,6 +276,14 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
|
|||
}
|
||||
}
|
||||
|
||||
with(binding.navSettings) {
|
||||
text1.text = getString(R.string.title_settings)
|
||||
icon.setImageResource(R.drawable.outline_settings_24)
|
||||
root.setOnClickListener {
|
||||
navigate(R.id.nav_settings)
|
||||
}
|
||||
}
|
||||
|
||||
binding.backupConfig.setOnClickListener {
|
||||
backupSAFLauncher.launch("HMA_Config_${System.currentTimeMillis()}.json")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,16 +18,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_nav"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/main_nav_graph" />
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_nav"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:labelVisibilityMode="selected"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:menu="@menu/menu_nav" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/home_nav_graph" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:fitsSystemWindows="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:fitsSystemWindows="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
|
@ -59,6 +58,10 @@
|
|||
android:id="@+id/nav_logs"
|
||||
layout="@layout/view_home_item" />
|
||||
|
||||
<include
|
||||
android:id="@+id/nav_settings"
|
||||
layout="@layout/view_home_item" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:fitsSystemWindows="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:fitsSystemWindows="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:fitsSystemWindows="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/home_nav_graph"
|
||||
android:icon="@drawable/ic_home_checkable"
|
||||
android:title="@string/title_home" />
|
||||
<item
|
||||
android:id="@+id/nav_settings"
|
||||
android:icon="@drawable/ic_settings_checkable"
|
||||
android:title="@string/title_settings" />
|
||||
</menu>
|
||||
|
|
@ -13,6 +13,11 @@
|
|||
android:name="icu.nullptr.hidemyapplist.ui.fragment.LogsFragment"
|
||||
android:label="@string/title_logs" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_settings"
|
||||
android:name="icu.nullptr.hidemyapplist.ui.fragment.SettingsFragment"
|
||||
android:label="@string/title_settings" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_template_manage"
|
||||
android:name="icu.nullptr.hidemyapplist.ui.fragment.TemplateManageFragment"
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main_nav_graph"
|
||||
app:startDestination="@id/home_nav_graph">
|
||||
<include app:graph="@navigation/home_nav_graph" />
|
||||
<fragment
|
||||
android:id="@+id/nav_settings"
|
||||
android:name="icu.nullptr.hidemyapplist.ui.fragment.SettingsFragment"
|
||||
android:label="@string/title_settings" />
|
||||
</navigation>
|
||||
Reference in a new issue