mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-27 19:35:10 +01:00
Use color button for widget configuration
This commit is contained in:
@@ -52,7 +52,7 @@ public class ActivityWidget extends ActivityBase {
|
||||
|
||||
private Spinner spAccount;
|
||||
private CheckBox cbSemiTransparent;
|
||||
private Button btnColor;
|
||||
private ViewButtonColor btnColor;
|
||||
private View inOld;
|
||||
private View inNew;
|
||||
private RadioButton rbOld;
|
||||
@@ -61,7 +61,6 @@ public class ActivityWidget extends ActivityBase {
|
||||
private ContentLoadingProgressBar pbWait;
|
||||
private Group grpReady;
|
||||
|
||||
private int background = Color.TRANSPARENT;
|
||||
private ArrayAdapter<EntityAccount> adapterAccount;
|
||||
|
||||
@Override
|
||||
@@ -74,9 +73,6 @@ public class ActivityWidget extends ActivityBase {
|
||||
return;
|
||||
}
|
||||
|
||||
if (savedInstanceState != null)
|
||||
background = savedInstanceState.getInt("fair:color");
|
||||
|
||||
appWidgetId = extras.getInt(
|
||||
AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||
|
||||
@@ -100,8 +96,8 @@ public class ActivityWidget extends ActivityBase {
|
||||
cbSemiTransparent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
btnColor.setColor(Color.TRANSPARENT);
|
||||
setBackground();
|
||||
btnColor.setEnabled(!isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -121,14 +117,16 @@ public class ActivityWidget extends ActivityBase {
|
||||
.setPositiveButton(android.R.string.ok, new ColorPickerClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
|
||||
background = selectedColor;
|
||||
cbSemiTransparent.setChecked(false);
|
||||
btnColor.setColor(selectedColor);
|
||||
setBackground();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.title_reset, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
background = Color.TRANSPARENT;
|
||||
cbSemiTransparent.setChecked(false);
|
||||
btnColor.setColor(Color.TRANSPARENT);
|
||||
setBackground();
|
||||
}
|
||||
})
|
||||
@@ -166,7 +164,7 @@ public class ActivityWidget extends ActivityBase {
|
||||
editor.remove("widget." + appWidgetId + ".name");
|
||||
editor.putLong("widget." + appWidgetId + ".account", account == null ? -1L : account.id);
|
||||
editor.putBoolean("widget." + appWidgetId + ".semi", cbSemiTransparent.isChecked());
|
||||
editor.putInt("widget." + appWidgetId + ".background", background);
|
||||
editor.putInt("widget." + appWidgetId + ".background", btnColor.getColor());
|
||||
editor.putInt("widget." + appWidgetId + ".layout", rbNew.isChecked() ? 1 : 0);
|
||||
editor.apply();
|
||||
|
||||
@@ -184,7 +182,8 @@ public class ActivityWidget extends ActivityBase {
|
||||
((TextView) inOld.findViewById(R.id.tvCount)).setText("12");
|
||||
((TextView) inNew.findViewById(R.id.tvCount)).setText("12");
|
||||
|
||||
btnColor.setEnabled(!cbSemiTransparent.isChecked());
|
||||
setBackground();
|
||||
|
||||
grpReady.setVisibility(View.GONE);
|
||||
pbWait.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -222,17 +221,12 @@ public class ActivityWidget extends ActivityBase {
|
||||
}.execute(this, new Bundle(), "widget:accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
outState.putInt("fair:color", background);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private void setBackground() {
|
||||
if (cbSemiTransparent.isChecked()) {
|
||||
inOld.setBackgroundResource(R.drawable.widget_background);
|
||||
inNew.setBackgroundResource(R.drawable.widget_background);
|
||||
} else {
|
||||
int background = btnColor.getColor();
|
||||
inOld.setBackgroundColor(background);
|
||||
inNew.setBackgroundColor(background);
|
||||
float lum = (float) ColorUtils.calculateLuminance(background);
|
||||
|
||||
Reference in New Issue
Block a user