diff --git a/library/src/org/whispersystems/textsecure/util/Util.java b/library/src/org/whispersystems/textsecure/util/Util.java index 229f8a7ac6..ef71cb1b39 100644 --- a/library/src/org/whispersystems/textsecure/util/Util.java +++ b/library/src/org/whispersystems/textsecure/util/Util.java @@ -1,6 +1,5 @@ package org.whispersystems.textsecure.util; -import android.app.AlertDialog; import android.content.Context; import android.telephony.TelephonyManager; import android.widget.EditText; @@ -88,14 +87,6 @@ public class Util { return value == null || value.length() == 0; } - public static void showAlertDialog(Context context, String title, String message) { - AlertDialog.Builder dialog = new AlertDialog.Builder(context); - dialog.setTitle(title); - dialog.setMessage(message); - dialog.setIcon(android.R.drawable.ic_dialog_alert); - dialog.setPositiveButton(android.R.string.ok, null); - dialog.show(); - } public static int generateRegistrationId() { try { diff --git a/res/drawable-hdpi/ic_dialog_alert_holo_dark.png b/res/drawable-hdpi/ic_dialog_alert_holo_dark.png new file mode 100644 index 0000000000..7e7750639a Binary files /dev/null and b/res/drawable-hdpi/ic_dialog_alert_holo_dark.png differ diff --git a/res/drawable-hdpi/ic_dialog_alert_holo_light.png b/res/drawable-hdpi/ic_dialog_alert_holo_light.png new file mode 100644 index 0000000000..c96047f27c Binary files /dev/null and b/res/drawable-hdpi/ic_dialog_alert_holo_light.png differ diff --git a/res/drawable-hdpi/ic_dialog_info_holo_dark.png b/res/drawable-hdpi/ic_dialog_info_holo_dark.png new file mode 100644 index 0000000000..b1f1406239 Binary files /dev/null and b/res/drawable-hdpi/ic_dialog_info_holo_dark.png differ diff --git a/res/drawable-hdpi/ic_dialog_info_holo_light.png b/res/drawable-hdpi/ic_dialog_info_holo_light.png new file mode 100644 index 0000000000..077dcec800 Binary files /dev/null and b/res/drawable-hdpi/ic_dialog_info_holo_light.png differ diff --git a/res/drawable-mdpi/ic_dialog_alert_holo_dark.png b/res/drawable-mdpi/ic_dialog_alert_holo_dark.png new file mode 100644 index 0000000000..98132d580e Binary files /dev/null and b/res/drawable-mdpi/ic_dialog_alert_holo_dark.png differ diff --git a/res/drawable-mdpi/ic_dialog_alert_holo_light.png b/res/drawable-mdpi/ic_dialog_alert_holo_light.png new file mode 100644 index 0000000000..4f39fd0eb6 Binary files /dev/null and b/res/drawable-mdpi/ic_dialog_alert_holo_light.png differ diff --git a/res/drawable-mdpi/ic_dialog_info_holo_dark.png b/res/drawable-mdpi/ic_dialog_info_holo_dark.png new file mode 100644 index 0000000000..ae2acd5c47 Binary files /dev/null and b/res/drawable-mdpi/ic_dialog_info_holo_dark.png differ diff --git a/res/drawable-mdpi/ic_dialog_info_holo_light.png b/res/drawable-mdpi/ic_dialog_info_holo_light.png new file mode 100644 index 0000000000..624e745b69 Binary files /dev/null and b/res/drawable-mdpi/ic_dialog_info_holo_light.png differ diff --git a/res/drawable-xhdpi/ic_dialog_alert_holo_dark.png b/res/drawable-xhdpi/ic_dialog_alert_holo_dark.png new file mode 100644 index 0000000000..6c845e2139 Binary files /dev/null and b/res/drawable-xhdpi/ic_dialog_alert_holo_dark.png differ diff --git a/res/drawable-xhdpi/ic_dialog_alert_holo_light.png b/res/drawable-xhdpi/ic_dialog_alert_holo_light.png new file mode 100644 index 0000000000..17d4280ba1 Binary files /dev/null and b/res/drawable-xhdpi/ic_dialog_alert_holo_light.png differ diff --git a/res/drawable-xhdpi/ic_dialog_info_holo_dark.png b/res/drawable-xhdpi/ic_dialog_info_holo_dark.png new file mode 100644 index 0000000000..4536a8d151 Binary files /dev/null and b/res/drawable-xhdpi/ic_dialog_info_holo_dark.png differ diff --git a/res/drawable-xhdpi/ic_dialog_info_holo_light.png b/res/drawable-xhdpi/ic_dialog_info_holo_light.png new file mode 100644 index 0000000000..3be3152704 Binary files /dev/null and b/res/drawable-xhdpi/ic_dialog_info_holo_light.png differ diff --git a/res/drawable-xxhdpi/ic_dialog_alert_holo_dark.png b/res/drawable-xxhdpi/ic_dialog_alert_holo_dark.png new file mode 100644 index 0000000000..c08e2815fc Binary files /dev/null and b/res/drawable-xxhdpi/ic_dialog_alert_holo_dark.png differ diff --git a/res/drawable-xxhdpi/ic_dialog_alert_holo_light.png b/res/drawable-xxhdpi/ic_dialog_alert_holo_light.png new file mode 100644 index 0000000000..81a0741da1 Binary files /dev/null and b/res/drawable-xxhdpi/ic_dialog_alert_holo_light.png differ diff --git a/res/drawable-xxhdpi/ic_dialog_info_holo_dark.png b/res/drawable-xxhdpi/ic_dialog_info_holo_dark.png new file mode 100644 index 0000000000..f3db08879b Binary files /dev/null and b/res/drawable-xxhdpi/ic_dialog_info_holo_dark.png differ diff --git a/res/drawable-xxhdpi/ic_dialog_info_holo_light.png b/res/drawable-xxhdpi/ic_dialog_info_holo_light.png new file mode 100644 index 0000000000..7c7e7647ad Binary files /dev/null and b/res/drawable-xxhdpi/ic_dialog_info_holo_light.png differ diff --git a/res/values-v11/resources.xml b/res/values-v11/resources.xml new file mode 100644 index 0000000000..beaa5425a6 --- /dev/null +++ b/res/values-v11/resources.xml @@ -0,0 +1,7 @@ + + + @drawable/ic_dialog_info_holo_light + @drawable/ic_dialog_info_holo_dark + @drawable/ic_dialog_alert_holo_light + @drawable/ic_dialog_alert_holo_dark + \ No newline at end of file diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 8e49386ffd..34a8043c02 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -35,6 +35,8 @@ + + diff --git a/res/values/resources.xml b/res/values/resources.xml new file mode 100644 index 0000000000..4c2a27a1b5 --- /dev/null +++ b/res/values/resources.xml @@ -0,0 +1,7 @@ + + + @android:drawable/ic_dialog_info + @android:drawable/ic_dialog_alert + @android:drawable/ic_dialog_info + @android:drawable/ic_dialog_alert + \ No newline at end of file diff --git a/res/values/themes.xml b/res/values/themes.xml index 83028fa9b3..acaf233aaa 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -39,6 +39,8 @@ @drawable/conversation_item_sent_triangle_shape @drawable/conversation_item_sent_push_shape @drawable/conversation_item_sent_push_triangle_shape + @drawable/ic_dialog_info_light + @drawable/ic_dialog_alert_light @drawable/ic_action_new_holo_light @drawable/ic_action_add_group_holo_light @@ -93,6 +95,8 @@ @drawable/conversation_item_sent_triangle_shape_dark @drawable/conversation_item_sent_push_shape_dark @drawable/conversation_item_sent_push_triangle_shape_dark + @drawable/ic_dialog_info_dark + @drawable/ic_dialog_alert_dark @drawable/actionbar_icon_holo_dark @drawable/divet_lower_right_light diff --git a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java index 0091adbaa3..7b66b535ac 100644 --- a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java +++ b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java @@ -53,6 +53,7 @@ import org.thoughtcrime.securesms.crypto.MasterSecretUtil; import org.thoughtcrime.securesms.push.PushServiceSocketFactory; import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.util.ActionBarUtil; +import org.thoughtcrime.securesms.util.Dialogs; import org.thoughtcrime.securesms.util.DirectoryHelper; import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicTheme; @@ -440,7 +441,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr AlertDialog.Builder builder = new AlertDialog.Builder(ApplicationPreferencesActivity.this); builder.setTitle(R.string.ApplicationPreferencesActivity_disable_storage_encryption); builder.setMessage(R.string.ApplicationPreferencesActivity_warning_this_will_disable_storage_encryption_for_all_messages); - builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setIcon(Dialogs.resolveIcon(ApplicationPreferencesActivity.this, R.attr.dialog_alert_icon)); builder.setPositiveButton(R.string.ApplicationPreferencesActivity_disable, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index ea497c2222..938879e6ea 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -92,6 +92,7 @@ import org.thoughtcrime.securesms.util.ActionBarUtil; import org.thoughtcrime.securesms.util.BitmapDecodingException; import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.CharacterCalculator; +import org.thoughtcrime.securesms.util.Dialogs; import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicTheme; import org.thoughtcrime.securesms.util.EncryptedCharacterCalculator; @@ -377,7 +378,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi String recipientName = (recipient.getName() == null ? recipient.getNumber() : recipient.getName()); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.ConversationActivity_initiate_secure_session_question); - builder.setIcon(android.R.drawable.ic_dialog_info); + builder.setIcon(Dialogs.resolveIcon(this, R.attr.dialog_info_icon)); builder.setCancelable(true); builder.setMessage(String.format(getString(R.string.ConversationActivity_initiate_secure_session_with_s_question), recipientName)); @@ -396,7 +397,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi private void handleAbortSecureSession() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.ConversationActivity_abort_secure_session_confirmation); - builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setIcon(Dialogs.resolveIcon(this, R.attr.dialog_alert_icon)); builder.setCancelable(true); builder.setMessage(R.string.ConversationActivity_are_you_sure_that_you_want_to_abort_this_secure_session_question); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @@ -438,7 +439,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.ConversationActivity_leave_group)); - builder.setIcon(android.R.drawable.ic_dialog_info); + builder.setIcon(Dialogs.resolveIcon(this, R.attr.dialog_info_icon)); builder.setCancelable(true); builder.setMessage(getString(R.string.ConversationActivity_are_you_sure_you_want_to_leave_this_group)); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @@ -520,7 +521,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi startActivity(dialIntent); } catch (ActivityNotFoundException anfe) { Log.w(TAG, anfe); - Util.showAlertDialog(this, + Dialogs.showAlertDialog(this, getString(R.string.ConversationActivity_calls_not_supported), getString(R.string.ConversationActivity_this_device_does_not_appear_to_support_dial_actions)); } @@ -533,7 +534,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi private void handleDeleteThread() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.ConversationActivity_delete_thread_confirmation); - builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setIcon(Dialogs.resolveIcon(this, R.attr.dialog_alert_icon)); builder.setCancelable(true); builder.setMessage(R.string.ConversationActivity_are_you_sure_that_you_want_to_permanently_delete_this_conversation_question); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java index 6ff0e2973e..770bccf997 100644 --- a/src/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationFragment.java @@ -27,6 +27,7 @@ import org.thoughtcrime.securesms.database.loaders.ConversationLoader; import org.thoughtcrime.securesms.database.model.MessageRecord; import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.sms.MessageSender; +import org.thoughtcrime.securesms.util.Dialogs; import java.sql.Date; import java.text.SimpleDateFormat; @@ -116,7 +117,7 @@ public class ConversationFragment extends SherlockListFragment AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.ConversationFragment_confirm_message_delete); - builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_alert_icon)); builder.setCancelable(true); builder.setMessage(R.string.ConversationFragment_are_you_sure_you_want_to_permanently_delete_this_message); @@ -149,7 +150,7 @@ public class ConversationFragment extends SherlockListFragment SimpleDateFormat dateFormatter = new SimpleDateFormat("EEE MMM d, yyyy 'at' hh:mm:ss a zzz"); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.ConversationFragment_message_details); - builder.setIcon(android.R.drawable.ic_dialog_info); + builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_info_icon)); builder.setCancelable(false); if (dateReceived == dateSent || message.isOutgoing()) { diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index 24090fe0ef..50992e0b0d 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -53,6 +53,7 @@ import org.thoughtcrime.securesms.service.SendReceiveService; import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.DateUtils; import org.thoughtcrime.securesms.util.Emoji; +import org.thoughtcrime.securesms.util.Dialogs; import org.whispersystems.textsecure.crypto.MasterSecret; import org.whispersystems.textsecure.storage.Session; import org.whispersystems.textsecure.util.FutureTaskListener; @@ -462,7 +463,7 @@ public class ConversationItem extends LinearLayout { public boolean onLongClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.ConversationItem_save_to_sd_card); - builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setIcon(Dialogs.resolveIcon(context, R.attr.dialog_alert_icon)); builder.setCancelable(true); builder.setMessage(R.string.ConversationItem_this_media_has_been_stored_in_an_encrypted_database_warning); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @@ -524,7 +525,7 @@ public class ConversationItem extends LinearLayout { public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.ConversationItem_view_secure_media_question); - builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setIcon(Dialogs.resolveIcon(context, R.attr.dialog_alert_icon)); builder.setCancelable(true); builder.setMessage(R.string.ConversationItem_this_media_has_been_stored_in_an_encrypted_database_external_viewer_warning); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @@ -589,7 +590,7 @@ public class ConversationItem extends LinearLayout { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.ConversationActivity_abort_secure_session_confirmation); - builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setIcon(Dialogs.resolveIcon(context, R.attr.dialog_alert_icon)); builder.setCancelable(true); builder.setMessage(R.string.ConversationActivity_are_you_sure_that_you_want_to_abort_this_secure_session_question); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { diff --git a/src/org/thoughtcrime/securesms/ConversationListFragment.java b/src/org/thoughtcrime/securesms/ConversationListFragment.java index a602857c7c..29b9cabae2 100644 --- a/src/org/thoughtcrime/securesms/ConversationListFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationListFragment.java @@ -38,6 +38,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.loaders.ConversationListLoader; import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.recipients.Recipients; +import org.thoughtcrime.securesms.util.Dialogs; import com.actionbarsherlock.app.SherlockListFragment; import com.actionbarsherlock.view.ActionMode; @@ -162,7 +163,7 @@ public class ConversationListFragment extends SherlockListFragment private void handleDeleteAllSelected() { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); - alert.setIcon(android.R.drawable.ic_dialog_alert); + alert.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_alert_icon)); alert.setTitle(R.string.ConversationListFragment_delete_threads_question); alert.setMessage(R.string.ConversationListFragment_are_you_sure_you_wish_to_delete_all_selected_conversation_threads); alert.setCancelable(true); diff --git a/src/org/thoughtcrime/securesms/ExportFragment.java b/src/org/thoughtcrime/securesms/ExportFragment.java index 2f4a38193f..c980c987a5 100644 --- a/src/org/thoughtcrime/securesms/ExportFragment.java +++ b/src/org/thoughtcrime/securesms/ExportFragment.java @@ -15,6 +15,7 @@ import android.widget.Toast; import com.actionbarsherlock.app.SherlockFragment; import org.whispersystems.textsecure.crypto.MasterSecret; +import org.thoughtcrime.securesms.util.Dialogs; import org.thoughtcrime.securesms.database.EncryptedBackupExporter; import org.thoughtcrime.securesms.database.NoExternalStorageException; import org.thoughtcrime.securesms.database.PlaintextBackupExporter; @@ -59,7 +60,7 @@ public class ExportFragment extends SherlockFragment { private void handleExportEncryptedBackup() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setIcon(android.R.drawable.ic_dialog_info); + builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_info_icon)); builder.setTitle(getActivity().getString(R.string.ExportFragment_export_to_sd_card)); builder.setMessage(getActivity().getString(R.string.ExportFragment_this_will_export_your_encrypted_keys_settings_and_messages)); builder.setPositiveButton(getActivity().getString(R.string.ExportFragment_export), new Dialog.OnClickListener() { @@ -74,7 +75,7 @@ public class ExportFragment extends SherlockFragment { private void handleExportPlaintextBackup() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_alert_icon)); builder.setTitle(getActivity().getString(R.string.ExportFragment_export_plaintext_to_sd_card)); builder.setMessage(getActivity().getString(R.string.ExportFragment_warning_this_will_export_the_plaintext_contents)); builder.setPositiveButton(getActivity().getString(R.string.ExportFragment_export), new Dialog.OnClickListener() { diff --git a/src/org/thoughtcrime/securesms/ImportFragment.java b/src/org/thoughtcrime/securesms/ImportFragment.java index 0d94061a18..0140d2f475 100644 --- a/src/org/thoughtcrime/securesms/ImportFragment.java +++ b/src/org/thoughtcrime/securesms/ImportFragment.java @@ -15,6 +15,7 @@ import android.widget.Toast; import com.actionbarsherlock.app.SherlockFragment; import org.whispersystems.textsecure.crypto.MasterSecret; +import org.thoughtcrime.securesms.util.Dialogs; import org.thoughtcrime.securesms.database.EncryptedBackupExporter; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.NoExternalStorageException; @@ -81,7 +82,7 @@ public class ImportFragment extends SherlockFragment { private void handleImportSms() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setIcon(android.R.drawable.ic_dialog_info); + builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_info_icon)); builder.setTitle(getActivity().getString(R.string.ImportFragment_import_system_sms_database)); builder.setMessage(getActivity().getString(R.string.ImportFragment_this_will_import_messages_from_the_system)); builder.setPositiveButton(getActivity().getString(R.string.ImportFragment_import), new AlertDialog.OnClickListener() { @@ -107,7 +108,7 @@ public class ImportFragment extends SherlockFragment { private void handleImportEncryptedBackup() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_alert_icon)); builder.setTitle(getActivity().getString(R.string.ImportFragment_restore_encrypted_backup)); builder.setMessage(getActivity().getString(R.string.ImportFragment_restoring_an_encrypted_backup_will_completely_replace_your_existing_keys)); builder.setPositiveButton(getActivity().getString(R.string.ImportFragment_restore), new AlertDialog.OnClickListener() { @@ -122,7 +123,7 @@ public class ImportFragment extends SherlockFragment { private void handleImportPlaintextBackup() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_alert_icon)); builder.setTitle(getActivity().getString(R.string.ImportFragment_import_plaintext_backup)); builder.setMessage(getActivity().getString(R.string.ImportFragment_this_will_import_messages_from_a_plaintext_backup)); builder.setPositiveButton(getActivity().getString(R.string.ImportFragment_import), new AlertDialog.OnClickListener() { diff --git a/src/org/thoughtcrime/securesms/KeyScanningActivity.java b/src/org/thoughtcrime/securesms/KeyScanningActivity.java index 415ea39716..020a62f298 100644 --- a/src/org/thoughtcrime/securesms/KeyScanningActivity.java +++ b/src/org/thoughtcrime/securesms/KeyScanningActivity.java @@ -88,9 +88,9 @@ public abstract class KeyScanningActivity extends PassphraseRequiredSherlockActi String data = scanResult.getContents(); if (data.equals(Base64.encodeBytes(getIdentityKeyToCompare().serialize()))) { - Dialogs.displayAlert(this, getVerifiedTitle(), getVerifiedMessage(), android.R.drawable.ic_dialog_info); + Dialogs.showInfoDialog(this, getVerifiedTitle(), getVerifiedMessage()); } else { - Dialogs.displayAlert(this, getNotVerifiedTitle(), getNotVerifiedMessage(), android.R.drawable.ic_dialog_alert); + Dialogs.showAlertDialog(this, getNotVerifiedTitle(), getNotVerifiedMessage()); } } else { Toast.makeText(this, R.string.KeyScanningActivity_no_scanned_key_found_exclamation, diff --git a/src/org/thoughtcrime/securesms/RegistrationActivity.java b/src/org/thoughtcrime/securesms/RegistrationActivity.java index c2ee16748b..55cd3564a0 100644 --- a/src/org/thoughtcrime/securesms/RegistrationActivity.java +++ b/src/org/thoughtcrime/securesms/RegistrationActivity.java @@ -28,6 +28,7 @@ import com.google.i18n.phonenumbers.Phonenumber; import org.thoughtcrime.securesms.util.ActionBarUtil; import org.whispersystems.textsecure.crypto.MasterSecret; import org.thoughtcrime.securesms.util.TextSecurePreferences; +import org.thoughtcrime.securesms.util.Dialogs; import org.whispersystems.textsecure.util.PhoneNumberFormatter; import org.whispersystems.textsecure.util.Util; @@ -166,7 +167,7 @@ public class RegistrationActivity extends SherlockActivity { final String e164number = getConfiguredE164Number(); if (!PhoneNumberFormatter.isValidNumber(e164number)) { - Util.showAlertDialog(self, + Dialogs.showAlertDialog(self, getString(R.string.RegistrationActivity_invalid_number), String.format(getString(R.string.RegistrationActivity_the_number_you_specified_s_is_invalid), e164number)); @@ -176,7 +177,7 @@ public class RegistrationActivity extends SherlockActivity { try { GCMRegistrar.checkDevice(self); } catch (UnsupportedOperationException uoe) { - Util.showAlertDialog(self, getString(R.string.RegistrationActivity_unsupported), + Dialogs.showAlertDialog(self, getString(R.string.RegistrationActivity_unsupported), getString(R.string.RegistrationActivity_sorry_this_device_is_not_supported_for_data_messaging)); return; } diff --git a/src/org/thoughtcrime/securesms/RegistrationProgressActivity.java b/src/org/thoughtcrime/securesms/RegistrationProgressActivity.java index 4a18d669ee..67cea2798d 100644 --- a/src/org/thoughtcrime/securesms/RegistrationProgressActivity.java +++ b/src/org/thoughtcrime/securesms/RegistrationProgressActivity.java @@ -33,6 +33,7 @@ import com.actionbarsherlock.app.SherlockActivity; import org.thoughtcrime.securesms.push.PushServiceSocketFactory; import org.thoughtcrime.securesms.service.RegistrationService; import org.thoughtcrime.securesms.util.ActionBarUtil; +import org.thoughtcrime.securesms.util.Dialogs; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.whispersystems.textsecure.crypto.MasterSecret; import org.whispersystems.textsecure.push.ExpectationFailedException; @@ -317,7 +318,7 @@ public class RegistrationProgressActivity extends SherlockActivity { private void handleMultiRegistrationError(RegistrationState state) { handleVerificationTimeout(state); - Util.showAlertDialog(this, getString(R.string.RegistrationProgressActivity_registration_conflict), + Dialogs.showAlertDialog(this, getString(R.string.RegistrationProgressActivity_registration_conflict), getString(R.string.RegistrationProgressActivity_this_number_is_already_registered_on_a_different)); } @@ -493,19 +494,19 @@ public class RegistrationProgressActivity extends SherlockActivity { startService(intent); break; case NETWORK_ERROR: - Util.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_network_error), + Dialogs.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_network_error), getString(R.string.RegistrationProgressActivity_unable_to_connect)); break; case VERIFICATION_ERROR: - Util.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_verification_failed), + Dialogs.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_verification_failed), getString(R.string.RegistrationProgressActivity_the_verification_code_you_submitted_is_incorrect)); break; case RATE_LIMIT_ERROR: - Util.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_too_many_attempts), + Dialogs.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_too_many_attempts), getString(R.string.RegistrationProgressActivity_youve_submitted_an_incorrect_verification_code_too_many_times)); break; case MULTI_REGISTRATION_ERROR: - Util.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_registration_conflict), + Dialogs.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_registration_conflict), getString(R.string.RegistrationProgressActivity_this_number_is_already_registered_on_a_different)); break; } @@ -585,17 +586,17 @@ public class RegistrationProgressActivity extends SherlockActivity { }, 15000); break; case NETWORK_ERROR: - Util.showAlertDialog(context, + Dialogs.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_network_error), getString(R.string.RegistrationProgressActivity_unable_to_connect)); break; case CREATE_ERROR: - Util.showAlertDialog(context, + Dialogs.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_server_error), getString(R.string.RegistrationProgressActivity_the_server_encountered_an_error)); break; case RATE_LIMIT_EXCEEDED: - Util.showAlertDialog(context, + Dialogs.showAlertDialog(context, getString(R.string.RegistrationProgressActivity_too_many_requests), getString(R.string.RegistrationProgressActivity_youve_already_requested_a_voice_call)); break; diff --git a/src/org/thoughtcrime/securesms/ViewLocalIdentityActivity.java b/src/org/thoughtcrime/securesms/ViewLocalIdentityActivity.java index 3573c7f47b..9983c76498 100644 --- a/src/org/thoughtcrime/securesms/ViewLocalIdentityActivity.java +++ b/src/org/thoughtcrime/securesms/ViewLocalIdentityActivity.java @@ -28,6 +28,7 @@ import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; import org.thoughtcrime.securesms.crypto.IdentityKeyUtil; +import org.thoughtcrime.securesms.util.Dialogs; import org.whispersystems.textsecure.crypto.MasterSecret; import org.whispersystems.textsecure.crypto.ecc.Curve; import org.whispersystems.textsecure.crypto.ecc.ECPublicKey; @@ -74,7 +75,7 @@ public class ViewLocalIdentityActivity extends ViewIdentityActivity { private void promptToRegenerateIdentityKey() { AlertDialog.Builder dialog = new AlertDialog.Builder(this); - dialog.setIcon(android.R.drawable.ic_dialog_alert); + dialog.setIcon(Dialogs.resolveIcon(this, R.attr.dialog_alert_icon)); dialog.setTitle(getString(R.string.ViewLocalIdentityActivity_reset_identity_key)); dialog.setMessage(getString(R.string.ViewLocalIdentityActivity_by_regenerating_your_identity_key_your_existing_contacts_will_receive_warnings)); dialog.setNegativeButton(getString(R.string.ViewLocalIdentityActivity_cancel), null); diff --git a/src/org/thoughtcrime/securesms/crypto/KeyExchangeInitiator.java b/src/org/thoughtcrime/securesms/crypto/KeyExchangeInitiator.java index 616221bf15..a7075fa589 100644 --- a/src/org/thoughtcrime/securesms/crypto/KeyExchangeInitiator.java +++ b/src/org/thoughtcrime/securesms/crypto/KeyExchangeInitiator.java @@ -26,6 +26,7 @@ import org.thoughtcrime.securesms.crypto.protocol.KeyExchangeMessageV2; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.OutgoingKeyExchangeMessage; +import org.thoughtcrime.securesms.util.Dialogs; import org.whispersystems.textsecure.crypto.IdentityKeyPair; import org.whispersystems.textsecure.crypto.MasterSecret; import org.whispersystems.textsecure.crypto.ecc.Curve; @@ -44,7 +45,7 @@ public class KeyExchangeInitiator { AlertDialog.Builder dialog = new AlertDialog.Builder(context); dialog.setTitle(R.string.KeyExchangeInitiator_initiate_despite_existing_request_question); dialog.setMessage(R.string.KeyExchangeInitiator_youve_already_sent_a_session_initiation_request_to_this_recipient_are_you_sure); - dialog.setIcon(android.R.drawable.ic_dialog_alert); + dialog.setIcon(Dialogs.resolveIcon(context, R.attr.dialog_alert_icon)); dialog.setCancelable(true); dialog.setPositiveButton(R.string.KeyExchangeInitiator_send, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { diff --git a/src/org/thoughtcrime/securesms/preferences/LedBlinkPatternListPreference.java b/src/org/thoughtcrime/securesms/preferences/LedBlinkPatternListPreference.java index 327b3b3fbd..6f6c2ca816 100644 --- a/src/org/thoughtcrime/securesms/preferences/LedBlinkPatternListPreference.java +++ b/src/org/thoughtcrime/securesms/preferences/LedBlinkPatternListPreference.java @@ -34,6 +34,7 @@ import android.widget.Toast; import org.thoughtcrime.securesms.ApplicationPreferencesActivity; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.util.TextSecurePreferences; +import org.thoughtcrime.securesms.util.Dialogs; /** * List preference for LED blink pattern notification. @@ -81,7 +82,7 @@ public class LedBlinkPatternListPreference extends ListPreference implements OnS private void initializeDialog(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setIcon(android.R.drawable.ic_dialog_info); + builder.setIcon(Dialogs.resolveIcon(context, R.attr.dialog_info_icon)); builder.setTitle(R.string.preferences__pref_led_blink_custom_pattern_title); builder.setView(view); builder.setOnCancelListener(new CustomDialogCancelListener()); diff --git a/src/org/thoughtcrime/securesms/util/Dialogs.java b/src/org/thoughtcrime/securesms/util/Dialogs.java index f4300aa9af..44d40ce594 100644 --- a/src/org/thoughtcrime/securesms/util/Dialogs.java +++ b/src/org/thoughtcrime/securesms/util/Dialogs.java @@ -18,15 +18,32 @@ package org.thoughtcrime.securesms.util; import android.app.AlertDialog; import android.content.Context; +import android.graphics.drawable.Drawable; +import android.util.TypedValue; + +import org.thoughtcrime.securesms.R; public class Dialogs { + public static void showAlertDialog(Context context, String title, String message) { + AlertDialog.Builder dialog = new AlertDialog.Builder(context); + dialog.setTitle(title); + dialog.setMessage(message); + dialog.setIcon(resolveIcon(context, R.attr.dialog_alert_icon)); + dialog.setPositiveButton(android.R.string.ok, null); + dialog.show(); + } + public static void showInfoDialog(Context context, String title, String message) { + AlertDialog.Builder dialog = new AlertDialog.Builder(context); + dialog.setTitle(title); + dialog.setMessage(message); + dialog.setIcon(resolveIcon(context, R.attr.dialog_info_icon)); + dialog.setPositiveButton(android.R.string.ok, null); + dialog.show(); + } - public static void displayAlert(Context context, String title, String message, int icon) { - AlertDialog.Builder alertDialog = new AlertDialog.Builder(context); - alertDialog.setTitle(title); - alertDialog.setMessage(message); - alertDialog.setIcon(icon); - alertDialog.setPositiveButton(android.R.string.ok, null); - alertDialog.show(); + public static Drawable resolveIcon(Context c, int iconAttr) { + TypedValue out = new TypedValue(); + c.getTheme().resolveAttribute(iconAttr, out, true); + return c.getResources().getDrawable(out.resourceId); } }