Dynamically update Top App Bar in Settings
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/textColorPrimary">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 20 11 L 7.83 11 L 13.42 5.41 L 12 4 L 4 12 L 12 20 L 13.41 18.59 L 7.83 13 L 20 13 L 20 11 Z"
|
||||
android:fillColor="#000"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,14 @@
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/textColorPrimary">
|
||||
<path
|
||||
android:name="path_2"
|
||||
android:pathData="M 3 17 L 3 19 L 9 19 L 9 17 L 3 17 Z M 3 5 L 3 7 L 13 7 L 13 5 L 3 5 Z M 13 21 L 13 19 L 21 19 L 21 17 L 13 17 L 13 15 L 11 15 L 11 21 L 13 21 Z M 7 9 L 7 11 L 3 11 L 3 13 L 7 13 L 7 15 L 9 15 L 9 9 L 7 9 Z M 21 13 L 21 11 L 11 11 L 11 13 L 21 13 Z M 15 9 L 17 9 L 17 7 L 21 7 L 21 5 L 17 5 L 17 3 L 15 3 L 15 9 Z"
|
||||
android:fillColor="#000"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,19 @@
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/textColorPrimary">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 12 5.5 L 18 10 L 18 19 L 6 19 L 6 10 L 12 5.5 Z M 12 3 L 4 9 L 4 21 L 20 21 L 20 9 L 12 3 Z"
|
||||
android:fillColor="#000000"
|
||||
android:strokeWidth="1"/>
|
||||
<path
|
||||
android:name="path_1"
|
||||
android:pathData="M 10 13 L 10 19 L 14 19 L 14 13 L 10 13 Z"
|
||||
android:fillColor="#000000"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
@@ -7,7 +7,6 @@
|
||||
android:key="pref_icon_badging"
|
||||
android:title="@string/notification_dots_title"
|
||||
android:persistent="false"
|
||||
app:iconSpaceReserved="false"
|
||||
android:widgetLayout="@layout/notification_pref_warning" >
|
||||
<intent android:action="android.settings.NOTIFICATION_SETTINGS">
|
||||
<extra
|
||||
|
||||
@@ -8,22 +8,19 @@
|
||||
android:title="@string/auto_add_shortcuts_label"
|
||||
android:summary="@string/auto_add_shortcuts_description"
|
||||
android:defaultValue="true"
|
||||
android:persistent="true"
|
||||
app:iconSpaceReserved="false"/>
|
||||
android:persistent="true" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="pref_allowRotation"
|
||||
android:title="@string/allow_rotation_title"
|
||||
android:summary="@string/allow_rotation_desc"
|
||||
android:defaultValue="@bool/allow_rotation"
|
||||
android:persistent="true"
|
||||
app:iconSpaceReserved="false"/>
|
||||
android:persistent="true" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="pref_grid_options"
|
||||
android:title="Enable grid options"
|
||||
android:defaultValue="false"
|
||||
android:persistent="true"
|
||||
app:iconSpaceReserved="false"/>
|
||||
android:persistent="true" />
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
@@ -5,11 +5,13 @@
|
||||
<Preference
|
||||
android:title="General"
|
||||
android:summary="Notification Dots"
|
||||
android:icon="@drawable/ic_general"
|
||||
android:fragment="ch.deletescape.lawnchair.settings.GeneralSettingsFragment" />
|
||||
|
||||
<Preference
|
||||
android:title="Home Screen"
|
||||
android:summary="Icon Pack, Grid Options"
|
||||
android:summary="Rotation, Grid Options"
|
||||
android:icon="@drawable/ic_home_screen"
|
||||
android:fragment="ch.deletescape.lawnchair.settings.HomeScreenSettingsFragment" />
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
@@ -3,6 +3,7 @@ package ch.deletescape.lawnchair.settings
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.preference.Preference
|
||||
@@ -12,9 +13,15 @@ import com.google.android.material.appbar.MaterialToolbar
|
||||
|
||||
class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
|
||||
private lateinit var topAppBar: MaterialToolbar
|
||||
private val context = this
|
||||
|
||||
private val fragmentListener = object: FragmentManager.FragmentLifecycleCallbacks() {
|
||||
override fun onFragmentViewCreated(fm: FragmentManager, fragment: Fragment, v: View, savedInstanceState: Bundle?) {
|
||||
if (fragment !is SettingsFragment && topAppBar.navigationIcon == null) {
|
||||
topAppBar.navigationIcon = ContextCompat.getDrawable(context, R.drawable.ic_back)
|
||||
} else {
|
||||
topAppBar.navigationIcon = null
|
||||
}
|
||||
topAppBar.title = (fragment as? TitledFragment)?.title
|
||||
}
|
||||
}
|
||||
@@ -23,6 +30,9 @@ class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPrefere
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.settings_activity)
|
||||
topAppBar = findViewById(R.id.top_app_bar)
|
||||
topAppBar.setNavigationOnClickListener {
|
||||
supportFragmentManager.popBackStack()
|
||||
}
|
||||
supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentListener, false)
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
|
||||
Reference in New Issue
Block a user