diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-08-18 11:59:19 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2011-08-18 15:30:17 -0700 |
commit | b654cbb896a6e6db9ecec164476b0ac4a3e72774 (patch) | |
tree | 943ad7937bd4e6a391fcdc7f7c86299fecf9c6f1 | |
parent | eee01c451051234e99ea612079ec533c8f9ad9c6 (diff) | |
download | packages_apps_settings-b654cbb896a6e6db9ecec164476b0ac4a3e72774.zip packages_apps_settings-b654cbb896a6e6db9ecec164476b0ac4a3e72774.tar.gz packages_apps_settings-b654cbb896a6e6db9ecec164476b0ac4a3e72774.tar.bz2 |
More TabWidget and padding tweaks to match spec.
Also fix NPE in UserDictionarySettings.
Bug: 5184822
Change-Id: I082981c3bcf9b1e6575dcf9f42495a17f0ec8672
-rw-r--r-- | res/layout-h720dp/tab_widget.xml | 29 | ||||
-rw-r--r-- | res/layout-w720dp/tab_widget.xml | 29 | ||||
-rw-r--r-- | res/layout/data_usage_chart.xml | 4 | ||||
-rw-r--r-- | res/layout/data_usage_header.xml | 4 | ||||
-rw-r--r-- | res/layout/data_usage_summary.xml | 18 | ||||
-rwxr-xr-x | res/layout/manage_applications.xml | 3 | ||||
-rw-r--r-- | res/layout/manage_apps_tab_content.xml | 18 | ||||
-rw-r--r-- | res/layout/tab_widget.xml | 30 | ||||
-rw-r--r-- | src/com/android/settings/DataUsageSummary.java | 4 | ||||
-rw-r--r-- | src/com/android/settings/UserDictionarySettings.java | 7 | ||||
-rw-r--r-- | src/com/android/settings/Utils.java | 29 | ||||
-rw-r--r-- | src/com/android/settings/applications/ManageApplications.java | 22 |
12 files changed, 151 insertions, 46 deletions
diff --git a/res/layout-h720dp/tab_widget.xml b/res/layout-h720dp/tab_widget.xml new file mode 100644 index 0000000..5a4e580 --- /dev/null +++ b/res/layout-h720dp/tab_widget.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 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. +--> + +<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:scrollbars="none"> + + <TabWidget + android:id="@android:id/tabs" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" + style="?android:attr/tabWidgetStyle" /> + +</HorizontalScrollView> diff --git a/res/layout-w720dp/tab_widget.xml b/res/layout-w720dp/tab_widget.xml new file mode 100644 index 0000000..5a4e580 --- /dev/null +++ b/res/layout-w720dp/tab_widget.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 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. +--> + +<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:scrollbars="none"> + + <TabWidget + android:id="@android:id/tabs" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" + style="?android:attr/tabWidgetStyle" /> + +</HorizontalScrollView> diff --git a/res/layout/data_usage_chart.xml b/res/layout/data_usage_chart.xml index 4dae248..7f63f3f 100644 --- a/res/layout/data_usage_chart.xml +++ b/res/layout/data_usage_chart.xml @@ -20,8 +20,8 @@ android:id="@+id/chart" android:layout_width="match_parent" android:layout_height="@dimen/data_usage_chart_height" - android:paddingLeft="@*android:dimen/preference_item_padding_side" - android:paddingRight="@*android:dimen/preference_item_padding_side" + android:paddingLeft="16dip" + android:paddingRight="16dip" android:paddingTop="16dip" android:paddingBottom="16dip" settings:optimalWidth="@dimen/data_usage_chart_optimalWidth" diff --git a/res/layout/data_usage_header.xml b/res/layout/data_usage_header.xml index ba41c88..b27d88f 100644 --- a/res/layout/data_usage_header.xml +++ b/res/layout/data_usage_header.xml @@ -17,7 +17,9 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical"> + android:orientation="vertical" + android:clipChildren="false" + android:clipToPadding="false"> <FrameLayout android:id="@+id/network_switches_container" diff --git a/res/layout/data_usage_summary.xml b/res/layout/data_usage_summary.xml index d59e0d6..b754d0c 100644 --- a/res/layout/data_usage_summary.xml +++ b/res/layout/data_usage_summary.xml @@ -25,20 +25,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - <HorizontalScrollView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="0" - android:scrollbars="none"> - - <TabWidget - android:id="@android:id/tabs" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - style="?android:attr/tabWidgetStyle" /> - - </HorizontalScrollView> + <include layout="@layout/tab_widget" /> <!-- give an empty content area to make tabhost happy --> <FrameLayout @@ -51,6 +38,9 @@ android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" + android:scrollbarStyle="@*android:integer/preference_fragment_scrollbarStyle" + android:clipChildren="false" + android:clipToPadding="false" android:smoothScrollbar="false" /> </LinearLayout> diff --git a/res/layout/manage_applications.xml b/res/layout/manage_applications.xml index 95d4847..7df2f54 100755 --- a/res/layout/manage_applications.xml +++ b/res/layout/manage_applications.xml @@ -29,7 +29,8 @@ <ListView android:id="@android:id/list" android:drawSelectorOnTop="false" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:scrollbarStyle="@*android:integer/preference_fragment_scrollbarStyle" /> <TextView android:id="@android:id/empty" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/res/layout/manage_apps_tab_content.xml b/res/layout/manage_apps_tab_content.xml index b8cee87..3898227 100644 --- a/res/layout/manage_apps_tab_content.xml +++ b/res/layout/manage_apps_tab_content.xml @@ -28,21 +28,8 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - - <HorizontalScrollView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="0" - android:scrollbars="none"> - - <TabWidget - android:id="@android:id/tabs" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - style="?android:attr/tabWidgetStyle" /> - - </HorizontalScrollView> + + <include layout="@layout/tab_widget" /> <FrameLayout android:id="@android:id/tabcontent" @@ -52,4 +39,3 @@ </LinearLayout> </TabHost> - diff --git a/res/layout/tab_widget.xml b/res/layout/tab_widget.xml new file mode 100644 index 0000000..a6adc5d --- /dev/null +++ b/res/layout/tab_widget.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 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. +--> + +<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:scrollbars="none" + android:fillViewport="true"> + + <TabWidget + android:id="@android:id/tabs" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + style="?android:attr/tabWidgetStyle" /> + +</HorizontalScrollView> diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java index b99264f..a6170c7 100644 --- a/src/com/android/settings/DataUsageSummary.java +++ b/src/com/android/settings/DataUsageSummary.java @@ -43,6 +43,7 @@ import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH; import static android.text.format.DateUtils.FORMAT_SHOW_DATE; import static android.text.format.Time.TIMEZONE_UTC; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; +import static com.android.settings.Utils.prepareCustomPreferencesList; import android.animation.LayoutTransition; import android.app.AlertDialog; @@ -272,6 +273,9 @@ public class DataUsageSummary extends Fragment { mTabWidget = (TabWidget) view.findViewById(android.R.id.tabs); mListView = (ListView) view.findViewById(android.R.id.list); + // adjust padding around tabwidget as needed + prepareCustomPreferencesList(container, view, mListView); + mTabHost.setup(); mTabHost.setOnTabChangedListener(mTabListener); diff --git a/src/com/android/settings/UserDictionarySettings.java b/src/com/android/settings/UserDictionarySettings.java index be8f453..496947b 100644 --- a/src/com/android/settings/UserDictionarySettings.java +++ b/src/com/android/settings/UserDictionarySettings.java @@ -96,6 +96,13 @@ public class UserDictionarySettings extends ListFragment implements DialogCreata } @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate( + com.android.internal.R.layout.preference_list_fragment, container, false); + } + + @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index b725d56..73a9a30 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -20,8 +20,8 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.graphics.drawable.Drawable; @@ -31,13 +31,17 @@ import android.os.BatteryManager; import android.os.Bundle; import android.os.SystemProperties; import android.preference.Preference; -import android.preference.PreferenceGroup; import android.preference.PreferenceActivity.Header; +import android.preference.PreferenceFrameLayout; +import android.preference.PreferenceGroup; import android.telephony.TelephonyManager; import android.text.TextUtils; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ListView; +import android.widget.TabWidget; import java.net.InetAddress; -import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -365,4 +369,23 @@ public class Utils { return statusString; } + + /** + * Prepare a custom preferences layout, moving padding to {@link ListView} + * when outside scrollbars are requested. Usually used to display + * {@link ListView} and {@link TabWidget} with correct padding. + */ + public static void prepareCustomPreferencesList(ViewGroup parent, View child, ListView list) { + final boolean movePadding = list.getScrollBarStyle() == View.SCROLLBARS_OUTSIDE_OVERLAY; + if (movePadding && parent instanceof PreferenceFrameLayout) { + ((PreferenceFrameLayout.LayoutParams) child.getLayoutParams()).removeBorders = true; + + final Resources res = list.getResources(); + final int paddingSide = res.getDimensionPixelSize( + com.android.internal.R.dimen.preference_fragment_padding_side); + final int paddingBottom = res.getDimensionPixelSize( + com.android.internal.R.dimen.preference_fragment_padding_bottom); + list.setPadding(paddingSide, 0, paddingSide, paddingBottom); + } + } } diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java index 68c942d..4f17d81 100644 --- a/src/com/android/settings/applications/ManageApplications.java +++ b/src/com/android/settings/applications/ManageApplications.java @@ -16,11 +16,7 @@ package com.android.settings.applications; -import com.android.internal.content.PackageHelper; -import com.android.settings.R; -import com.android.settings.Settings.RunningServicesActivity; -import com.android.settings.Settings.StorageUseActivity; -import com.android.settings.applications.ApplicationsState.AppEntry; +import static com.android.settings.Utils.prepareCustomPreferencesList; import android.app.Activity; import android.app.Fragment; @@ -58,6 +54,12 @@ import android.widget.ListView; import android.widget.TabHost; import android.widget.TextView; +import com.android.internal.content.PackageHelper; +import com.android.settings.R; +import com.android.settings.Settings.RunningServicesActivity; +import com.android.settings.Settings.StorageUseActivity; +import com.android.settings.applications.ApplicationsState.AppEntry; + import java.util.ArrayList; import java.util.Comparator; @@ -618,9 +620,8 @@ public class ManageApplications extends Fragment implements mCreatedRunning = mResumedRunning = false; mCurView = VIEW_NOTHING; - - View tabRoot = mInflater.inflate(R.layout.manage_apps_tab_content, null); - mTabHost = (TabHost)tabRoot.findViewById(com.android.internal.R.id.tabhost); + + mTabHost = (TabHost) mInflater.inflate(R.layout.manage_apps_tab_content, container, false); mTabHost.setup(); final TabHost tabHost = mTabHost; tabHost.addTab(tabHost.newTabSpec(TAB_DOWNLOADED) @@ -644,7 +645,10 @@ public class ManageApplications extends Fragment implements tabHost.setCurrentTabByTag(mDefaultTab); tabHost.setOnTabChangedListener(this); - return tabRoot; + // adjust padding around tabwidget as needed + prepareCustomPreferencesList(container, mTabHost, mListView); + + return mTabHost; } @Override |