mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-04 18:29:17 +02:00
tint destructive buttons in red
This commit is contained in:
parent
36b1f9567a
commit
36a480fec8
9 changed files with 41 additions and 20 deletions
|
@ -35,6 +35,7 @@ import org.thoughtcrime.securesms.connect.DcHelper;
|
|||
import org.thoughtcrime.securesms.connect.DirectShareUtil;
|
||||
import org.thoughtcrime.securesms.util.RelayUtil;
|
||||
import org.thoughtcrime.securesms.util.SendRelayedMessageUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.task.SnackbarAsyncTask;
|
||||
import org.thoughtcrime.securesms.util.views.ProgressDialog;
|
||||
|
||||
|
@ -302,7 +303,8 @@ public abstract class BaseConversationListFragment extends Fragment implements A
|
|||
});
|
||||
|
||||
alert.setNegativeButton(android.R.string.cancel, null);
|
||||
alert.show();
|
||||
AlertDialog dialog = alert.show();
|
||||
Util.redPositiveButton(dialog);
|
||||
}
|
||||
|
||||
private void handleSelectAllThreads() {
|
||||
|
|
|
@ -211,9 +211,9 @@ public class ContactSelectionListFragment extends Fragment
|
|||
}
|
||||
|
||||
private void handleDeleteSelected() {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
AlertDialog dialog = new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.ask_delete_contacts)
|
||||
.setPositiveButton(R.string.delete, (dialogInterface, i) -> {
|
||||
.setPositiveButton(R.string.delete, (d, i) -> {
|
||||
ContactSelectionListAdapter adapter = getContactSelectionListAdapter();
|
||||
final SparseIntArray actionModeSelection = adapter.getActionModeSelection().clone();
|
||||
new Thread(() -> {
|
||||
|
@ -234,6 +234,7 @@ public class ContactSelectionListFragment extends Fragment
|
|||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
Util.redPositiveButton(dialog);
|
||||
}
|
||||
|
||||
private ContactSelectionListAdapter getContactSelectionListAdapter() {
|
||||
|
|
|
@ -609,14 +609,15 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
|
||||
private void handleLeaveGroup() {
|
||||
new AlertDialog.Builder(this)
|
||||
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||
.setMessage(getString(R.string.ask_leave_group))
|
||||
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
.setPositiveButton(R.string.menu_leave_group, (d, which) -> {
|
||||
dcContext.removeContactFromChat(chatId, DcContact.DC_CONTACT_ID_SELF);
|
||||
Toast.makeText(this, getString(R.string.done), Toast.LENGTH_SHORT).show();
|
||||
})
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
Util.redPositiveButton(dialog);
|
||||
}
|
||||
|
||||
private void handleArchiveChat() {
|
||||
|
@ -632,16 +633,16 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
|
||||
private void handleDeleteChat() {
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||
.setMessage(getResources().getString(R.string.ask_delete_named_chat, dcChat.getName()))
|
||||
.setPositiveButton(R.string.delete, (dialog, which) -> {
|
||||
.setPositiveButton(R.string.delete, (d, which) -> {
|
||||
dcContext.deleteChat(chatId);
|
||||
DirectShareUtil.clearShortcut(this, chatId);
|
||||
finish();
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
Util.redPositiveButton(dialog);
|
||||
}
|
||||
|
||||
private void handleAddAttachment() {
|
||||
|
|
|
@ -365,7 +365,8 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity
|
|||
finish();
|
||||
});
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
builder.show();
|
||||
AlertDialog dialog = builder.show();
|
||||
Util.redPositiveButton(dialog);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.connect.DcHelper;
|
|||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.util.SaveAttachmentTask;
|
||||
import org.thoughtcrime.securesms.util.StorageUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -66,15 +67,16 @@ public abstract class MessageSelectorFragment
|
|||
dcChat.isDeviceTalk()? R.plurals.ask_delete_messages_simple : R.plurals.ask_delete_messages,
|
||||
messageIds.length, messageIds.length);
|
||||
|
||||
new AlertDialog.Builder(getActivity())
|
||||
AlertDialog dialog = new AlertDialog.Builder(getActivity())
|
||||
.setMessage(text)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(R.string.delete, (dialog, which) -> {
|
||||
.setPositiveButton(R.string.delete, (d, which) -> {
|
||||
dcContext.deleteMsgs(messageIds);
|
||||
if (actionMode != null) actionMode.finish();
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
Util.redPositiveButton(dialog);
|
||||
}
|
||||
|
||||
protected void handleSaveAttachment(final Set<DcMsg> messageRecords) {
|
||||
|
|
|
@ -595,13 +595,14 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
}).show();
|
||||
}
|
||||
else {
|
||||
new AlertDialog.Builder(this)
|
||||
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||
.setMessage(R.string.ask_block_contact)
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.menu_block_contact, (dialog, which) -> {
|
||||
.setPositiveButton(R.string.menu_block_contact, (d, which) -> {
|
||||
dcContext.blockContact(contactId, 1);
|
||||
}).show();
|
||||
Util.redPositiveButton(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -299,8 +299,8 @@ public class ProfileSettingsFragment extends Fragment
|
|||
readableToDelList.append(dcContext.getContact(toDelId).getDisplayName());
|
||||
}
|
||||
DcChat dcChat = dcContext.getChat(chatId);
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
AlertDialog dialog = new AlertDialog.Builder(getContext())
|
||||
.setPositiveButton(R.string.remove_desktop, (d, which) -> {
|
||||
for (Integer toDelId : toDelIds) {
|
||||
dcContext.removeContactFromChat(chatId, toDelId);
|
||||
}
|
||||
|
@ -309,6 +309,7 @@ public class ProfileSettingsFragment extends Fragment
|
|||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setMessage(getString(dcChat.isBroadcast()? R.string.ask_remove_from_broadcast : R.string.ask_remove_members, readableToDelList))
|
||||
.show();
|
||||
Util.redPositiveButton(dialog);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -117,16 +117,17 @@ public class AccountSelectionListFragment extends DialogFragment
|
|||
AccountSelectionListFragment.this.dismiss();
|
||||
if (activity == null) return;
|
||||
DcAccounts accounts = DcHelper.getAccounts(activity);
|
||||
new AlertDialog.Builder(activity)
|
||||
AlertDialog dialog = new AlertDialog.Builder(activity)
|
||||
.setTitle(accounts.getAccount(accountId).getNameNAddr())
|
||||
.setMessage(R.string.forget_login_confirmation_desktop)
|
||||
.setNegativeButton(R.string.cancel, (dialog, which) -> AccountManager.getInstance().showSwitchAccountMenu(activity))
|
||||
.setPositiveButton(R.string.ok, (dialog2, which2) -> {
|
||||
.setNegativeButton(R.string.cancel, (d, which) -> AccountManager.getInstance().showSwitchAccountMenu(activity))
|
||||
.setPositiveButton(R.string.delete, (d2, which2) -> {
|
||||
DcHelper.getNotificationCenter(activity).removeAllNotifiations(accountId);
|
||||
accounts.removeAccount(accountId);
|
||||
AccountManager.getInstance().showSwitchAccountMenu(activity);
|
||||
})
|
||||
.show();
|
||||
Util.redPositiveButton(dialog);
|
||||
}
|
||||
|
||||
private void onToggleMute(int accountId) {
|
||||
|
|
|
@ -41,6 +41,7 @@ import android.view.accessibility.AccessibilityManager;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.ComposeText;
|
||||
|
@ -92,13 +93,23 @@ public class Util {
|
|||
return spanned;
|
||||
}
|
||||
|
||||
private static final int redDestructiveColor = 0xffff0c16; // typical "destructive red" for light/dark mode
|
||||
|
||||
public static void redMenuItem(Menu menu, int id) {
|
||||
MenuItem item = menu.findItem(id);
|
||||
SpannableString s = new SpannableString(item.getTitle());
|
||||
s.setSpan(new ForegroundColorSpan(0xffff0c16 /*typical "destructive red" for light/dark mode*/), 0, s.length(), 0);
|
||||
s.setSpan(new ForegroundColorSpan(redDestructiveColor), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
}
|
||||
|
||||
public static void redPositiveButton(AlertDialog dialog) {
|
||||
try {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(redDestructiveColor);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static @NonNull int[] appendInt(@Nullable int[] cur, int val) {
|
||||
if (cur == null) {
|
||||
return new int[] { val };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue