From 35711e7c1b27901b1118aa6b86af76b0f147f48d Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 19 Sep 2024 15:21:33 +0200 Subject: [PATCH] Implement collapsing toolbar --- app/src/main/AndroidManifest.xml | 7 +-- .../io/heckel/ntfy/ui/MainSettingsActivity.kt | 4 ++ .../io/heckel/ntfy/ui/PreferencesFragment.kt | 6 +++ .../res/layout/main_settings_activity.xml | 46 +++++++++++++++++-- app/src/main/res/xml/settings_preferences.xml | 1 + 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1f9b952..3fbe559 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -181,18 +181,13 @@ + android:process=":ui"/> diff --git a/app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt index 6675363..dd7f6e7 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt @@ -16,6 +16,10 @@ class MainSettingsActivity: AppCompatActivity() { mBinding = MainSettingsActivityBinding.inflate(layoutInflater) setContentView(mBinding.root) + mBinding.toolbar.setNavigationOnClickListener { + onBackPressed() + } + supportFragmentManager .beginTransaction() .replace(R.id.fragment_container, PreferencesFragment()) diff --git a/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt b/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt index fac1ee1..d5f0a5f 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt @@ -1,11 +1,17 @@ package io.heckel.ntfy.ui +import android.content.Context import android.content.Intent import android.os.Bundle +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem +import android.widget.Toolbar import androidx.preference.PreferenceFragmentCompat import androidx.preference.SwitchPreferenceCompat import io.heckel.ntfy.R import io.heckel.ntfy.service.SubscriberService +import io.heckel.ntfy.util.Log class PreferencesFragment : PreferenceFragmentCompat() { diff --git a/app/src/main/res/layout/main_settings_activity.xml b/app/src/main/res/layout/main_settings_activity.xml index 4d24822..0673195 100644 --- a/app/src/main/res/layout/main_settings_activity.xml +++ b/app/src/main/res/layout/main_settings_activity.xml @@ -1,11 +1,49 @@ - - + android:layout_height="wrap_content" + android:fitsSystemWindows="true"> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/settings_preferences.xml b/app/src/main/res/xml/settings_preferences.xml index 55da1ee..489df1f 100644 --- a/app/src/main/res/xml/settings_preferences.xml +++ b/app/src/main/res/xml/settings_preferences.xml @@ -2,6 +2,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto">