Use modern icons in info and alert dialogs for ICS+

This commit is contained in:
Benjamin Albrecht 2014-03-01 01:32:00 +01:00
parent 8ea4db03db
commit 0f6c7660cb
35 changed files with 88 additions and 48 deletions

View file

@ -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 {

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="drawable" name="ic_dialog_info_light">@drawable/ic_dialog_info_holo_light</item>
<item type="drawable" name="ic_dialog_info_dark">@drawable/ic_dialog_info_holo_dark</item>
<item type="drawable" name="ic_dialog_alert_light">@drawable/ic_dialog_alert_holo_light</item>
<item type="drawable" name="ic_dialog_alert_dark">@drawable/ic_dialog_alert_holo_dark</item>
</resources>

View file

@ -35,6 +35,8 @@
<attr name="conversation_item_sent_triangle_background" format="reference" />
<attr name="conversation_item_sent_push_background" format="reference" />
<attr name="conversation_item_sent_push_triangle_background" format="reference" />
<attr name="dialog_info_icon" format="reference" />
<attr name="dialog_alert_icon" format="reference" />
<attr name="contact_selection_push_user" format="reference|color" />
<attr name="contact_selection_lay_user" format="reference|color" />

7
res/values/resources.xml Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="drawable" name="ic_dialog_info_light">@android:drawable/ic_dialog_info</item>
<item type="drawable" name="ic_dialog_alert_light">@android:drawable/ic_dialog_alert</item>
<item type="drawable" name="ic_dialog_info_dark">@android:drawable/ic_dialog_info</item>
<item type="drawable" name="ic_dialog_alert_dark">@android:drawable/ic_dialog_alert</item>
</resources>

View file

@ -39,6 +39,8 @@
<item name="conversation_item_sent_triangle_background">@drawable/conversation_item_sent_triangle_shape</item>
<item name="conversation_item_sent_push_background">@drawable/conversation_item_sent_push_shape</item>
<item name="conversation_item_sent_push_triangle_background">@drawable/conversation_item_sent_push_triangle_shape</item>
<item name="dialog_info_icon">@drawable/ic_dialog_info_light</item>
<item name="dialog_alert_icon">@drawable/ic_dialog_alert_light</item>
<item name="menu_new_conversation_icon">@drawable/ic_action_new_holo_light</item>
<item name="menu_new_group_icon">@drawable/ic_action_add_group_holo_light</item>
@ -93,6 +95,8 @@
<item name="conversation_item_sent_triangle_background">@drawable/conversation_item_sent_triangle_shape_dark</item>
<item name="conversation_item_sent_push_background">@drawable/conversation_item_sent_push_shape_dark</item>
<item name="conversation_item_sent_push_triangle_background">@drawable/conversation_item_sent_push_triangle_shape_dark</item>
<item name="dialog_info_icon">@drawable/ic_dialog_info_dark</item>
<item name="dialog_alert_icon">@drawable/ic_dialog_alert_dark</item>
<item name="actionbar_icon">@drawable/actionbar_icon_holo_dark</item>
<item name="lower_right_divet">@drawable/divet_lower_right_light</item>

View file

@ -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) {

View file

@ -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() {

View file

@ -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()) {

View file

@ -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() {

View file

@ -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);

View file

@ -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() {

View file

@ -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() {

View file

@ -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,

View file

@ -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;
}

View file

@ -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;

View file

@ -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);

View file

@ -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) {

View file

@ -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());

View file

@ -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);
}
}