Implement collapsing toolbar
This commit is contained in:
parent
4f97fee55c
commit
35711e7c1b
5 changed files with 54 additions and 10 deletions
|
@ -181,18 +181,13 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.MainSettingsActivity"
|
android:name=".ui.MainSettingsActivity"
|
||||||
android:theme="@style/PreferenceTheme"
|
android:theme="@style/PreferenceTheme"
|
||||||
android:icon="@drawable/ic_notification"
|
android:process=":ui"/>
|
||||||
android:label="@string/app_name"
|
|
||||||
android:process=":ui"
|
|
||||||
android:roundIcon="@drawable/ic_notification"/>
|
|
||||||
|
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name=".ui.SettingsActivityLink"
|
android:name=".ui.SettingsActivityLink"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@drawable/ic_notification"
|
|
||||||
android:label="@string/eos_settings_title"
|
android:label="@string/eos_settings_title"
|
||||||
android:process=":ui"
|
android:process=":ui"
|
||||||
android:roundIcon="@drawable/ic_notification"
|
|
||||||
android:targetActivity=".ui.MainSettingsActivity">
|
android:targetActivity=".ui.MainSettingsActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.android.settings.action.EXTRA_SETTINGS" />
|
<action android:name="com.android.settings.action.EXTRA_SETTINGS" />
|
||||||
|
|
|
@ -16,6 +16,10 @@ class MainSettingsActivity: AppCompatActivity() {
|
||||||
mBinding = MainSettingsActivityBinding.inflate(layoutInflater)
|
mBinding = MainSettingsActivityBinding.inflate(layoutInflater)
|
||||||
setContentView(mBinding.root)
|
setContentView(mBinding.root)
|
||||||
|
|
||||||
|
mBinding.toolbar.setNavigationOnClickListener {
|
||||||
|
onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
supportFragmentManager
|
supportFragmentManager
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.replace(R.id.fragment_container, PreferencesFragment())
|
.replace(R.id.fragment_container, PreferencesFragment())
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
package io.heckel.ntfy.ui
|
package io.heckel.ntfy.ui
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
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.PreferenceFragmentCompat
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import io.heckel.ntfy.R
|
import io.heckel.ntfy.R
|
||||||
import io.heckel.ntfy.service.SubscriberService
|
import io.heckel.ntfy.service.SubscriberService
|
||||||
|
import io.heckel.ntfy.util.Log
|
||||||
|
|
||||||
class PreferencesFragment : PreferenceFragmentCompat() {
|
class PreferencesFragment : PreferenceFragmentCompat() {
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,49 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<FrameLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/fragment_container"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="wrap_content"
|
||||||
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
|
android:id="@+id/collapsing_toolbar"
|
||||||
|
style="?attr/collapsingToolbarLayoutLargeStyle"
|
||||||
|
android:background="@color/e_background"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
|
||||||
|
android:layout_height="?attr/collapsingToolbarLayoutLargeSize">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
app:navigationIcon="@drawable/e_ic_back"
|
||||||
|
app:title="@string/eos_settings_title"
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:background="@color/e_background"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:layout_collapseMode="pin" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fillViewport="true"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fragment_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -2,6 +2,7 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
|
app:icon="@drawable/ic_notification"
|
||||||
app:key="isEnabled"
|
app:key="isEnabled"
|
||||||
app:defaultValue="false"
|
app:defaultValue="false"
|
||||||
app:title="@string/eos_settings_enable_title"
|
app:title="@string/eos_settings_enable_title"
|
||||||
|
|
Loading…
Reference in a new issue