Merge "Add RecyclerView for contextual settings homepage."

This commit is contained in:
TreeHugger Robot
2018-08-21 00:49:31 +00:00
committed by Android (Google) Code Review
4 changed files with 48 additions and 14 deletions

View File

@@ -21,10 +21,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@id/main_content"
android:layout_height="match_parent"
android:layout_width="match_parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/card_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<RelativeLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
@@ -45,7 +46,7 @@
android:layout_height="wrap_content"
android:src="@drawable/ic_search_floating_24dp"
app:backgroundTint="@android:color/white"
app:layout_anchor="@id/bar" />
app:layout_anchor="@id/bar"/>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bar"
@@ -58,17 +59,17 @@
app:fabAlignmentMode="end"
app:fabCradleDiameter="@dimen/homepage_bottombar_fab_cradle"
app:navigationIcon="@drawable/ic_list_24dp"
style="@style/Widget.MaterialComponents.BottomAppBar" />
style="@style/Widget.MaterialComponents.BottomAppBar"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<include layout="@layout/search_bar"
android:visibility="invisible" />
android:visibility="invisible"/>
<FrameLayout
android:id="@+id/bottom_sheet_fragment"
android:layout_below="@id/bottom_area"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"/>
</RelativeLayout>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2018 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.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/main_content"
android:layout_height="match_parent"
android:layout_width="match_parent"/>

View File

@@ -21,14 +21,14 @@ import android.content.Intent;
import android.os.Bundle;
import android.util.FeatureFlagUtils;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.homepage.HomepageFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.homepage.HomepageFragment;
public class SettingsHomepageActivity extends SettingsBaseActivity {
@Override
@@ -42,7 +42,7 @@ public class SettingsHomepageActivity extends SettingsBaseActivity {
finish();
return;
}
setContentView(R.layout.settings_homepage);
setContentView(R.layout.settings_homepage_container);
if (savedInstanceState == null) {
switchToFragment(this, R.id.main_content, HomepageFragment.class.getName());
}

View File

@@ -26,6 +26,8 @@ import android.view.ViewGroup;
import android.widget.Toolbar;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -45,6 +47,9 @@ public class HomepageFragment extends InstrumentedFragment {
private static final String SAVE_BOTTOMBAR_STATE = "bottombar_state";
private static final String SAVE_BOTTOM_FRAGMENT_LOADED = "bottom_fragment_loaded";
private RecyclerView mCardsContainer;
private LinearLayoutManager mLayoutManager;
private FloatingActionButton mSearchButton;
private BottomSheetBehavior mBottomSheetBehavior;
private View mBottomBar;
@@ -54,7 +59,13 @@ public class HomepageFragment extends InstrumentedFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.dashboard, container, false);
final View rootView = inflater.inflate(R.layout.settings_homepage,
container, false);
mCardsContainer = (RecyclerView) rootView.findViewById(R.id.card_container);
//TODO(b/111822407): May have to swap to GridLayoutManager
mLayoutManager = new LinearLayoutManager(getActivity());
mCardsContainer.setLayoutManager(mLayoutManager);
return rootView;
}