Set paddings on the portrait contact list view
Bug: 16568715
Change-Id: I3750285bf3354c4df1ea58a5cce30ecf7bcdcbcd
diff --git a/res/layout-sw600dp-land/contact_list_content.xml b/res/layout-sw600dp/contact_list_content.xml
similarity index 92%
rename from res/layout-sw600dp-land/contact_list_content.xml
rename to res/layout-sw600dp/contact_list_content.xml
index 7a23430..1b52068 100644
--- a/res/layout-sw600dp-land/contact_list_content.xml
+++ b/res/layout-sw600dp/contact_list_content.xml
@@ -25,18 +25,18 @@
<View
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_weight="@integer/people_activity_land_space_layout_weight"
+ android:layout_weight="@integer/people_activity_space_layout_weight"
android:background="@color/background_primary"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/contact_all_list_background_color"
- android:layout_weight="@integer/people_activity_land_list_view_layout_weight"
+ android:layout_weight="@integer/people_activity_list_view_layout_weight"
android:elevation="@dimen/people_activity_card_elevation"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_weight="@integer/people_activity_land_space_layout_weight"
+ android:layout_weight="@integer/people_activity_space_layout_weight"
android:background="@color/background_primary"/>
</LinearLayout>
<LinearLayout
diff --git a/res/layout-sw600dp-land/contact_tile_list.xml b/res/layout-sw600dp/contact_tile_list.xml
similarity index 90%
rename from res/layout-sw600dp-land/contact_tile_list.xml
rename to res/layout-sw600dp/contact_tile_list.xml
index 5b8200e..102a58d 100644
--- a/res/layout-sw600dp-land/contact_tile_list.xml
+++ b/res/layout-sw600dp/contact_tile_list.xml
@@ -26,18 +26,18 @@
<View
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_weight="@integer/people_activity_land_space_layout_weight"
+ android:layout_weight="@integer/people_activity_space_layout_weight"
android:background="@color/background_primary"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/contact_favorites_list_background_color"
- android:layout_weight="@integer/people_activity_land_list_view_layout_weight"
+ android:layout_weight="@integer/people_activity_list_view_layout_weight"
android:elevation="@dimen/people_activity_card_elevation"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_weight="@integer/people_activity_land_space_layout_weight"
+ android:layout_weight="@integer/people_activity_space_layout_weight"
android:background="@color/background_primary"/>
</LinearLayout>
<FrameLayout
diff --git a/res/layout-sw600dp-land/contacts_unavailable_fragment.xml b/res/layout-sw600dp/contacts_unavailable_fragment.xml
similarity index 87%
rename from res/layout-sw600dp-land/contacts_unavailable_fragment.xml
rename to res/layout-sw600dp/contacts_unavailable_fragment.xml
index eb3e5f2..8727359 100644
--- a/res/layout-sw600dp-land/contacts_unavailable_fragment.xml
+++ b/res/layout-sw600dp/contacts_unavailable_fragment.xml
@@ -26,18 +26,18 @@
<View
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_weight="@integer/people_activity_land_space_layout_weight"
+ android:layout_weight="@integer/people_activity_space_layout_weight"
android:background="@color/background_primary"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/contact_favorites_list_background_color"
- android:layout_weight="@integer/people_activity_land_list_view_layout_weight"
+ android:layout_weight="@integer/people_activity_list_view_layout_weight"
android:elevation="@dimen/people_activity_card_elevation"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_weight="@integer/people_activity_land_space_layout_weight"
+ android:layout_weight="@integer/people_activity_space_layout_weight"
android:background="@color/background_primary"/>
</LinearLayout>
<ScrollView
diff --git a/res/values-sw600dp-land/integers.xml b/res/values-sw600dp-land/integers.xml
index bcc008d..4bf44c0 100644
--- a/res/values-sw600dp-land/integers.xml
+++ b/res/values-sw600dp-land/integers.xml
@@ -18,4 +18,11 @@
<integer name="contact_tile_column_count_in_favorites">4</integer>
<integer name="contact_tile_column_count">3</integer>
+
+ <!-- Layout weight of space elements in PeopleActivity for favorites list and all
+ contacts list-->
+ <integer name="people_activity_space_layout_weight">1</integer>
+ <!-- Layout weight of ListViews in PeopleActivityfor tile favorites list and all
+ contacts list in PeopleActivity -->
+ <integer name="people_activity_list_view_layout_weight">3</integer>
</resources>
diff --git a/res/values-sw600dp/bools.xml b/res/values-sw600dp/bools.xml
new file mode 100644
index 0000000..2ef703c
--- /dev/null
+++ b/res/values-sw600dp/bools.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+<resources>
+
+ <bool name="contact_all_list_show_card_frame">true</bool>
+
+</resources>
diff --git a/res/values-sw600dp/integers.xml b/res/values-sw600dp/integers.xml
index c629f7e..ab2a52d 100644
--- a/res/values-sw600dp/integers.xml
+++ b/res/values-sw600dp/integers.xml
@@ -15,4 +15,10 @@
-->
<resources>
<integer name="contact_tile_column_count">2</integer>
+ <!-- Layout weight of space elements in PeopleActivity for favorites list and all
+ contacts list-->
+ <integer name="people_activity_space_layout_weight">1</integer>
+ <!-- Layout weight of ListViews in PeopleActivityfor tile favorites list and all
+ contacts list in PeopleActivity -->
+ <integer name="people_activity_list_view_layout_weight">5</integer>
</resources>
diff --git a/res/values/integers.xml b/res/values/integers.xml
index 3cd5711..0de1de1 100644
--- a/res/values/integers.xml
+++ b/res/values/integers.xml
@@ -24,10 +24,4 @@
<!-- Number of lines the QuickContact title can have -->
<integer name="quickcontact_title_lines">1</integer>
- <!-- Layout weight of space elements in PeopleActivity for favorites list and all
- contacts list when in sw600dp landscape. -->
- <integer name="people_activity_land_space_layout_weight">2</integer>
- <!-- Layout weight of ListViews in PeopleActivityfor tile favorites list and all
- contacts list in PeopleActivity when in sw600dp landscape. -->
- <integer name="people_activity_land_list_view_layout_weight">6</integer>
</resources>
diff --git a/src/com/android/contacts/list/ContactTileListFragment.java b/src/com/android/contacts/list/ContactTileListFragment.java
index 622c090..bce7bfe 100644
--- a/src/com/android/contacts/list/ContactTileListFragment.java
+++ b/src/com/android/contacts/list/ContactTileListFragment.java
@@ -97,15 +97,22 @@
mListView.setItemsCanFocus(true);
mListView.setAdapter(mAdapter);
- // If the device is in the sw600dp class and in landscape mode, set a padding on the list
+ // If the device is in the sw600dp class, set a padding on the list
// view so it appears in the center of the card in the layout.
if (mContactAllListShowCardFrame) {
SchedulingUtils.doOnPreDraw(mListView, true, new Runnable() {
@Override
public void run() {
+ Resources res = getResources();
+ int listSpaceWeight = res.getInteger(R.integer
+ .people_activity_space_layout_weight);
+ int listViewWeight = res.getInteger(R.integer
+ .people_activity_list_view_layout_weight);
+ double paddingPercent = (double) listSpaceWeight / (double)
+ (listSpaceWeight * 2 + listViewWeight);
int width = mListView.getWidth();
- mListView.setPadding(width / 4, mListView.getPaddingTop(),
- width / 4, mListView.getPaddingBottom());
+ mListView.setPadding((int) (width * paddingPercent), mListView.getPaddingTop(),
+ (int)(width * paddingPercent), mListView.getPaddingBottom());
}
});
}