1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00

Use the framework to manage the color picker dialog in account settings

This way the dialog will survive orientation changes.
This commit is contained in:
cketti 2012-06-06 15:09:45 +02:00
parent 2f7f7ad908
commit 9b77aad8b7
2 changed files with 43 additions and 11 deletions

View File

@ -10,6 +10,7 @@
package com.fsck.k9.activity; package com.fsck.k9.activity;
import com.fsck.k9.R; import com.fsck.k9.R;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog;
import android.content.*; import android.content.*;
import android.graphics.Color; import android.graphics.Color;
import android.util.Log; import android.util.Log;
@ -177,4 +178,8 @@ public class ColorPickerDialog {
public void show() { public void show() {
dialog.show(); dialog.show();
} }
public Dialog create() {
return dialog;
}
} }

View File

@ -1,6 +1,7 @@
package com.fsck.k9.activity.setup; package com.fsck.k9.activity.setup;
import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -39,6 +40,9 @@ import com.fsck.k9.mail.store.LocalStore.LocalFolder;
public class AccountSettings extends K9PreferenceActivity { public class AccountSettings extends K9PreferenceActivity {
private static final String EXTRA_ACCOUNT = "account"; private static final String EXTRA_ACCOUNT = "account";
private static final int DIALOG_COLOR_PICKER_ACCOUNT = 1;
private static final int DIALOG_COLOR_PICKER_LED = 2;
private static final int SELECT_AUTO_EXPAND_FOLDER = 1; private static final int SELECT_AUTO_EXPAND_FOLDER = 1;
private static final int ACTIVITY_MANAGE_IDENTITIES = 2; private static final int ACTIVITY_MANAGE_IDENTITIES = 2;
@ -809,21 +813,44 @@ public class AccountSettings extends K9PreferenceActivity {
} }
public void onChooseChipColor() { public void onChooseChipColor() {
new ColorPickerDialog(this, new ColorPickerDialog.OnColorChangedListener() { showDialog(DIALOG_COLOR_PICKER_ACCOUNT);
public void colorChanged(int color) {
mAccount.setChipColor(color);
}
},
mAccount.getChipColor()).show();
} }
public void onChooseLedColor() { public void onChooseLedColor() {
new ColorPickerDialog(this, new ColorPickerDialog.OnColorChangedListener() { showDialog(DIALOG_COLOR_PICKER_LED);
public void colorChanged(int color) { }
mAccount.getNotificationSetting().setLedColor(color);
@Override
public Dialog onCreateDialog(int id) {
Dialog dialog = null;
switch (id) {
case DIALOG_COLOR_PICKER_ACCOUNT: {
dialog = new ColorPickerDialog(this,
new ColorPickerDialog.OnColorChangedListener() {
public void colorChanged(int color) {
mAccount.setChipColor(color);
}
},
mAccount.getChipColor()).create();
break;
} }
}, case DIALOG_COLOR_PICKER_LED: {
mAccount.getNotificationSetting().getLedColor()).show(); dialog = new ColorPickerDialog(this,
new ColorPickerDialog.OnColorChangedListener() {
public void colorChanged(int color) {
mAccount.getNotificationSetting().setLedColor(color);
}
},
mAccount.getNotificationSetting().getLedColor()).create();
break;
}
}
return dialog;
} }
public void onChooseAutoExpandFolder() { public void onChooseAutoExpandFolder() {