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

Commit 7e4c9609 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio Committed by Android Git Automerger
Browse files

am 53c2cf79: Add support for saving and using the Preference\'s key value

* commit '53c2cf79':
  Add support for saving and using the Preference's key value
parents 71f92239 53c2cf79
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -45,8 +45,11 @@ import android.widget.ListView;
 * adapter, use {@link PreferenceCategoryAdapter} instead.
 * 
 * @see PreferenceCategoryAdapter
 *
 * @hide
 */
class PreferenceGroupAdapter extends BaseAdapter implements OnPreferenceChangeInternalListener {
public class PreferenceGroupAdapter extends BaseAdapter
        implements OnPreferenceChangeInternalListener {
    
    private static final String TAG = "PreferenceGroupAdapter";

@@ -88,6 +91,8 @@ class PreferenceGroupAdapter extends BaseAdapter implements OnPreferenceChangeIn
        }
    };

    private int mActivatedPosition = -1;

    private static class PreferenceLayout implements Comparable<PreferenceLayout> {
        private int resId;
        private int widgetResId;
@@ -207,6 +212,10 @@ class PreferenceGroupAdapter extends BaseAdapter implements OnPreferenceChangeIn
        return this.getItem(position).getId();
    }

    public void setActivated(int position) {
        mActivatedPosition = position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        final Preference preference = this.getItem(position);
        // Build a PreferenceLayout to compare with known ones that are cacheable.
@@ -217,8 +226,9 @@ class PreferenceGroupAdapter extends BaseAdapter implements OnPreferenceChangeIn
        if (Collections.binarySearch(mPreferenceLayouts, mTempPreferenceLayout) < 0) {
            convertView = null;
        }

        return preference.getView(convertView, parent);
        View result = preference.getView(convertView, parent);
        result.setActivated(position == mActivatedPosition);
        return result;
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:gravity="center_vertical"
    android:paddingStart="@dimen/preference_item_padding_side"
    android:paddingEnd="?android:attr/scrollbarSize">
    android:paddingEnd="?android:attr/scrollbarSize"
    android:background="?android:attr/activatedBackgroundIndicator">

    <LinearLayout
        android:layout_width="wrap_content"