reactivating the stripe now sets the colorwheel's current color

increased thickness of saturation and value bars
This commit is contained in:
Giovanni Harting
2015-09-17 17:31:54 +02:00
parent 34776fc225
commit 6c321aaa90
2 changed files with 15 additions and 13 deletions

View File

@@ -85,7 +85,6 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
private double per = 100.0;
private double allowance = rate;
private long last_check = System.currentTimeMillis();
private boolean isDisabled = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -112,11 +111,8 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
colorPicker.setOnColorChangedListener(new ColorPicker.OnColorChangedListener() {
@Override
public void onColorChanged(int i) {
if (mCurrentStripe != null && mCurrentHelper != null && isRateAcceptable() && !isDisabled) {
float[] hsv = new float[3];
Color.colorToHSV(i, hsv);
mCurrentStripe.setColor(new HSV(hsv[0], hsv[1], hsv[2]));
mCurrentHelper.setColor(mCurrentStripe);
if (mCurrentStripe != null && mCurrentHelper != null && isRateAcceptable() && aSwitch.isChecked()) {
setStripeFromColor(i);
}
}
});
@@ -193,10 +189,9 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
nHSV.setValue(0.0);
mCurrentStripe.setColor(nHSV);
mCurrentHelper.setColor(mCurrentStripe);
colorPicker.setColor(Color.HSVToColor(new float[]{(float) nHSV.getHue(), (float) nHSV.getSaturation(), (float) nHSV.getValue()}));
isDisabled = true;
//colorPicker.setColor(Color.HSVToColor(new float[]{(float) nHSV.getHue(), (float) nHSV.getSaturation(), (float) nHSV.getValue()}));
} else {
isDisabled = false;
setStripeFromColor(colorPicker.getColor());
}
}
}
@@ -363,10 +358,8 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
colorPicker.setColor(color);
if (cColor.getValue() == 0.0) {
aSwitch.setChecked(false);
isDisabled = true;
} else {
aSwitch.setChecked(true);
isDisabled = false;
}
}
});
@@ -401,6 +394,13 @@ public class ColorActivity extends AppCompatActivity implements NavigationView.O
}
}
private void setStripeFromColor(int color) {
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
mCurrentStripe.setColor(new HSV(hsv[0], hsv[1], hsv[2]));
mCurrentHelper.setColor(mCurrentStripe);
}
protected class refreshDaemonsListener extends BroadcastReceiver {
@Override

View File

@@ -63,13 +63,15 @@
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"/>
android:layout_marginTop="15dp"
app:bar_thickness="15dp"/>
<com.larswerkman.holocolorpicker.ValueBar
android:id="@+id/valuebar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"/>
android:layout_margin="10dp"
app:bar_thickness="15dp"/>
</LinearLayout>