Add RecyclerView for contextual settings homepage.

Bug: 111676964
Test: robotests
Change-Id: I36002a9085ca12ef027726c5a600ba833dd4f47e
This commit is contained in:
Emily Chuang
2018-08-21 07:17:05 +08:00
parent 5d4bedb7d2
commit 150b2ba7ce
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"

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;
}