Display setting and support in a tab layout - DO NOT MERGE

Bug: 28269035
Bug: 28139604
This commit is contained in:
Fan Zhang
2016-03-23 15:31:08 -07:00
parent 18bf2fbdac
commit 2869157ba9
21 changed files with 782 additions and 22 deletions

View File

@@ -0,0 +1,32 @@
<?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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorAccent">
<path
android:fillColor="#FFFFFF"
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52
22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8
-8,8zm3.5,-9c0.83,0 1.5,-0.67 1.5,-1.5S16.33,8 15.5,8 14,8.67 14,9.5s0.67,1.5
1.5,1.5zm-7,0c0.83,0 1.5,-0.67 1.5,-1.5S9.33,8 8.5,8 7,8.67 7,9.5 7.67,11
8.5,11zm3.5,6.5c2.33,0 4.31,-1.46 5.11,-3.5H6.89c0.8,2.04 2.78,3.5 5.11,3.5z"/>
</vector>

View File

@@ -0,0 +1,30 @@
<?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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorAccent">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M21,6h-2v9H6v2c0,0.55 0.45,1 1,1h11l4,4V7c0,-0.55 -0.45,-1
-1,-1zm-4,6V3c0,-0.55 -0.45,-1 -1,-1H3c-0.55,0 -1,0.45 -1,1v14l4,-4h10c0.55,0
1,-0.45 1,-1z"/>
</vector>

View File

@@ -0,0 +1,32 @@
<?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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorAccent">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48
10,-10S17.52,2 12,2zm1,17h-2v-2h2v2zm2.07,-7.75l-0.9,0.92C13.45,12.9 13,13.5
13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41
0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2H8c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88
-0.36,1.68 -0.93,2.25z"/>
</vector>

View 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"/>

View File

@@ -0,0 +1,23 @@
<?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.
-->
<com.android.settings.widget.SlidingTabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorPrimary"/>

View File

@@ -0,0 +1,22 @@
<?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.
-->
<View
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sliding_tab_selected_indicator"
android:layout_width="wrap_content"
android:layout_height="@dimen/pager_tabs_selected_indicator_height"
android:background="?android:attr/colorAccent"/>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@android:color/white"
android:gravity="center"
android:background="?android:attr/selectableItemBackground"
android:textAllCaps="true"
android:padding="@dimen/pager_tabs_title_padding"/>

View File

@@ -0,0 +1,45 @@
<?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.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:background="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.TileTitle"/>
<TextView
android:id="@+id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Small"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
</android.support.v7.widget.CardView>

View File

@@ -0,0 +1,67 @@
<?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.
-->
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:text="@string/support_escalation_title"
android:textColor="@color/material_grey_900"
android:textSize="16sp"/>
<LinearLayout
android:id="@+id/escalation_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingEnd="8dp"
android:paddingStart="8dp">
<include
android:id="@+id/escalation_by_phone"
layout="@layout/support_escalation_card"/>
<include
android:id="@+id/escalation_by_email"
layout="@layout/support_escalation_card"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"/>
<include
android:id="@+id/forum_tile"
layout="@layout/support_tile"/>
<include
android:id="@+id/article_tile"
layout="@layout/support_tile"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"/>
<include
android:id="@+id/feedback_tile"
layout="@layout/support_tile"/>
</LinearLayout>
</ScrollView>

View File

@@ -0,0 +1,41 @@
<?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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/dashboard_tile_minimum_height"
android:orientation="horizontal">
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
android:scaleType="centerInside"
android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"/>
<TextView
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.TileTitle"
android:ellipsize="end"
android:fadingEdge="horizontal"/>
</LinearLayout>

View File

@@ -59,6 +59,8 @@
<dimen name="appwidget_min_height">40dip</dimen>
<dimen name="pager_tabs_padding">0dp</dimen>
<dimen name="pager_tabs_title_padding">16dp</dimen>
<dimen name="pager_tabs_selected_indicator_height">3dp</dimen>
<!-- Minimum width for the popup for updating a user's photo. -->
<dimen name="update_user_photo_popup_min_width">300dip</dimen>

View File

