Skip to content

Commit

Permalink
Use android:title as color picker dialog title (#50)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
johnchrisdc authored Apr 14, 2020
1 parent a35fc0d commit e7ba5e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package net.margaritov.preference.colorpicker;

import android.app.Dialog;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
Expand All @@ -34,11 +33,13 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatDialog;

import java.util.Locale;

public class ColorPickerDialog
extends
Dialog
AppCompatDialog
implements
ColorPickerView.OnColorChangedListener,
View.OnClickListener, ViewTreeObserver.OnGlobalLayoutListener {
Expand All @@ -56,6 +57,8 @@ public class ColorPickerDialog
private int mOrientation;
private View mLayout;

private String mTitle;

@Override
public void onGlobalLayout() {
if (getContext().getResources().getConfiguration().orientation != mOrientation) {
Expand All @@ -72,9 +75,10 @@ public interface OnColorChangedListener {
public void onColorChanged(int color);
}

public ColorPickerDialog(Context context, int initialColor) {
public ColorPickerDialog(Context context, int initialColor, String title) {
super(context);

mTitle = title;
init(initialColor);
}

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

setTitle(R.string.dialog_color_picker);
setTitle(mTitle);

mColorPicker = (ColorPickerView) mLayout.findViewById(R.id.color_picker_view);
mOldColor = (ColorPickerPanelView) mLayout.findViewById(R.id.old_color_panel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public boolean onPreferenceClick(Preference preference) {
}

protected void showDialog(Bundle state) {
mDialog = new ColorPickerDialog(getContext(), mValue);
mDialog = new ColorPickerDialog(getContext(), mValue, getTitle().toString());
mDialog.setOnColorChangedListener(this);
if (mAlphaSliderEnabled) {
mDialog.setAlphaSliderVisible(true);
Expand Down

0 comments on commit e7ba5e6

Please sign in to comment.