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

Commit c0b90aef authored by Mill Chen's avatar Mill Chen
Browse files

Support regular toolbar

To make Settings UI consistent, the different types of toolbar will be
applied according to what the android platform is. The collapsing
toolbar is only supported on S or higher and the general toolbar will be
shown on the other platforms.

Bug: 179380824
Test: visual verified
Change-Id: Ia59f9ec22010708c46ece55d69b47870ed16f021
parent af76755f
Loading
Loading
Loading
Loading
+36 −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.
-->
<!-- The main content view -->
<LinearLayout
    android:id="@+id/content_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:transitionGroup="true"
    android:orientation="vertical">
    <Toolbar
        android:id="@+id/action_bar"
        style="?android:attr/actionBarStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="?android:attr/actionBarTheme" />
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>
+18 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.ViewGroup;
import android.widget.Toolbar;

import androidx.annotation.Nullable;
import androidx.core.os.BuildCompat;
import androidx.fragment.app.FragmentActivity;

import com.google.android.material.appbar.CollapsingToolbarLayout;
@@ -40,8 +41,15 @@ public class CollapsingToolbarBaseActivity extends FragmentActivity {
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // TODO(b/181723278): Update the version check after SDK for S is finalized
        // The collapsing toolbar is only supported if the android platform version is S or higher.
        // Otherwise the regular action bar will be shown.
        if (BuildCompat.isAtLeastS()) {
            super.setContentView(R.layout.collapsing_toolbar_base_layout);
            mCollapsingToolbarLayout = findViewById(R.id.collapsing_toolbar);
        } else {
            super.setContentView(R.layout.toolbar_base_layout);
        }

        final Toolbar toolbar = findViewById(R.id.action_bar);
        setActionBar(toolbar);
@@ -90,6 +98,14 @@ public class CollapsingToolbarBaseActivity extends FragmentActivity {
        super.setTitle(titleId);
    }

    @Override
    public boolean onNavigateUp() {
        if (!super.onNavigateUp()) {
            finish();
        }
        return true;
    }

    /**
     * Returns an instance of collapsing toolbar.
     */