That fuck shit the fascists are using
1/**
2 * Copyright (C) 2011 Whisper Systems
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17package org.tm.archive.util;
18
19import android.content.Context;
20
21import androidx.annotation.NonNull;
22
23import com.google.android.material.dialog.MaterialAlertDialogBuilder;
24
25import org.tm.archive.R;
26import org.tm.archive.keyvalue.SignalStore;
27import org.tm.archive.registration.RegistrationNavigationActivity;
28
29public class Dialogs {
30 public static void showAlertDialog(Context context, String title, String message) {
31 new MaterialAlertDialogBuilder(context)
32 .setTitle(title)
33 .setMessage(message)
34 .setPositiveButton(android.R.string.ok, null)
35 .show();
36 }
37
38 public static void showInfoDialog(Context context, String title, String message) {
39 new MaterialAlertDialogBuilder(context)
40 .setTitle(title)
41 .setMessage(message)
42 .setIcon(R.drawable.symbol_info_24)
43 .setPositiveButton(android.R.string.ok, null)
44 .show();
45 }
46
47 public static void showFormattedTextDialog(@NonNull Context context, @NonNull Runnable onSendAnyway) {
48 new MaterialAlertDialogBuilder(context)
49 .setTitle(R.string.SendingFormattingTextDialog_title)
50 .setMessage(R.string.SendingFormattingTextDialog_message)
51 .setNegativeButton(R.string.SendingFormattingTextDialog_cancel_send_button, null)
52 .setPositiveButton(R.string.SendingFormattingTextDialog_send_anyway_button, (d, w) -> {
53 SignalStore.uiHints().markHasSeenTextFormattingAlert();
54 onSendAnyway.run();
55 })
56 .show();
57 }
58
59 public static void showEditMessageBetaDialog(@NonNull Context context, @NonNull Runnable onSendAnyway) {
60 new MaterialAlertDialogBuilder(context)
61 .setTitle(R.string.SendingEditMessageBetaOnlyDialog_title)
62 .setMessage(R.string.SendingEditMessageBetaOnlyDialog_body)
63 .setNegativeButton(R.string.SendingEditMessageBetaOnlyDialog_cancel, null)
64 .setPositiveButton(R.string.SendingEditMessageBetaOnlyDialog_send, (d, w) -> {
65 SignalStore.uiHints().markHasSeenEditMessageBetaAlert();
66 onSendAnyway.run();
67 })
68 .show();
69 }
70
71 public static void showUpgradeSignalDialog(@NonNull Context context) {
72 new MaterialAlertDialogBuilder(context)
73 .setTitle(R.string.UpdateSignalExpiredDialog__title)
74 .setMessage(R.string.UpdateSignalExpiredDialog__message)
75 .setNegativeButton(R.string.UpdateSignalExpiredDialog__cancel_action, null)
76 .setPositiveButton(R.string.UpdateSignalExpiredDialog__update_action, (d, w) -> {
77 PlayStoreUtil.openPlayStoreOrOurApkDownloadPage(context);
78 })
79 .show();
80 }
81
82 public static void showReregisterSignalDialog(@NonNull Context context) {
83 new MaterialAlertDialogBuilder(context)
84 .setTitle(R.string.ReregisterSignalDialog__title)
85 .setMessage(R.string.ReregisterSignalDialog__message)
86 .setNegativeButton(R.string.ReregisterSignalDialog__cancel_action, null)
87 .setPositiveButton(R.string.ReregisterSignalDialog__reregister_action, (d, w) -> {
88 context.startActivity(RegistrationNavigationActivity.newIntentForReRegistration(context));
89 })
90 .show();
91 }
92}