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

Commit 2964c7b8 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Update seek bar dialog preference for Material" into mnc-dev

parents 09425e50 5c3188e7
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -18,29 +18,28 @@ package android.preference;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.SeekBar;

import com.android.internal.R;

/**
 * @hide
 */
public class SeekBarDialogPreference extends DialogPreference {
    private static final String TAG = "SeekBarDialogPreference";

    private Drawable mMyIcon;
    private final Drawable mMyIcon;

    public SeekBarDialogPreference(
            Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);

        setDialogLayoutResource(com.android.internal.R.layout.seekbar_dialog);
        createActionButtons();

        // Steal the XML dialogIcon attribute's value
        mMyIcon = getDialogIcon();

        setDialogIcon(null);
    }

@@ -49,7 +48,7 @@ public class SeekBarDialogPreference extends DialogPreference {
    }

    public SeekBarDialogPreference(Context context, AttributeSet attrs) {
        this(context, attrs, com.android.internal.R.attr.dialogPreferenceStyle);
        this(context, attrs, R.attr.seekBarDialogPreferenceStyle);
    }

    public SeekBarDialogPreference(Context context) {
@@ -58,15 +57,15 @@ public class SeekBarDialogPreference extends DialogPreference {

    // Allow subclasses to override the action buttons
    public void createActionButtons() {
        setPositiveButtonText(android.R.string.ok);
        setNegativeButtonText(android.R.string.cancel);
        setPositiveButtonText(R.string.ok);
        setNegativeButtonText(R.string.cancel);
    }

    @Override
    protected void onBindDialogView(View view) {
        super.onBindDialogView(view);

        final ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
        final ImageView iconView = (ImageView) view.findViewById(R.id.icon);
        if (mMyIcon != null) {
            iconView.setImageDrawable(mMyIcon);
        } else {
@@ -75,6 +74,6 @@ public class SeekBarDialogPreference extends DialogPreference {
    }

    protected static SeekBar getSeekBar(View dialogView) {
        return (SeekBar) dialogView.findViewById(com.android.internal.R.id.seekbar);
        return (SeekBar) dialogView.findViewById(R.id.seekbar);
    }
}
+16 −10
Original line number Diff line number Diff line
@@ -26,14 +26,13 @@ import android.view.KeyEvent;
import android.view.View;
import android.widget.SeekBar;

import com.android.internal.R;

/**
 * @hide
 */
public class VolumePreference extends SeekBarDialogPreference implements
        PreferenceManager.OnActivityStopListener, View.OnKeyListener, SeekBarVolumizer.Callback {

    static final String TAG = "VolumePreference";

    private int mStreamType;

    /** May be null if the dialog isn't visible. */
@@ -44,7 +43,7 @@ public class VolumePreference extends SeekBarDialogPreference implements
        super(context, attrs, defStyleAttr, defStyleRes);

        final TypedArray a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.VolumePreference, defStyleAttr, defStyleRes);
                R.styleable.VolumePreference, defStyleAttr, defStyleRes);
        mStreamType = a.getInt(android.R.styleable.VolumePreference_streamType, 0);
        a.recycle();
    }
@@ -54,7 +53,11 @@ public class VolumePreference extends SeekBarDialogPreference implements
    }

    public VolumePreference(Context context, AttributeSet attrs) {
        this(context, attrs, com.android.internal.R.attr.dialogPreferenceStyle);
        this(context, attrs, R.attr.seekBarDialogPreferenceStyle);
    }

    public VolumePreference(Context context) {
        this(context, null);
    }

    public void setStreamType(int streamType) {
@@ -65,7 +68,7 @@ public class VolumePreference extends SeekBarDialogPreference implements
    protected void onBindDialogView(View view) {
        super.onBindDialogView(view);

        final SeekBar seekBar = (SeekBar) view.findViewById(com.android.internal.R.id.seekbar);
        final SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar);
        mSeekBarVolumizer = new SeekBarVolumizer(getContext(), mStreamType, null, this);
        mSeekBarVolumizer.start();
        mSeekBarVolumizer.setSeekBar(seekBar);
@@ -128,14 +131,17 @@ public class VolumePreference extends SeekBarDialogPreference implements
       getPreferenceManager().unregisterOnActivityStopListener(this);

       if (mSeekBarVolumizer != null) {
           Dialog dialog = getDialog();
           final Dialog dialog = getDialog();
           if (dialog != null && dialog.isShowing()) {
               View view = dialog.getWindow().getDecorView()
                       .findViewById(com.android.internal.R.id.seekbar);
               if (view != null) view.setOnKeyListener(null);
               final View view = dialog.getWindow().getDecorView().findViewById(R.id.seekbar);
               if (view != null) {
                   view.setOnKeyListener(null);
               }

               // Stopped while dialog was showing, revert changes
               mSeekBarVolumizer.revertVolume();
           }

           mSeekBarVolumizer.stop();
           mSeekBarVolumizer = null;
       }
+17 −16
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
<!-- Copyright (C) 2015 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.
@@ -17,18 +17,19 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center_horizontal">
              android:gravity="center_horizontal"
              android:orientation="vertical">

    <ImageView android:id="@+id/icon"
    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
            android:paddingTop="20dip" />
        android:paddingTop="20dp" />

    <SeekBar android:id="@+id/seekbar"
    <SeekBar
        android:id="@+id/seekbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
            android:padding="20dip" />
        android:padding="20dp" />

</LinearLayout>
 
+37 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 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.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:gravity="center_horizontal"
              android:orientation="vertical">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="?attr/dialogPreferredPadding" />

    <SeekBar
        android:id="@+id/seekbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="?attr/dialogPreferredPadding"
        android:paddingStart="?attr/dialogPreferredPadding"
        android:paddingEnd="?attr/dialogPreferredPadding" />

</LinearLayout>
+2 −0
Original line number Diff line number Diff line
@@ -868,6 +868,8 @@
        <attr name="dialogPreferenceStyle" format="reference" />
        <!-- Default style for EditTextPreference. -->
        <attr name="editTextPreferenceStyle" format="reference" />
        <!-- @hide Default style for SeekBarDialogPreference. -->
        <attr name="seekBarDialogPreferenceStyle" format="reference" />
        <!-- Default style for RingtonePreference. -->
        <attr name="ringtonePreferenceStyle" format="reference" />
        <!-- The preference layout that has the child/tabbed effect. -->
Loading