use of com.larswerkman.holocolorpicker.OpacityBar in project Xposed-Tinted-Status-Bar by MohammadAG.
the class ColorPickerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
String prefTitle = bundle.getString("title");
prefKey = bundle.getString("key");
prefColor = bundle.getString("color");
prefEnabled = bundle.getBoolean("enabled");
setTitle(prefTitle);
if (Utils.hasActionBar())
getActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_color_picker);
final ColorPicker picker = (ColorPicker) findViewById(R.id.picker);
OpacityBar opacityBar = (OpacityBar) findViewById(R.id.opacitybar);
SaturationBar saturationBar = (SaturationBar) findViewById(R.id.saturationbar);
ValueBar valueBar = (ValueBar) findViewById(R.id.valuebar);
picker.addOpacityBar(opacityBar);
picker.addSaturationBar(saturationBar);
picker.addValueBar(valueBar);
editText = (EditText) findViewById(R.id.edittext);
picker.setOldCenterColor(Color.parseColor("#ff33b5e5"));
picker.setOnColorChangedListener(this);
picker.setColor(Color.parseColor(Utils.addHashIfNeeded(prefColor)));
Button bPreview = (Button) findViewById(R.id.bPreviewColor);
bPreview.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
String textEditString = editText.getText().toString();
int colourHex;
if (isFullyTransparent(textEditString)) {
colourHex = Color.parseColor("#00000000");
} else {
colourHex = Color.parseColor(Utils.addHashIfNeeded(textEditString));
picker.setColor(colourHex);
}
ColorDrawable previewDrawable = new ColorDrawable(colourHex);
if (SettingsKeys.STATUS_BAR_TINT.equals(prefKey) && Utils.hasActionBar()) {
getActionBar().setBackgroundDrawable(previewDrawable);
/* Workaround, there's no invalidate() method that would redraw the
* action bar, and setting the drawable at runtime simply does nothing.
*/
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setDisplayShowTitleEnabled(true);
}
String previewKey;
Intent intent = new Intent(StatusBarTintApi.INTENT_CHANGE_COLOR_NAME);
if (SettingsKeys.DEFAULT_NAV_BAR_IM_TINT.equals(prefKey) || SettingsKeys.DEFAULT_NAV_BAR_TINT.equals(prefKey)) {
previewKey = SettingsKeys.NAVIGATION_BAR_TINT;
} else if (SettingsKeys.DEFAULT_STATUS_BAR_TINT.equals(prefKey)) {
previewKey = SettingsKeys.STATUS_BAR_TINT;
} else if (SettingsKeys.DEFAULT_NAV_BAR_ICON_TINT.equals(prefKey) || SettingsKeys.DEFAULT_NAV_BAR_ICON_IM_TINT.equals(prefKey)) {
previewKey = SettingsKeys.NAVIGATION_BAR_ICON_TINT;
} else if (SettingsKeys.DEFAULT_STATUS_BAR_ICON_TINT.equals(prefKey) || SettingsKeys.DEFAULT_STATUS_BAR_INVERTED_ICON_TINT.equals(prefKey)) {
if (SettingsKeys.DEFAULT_STATUS_BAR_INVERTED_ICON_TINT.equals(prefKey))
intent.putExtra(SettingsKeys.STATUS_BAR_TINT, Color.WHITE);
previewKey = SettingsKeys.STATUS_BAR_ICON_TINT;
} else {
previewKey = prefKey;
}
intent.putExtra(previewKey, colourHex);
sendOrderedBroadcast(intent, null);
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), R.string.invalid_color, Toast.LENGTH_SHORT).show();
}
}
});
Button bApply = (Button) findViewById(R.id.bApplyColor);
bApply.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
Color.parseColor(Utils.addHashIfNeeded(editText.getText().toString()));
returnResults();
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), R.string.invalid_color, Toast.LENGTH_SHORT).show();
}
}
});
}
Aggregations