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