@@ -7392,6 +7392,10 @@
<string name="notification_suggestion_title">Control lock screen notifications</string>
<!-- Summary of notification suggestion during optional steps of setup. [CHAR_LIMIT=80] -->
<string name="notification_suggestion_summary">Show or hide notification content</string>
<!-- Setting tab title for all setting options. [CHAR LIMIT=20] -->
<string name="page_tab_title_summary">All</string>
<!-- Setting tab title for support setting options. [CHAR LIMIT=20] -->
<string name="page_tab_title_support">Support</string>
<!-- Summary of developer options to set the smallest width of the screen [CHAR LIMIT=60]-->
<string name="developer_density_summary"><xliff:g name="count" example="320">%d</xliff:g> dp</string>
@@ -7414,4 +7418,34 @@
<!-- [CHAR LIMIT=60] Name of dev option called demo mode -->
<string name="demo_mode">Demo mode</string>
<!-- Activity title for deletion helper. [CHAR LIMIT=25] -->
<string name="deletion_helper_title">Remove from Device</string>
<!-- Preference group title for the list of apps to uninstall. [CHAR LIMIT=40]-->
<string name="deletion_helper_apps_title">Apps</string>
<!-- Summary of how much storage an app is using and the number of days since last use. [CHAR LIMIT=NONE]-->
<string name="deletion_helper_app_summary"><xliff:g id="used" example="1.2GB">%1$s</xliff:g>, last used <xliff:g id="days" example="67">%2$d</xliff:g> days ago</string>
<!-- Summary of how much storage an app is using when it has never been used before. [CHAR LIMIT=NONE]-->
<string name="deletion_helper_app_summary_never_used"><xliff:g id="used" example="1.2GB">%1$s</xliff:g>, never used before</string>
<!-- Summary of how much storage an app is using when its last use is unknown. [CHAR LIMIT=NONE]-->
<string name="deletion_helper_app_summary_unknown_used"><xliff:g id="used" example="1.2GB">%1$s</xliff:g>, not sure when last used</string>
<!-- Button which clears out storage in the deletion helper. [CHAR LIMIT=60]-->
<string name="deletion_helper_free_button">Free up <xliff:g id="freeable" example="1.2GB">%1$s</xliff:g></string>
<!-- Title text for calling or emailing customer support [CHAR LIMIT=80]-->
<string name="support_escalation_title">24/7 support</string>
<!-- Button label for contacting customer support by phone [CHAR LIMIT=20]-->
<string name="support_escalation_by_phone">Phone</string>
<!-- Button label for contacting customer support by email [CHAR LIMIT=20]-->
<string name="support_escalation_by_email">Email</string>
<!-- Button label for visiting help forum [CHAR LIMIT=60]-->
<string name="support_forum_title">Help forum</string>
<!-- Button label for visiting help articles [CHAR LIMIT=60]-->
<string name="support_articles_title">Help articles</string>
<!-- Button label for sending user feedback [CHAR LIMIT=60]-->
<string name="support_feedback_title">Send feedback</string>
</resources>

View File

