diff --git a/res/drawable/ic_feedback_24dp.xml b/res/drawable/ic_feedback_24dp.xml new file mode 100644 index 00000000000..f616f955fd8 --- /dev/null +++ b/res/drawable/ic_feedback_24dp.xml @@ -0,0 +1,32 @@ + + + + + + \ No newline at end of file diff --git a/res/drawable/ic_forum_24dp.xml b/res/drawable/ic_forum_24dp.xml new file mode 100644 index 00000000000..34c086952e1 --- /dev/null +++ b/res/drawable/ic_forum_24dp.xml @@ -0,0 +1,30 @@ + + + + + + \ No newline at end of file diff --git a/res/drawable/ic_help_24dp.xml b/res/drawable/ic_help_24dp.xml new file mode 100644 index 00000000000..5fd1e79b28c --- /dev/null +++ b/res/drawable/ic_help_24dp.xml @@ -0,0 +1,32 @@ + + + + + + \ No newline at end of file diff --git a/res/layout/sliding_tab_title_view.xml b/res/layout/sliding_tab_title_view.xml index 6b91ed7f19f..0386345cb08 100644 --- a/res/layout/sliding_tab_title_view.xml +++ b/res/layout/sliding_tab_title_view.xml @@ -16,7 +16,7 @@ + + + + + + + + \ No newline at end of file diff --git a/res/layout/support_fragment.xml b/res/layout/support_fragment.xml new file mode 100644 index 00000000000..d81849d5923 --- /dev/null +++ b/res/layout/support_fragment.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/support_tile.xml b/res/layout/support_tile.xml new file mode 100644 index 00000000000..74d460e4bc6 --- /dev/null +++ b/res/layout/support_tile.xml @@ -0,0 +1,41 @@ + + + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 040e127e653..f4f906fe405 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -7393,6 +7393,8 @@ Show or hide notification content All + + Support %d dp @@ -7428,4 +7430,21 @@ Free up %1$s + + 24/7 support + + + Phone + + + Email + + + Help forum + + + Help articles + + + Send feedback diff --git a/src/com/android/settings/InstrumentedFragment.java b/src/com/android/settings/InstrumentedFragment.java index bb6a1bad5b9..a042096d8dd 100644 --- a/src/com/android/settings/InstrumentedFragment.java +++ b/src/com/android/settings/InstrumentedFragment.java @@ -32,6 +32,8 @@ 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 + 2; + public static final int SUPPORT_FRAGMENT = UNDECLARED + 3; + /** * Declare the view of this category. * diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index 3d6fef2d18c..c780695f791 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -103,7 +103,6 @@ import com.android.settings.notification.ZenModePrioritySettings; import com.android.settings.notification.ZenModeScheduleRuleSettings; import com.android.settings.notification.ZenModeSettings; import com.android.settings.notification.ZenModeVisualInterruptionSettings; -import com.android.settings.overlay.FeatureFactory; import com.android.settings.print.PrintJobSettingsFragment; import com.android.settings.print.PrintSettingsFragment; import com.android.settings.search.DynamicIndexableContentMonitor; diff --git a/src/com/android/settings/dashboard/DashboardContainerFragment.java b/src/com/android/settings/dashboard/DashboardContainerFragment.java index 5d8f092868b..142cfd33dc1 100644 --- a/src/com/android/settings/dashboard/DashboardContainerFragment.java +++ b/src/com/android/settings/dashboard/DashboardContainerFragment.java @@ -31,8 +31,11 @@ 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.HelpUtils; +import com.android.settingslib.drawer.SettingsDrawerActivity; /** * Container for Dashboard fragments. @@ -40,6 +43,7 @@ import com.android.settingslib.HelpUtils; 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; @@ -70,7 +74,12 @@ public final class DashboardContainerFragment extends InstrumentedFragment { @Override public void onResume() { super.onResume(); - final Activity activity = getActivity(); + if (mPagerAdapter.getCount() > 1) { + final Activity activity = getActivity(); + if (activity instanceof SettingsDrawerActivity) { + ((SettingsDrawerActivity) getActivity()).setContentHeaderView(mHeaderView); + } + } } @Override @@ -84,10 +93,13 @@ public final class DashboardContainerFragment extends InstrumentedFragment { 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 @@ -95,6 +107,8 @@ public final class DashboardContainerFragment extends InstrumentedFragment { 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); } @@ -104,6 +118,8 @@ public final class DashboardContainerFragment extends InstrumentedFragment { switch (position) { case INDEX_SUMMARY_FRAGMENT: return new DashboardSummary(); + case INDEX_SUPPORT_FRAGMENT: + return new SupportFragment(); default: throw new IllegalArgumentException( String.format( @@ -114,7 +130,7 @@ public final class DashboardContainerFragment extends InstrumentedFragment { @Override public int getCount() { - return 1; + return mSupportFeatureProvider == null ? 1 : 2; } } } diff --git a/src/com/android/settings/dashboard/SupportFragment.java b/src/com/android/settings/dashboard/SupportFragment.java new file mode 100644 index 00000000000..2e4fedc5995 --- /dev/null +++ b/src/com/android/settings/dashboard/SupportFragment.java @@ -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); + } +} diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java index b0b2a3f48eb..4dc9ba2eb45 100644 --- a/src/com/android/settings/overlay/FeatureFactory.java +++ b/src/com/android/settings/overlay/FeatureFactory.java @@ -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); diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java index 036b4e7075f..d884080a823 100644 --- a/src/com/android/settings/overlay/FeatureFactoryImpl.java +++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java @@ -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; + } + } diff --git a/src/com/android/settings/overlay/SupportFeatureProvider.java b/src/com/android/settings/overlay/SupportFeatureProvider.java new file mode 100644 index 00000000000..3b654f469ae --- /dev/null +++ b/src/com/android/settings/overlay/SupportFeatureProvider.java @@ -0,0 +1,8 @@ +package com.android.settings.overlay; + +/** + * Feature provider for support tab. + */ +public interface SupportFeatureProvider { + +}