mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-05 01:47:24 +00:00
Added an action bar to launcher settings
This commit is contained in:
parent
e845ce7983
commit
05e29c5140
14 changed files with 83 additions and 78 deletions
|
|
@ -12,7 +12,7 @@ import androidx.fragment.app.Fragment
|
|||
import eu.ottop.yamlauncher.R
|
||||
import eu.ottop.yamlauncher.utils.StringUtils
|
||||
|
||||
class AboutFragment : Fragment() {
|
||||
class AboutFragment : Fragment(), TitleProvider {
|
||||
|
||||
private val stringUtils = StringUtils()
|
||||
|
||||
|
|
@ -41,4 +41,8 @@ class AboutFragment : Fragment() {
|
|||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTitle(): String {
|
||||
return "About YAM Launcher"
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,13 @@ import android.os.Bundle
|
|||
import androidx.preference.PreferenceFragmentCompat
|
||||
import eu.ottop.yamlauncher.R
|
||||
|
||||
class AppMenuSettingsFragment : PreferenceFragmentCompat() {
|
||||
class AppMenuSettingsFragment : PreferenceFragmentCompat(), TitleProvider {
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.app_menu_preferences, rootKey)
|
||||
}
|
||||
|
||||
override fun getTitle(): String {
|
||||
return "App Menu Settings"
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ import eu.ottop.yamlauncher.utils.UIUtils
|
|||
import kotlinx.coroutines.launch
|
||||
|
||||
class GestureAppsFragment(private val direction: String) : Fragment(),
|
||||
GestureAppsAdapter.OnItemClickListener {
|
||||
GestureAppsAdapter.OnItemClickListener, TitleProvider {
|
||||
|
||||
private var adapter: GestureAppsAdapter? = null
|
||||
private lateinit var sharedPreferenceManager: SharedPreferenceManager
|
||||
|
|
@ -64,7 +64,6 @@ class GestureAppsFragment(private val direction: String) : Fragment(),
|
|||
|
||||
val searchView = view.findViewById<TextInputEditText>(R.id.gestureAppSearch)
|
||||
|
||||
uiUtils.setMenuTitleAlignment(view.findViewById(R.id.gestureMenuTitle))
|
||||
uiUtils.setSearchAlignment(searchView)
|
||||
uiUtils.setSearchSize(searchView)
|
||||
|
||||
|
|
@ -165,5 +164,8 @@ class GestureAppsFragment(private val direction: String) : Fragment(),
|
|||
).toString(), profile)
|
||||
}
|
||||
|
||||
override fun getTitle(): String {
|
||||
return "Select an App"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ import eu.ottop.yamlauncher.utils.StringUtils
|
|||
import eu.ottop.yamlauncher.utils.UIUtils
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener {
|
||||
class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener, TitleProvider {
|
||||
|
||||
private lateinit var sharedPreferenceManager: SharedPreferenceManager
|
||||
private var adapter: HiddenAppsAdapter? = null
|
||||
|
|
@ -62,7 +62,6 @@ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener {
|
|||
|
||||
val searchView = view.findViewById<TextInputEditText>(R.id.hiddenAppSearch)
|
||||
|
||||
uiUtils.setMenuTitleAlignment(view.findViewById(R.id.hiddenMenuTitle))
|
||||
uiUtils.setSearchAlignment(searchView)
|
||||
uiUtils.setSearchSize(searchView)
|
||||
|
||||
|
|
@ -162,4 +161,8 @@ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener {
|
|||
).toString(), profile)
|
||||
}
|
||||
|
||||
override fun getTitle(): String {
|
||||
return "Hidden Apps"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import androidx.preference.PreferenceFragmentCompat
|
|||
import androidx.preference.SwitchPreference
|
||||
import eu.ottop.yamlauncher.R
|
||||
|
||||
class HomeSettingsFragment : PreferenceFragmentCompat() {
|
||||
class HomeSettingsFragment : PreferenceFragmentCompat(), TitleProvider {
|
||||
|
||||
private lateinit var sharedPreferenceManager: SharedPreferenceManager
|
||||
|
||||
|
|
@ -73,4 +73,8 @@ class HomeSettingsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
rightSwipePref?.summary = sharedPreferenceManager.getGestureName("right")
|
||||
}
|
||||
|
||||
override fun getTitle(): String {
|
||||
return "Home Screen Settings"
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class LocationFragment : Fragment(), LocationListAdapter.OnItemClickListener {
|
||||
class LocationFragment : Fragment(), LocationListAdapter.OnItemClickListener, TitleProvider {
|
||||
|
||||
private var adapter: LocationListAdapter? = null
|
||||
private lateinit var weatherSystem: WeatherSystem
|
||||
|
|
@ -58,7 +58,6 @@ class LocationFragment : Fragment(), LocationListAdapter.OnItemClickListener {
|
|||
adapter = LocationListAdapter(requireContext(), locationList, this)
|
||||
val recyclerView = view.findViewById<RecyclerView>(R.id.locationRecycler)
|
||||
val appMenuEdgeFactory = AppMenuEdgeFactory(requireActivity())
|
||||
uiUtils.setMenuTitleAlignment(view.findViewById(R.id.locationMenuTitle))
|
||||
uiUtils.setSearchAlignment(searchView)
|
||||
uiUtils.setSearchSize(searchView)
|
||||
|
||||
|
|
@ -130,6 +129,8 @@ class LocationFragment : Fragment(), LocationListAdapter.OnItemClickListener {
|
|||
showConfirmationDialog(name, latitude, longitude)
|
||||
}
|
||||
|
||||
|
||||
override fun getTitle(): String {
|
||||
return "Search for Your City"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,14 +9,41 @@ class SettingsActivity : AppCompatActivity() {
|
|||
|
||||
private lateinit var binding: ActivitySettingsBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.settingsLayout, SettingsFragment())
|
||||
.commit()
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.title = "Launcher Settings"
|
||||
supportActionBar?.setDisplayShowTitleEnabled(true)
|
||||
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.settingsLayout, SettingsFragment())
|
||||
.commit()
|
||||
|
||||
supportFragmentManager.addOnBackStackChangedListener {
|
||||
updateActionBarTitle()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
// Handle the back arrow button in the ActionBar
|
||||
if (supportFragmentManager.backStackEntryCount > 0) {
|
||||
supportFragmentManager.popBackStack()
|
||||
} else {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun updateActionBarTitle() {
|
||||
val fragment = supportFragmentManager.findFragmentById(R.id.settingsLayout)
|
||||
if (fragment is TitleProvider) {
|
||||
supportActionBar?.title = fragment.getTitle()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import androidx.preference.Preference
|
|||
import androidx.preference.PreferenceFragmentCompat
|
||||
import eu.ottop.yamlauncher.R
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat() {
|
||||
class SettingsFragment : PreferenceFragmentCompat(), TitleProvider {
|
||||
|
||||
private lateinit var sharedPreferenceManager: SharedPreferenceManager
|
||||
|
||||
|
|
@ -73,4 +73,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
|
||||
}
|
||||
|
||||
override fun getTitle(): String {
|
||||
return "Launcher Settings"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package eu.ottop.yamlauncher.settings
|
||||
|
||||
interface TitleProvider {
|
||||
fun getTitle(): String
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
android:id="@+id/settingsLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="40dp">
|
||||
android:paddingTop="5dp">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,24 +8,6 @@
|
|||
android:gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gestureMenuTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingRight="40dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:text="@string/select_an_app"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#C1F3F3F3"
|
||||
android:textSize="36sp" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/gestureAppRecycler"
|
||||
|
|
|
|||
|
|
@ -9,25 +9,6 @@
|
|||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hiddenMenuTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingRight="40dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:text="@string/unhide_an_app"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#C1F3F3F3"
|
||||
android:textSize="36sp" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/hiddenAppRecycler"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -9,25 +9,6 @@
|
|||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/locationMenuTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingRight="40dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:text="@string/find_your_city"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#C1F3F3F3"
|
||||
android:textSize="36sp" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/locationRecycler"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.YamLauncher" parent="Theme.Material3.DynamicColors.DayNight.NoActionBar">
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
</style>
|
||||
|
||||
<style name="SettingsTheme" parent="Theme.AppCompat.NoActionBar">
|
||||
<style name="SettingsTheme" parent="Theme.AppCompat">
|
||||
<item name="android:windowBackground">@color/settings_bg</item>
|
||||
<item name="android:windowShowWallpaper">false</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
|
|
@ -24,6 +24,13 @@
|
|||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||
<item name="android:enforceNavigationBarContrast">false</item>
|
||||
<item name="android:enforceStatusBarContrast">false</item>
|
||||
<item name="actionBarStyle">@style/TransparentActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="TransparentActionBar" parent="Widget.AppCompat.ActionBar">
|
||||
<!-- Transparent background for ActionBar -->
|
||||
<item name="background">@android:color/transparent</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="AppSearchView" parent="Widget.AppCompat.SearchView" >
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue