Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 405c1af7 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Manual merge. Preference activity changes to work on smaller tablet screens and phones.

Padding around fragments and to the left of preference items
adjusted for different display sizes.

Change-Id: I2d29e5525c381092a3f1d2fb1265ce07db893d78
parent 1b9b34ad
Loading
Loading
Loading
Loading
+19 −10
Original line number Diff line number Diff line
@@ -472,11 +472,15 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
        
        final View layout = layoutInflater.inflate(mLayoutResId, parent, false); 
        
        final ViewGroup widgetFrame = (ViewGroup) layout
                .findViewById(com.android.internal.R.id.widget_frame);
        if (widgetFrame != null) {
            if (mWidgetLayoutResId != 0) {
            final ViewGroup widgetFrame = (ViewGroup)layout.findViewById(com.android.internal.R.id.widget_frame);
                layoutInflater.inflate(mWidgetLayoutResId, widgetFrame);
            } else {
                widgetFrame.setVisibility(View.GONE);
            }
        }

        return layout;
    }
    
@@ -514,7 +518,8 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
        }
        
        ImageView imageView = (ImageView) view.findViewById(com.android.internal.R.id.icon);
        if (imageView != null && (mIconResId != 0 || mIcon != null)) {
        if (imageView != null) {
            if (mIconResId != 0 || mIcon != null) {
                if (mIcon == null) {
                    mIcon = getContext().getResources().getDrawable(mIconResId);
                }
@@ -522,6 +527,9 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
                    imageView.setImageDrawable(mIcon);
                }
            }
            imageView.setVisibility(mIcon != null ? View.VISIBLE : View.GONE);
        }

        if (mShouldDisableView) {
            setEnabledStateOnViews(view, isEnabled());
        }
@@ -633,6 +641,7 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
    public void setIcon(Drawable icon) {
        if ((icon == null && mIcon != null) || (icon != null && mIcon != icon)) {
            mIcon = icon;

            notifyChanged();
        }
    }
+9 −27
Original line number Diff line number Diff line
@@ -18,9 +18,6 @@ package android.preference;

import com.android.internal.util.XmlUtils;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentBreadCrumbs;
@@ -44,8 +41,8 @@ import android.util.TypedValue;
import android.util.Xml;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.ArrayAdapter;
import android.widget.Button;
@@ -58,6 +55,9 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

/**
 * This is the base class for an activity to show a hierarchy of preferences
 * to the user.  Prior to {@link android.os.Build.VERSION_CODES#HONEYCOMB}
@@ -503,12 +503,7 @@ public abstract class PreferenceActivity extends ListActivity implements
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (getResources().getConfiguration().isLayoutSizeAtLeast(
                Configuration.SCREENLAYOUT_SIZE_LARGE)) {
            setContentView(com.android.internal.R.layout.preference_list_content_large);
        } else {
        setContentView(com.android.internal.R.layout.preference_list_content);
        }

        mListFooter = (FrameLayout)findViewById(com.android.internal.R.id.list_footer);
        mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs_frame);
@@ -585,12 +580,7 @@ public abstract class PreferenceActivity extends ListActivity implements
        } else {
            // If there are no headers, we are in the old "just show a screen
            // of preferences" mode.
            if (getResources().getConfiguration().isLayoutSizeAtLeast(
                    Configuration.SCREENLAYOUT_SIZE_LARGE)) {
                setContentView(com.android.internal.R.layout.preference_list_content_single_large);
            } else {
            setContentView(com.android.internal.R.layout.preference_list_content_single);
            }
            mListFooter = (FrameLayout) findViewById(com.android.internal.R.id.list_footer);
            mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs);
            mPreferenceManager = new PreferenceManager(this, FIRST_REQUEST_CODE);
@@ -674,17 +664,9 @@ public abstract class PreferenceActivity extends ListActivity implements
     * enough.
     */
    public boolean onIsMultiPane() {
        Configuration config = getResources().getConfiguration();
        if ((config.screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK)
                == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
            return true;
        }
        if ((config.screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK)
                == Configuration.SCREENLAYOUT_SIZE_LARGE
                && config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            return true;
        }
        return false;
        boolean preferMultiPane = getResources().getBoolean(
                com.android.internal.R.bool.preferences_prefer_dual_pane);
        return preferMultiPane;
    }

    /**
+2 −8
Original line number Diff line number Diff line
@@ -152,14 +152,8 @@ public abstract class PreferenceFragment extends Fragment implements
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        if (getResources().getConfiguration().isLayoutSizeAtLeast(
                Configuration.SCREENLAYOUT_SIZE_LARGE)) {
            return inflater.inflate(com.android.internal.R.layout.preference_list_fragment_large,
                    container, false);
        } else {
            return inflater.inflate(com.android.internal.R.layout.preference_list_fragment,
                    container, false);
        }
        return inflater.inflate(com.android.internal.R.layout.preference_list_fragment, container,
                false);
    }

    @Override
+12 −26
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
<!--
/* //device/apps/common/assets/res/layout/list_content.xml
**
** Copyright 2011, The Android Open Source Project
** Copyright 2006, 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.
@@ -27,6 +27,8 @@
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_marginTop="@dimen/preference_screen_top_margin"
        android:layout_marginBottom="@dimen/preference_screen_bottom_margin"
        android:layout_weight="1">

        <LinearLayout
@@ -36,14 +38,15 @@
            android:layout_height="match_parent"
            android:layout_marginRight="@dimen/preference_screen_side_margin_negative"
            android:layout_marginLeft="@dimen/preference_screen_side_margin"
            android:layout_marginTop="32dp"
            android:layout_marginBottom="32dp"
            android:layout_weight="10">
            android:layout_weight="@integer/preferences_left_pane_weight">

            <ListView android:id="@android:id/list"
                android:layout_width="match_parent"
                android:layout_height="0px"
                android:layout_weight="1"
                android:paddingTop="16dp"
                android:paddingBottom="16dp"

                android:drawSelectorOnTop="false"
                android:cacheColorHint="@android:color/transparent"
                android:listPreferredItemHeight="48dp"
@@ -60,39 +63,22 @@
                android:id="@+id/prefs_frame"
                android:layout_width="0px"
                android:layout_height="match_parent"
                android:layout_weight="20"
                android:layout_weight="@integer/preferences_right_pane_weight"
                android:layout_marginLeft="@dimen/preference_screen_side_margin"
                android:layout_marginRight="@dimen/preference_screen_side_margin"
                android:layout_marginTop="16dp"
                android:layout_marginBottom="16dp"
                android:background="?attr/detailsElementBackground"
                android:orientation="vertical"
                android:visibility="gone" >

            <!-- Breadcrumb inserted here -->
            <android.app.FragmentBreadCrumbs
                android:id="@android:id/title"
                android:layout_height="72dip"
                android:layout_width="match_parent"
                android:paddingTop="16dip"
                android:paddingBottom="8dip"
                android:gravity="center_vertical|left"
                android:layout_marginLeft="48dip"
                android:layout_marginRight="48dip"
                />
            <!-- Breadcrumb inserted here, in certain screen sizes. In others, it will be an
                empty layout or just padding, and PreferenceActivity will put the breadcrumbs in
                the action bar. -->
            <include layout="@layout/breadcrumbs_in_fragment" />

            <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="1dip"
                    android:paddingLeft="32dip"
                    android:paddingRight="32dip"
                    android:src="#404040"
                />
            <android.preference.PreferenceFrameLayout android:id="@+id/prefs"
                    android:layout_width="match_parent"
                    android:layout_height="0dip"
                    android:layout_weight="1"
                    android:layout_marginTop="-1dip"
                />
        </LinearLayout>
    </LinearLayout>
Loading