Skip to content

Commit

Permalink
Allow setting background color for ColorPickerWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
chinalwb committed Dec 18, 2020
1 parent d7de08d commit 6afaa44
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ public class ARE_ToolItem_FontColor extends ARE_ToolItem_Abstract {

private final ColorPickerView colorPickerView;

private int colorPickerBackgroundColor;

public ARE_ToolItem_FontColor() {
this(android.R.color.white);
}

public ARE_ToolItem_FontColor(int colorPickerBackgroundColor) {
this.colorPickerView = null;
this.colorPickerBackgroundColor = colorPickerBackgroundColor;
}

public ARE_ToolItem_FontColor(ColorPickerView colorPickerView) {
Expand All @@ -32,6 +39,7 @@ public IARE_Style getStyle() {
AREditText editText = this.getEditText();
mStyle = new ARE_Style_FontColor(editText, (ImageView) mToolItemView, colorPickerView);
}
((ARE_Style_FontColor) mStyle).setColorPickerBackgroundColor(colorPickerBackgroundColor);
return mStyle;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.widget.EditText;
import android.widget.ImageView;

import androidx.annotation.ColorInt;

import com.chinalwb.are.AREditText;
import com.chinalwb.are.Util;
import com.chinalwb.are.colorpicker.ColorPickerListener;
Expand All @@ -25,6 +27,8 @@ public class ARE_Style_FontColor extends ARE_ABS_Dynamic_Style<AreForegroundColo

private int mColor;

@ColorInt private int mColorPickerBackgroundColor;

private boolean mIsChecked;

/**
Expand Down Expand Up @@ -78,6 +82,7 @@ private void showFontColorPickerWindow() {
}
int yOff = Util.getPixelByDp(mContext, -5);
mColorPickerWindow.showAsDropDown(mFontColorImageView, 0, yOff);
mColorPickerWindow.setBackgroundColor(mColorPickerBackgroundColor);
}

@Override
Expand Down Expand Up @@ -141,4 +146,8 @@ public void run() {
}
}
}

public void setColorPickerBackgroundColor(int colorPickerBackgroundColor) {
mColorPickerBackgroundColor = colorPickerBackgroundColor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ public void setColor(int color) {
private void setupListeners() {
this.colorPickerView.setColorPickerListener(mColorPickerListener);
}

public void setBackgroundColor(int backgroundColor) {
this.colorPickerView.setBackgroundColor(backgroundColor);
}
}

0 comments on commit 6afaa44

Please sign in to comment.