Add a DashboardContainerFragment to host DashboardSummary.
Eventually the container fragment will host more dashboard-type fragments. For now it's just DashboardSummary. Change-Id: I217ad71c2f2bbc4b7247c9dd2c3c2b8c8660d945
This commit is contained in:
21
res/layout/dashboard_container.xml
Normal file
21
res/layout/dashboard_container.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2016 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<android.support.v4.view.ViewPager
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/pager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
@@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v14.preference.PreferenceFragment;
|
import android.support.v14.preference.PreferenceFragment;
|
||||||
|
|
||||||
|
import com.android.internal.logging.MetricsLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instrumented fragment that logs visibility state.
|
* Instrumented fragment that logs visibility state.
|
||||||
*/
|
*/
|
||||||
@@ -28,6 +28,8 @@ public abstract class InstrumentedFragment extends PreferenceFragment {
|
|||||||
// Declare new temporary categories here, starting after this value.
|
// Declare new temporary categories here, starting after this value.
|
||||||
public static final int UNDECLARED = 100000;
|
public static final int UNDECLARED = 100000;
|
||||||
|
|
||||||
|
public static final int DASHBOARD_CONTAINER = UNDECLARED + 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declare the view of this category.
|
* Declare the view of this category.
|
||||||
*
|
*
|
||||||
|
@@ -49,6 +49,7 @@ import android.view.View.OnClickListener;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.SearchView;
|
import android.widget.SearchView;
|
||||||
|
|
||||||
import com.android.internal.util.ArrayUtils;
|
import com.android.internal.util.ArrayUtils;
|
||||||
import com.android.settings.Settings.WifiSettingsActivity;
|
import com.android.settings.Settings.WifiSettingsActivity;
|
||||||
import com.android.settings.accessibility.AccessibilitySettings;
|
import com.android.settings.accessibility.AccessibilitySettings;
|
||||||
@@ -67,7 +68,7 @@ import com.android.settings.applications.ProcessStatsUi;
|
|||||||
import com.android.settings.applications.UsageAccessDetails;
|
import com.android.settings.applications.UsageAccessDetails;
|
||||||
import com.android.settings.applications.WriteSettingsDetails;
|
import com.android.settings.applications.WriteSettingsDetails;
|
||||||
import com.android.settings.bluetooth.BluetoothSettings;
|
import com.android.settings.bluetooth.BluetoothSettings;
|
||||||
import com.android.settings.dashboard.DashboardSummary;
|
import com.android.settings.dashboard.DashboardContainerFragment;
|
||||||
import com.android.settings.dashboard.SearchResultsSummary;
|
import com.android.settings.dashboard.SearchResultsSummary;
|
||||||
import com.android.settings.datausage.DataUsageSummary;
|
import com.android.settings.datausage.DataUsageSummary;
|
||||||
import com.android.settings.deviceinfo.PrivateVolumeForget;
|
import com.android.settings.deviceinfo.PrivateVolumeForget;
|
||||||
@@ -610,7 +611,7 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
// Show Search affordance
|
// Show Search affordance
|
||||||
mDisplaySearch = true;
|
mDisplaySearch = true;
|
||||||
mInitialTitleResId = R.string.dashboard_title;
|
mInitialTitleResId = R.string.dashboard_title;
|
||||||
switchToFragment(DashboardSummary.class.getName(), null, false, false,
|
switchToFragment(DashboardContainerFragment.class.getName(), null, false, false,
|
||||||
mInitialTitleResId, mInitialTitle, false);
|
mInitialTitleResId, mInitialTitle, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.dashboard;
|
||||||
|
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.app.FragmentManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v13.app.FragmentPagerAdapter;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.android.settings.InstrumentedFragment;
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container for Dashboard fragments.
|
||||||
|
*/
|
||||||
|
public final class DashboardContainerFragment extends InstrumentedFragment {
|
||||||
|
|
||||||
|
private ViewPager mViewPager;
|
||||||
|
private DashboardViewPagerAdapter mPagerAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMetricsCategory() {
|
||||||
|
return DASHBOARD_CONTAINER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
|
||||||
|
final View content = inflater.inflate(R.layout.dashboard_container, parent, false);
|
||||||
|
mViewPager = (ViewPager) content.findViewById(R.id.pager);
|
||||||
|
mPagerAdapter = new DashboardViewPagerAdapter(getChildFragmentManager());
|
||||||
|
mViewPager.setAdapter(mPagerAdapter);
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class DashboardViewPagerAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
|
|
||||||
|
public DashboardViewPagerAdapter(FragmentManager fragmentManager) {
|
||||||
|
super(fragmentManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
return new DashboardSummary();
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"Position %d does not map to a valid dashboard fragment",
|
||||||
|
position));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user