Loading packages/SettingsLib/CollapsingToolbarBaseActivity/res/layout/toolbar_base_layout.xml 0 → 100644 +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> packages/SettingsLib/CollapsingToolbarBaseActivity/src/com/android/settingslib/collapsingtoolbar/CollapsingToolbarBaseActivity.java +18 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading Loading @@ -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. */ Loading Loading
packages/SettingsLib/CollapsingToolbarBaseActivity/res/layout/toolbar_base_layout.xml 0 → 100644 +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>
packages/SettingsLib/CollapsingToolbarBaseActivity/src/com/android/settingslib/collapsingtoolbar/CollapsingToolbarBaseActivity.java +18 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading Loading @@ -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. */ Loading