Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ad0e3dc authored by Mill Chen's avatar Mill Chen
Browse files

Create a collapsing toolbar based activity

On Android S, each of subsetting pages will have a collapsing toolbar to
enlarge its title. However, there are many different pages from
differennt apps. So we extracted a base activity with collapsing toolbar
layout so it is easier to enbale a collapsing toolbar in their own
pages.

Bug: 179380824
Test: visual verified
Change-Id: Ic505d65320081589d1e1b5eb4bd2af7a06e60d39
parent 2441a6bb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ java_defaults {
        "SettingsLibBannerMessagePreference",
        "SettingsLibFooterPreference",
        "SettingsLibUsageProgressBarPreference",
        "SettingsLibCollapsingToolbarBaseActivity",
    ],
}

+14 −0
Original line number Diff line number Diff line
android_library {
    name: "SettingsLibCollapsingToolbarBaseActivity",

    srcs: ["src/**/*.java"],
    resource_dirs: ["res"],

    static_libs: [
        "androidx.annotation_annotation",
        "androidx.core_core",
        "com.google.android.material_material",
    ],
    sdk_version: "system_current",
    min_sdk_version: "21",
}
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2021 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.android.settingslib.collapsingtoolbar">

    <uses-sdk android:minSdkVersion="21" />

</manifest>
+60 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2021 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/content_parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:transitionGroup="true">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:theme="@style/Theme.CollapsingToolbar.Settings">

        <com.android.settingslib.collapsingtoolbar.AdjustableToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:background="?android:attr/colorPrimary"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:maxLines="3"
            app:contentScrim="?android:attr/colorPrimary"
            app:collapsedTitleTextAppearance="@style/CollapsingToolbarTitle.Collapsed"
            app:statusBarScrim="?android:attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:expandedTitleMarginStart="18dp"
            app:expandedTitleMarginEnd="18dp"
            app:toolbarId="@id/action_bar">

            <Toolbar
                android:id="@+id/action_bar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:theme="?android:attr/actionBarTheme"
                app:layout_collapseMode="pin"/>

        </com.android.settingslib.collapsingtoolbar.AdjustableToolbarLayout>
    </com.google.android.material.appbar.AppBarLayout>

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2021 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<resources>
    <style name="Theme.CollapsingToolbar.Settings"
           parent="@style/Theme.MaterialComponents.DayNight">
        <item name="colorPrimary">@*android:color/primary_dark_device_default_settings</item>
        <item name="colorAccent">@*android:color/accent_device_default_dark</item>
    </style>
</resources>
 No newline at end of file
Loading