Merge pull request #1680 from philipwhiuk/GH-1597-activeNeverSign

Use a darker grey to highlight the Never Sign/Encrypt as active
This commit is contained in:
cketti 2016-10-07 06:45:14 +02:00 committed by GitHub
commit c7b5a50636
4 changed files with 24 additions and 2 deletions

View file

@ -15,17 +15,21 @@ import com.fsck.k9.R;
public class CryptoModeSelector extends FrameLayout implements OnSeekBarChangeListener { public class CryptoModeSelector extends FrameLayout implements OnSeekBarChangeListener {
public static final int CROSSFADE_THRESH_1_LOW = -50;
public static final int CROSSFADE_THRESH_1_HIGH = 50;
public static final int CROSSFADE_THRESH_2_LOW = 50; public static final int CROSSFADE_THRESH_2_LOW = 50;
public static final int CROSSFADE_THRESH_2_HIGH = 150; public static final int CROSSFADE_THRESH_2_HIGH = 150;
public static final int CROSSFADE_THRESH_3_LOW = 150; public static final int CROSSFADE_THRESH_3_LOW = 150;
public static final int CROSSFADE_THRESH_3_HIGH = 250; public static final int CROSSFADE_THRESH_3_HIGH = 250;
public static final int CROSSFADE_THRESH_4_LOW = 250; public static final int CROSSFADE_THRESH_4_LOW = 250;
public static final float CROSSFADE_DIVISOR_1 = 50.0f;
public static final float CROSSFADE_DIVISOR_2 = 50.0f; public static final float CROSSFADE_DIVISOR_2 = 50.0f;
public static final float CROSSFADE_DIVISOR_3 = 50.0f; public static final float CROSSFADE_DIVISOR_3 = 50.0f;
public static final float CROSSFADE_DIVISOR_4 = 50.0f; public static final float CROSSFADE_DIVISOR_4 = 50.0f;
private SeekBar seekbar; private SeekBar seekbar;
private ImageView modeIcon1;
private ImageView modeIcon2; private ImageView modeIcon2;
private ImageView modeIcon3; private ImageView modeIcon3;
private ImageView modeIcon4; private ImageView modeIcon4;
@ -51,6 +55,7 @@ public class CryptoModeSelector extends FrameLayout implements OnSeekBarChangeLi
public void init() { public void init() {
inflate(getContext(), R.layout.crypto_mode_selector, this); inflate(getContext(), R.layout.crypto_mode_selector, this);
seekbar = (SeekBar) findViewById(R.id.seek_bar); seekbar = (SeekBar) findViewById(R.id.seek_bar);
modeIcon1 = (ImageView) findViewById(R.id.icon_1);
modeIcon2 = (ImageView) findViewById(R.id.icon_2); modeIcon2 = (ImageView) findViewById(R.id.icon_2);
modeIcon3 = (ImageView) findViewById(R.id.icon_3); modeIcon3 = (ImageView) findViewById(R.id.icon_3);
modeIcon4 = (ImageView) findViewById(R.id.icon_4); modeIcon4 = (ImageView) findViewById(R.id.icon_4);
@ -63,7 +68,18 @@ public class CryptoModeSelector extends FrameLayout implements OnSeekBarChangeLi
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int grey = ThemeUtils.getStyledColor(getContext(), R.attr.openpgp_grey); int grey = ThemeUtils.getStyledColor(getContext(), R.attr.openpgp_grey);
float crossfadeValue2, crossfadeValue3, crossfadeValue4; float crossfadeValue1, crossfadeValue2, crossfadeValue3, crossfadeValue4;
if (progress < CROSSFADE_THRESH_1_HIGH) {
crossfadeValue1 = (progress -CROSSFADE_THRESH_1_LOW) / CROSSFADE_DIVISOR_1;
if (crossfadeValue1 > 1.0f) {
crossfadeValue1 = 2.0f -crossfadeValue1;
}
} else {
crossfadeValue1 = 0.0f;
}
if (progress > CROSSFADE_THRESH_2_LOW && progress < CROSSFADE_THRESH_2_HIGH) { if (progress > CROSSFADE_THRESH_2_LOW && progress < CROSSFADE_THRESH_2_HIGH) {
crossfadeValue2 = (progress -CROSSFADE_THRESH_2_LOW) / CROSSFADE_DIVISOR_2; crossfadeValue2 = (progress -CROSSFADE_THRESH_2_LOW) / CROSSFADE_DIVISOR_2;
if (crossfadeValue2 > 1.0f) { if (crossfadeValue2 > 1.0f) {
@ -90,6 +106,9 @@ public class CryptoModeSelector extends FrameLayout implements OnSeekBarChangeLi
int crossfadedColor; int crossfadedColor;
crossfadedColor = crossfadeColor(grey, ThemeUtils.getStyledColor(getContext(), R.attr.openpgp_dark_grey), crossfadeValue1);
modeIcon1.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP);
crossfadedColor = crossfadeColor(grey, ThemeUtils.getStyledColor(getContext(), R.attr.openpgp_blue), crossfadeValue2); crossfadedColor = crossfadeColor(grey, ThemeUtils.getStyledColor(getContext(), R.attr.openpgp_blue), crossfadeValue2);
modeIcon2.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP); modeIcon2.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP);

View file

@ -19,7 +19,7 @@
android:layout_weight="1" android:layout_weight="1"
android:src="@drawable/status_lock_disabled" android:src="@drawable/status_lock_disabled"
android:id="@+id/icon_1" android:id="@+id/icon_1"
android:tint="?attr/openpgp_grey" android:tint="?attr/openpgp_dark_grey"
/> />
<ImageView <ImageView

View file

@ -63,6 +63,7 @@
<attr name="openpgp_green" format="reference|color" /> <attr name="openpgp_green" format="reference|color" />
<attr name="openpgp_blue" format="reference|color" /> <attr name="openpgp_blue" format="reference|color" />
<attr name="openpgp_grey" format="reference|color" /> <attr name="openpgp_grey" format="reference|color" />
<attr name="openpgp_dark_grey" format="reference|color" />
</declare-styleable> </declare-styleable>
<declare-styleable name="SliderPreference"> <declare-styleable name="SliderPreference">

View file

@ -70,6 +70,7 @@
<item name="openpgp_green">#669900</item> <item name="openpgp_green">#669900</item>
<item name="openpgp_blue">#336699</item> <item name="openpgp_blue">#336699</item>
<item name="openpgp_grey">#bbb</item> <item name="openpgp_grey">#bbb</item>
<item name="openpgp_dark_grey">#888</item>
</style> </style>
<style name="Theme.K9.Dark.Common" parent="Theme.K9.Dark.Base"> <style name="Theme.K9.Dark.Common" parent="Theme.K9.Dark.Base">
@ -133,6 +134,7 @@
<item name="openpgp_green">#77aa00</item> <item name="openpgp_green">#77aa00</item>
<item name="openpgp_blue">#6699cc</item> <item name="openpgp_blue">#6699cc</item>
<item name="openpgp_grey">#888</item> <item name="openpgp_grey">#888</item>
<item name="openpgp_dark_grey">#bbb</item>
</style> </style>
<style name="Theme.K9.Light" parent="Theme.K9.Light.Common" /> <style name="Theme.K9.Light" parent="Theme.K9.Light.Common" />