Skip to content

Commit e7ba5e6

Browse files
authored
Use android:title as color picker dialog title (#50)
* Enabled multidex * Used PreferenceFragmentCompat Used PreferenceFragmentCompat instead of Preference. This will also made the library works well with AppCompat and AndroidX * Use android:title as dialog title
1 parent a35fc0d commit e7ba5e6

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

ColorPickerPreference/src/main/java/net/margaritov/preference/colorpicker/ColorPickerDialog.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package net.margaritov.preference.colorpicker;
1818

19-
import android.app.Dialog;
2019
import android.content.Context;
2120
import android.content.res.ColorStateList;
2221
import android.graphics.Color;
@@ -34,11 +33,13 @@
3433
import android.widget.LinearLayout;
3534
import android.widget.TextView;
3635

36+
import androidx.appcompat.app.AppCompatDialog;
37+
3738
import java.util.Locale;
3839

3940
public class ColorPickerDialog
4041
extends
41-
Dialog
42+
AppCompatDialog
4243
implements
4344
ColorPickerView.OnColorChangedListener,
4445
View.OnClickListener, ViewTreeObserver.OnGlobalLayoutListener {
@@ -56,6 +57,8 @@ public class ColorPickerDialog
5657
private int mOrientation;
5758
private View mLayout;
5859

60+
private String mTitle;
61+
5962
@Override
6063
public void onGlobalLayout() {
6164
if (getContext().getResources().getConfiguration().orientation != mOrientation) {
@@ -72,9 +75,10 @@ public interface OnColorChangedListener {
7275
public void onColorChanged(int color);
7376
}
7477

75-
public ColorPickerDialog(Context context, int initialColor) {
78+
public ColorPickerDialog(Context context, int initialColor, String title) {
7679
super(context);
7780

81+
mTitle = title;
7882
init(initialColor);
7983
}
8084

@@ -96,7 +100,7 @@ private void setUp(int color) {
96100
mOrientation = getContext().getResources().getConfiguration().orientation;
97101
setContentView(mLayout);
98102

99-
setTitle(R.string.dialog_color_picker);
103+
setTitle(mTitle);
100104

101105
mColorPicker = (ColorPickerView) mLayout.findViewById(R.id.color_picker_view);
102106
mOldColor = (ColorPickerPanelView) mLayout.findViewById(R.id.old_color_panel);

ColorPickerPreference/src/main/java/net/margaritov/preference/colorpicker/ColorPickerPreference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public boolean onPreferenceClick(Preference preference) {
169169
}
170170

171171
protected void showDialog(Bundle state) {
172-
mDialog = new ColorPickerDialog(getContext(), mValue);
172+
mDialog = new ColorPickerDialog(getContext(), mValue, getTitle().toString());
173173
mDialog.setOnColorChangedListener(this);
174174
if (mAlphaSliderEnabled) {
175175
mDialog.setAlphaSliderVisible(true);

0 commit comments

Comments
 (0)