Merge "Update seek bar dialog preference for Material" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2964c7b8af
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?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.
|
||||
@@ -15,20 +15,21 @@
|
||||
-->
|
||||
|
||||
<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="20dp" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<ImageView android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="20dip" />
|
||||
|
||||
<SeekBar android:id="@+id/seekbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dip" />
|
||||
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
37
core/res/res/layout/preference_dialog_seekbar_material.xml
Normal file
37
core/res/res/layout/preference_dialog_seekbar_material.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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>
|
||||
@@ -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. -->
|
||||
|
||||
@@ -1017,6 +1017,10 @@ please see styles_device_defaults.xml.
|
||||
<item name="negativeButtonText">@string/no</item>
|
||||
</style>
|
||||
|
||||
<style name="Preference.DialogPreference.SeekBarPreference">
|
||||
<item name="dialogLayout">@layout/preference_dialog_seekbar</item>
|
||||
</style>
|
||||
|
||||
<style name="Preference.DialogPreference.EditTextPreference">
|
||||
<item name="dialogLayout">@layout/preference_dialog_edittext</item>
|
||||
</style>
|
||||
|
||||
@@ -87,6 +87,10 @@ please see styles_device_defaults.xml.
|
||||
<item name="negativeButtonText">@string/no</item>
|
||||
</style>
|
||||
|
||||
<style name="Preference.Material.DialogPreference.SeekBarPreference">
|
||||
<item name="dialogLayout">@layout/preference_dialog_seekbar_material</item>
|
||||
</style>
|
||||
|
||||
<style name="Preference.Material.DialogPreference.EditTextPreference">
|
||||
<item name="dialogLayout">@layout/preference_dialog_edittext_material</item>
|
||||
</style>
|
||||
|
||||
@@ -1341,7 +1341,6 @@
|
||||
<java-symbol type="layout" name="preference_widget_seekbar" />
|
||||
<java-symbol type="layout" name="progress_dialog" />
|
||||
<java-symbol type="layout" name="resolve_list_item" />
|
||||
<java-symbol type="layout" name="seekbar_dialog" />
|
||||
<java-symbol type="layout" name="select_dialog_singlechoice_holo" />
|
||||
<java-symbol type="layout" name="ssl_certificate" />
|
||||
<java-symbol type="layout" name="tab_content" />
|
||||
@@ -2292,4 +2291,5 @@
|
||||
<java-symbol type="string" name="config_radio_access_family" />
|
||||
<java-symbol type="string" name="notification_inbox_ellipsis" />
|
||||
<java-symbol type="bool" name="config_mainBuiltInDisplayIsRound" />
|
||||
<java-symbol type="attr" name="seekBarDialogPreferenceStyle" />
|
||||
</resources>
|
||||
|
||||
@@ -331,6 +331,7 @@ please see themes_device_defaults.xml.
|
||||
<item name="seekBarPreferenceStyle">@style/Preference.SeekBarPreference</item>
|
||||
<item name="yesNoPreferenceStyle">@style/Preference.DialogPreference.YesNoPreference</item>
|
||||
<item name="dialogPreferenceStyle">@style/Preference.DialogPreference</item>
|
||||
<item name="seekBarDialogPreferenceStyle">@style/Preference.DialogPreference.SeekBarPreference</item>
|
||||
<item name="editTextPreferenceStyle">@style/Preference.DialogPreference.EditTextPreference</item>
|
||||
<item name="ringtonePreferenceStyle">@style/Preference.RingtonePreference</item>
|
||||
<item name="preferenceLayoutChild">@layout/preference_child</item>
|
||||
|
||||
@@ -295,6 +295,7 @@ please see themes_device_defaults.xml.
|
||||
<item name="seekBarPreferenceStyle">@style/Preference.Material.SeekBarPreference</item>
|
||||
<item name="yesNoPreferenceStyle">@style/Preference.Material.DialogPreference.YesNoPreference</item>
|
||||
<item name="dialogPreferenceStyle">@style/Preference.Material.DialogPreference</item>
|
||||
<item name="seekBarDialogPreferenceStyle">@style/Preference.Material.DialogPreference.SeekBarPreference</item>
|
||||
<item name="editTextPreferenceStyle">@style/Preference.Material.DialogPreference.EditTextPreference</item>
|
||||
<item name="ringtonePreferenceStyle">@style/Preference.Material.RingtonePreference</item>
|
||||
<item name="preferenceLayoutChild">@layout/preference_child_material</item>
|
||||
@@ -651,6 +652,7 @@ please see themes_device_defaults.xml.
|
||||
<item name="seekBarPreferenceStyle">@style/Preference.Material.SeekBarPreference</item>
|
||||
<item name="yesNoPreferenceStyle">@style/Preference.Material.DialogPreference.YesNoPreference</item>
|
||||
<item name="dialogPreferenceStyle">@style/Preference.Material.DialogPreference</item>
|
||||
<item name="seekBarDialogPreferenceStyle">@style/Preference.Material.DialogPreference.SeekBarPreference</item>
|
||||
<item name="editTextPreferenceStyle">@style/Preference.Material.DialogPreference.EditTextPreference</item>
|
||||
<item name="ringtonePreferenceStyle">@style/Preference.Material.RingtonePreference</item>
|
||||
<item name="preferenceLayoutChild">@layout/preference_child_material</item>
|
||||
|
||||
Reference in New Issue
Block a user