@@ -16,11 +16,11 @@
package com.android.settings;
import com.android.internal.logging.MetricsLogger;
import android.os.Bundle;
import android.support.v14.preference.PreferenceFragment;
import com.android.internal.logging.MetricsLogger;
/**
* Instrumented fragment that logs visibility state.
*/
@@ -30,6 +30,9 @@ public abstract class InstrumentedFragment extends PreferenceFragment {
// Used by PreferenceActivity for the dummy fragment it adds, no useful data here.
public static final int PREFERENCE_ACTIVITY_FRAGMENT = UNDECLARED + 1;
public static final int DASHBOARD_CONTAINER = UNDECLARED + 2;
public static final int SUPPORT_FRAGMENT = UNDECLARED + 3;
/**
* Declare the view of this category.

View File

@@ -49,6 +49,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.SearchView;
import com.android.internal.util.ArrayUtils;
import com.android.settings.Settings.WifiSettingsActivity;
import com.android.settings.accessibility.AccessibilitySettings;
@@ -68,7 +69,7 @@ import com.android.settings.applications.UsageAccessDetails;
import com.android.settings.applications.WriteSettingsDetails;
import com.android.settings.applications.VrListenerSettings;
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.datausage.DataUsageSummary;
import com.android.settings.deviceinfo.PrivateVolumeForget;
@@ -613,7 +614,7 @@ public class SettingsActivity extends SettingsDrawerActivity
// Show Search affordance
mDisplaySearch = true;
mInitialTitleResId = R.string.dashboard_title;
switchToFragment(DashboardSummary.class.getName(), null, false, false,
switchToFragment(DashboardContainerFragment.class.getName(), null, false, false,
mInitialTitleResId, mInitialTitle, false);
}
}
@@ -687,7 +688,7 @@ public class SettingsActivity extends SettingsDrawerActivity
}
/**
* Sets the id of the view continaing the main content. Should be called before calling super's
* Sets the id of the view containing the main content. Should be called before calling super's
* onCreate.
*/
protected void setMainContentId(int contentId) {
@@ -729,7 +730,7 @@ public class SettingsActivity extends SettingsDrawerActivity
setTitleFromBackStack();
}
private int setTitleFromBackStack() {
private void setTitleFromBackStack() {
final int count = getFragmentManager().getBackStackEntryCount();
if (count == 0) {
@@ -738,13 +739,11 @@ public class SettingsActivity extends SettingsDrawerActivity
} else {
setTitle(mInitialTitle);
}
return 0;
return;
}
FragmentManager.BackStackEntry bse = getFragmentManager().getBackStackEntryAt(count - 1);
setTitleFromBackStackEntry(bse);
return count;
}
private void setTitleFromBackStackEntry(FragmentManager.BackStackEntry bse) {
@@ -1196,6 +1195,7 @@ public class SettingsActivity extends SettingsDrawerActivity
if (current != null && current instanceof SearchResultsSummary) {
mSearchResultsFragment = (SearchResultsSummary) current;
} else {
setContentHeaderView(null);
mSearchResultsFragment = (SearchResultsSummary) switchToFragment(
SearchResultsSummary.class.getName(), null, false, true,
R.string.search_results_title, null, true);

View File

@@ -0,0 +1,136 @@
/*
* 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.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.os.Bundle;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.settings.InstrumentedFragment;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.overlay.SupportFeatureProvider;
import com.android.settings.widget.SlidingTabLayout;
import com.android.settingslib.drawer.SettingsDrawerActivity;
import com.android.settingslib.HelpUtils;
/**
* Container for Dashboard fragments.
*/
public final class DashboardContainerFragment extends InstrumentedFragment {
private static final int INDEX_SUMMARY_FRAGMENT = 0;
private static final int INDEX_SUPPORT_FRAGMENT = 1;
private ViewPager mViewPager;
private View mHeaderView;
private DashboardViewPagerAdapter mPagerAdapter;
@Override
protected int getMetricsCategory() {
return DASHBOARD_CONTAINER;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@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(getContext(), getChildFragmentManager());
mViewPager.setAdapter(mPagerAdapter);
mHeaderView = inflater.inflate(R.layout.dashboard_container_header, parent, false);
((SlidingTabLayout) mHeaderView).setViewPager(mViewPager);
return content;
}
@Override
public void onResume() {
super.onResume();
if (mPagerAdapter.getCount() > 1) {
final Activity activity = getActivity();
if (activity instanceof SettingsDrawerActivity) {
((SettingsDrawerActivity) getActivity()).setContentHeaderView(mHeaderView);
}
}
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (getActivity() == null) return;
HelpUtils.prepareHelpMenuItem(getActivity(), menu, R.string.help_uri_dashboard,
getClass().getName());
}
private static final class DashboardViewPagerAdapter extends FragmentPagerAdapter {
private final Context mContext;
private final SupportFeatureProvider mSupportFeatureProvider;
public DashboardViewPagerAdapter(Context context, FragmentManager fragmentManager) {
super(fragmentManager);
mContext = context;
mSupportFeatureProvider =
FeatureFactory.getFactory(context).getSupportFeatureProvider();
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case INDEX_SUMMARY_FRAGMENT:
return mContext.getString(R.string.page_tab_title_summary);
case INDEX_SUPPORT_FRAGMENT:
return mContext.getString(R.string.page_tab_title_support);
}
return super.getPageTitle(position);
}
@Override
public Fragment getItem(int position) {
switch (position) {
case INDEX_SUMMARY_FRAGMENT:
return new DashboardSummary();
case INDEX_SUPPORT_FRAGMENT:
return new SupportFragment();
default:
throw new IllegalArgumentException(
String.format(
"Position %d does not map to a valid dashboard fragment",
position));
}
}
@Override
public int getCount() {
return mSupportFeatureProvider == null ? 1 : 2;
}
}
}

View File

@@ -21,13 +21,11 @@ import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settingslib.HelpUtils;
import com.android.settings.InstrumentedFragment;
import com.android.settings.R;
import com.android.settings.Settings;
@@ -83,7 +81,6 @@ public class DashboardSummary extends InstrumentedFragment
List<DashboardCategory> categories =
((SettingsActivity) getActivity()).getDashboardCategories();
mSummaryLoader = new SummaryLoader(getActivity(), categories);
setHasOptionsMenu(true);
Context context = getContext();
mConditionManager = ConditionManager.get(context);
mSuggestionParser = new SuggestionParser(context,
@@ -98,14 +95,6 @@ public class DashboardSummary extends InstrumentedFragment
super.onDestroy();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (getActivity() == null) return;
HelpUtils.prepareHelpMenuItem(getActivity(), menu, R.string.help_uri_dashboard,
getClass().getName());
}
@Override
public void onResume() {
long startTime = System.currentTimeMillis();

View File

@@ -0,0 +1,71 @@
/*
* 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.annotation.DrawableRes;
import android.annotation.IdRes;
import android.annotation.StringRes;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.settings.InstrumentedFragment;
import com.android.settings.R;
/**
* Fragment for support tab in SettingsGoogle.
*/
public final class SupportFragment extends InstrumentedFragment {
private View mContent;
@Override
protected int getMetricsCategory() {
return SUPPORT_FRAGMENT;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mContent = inflater.inflate(R.layout.support_fragment, container, false);
// Update escalation items.
updateEscalationCard(R.id.escalation_by_phone, R.string.support_escalation_by_phone);
updateEscalationCard(R.id.escalation_by_email, R.string.support_escalation_by_email);
// Update other support items.
updateSupportTile(R.id.forum_tile, R.drawable.ic_forum_24dp, R.string.support_forum_title);
updateSupportTile(R.id.article_tile, R.drawable.ic_help_24dp,
R.string.support_articles_title);
// Update feedback item.
updateSupportTile(R.id.feedback_tile, R.drawable.ic_feedback_24dp,
R.string.support_feedback_title);
return mContent;
}
private void updateEscalationCard(@IdRes int cardId, @StringRes int title) {
final View card = mContent.findViewById(cardId);
((TextView) card.findViewById(R.id.title)).setText(title);
}
private void updateSupportTile(@IdRes int tileId, @DrawableRes int icon, @StringRes int title) {
final View tile = mContent.findViewById(tileId);
((ImageView) tile.findViewById(android.R.id.icon)).setImageResource(icon);
((TextView) tile.findViewById(android.R.id.title)).setText(title);
}
}

View File

@@ -59,6 +59,8 @@ public abstract class FeatureFactory {
return sFactory;
}
public abstract SupportFeatureProvider getSupportFeatureProvider();
public static final class FactoryNotFoundException extends RuntimeException {
public FactoryNotFoundException(Throwable throwable) {
super("Unable to create factory. Did you misconfigure Proguard?", throwable);

View File

@@ -19,5 +19,11 @@ package com.android.settings.overlay;
/**
* {@link FeatureFactory} implementation for AOSP Settings.
*/
public class FeatureFactoryImpl extends FeatureFactory {
public final class FeatureFactoryImpl extends FeatureFactory {
@Override
public SupportFeatureProvider getSupportFeatureProvider() {
return null;
}
}

View File

@@ -0,0 +1,8 @@
package com.android.settings.overlay;
/**
* Feature provider for support tab.
*/
public interface SupportFeatureProvider {
}

View File

@@ -0,0 +1,168 @@
/*
* 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.widget;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.settings.R;
/**
* To be used with ViewPager to provide a tab indicator component which give constant feedback as
* to the user's scroll progress.
*/
public final class SlidingTabLayout extends FrameLayout implements View.OnClickListener {
private final LinearLayout mTitleView;
private final View mIndicatorView;
private final LayoutInflater mLayoutInflater;
private ViewPager mViewPager;
private int mSelectedPosition;
private float mSelectionOffset;
public SlidingTabLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mLayoutInflater = LayoutInflater.from(context);
mTitleView = new LinearLayout(context);
mTitleView.setGravity(Gravity.CENTER_HORIZONTAL);
mIndicatorView = mLayoutInflater.inflate(R.layout.sliding_tab_indicator_view, this, false);
addView(mTitleView, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
addView(mIndicatorView, mIndicatorView.getLayoutParams());
}
/**
* Sets the associated view pager. Note that the assumption here is that the pager content
* (number of tabs and tab titles) does not change after this call has been made.
*/
public void setViewPager(ViewPager viewPager) {
mTitleView.removeAllViews();
mViewPager = viewPager;
if (viewPager != null) {
viewPager.addOnPageChangeListener(new InternalViewPagerListener());
populateTabStrip();
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final int titleCount = mTitleView.getChildCount();
if (titleCount > 0) {
final int width = MeasureSpec.makeMeasureSpec(
mTitleView.getMeasuredWidth() / titleCount, MeasureSpec.EXACTLY);
final int height = MeasureSpec.makeMeasureSpec(
mIndicatorView.getMeasuredHeight(), MeasureSpec.EXACTLY);
mIndicatorView.measure(width, height);
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (mTitleView.getChildCount() > 0) {
mTitleView.layout(0, 0, mTitleView.getMeasuredWidth(), mTitleView.getMeasuredHeight());
final int indicatorBottom = getMeasuredHeight();
final int indicatorHeight = mIndicatorView.getMeasuredHeight();
mIndicatorView.layout(0, indicatorBottom - indicatorHeight,
mIndicatorView.getMeasuredWidth(), indicatorBottom);
}
}
@Override
public void onClick(View v) {
final int titleCount = mTitleView.getChildCount();
for (int i = 0; i < titleCount; i++) {
if (v == mTitleView.getChildAt(i)) {
mViewPager.setCurrentItem(i);
return;
}
}
}
private void onViewPagerPageChanged(int position, float positionOffset) {
mSelectedPosition = position;
mSelectionOffset = positionOffset;
mIndicatorView.setTranslationX(getIndicatorLeft());
}
private void populateTabStrip() {
final PagerAdapter adapter = mViewPager.getAdapter();
for (int i = 0; i < adapter.getCount(); i++) {
final TextView tabTitleView = (TextView) mLayoutInflater.inflate(
R.layout.sliding_tab_title_view, mTitleView, false);
tabTitleView.setText(adapter.getPageTitle(i));
tabTitleView.setOnClickListener(this);
mTitleView.addView(tabTitleView);
if (i == mViewPager.getCurrentItem()) {
tabTitleView.setSelected(true);
}
}
}
private int getIndicatorLeft() {
View selectedTitle = mTitleView.getChildAt(mSelectedPosition);
int left = selectedTitle.getLeft();
if (mSelectionOffset > 0f && mSelectedPosition < (getChildCount() - 1)) {
View nextTitle = mTitleView.getChildAt(mSelectedPosition + 1);
left = (int) (mSelectionOffset * nextTitle.getLeft()
+ (1.0f - mSelectionOffset) * left);
}
return left;
}
private final class InternalViewPagerListener implements ViewPager.OnPageChangeListener {
private int mScrollState;
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
final int titleCount = mTitleView.getChildCount();
if ((titleCount == 0) || (position < 0) || (position >= titleCount)) {
return;
}
onViewPagerPageChanged(position, positionOffset);
}
@Override
public void onPageScrollStateChanged(int state) {
mScrollState = state;
}
@Override
public void onPageSelected(int position) {
if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
onViewPagerPageChanged(position, 0f);
}
final int titleCount = getChildCount();
for (int i = 0; i < titleCount; i++) {
getChildAt(i).setSelected(position == i);
}
}
}
}