2020import butterknife .BindView ;
2121import butterknife .ButterKnife ;
2222import butterknife .OnClick ;
23+ import yuku .ambilwarna .AmbilWarnaDialog ;
2324
2425public class WidgetConfigureActivity extends AppCompatActivity {
2526 @ BindView (R .id .config_widget_seekbar ) SeekBar mWidgetSeekBar ;
@@ -61,7 +62,7 @@ private void initVariables() {
6162 mWidgetColorWithoutTransparency = Color .rgb (Color .red (mWidgetColor ), Color .green (mWidgetColor ), Color .blue (mWidgetColor ));
6263 mWidgetSeekBar .setOnSeekBarChangeListener (seekbarChangeListener );
6364 mWidgetSeekBar .setProgress ((int ) (mWidgetAlpha * 100 ));
64- updateBackgroundColor ();
65+ updateColors ();
6566 }
6667
6768 @ OnClick (R .id .config_save )
@@ -81,7 +82,19 @@ public void saveConfig() {
8182
8283 @ OnClick (R .id .config_widget_color )
8384 public void pickBackgroundColor () {
84-
85+ AmbilWarnaDialog dialog = new AmbilWarnaDialog (this , mWidgetColorWithoutTransparency , new AmbilWarnaDialog .OnAmbilWarnaListener () {
86+ @ Override
87+ public void onCancel (AmbilWarnaDialog dialog ) {
88+ }
89+
90+ @ Override
91+ public void onOk (AmbilWarnaDialog dialog , int color ) {
92+ mWidgetColorWithoutTransparency = color ;
93+ updateColors ();
94+ }
95+ });
96+
97+ dialog .show ();
8598 }
8699
87100 private void storeWidgetColors () {
@@ -95,7 +108,7 @@ private void requestWidgetUpdate() {
95108 sendBroadcast (intent );
96109 }
97110
98- private void updateBackgroundColor () {
111+ private void updateColors () {
99112 mWidgetColor = adjustAlpha (mWidgetColorWithoutTransparency , mWidgetAlpha );
100113 mWidgetColorPicker .setBackgroundColor (mWidgetColor );
101114 mImage .getDrawable ().mutate ().setColorFilter (mWidgetColor , PorterDuff .Mode .SRC_IN );
@@ -105,7 +118,7 @@ private void updateBackgroundColor() {
105118 @ Override
106119 public void onProgressChanged (SeekBar seekBar , int progress , boolean fromUser ) {
107120 mWidgetAlpha = (float ) progress / (float ) 100 ;
108- updateBackgroundColor ();
121+ updateColors ();
109122 }
110123
111124 @ Override
0 commit comments