diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-05-08 18:06:12 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-05-08 18:12:55 +0200 |
commit | 4ba06e7735eb64c7b3d02c605e8c91fe986c1976 (patch) | |
tree | cd7d7aa916f6d283d63529e202fc902be29f75ce /OpenKeychain/src/main/java/org | |
parent | cbc3988628d09ed8a4fe967e1f21786f46cb038b (diff) | |
download | open-keychain-4ba06e7735eb64c7b3d02c605e8c91fe986c1976.tar.gz open-keychain-4ba06e7735eb64c7b3d02c605e8c91fe986c1976.tar.bz2 open-keychain-4ba06e7735eb64c7b3d02c605e8c91fe986c1976.zip |
ui: purplize dialog headers (huge hack inside)
Diffstat (limited to 'OpenKeychain/src/main/java/org')
12 files changed, 63 insertions, 28 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 4c747d0d9..bd3a98567 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -59,6 +59,7 @@ import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.PassphraseCacheService; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; +import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.widget.Editor; @@ -504,7 +505,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener int curID = 0; for (String userID : userIDs) { if (userID.equals("") && (!userID.equals(originalIDs.get(curID)) || newIDs.get(curID))) { - AlertDialog.Builder alert = new AlertDialog.Builder( + CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder( EditKeyActivity.this); alert.setIcon(R.drawable.ic_dialog_alert_holo_light); @@ -527,7 +528,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } ); alert.setCancelable(false); - alert.create().show(); + alert.show(); return; } curID++; @@ -617,7 +618,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener private void cancelClicked() { if (needsSaving()) { //ask if we want to save - AlertDialog.Builder alert = new AlertDialog.Builder( + CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder( EditKeyActivity.this); alert.setIcon(R.drawable.ic_dialog_alert_holo_light); @@ -640,7 +641,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } }); alert.setCancelable(false); - alert.create().show(); + alert.show(); } else { setResult(RESULT_CANCELED); finish(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index bb5d2e922..35076287b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -38,7 +38,6 @@ import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; -import com.beardedhen.androidbootstrap.BootstrapButton; import com.devspark.appmsg.AppMsg; import org.sufficientlysecure.keychain.Constants; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/BadImportKeyDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/BadImportKeyDialogFragment.java index 35e464423..19cf27259 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/BadImportKeyDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/BadImportKeyDialogFragment.java @@ -17,7 +17,6 @@ package org.sufficientlysecure.keychain.ui.dialog; -import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; @@ -50,7 +49,7 @@ public class BadImportKeyDialogFragment extends DialogFragment { final FragmentActivity activity = getActivity(); final int badImport = getArguments().getInt(ARG_BAD_IMPORT); - AlertDialog.Builder alert = new AlertDialog.Builder(activity); + CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); alert.setIcon(R.drawable.ic_dialog_alert_holo_light); alert.setTitle(R.string.warning); alert.setMessage(activity.getResources() @@ -63,6 +62,6 @@ public class BadImportKeyDialogFragment extends DialogFragment { }); alert.setCancelable(true); - return alert.create(); + return alert.show(); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java index c71bc160a..6c012cb94 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java @@ -83,7 +83,7 @@ public class CreateKeyDialogFragment extends DialogFragment { final int childCount = getArguments().getInt(ARG_EDITOR_CHILD_COUNT); mInflater = context.getLayoutInflater(); - AlertDialog.Builder dialog = new AlertDialog.Builder(context); + CustomAlertDialogBuilder dialog = new CustomAlertDialogBuilder(context); View view = mInflater.inflate(R.layout.create_key_dialog, null); dialog.setView(view); @@ -146,7 +146,7 @@ public class CreateKeyDialogFragment extends DialogFragment { } }); - final AlertDialog alertDialog = dialog.create(); + final AlertDialog alertDialog = dialog.show(); mCustomKeyEditText.addTextChangedListener(new TextWatcher() { @Override diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CustomAlertDialogBuilder.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CustomAlertDialogBuilder.java new file mode 100644 index 000000000..4b40b7ef1 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CustomAlertDialogBuilder.java @@ -0,0 +1,40 @@ +package org.sufficientlysecure.keychain.ui.dialog; + +import android.app.Activity; +import android.app.AlertDialog; +import android.view.View; +import android.widget.TextView; + +import org.sufficientlysecure.keychain.R; + +/** This class extends AlertDiaog.Builder, styling the header using emphasis color. + * Note that this class is a huge hack, because dialog boxes aren't easily stylable. + * Also, the dialog NEEDS to be called with show() directly, not create(), otherwise + * the order of internal operations will lead to a crash! + */ +public class CustomAlertDialogBuilder extends AlertDialog.Builder { + + public CustomAlertDialogBuilder(Activity activity) { + super(activity); + } + + @Override + public AlertDialog show() { + AlertDialog dialog = super.show(); + + int dividerId = dialog.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); + View divider = dialog.findViewById(dividerId); + if (divider != null) { + divider.setBackgroundColor(dialog.getContext().getResources().getColor(R.color.emphasis)); + } + + int textViewId = dialog.getContext().getResources().getIdentifier("android:id/alertTitle", null, null); + TextView tv = (TextView) dialog.findViewById(textViewId); + if (tv != null) { + tv.setTextColor(dialog.getContext().getResources().getColor(R.color.emphasis)); + } + + return dialog; + } + +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java index 37dec70cd..b42a79993 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java @@ -17,7 +17,6 @@ package org.sufficientlysecure.keychain.ui.dialog; -import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; import android.content.DialogInterface; @@ -59,7 +58,7 @@ public class DeleteFileDialogFragment extends DialogFragment { final String deleteFile = getArguments().getString(ARG_DELETE_FILE); - AlertDialog.Builder alert = new AlertDialog.Builder(activity); + CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); alert.setIcon(R.drawable.ic_dialog_alert_holo_light); @@ -120,6 +119,6 @@ public class DeleteFileDialogFragment extends DialogFragment { }); alert.setCancelable(true); - return alert.create(); + return alert.show(); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index 93cdef5e3..01d2fae6a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -17,7 +17,6 @@ package org.sufficientlysecure.keychain.ui.dialog; -import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; @@ -73,7 +72,7 @@ public class DeleteKeyDialogFragment extends DialogFragment { final long[] masterKeyIds = getArguments().getLongArray(ARG_DELETE_MASTER_KEY_IDS); - AlertDialog.Builder builder = new AlertDialog.Builder(activity); + CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(activity); // Setup custom View to display in AlertDialog LayoutInflater inflater = activity.getLayoutInflater(); @@ -144,7 +143,7 @@ public class DeleteKeyDialogFragment extends DialogFragment { } }); - return builder.create(); + return builder.show(); } /** diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FileDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FileDialogFragment.java index 6a5baf658..24f93bed7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FileDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FileDialogFragment.java @@ -97,7 +97,7 @@ public class FileDialogFragment extends DialogFragment { LayoutInflater inflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - AlertDialog.Builder alert = new AlertDialog.Builder(activity); + CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); alert.setTitle(title); View view = inflater.inflate(R.layout.file_dialog, null); @@ -157,7 +157,7 @@ public class FileDialogFragment extends DialogFragment { dismiss(); } }); - return alert.create(); + return alert.show(); } /** diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java index 3cb1ce7b4..12fd77141 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java @@ -135,7 +135,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor final long secretKeyId = getArguments().getLong(ARG_SECRET_KEY_ID); mMessenger = getArguments().getParcelable(ARG_MESSENGER); - AlertDialog.Builder alert = new AlertDialog.Builder(activity); + CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); alert.setTitle(R.string.title_authentication); @@ -262,7 +262,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor }); mCanKB = true; - return alert.create(); + return alert.show(); } @Override diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java index e5db22a04..04bec3282 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java @@ -81,7 +81,7 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi int title = getArguments().getInt(ARG_TITLE); mMessenger = getArguments().getParcelable(ARG_MESSENGER); - AlertDialog.Builder alert = new AlertDialog.Builder(activity); + CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); alert.setTitle(title); alert.setMessage(R.string.enter_passphrase_twice); @@ -135,7 +135,7 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi } }); - return alert.create(); + return alert.show(); } @Override diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareNfcDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareNfcDialogFragment.java index cd2364d7c..961f92f03 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareNfcDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareNfcDialogFragment.java @@ -18,7 +18,6 @@ package org.sufficientlysecure.keychain.ui.dialog; import android.annotation.TargetApi; -import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; @@ -51,7 +50,7 @@ public class ShareNfcDialogFragment extends DialogFragment { public Dialog onCreateDialog(Bundle savedInstanceState) { final FragmentActivity activity = getActivity(); - AlertDialog.Builder alert = new AlertDialog.Builder(activity); + CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); alert.setTitle(R.string.share_nfc_dialog); alert.setCancelable(true); @@ -93,6 +92,6 @@ public class ShareNfcDialogFragment extends DialogFragment { } } - return alert.create(); + return alert.show(); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java index 1b998ec8d..24608784b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java @@ -18,7 +18,6 @@ package org.sufficientlysecure.keychain.ui.dialog; import android.app.Activity; -import android.app.AlertDialog; import android.app.Dialog; import android.net.Uri; import android.os.Bundle; @@ -68,7 +67,7 @@ public class ShareQrCodeDialogFragment extends DialogFragment { Uri dataUri = getArguments().getParcelable(ARG_KEY_URI); - AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); + CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(getActivity()); alert.setTitle(R.string.share_qr_code_dialog_title); LayoutInflater inflater = activity.getLayoutInflater(); @@ -102,7 +101,7 @@ public class ShareQrCodeDialogFragment extends DialogFragment { return null; } - return alert.create(); + return alert.show(); } private void setQrCode(String data) { |