From 4641512644df1d25728e7318183f68d7b8f05ce2 Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 2 Jun 2023 19:11:58 +0930 Subject: [PATCH] Utilise dialog dsl in RationaleDialog --- .../securesms/ExpirationDialog.kt | 2 +- .../org/thoughtcrime/securesms/MuteDialog.kt | 6 +- .../securesms/SessionDialogBuilder.kt | 2 +- .../conversation/v2/ConversationActivityV2.kt | 15 +++-- .../conversation/v2/ConversationAdapter.kt | 5 +- .../v2/menus/ConversationMenuHelper.kt | 8 +-- .../v2/utilities/NotificationUtils.kt | 4 +- .../securesms/home/HomeActivity.kt | 11 ++-- .../MessageRequestsActivity.kt | 9 ++- .../securesms/onboarding/PNModeActivity.kt | 5 +- .../securesms/permissions/Permissions.java | 14 ++--- .../permissions/RationaleDialog.java | 56 ------------------- .../securesms/permissions/RationaleDialog.kt | 54 ++++++++++++++++++ .../preferences/BlockedContactsActivity.kt | 5 +- .../preferences/CallToggleListener.kt | 2 - .../preferences/ListPreferenceDialog.kt | 4 +- .../securesms/preferences/SeedDialog.kt | 1 - .../securesms/preferences/SettingsActivity.kt | 5 +- .../securesms/util/SaveAttachmentTask.kt | 4 +- 19 files changed, 96 insertions(+), 116 deletions(-) delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/permissions/RationaleDialog.java create mode 100644 app/src/main/java/org/thoughtcrime/securesms/permissions/RationaleDialog.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/ExpirationDialog.kt b/app/src/main/java/org/thoughtcrime/securesms/ExpirationDialog.kt index c12f9c46eb..cab11c907f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ExpirationDialog.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ExpirationDialog.kt @@ -44,7 +44,7 @@ fun Context.showExpirationDialog( updateText(selectedIndex) - return sessionDialog { + return showSessionDialog { title(getString(R.string.ExpirationDialog_disappearing_messages)) view(view) okButton { onExpirationTime(numberPickerView.let { expirationTimes[it.value] }) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/MuteDialog.kt b/app/src/main/java/org/thoughtcrime/securesms/MuteDialog.kt index 96523d2e7d..f294e387ff 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/MuteDialog.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/MuteDialog.kt @@ -1,19 +1,15 @@ package org.thoughtcrime.securesms import android.content.Context -import android.content.DialogInterface import androidx.annotation.StringRes import androidx.appcompat.app.AlertDialog import network.loki.messenger.R -import java.math.BigInteger -import java.time.Instant -import java.util.* import java.util.concurrent.TimeUnit fun showMuteDialog( context: Context, onMuteDuration: (Long) -> Unit -): AlertDialog = context.sessionDialog { +): AlertDialog = context.showSessionDialog { title(R.string.MuteDialog_mute_notifications) items(Option.values().map { it.stringRes }.map(context::getString).toTypedArray()) { onMuteDuration(Option.values()[it].getTime()) diff --git a/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt b/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt index a516e89947..96bc32f14e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt @@ -137,7 +137,7 @@ class SessionDialogBuilder(val context: Context) { fun show(): AlertDialog = dialogBuilder.show().also { dialog = it } } -fun Context.sessionDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog = +fun Context.showSessionDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog = SessionDialogBuilder(this).apply { build() }.show() fun Fragment.showSessionDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog = diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 81a559f7cf..688f5ecd39 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -20,7 +20,6 @@ import android.widget.RelativeLayout import android.widget.Toast import androidx.activity.viewModels import androidx.annotation.DimenRes -import androidx.appcompat.app.AlertDialog import androidx.core.view.isVisible import androidx.fragment.app.DialogFragment import androidx.lifecycle.Observer @@ -960,7 +959,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } override fun block(deleteThread: Boolean) { - sessionDialog { + showSessionDialog { title(R.string.RecipientPreferenceActivity_block_this_contact_question) text(R.string.RecipientPreferenceActivity_you_will_no_longer_receive_messages_and_calls_from_this_contact) destructiveButton(R.string.RecipientPreferenceActivity_block, R.string.AccessibilityId_block_confirm) { @@ -1011,7 +1010,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } override fun unblock() { - sessionDialog { + showSessionDialog { title(R.string.ConversationActivity_unblock_this_contact_question) text(R.string.ConversationActivity_you_will_once_again_be_able_to_receive_messages_and_calls_from_this_contact) destructiveButton( @@ -1455,7 +1454,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe private fun showGIFPicker() { val hasSeenGIFMetaDataWarning: Boolean = textSecurePreferences.hasSeenGIFMetaDataWarning() if (!hasSeenGIFMetaDataWarning) { - sessionDialog { + showSessionDialog { title(R.string.giphy_permission_title) text(R.string.giphy_permission_message) button(R.string.continue_2) { @@ -1618,7 +1617,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe if (recipient.isOpenGroupRecipient) { val messageCount = 1 - sessionDialog { + showSessionDialog { title(resources.getQuantityString(R.plurals.ConversationFragment_delete_selected_messages, messageCount, messageCount)) text(resources.getQuantityString(R.plurals.ConversationFragment_this_will_permanently_delete_all_n_selected_messages, messageCount, messageCount)) button(R.string.delete) { messages.forEach(viewModel::deleteForEveryone); endActionMode() } @@ -1645,7 +1644,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } else { val messageCount = 1 - sessionDialog { + showSessionDialog { title(resources.getQuantityString(R.plurals.ConversationFragment_delete_selected_messages, messageCount, messageCount)) text(resources.getQuantityString(R.plurals.ConversationFragment_this_will_permanently_delete_all_n_selected_messages, messageCount, messageCount)) button(R.string.delete) { messages.forEach(viewModel::deleteLocally); endActionMode() } @@ -1655,7 +1654,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } override fun banUser(messages: Set) { - sessionDialog { + showSessionDialog { title(R.string.ConversationFragment_ban_selected_user) text("This will ban the selected user from this room. It won't ban them from other rooms.") button(R.string.ban) { viewModel.banUser(messages.first().individualRecipient); endActionMode() } @@ -1664,7 +1663,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } override fun banAndDeleteAll(messages: Set) { - sessionDialog { + showSessionDialog { title(R.string.ConversationFragment_ban_selected_user) text("This will ban the selected user from this room and delete all messages sent by them. It won't ban them from other rooms or delete the messages they sent there.") button(R.string.ban) { viewModel.banAndDeleteAll(messages.first().individualRecipient); endActionMode() } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt index 325b411290..ca7e1de780 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt @@ -1,6 +1,5 @@ package org.thoughtcrime.securesms.conversation.v2 -import android.app.AlertDialog import android.content.Context import android.content.Intent import android.database.Cursor @@ -31,7 +30,7 @@ import org.thoughtcrime.securesms.database.model.MessageRecord import org.thoughtcrime.securesms.dependencies.DatabaseComponent import org.thoughtcrime.securesms.mms.GlideRequests import org.thoughtcrime.securesms.preferences.PrivacySettingsActivity -import org.thoughtcrime.securesms.sessionDialog +import org.thoughtcrime.securesms.showSessionDialog class ConversationAdapter( context: Context, @@ -147,7 +146,7 @@ class ConversationAdapter( viewHolder.view.bind(message, messageBefore) if (message.isCallLog && message.isFirstMissedCall) { viewHolder.view.setOnClickListener { - context.sessionDialog { + context.showSessionDialog { title(R.string.CallNotificationBuilder_first_call_title) text(R.string.CallNotificationBuilder_first_call_message) button(R.string.activity_settings_title) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt index 20335aec59..11add657f2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt @@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.conversation.v2.menus import android.annotation.SuppressLint import android.content.Context -import android.content.DialogInterface import android.content.Intent import android.graphics.BitmapFactory import android.graphics.PorterDuff @@ -15,7 +14,6 @@ import android.widget.ImageView import android.widget.TextView import android.widget.Toast import androidx.annotation.ColorInt -import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.view.ContextThemeWrapper import androidx.appcompat.widget.SearchView @@ -44,7 +42,7 @@ import org.thoughtcrime.securesms.groups.EditClosedGroupActivity import org.thoughtcrime.securesms.groups.EditClosedGroupActivity.Companion.groupIDKey import org.thoughtcrime.securesms.preferences.PrivacySettingsActivity import org.thoughtcrime.securesms.service.WebRtcCallService -import org.thoughtcrime.securesms.sessionDialog +import org.thoughtcrime.securesms.showSessionDialog import org.thoughtcrime.securesms.showMuteDialog import org.thoughtcrime.securesms.util.BitmapUtil import java.io.IOException @@ -187,7 +185,7 @@ object ConversationMenuHelper { private fun call(context: Context, thread: Recipient) { if (!TextSecurePreferences.isCallNotificationsEnabled(context)) { - context.sessionDialog { + context.showSessionDialog { title(R.string.ConversationActivity_call_title) text(R.string.ConversationActivity_call_prompt) button(R.string.activity_settings_title, R.string.AccessibilityId_settings) { @@ -303,7 +301,7 @@ object ConversationMenuHelper { fun onLeaveFailed() = Toast.makeText(context, R.string.ConversationActivity_error_leaving_group, Toast.LENGTH_LONG).show() - context.sessionDialog { + context.showSessionDialog { title(R.string.ConversationActivity_leave_group) text(message) button(R.string.yes) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/NotificationUtils.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/NotificationUtils.kt index 0a6f839405..c0ce83f631 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/NotificationUtils.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/NotificationUtils.kt @@ -3,11 +3,11 @@ package org.thoughtcrime.securesms.conversation.v2.utilities import android.content.Context import network.loki.messenger.R import org.session.libsession.utilities.recipients.Recipient -import org.thoughtcrime.securesms.sessionDialog +import org.thoughtcrime.securesms.showSessionDialog object NotificationUtils { fun showNotifyDialog(context: Context, thread: Recipient, notifyTypeHandler: (Int)->Unit) { - context.sessionDialog { + context.showSessionDialog { title(R.string.RecipientPreferenceActivity_notification_settings) singleChoiceItems( context.resources.getStringArray(R.array.notify_types), diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt index adcae62f58..2470c0ed04 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -10,7 +10,6 @@ import android.os.Bundle import android.text.SpannableString import android.widget.Toast import androidx.activity.viewModels -import androidx.appcompat.app.AlertDialog import androidx.core.os.bundleOf import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope @@ -62,7 +61,7 @@ import org.thoughtcrime.securesms.mms.GlideRequests import org.thoughtcrime.securesms.onboarding.SeedActivity import org.thoughtcrime.securesms.onboarding.SeedReminderViewDelegate import org.thoughtcrime.securesms.preferences.SettingsActivity -import org.thoughtcrime.securesms.sessionDialog +import org.thoughtcrime.securesms.showSessionDialog import org.thoughtcrime.securesms.showMuteDialog import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities import org.thoughtcrime.securesms.util.DateUtils @@ -489,7 +488,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), } private fun blockConversation(thread: ThreadRecord) { - sessionDialog { + showSessionDialog { title(R.string.RecipientPreferenceActivity_block_this_contact_question) text(R.string.RecipientPreferenceActivity_you_will_no_longer_receive_messages_and_calls_from_this_contact) button(R.string.RecipientPreferenceActivity_block) { @@ -505,7 +504,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), } private fun unblockConversation(thread: ThreadRecord) { - sessionDialog { + showSessionDialog { title(R.string.RecipientPreferenceActivity_unblock_this_contact_question) text(R.string.RecipientPreferenceActivity_you_will_once_again_be_able_to_receive_messages_and_calls_from_this_contact) button(R.string.RecipientPreferenceActivity_unblock) { @@ -576,7 +575,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), resources.getString(R.string.activity_home_delete_conversation_dialog_message) } - sessionDialog { + showSessionDialog { text(message) button(R.string.yes) { lifecycleScope.launch(Dispatchers.Main) { @@ -643,7 +642,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), } private fun hideMessageRequests() { - sessionDialog { + showSessionDialog { text("Hide message requests?") button(R.string.yes) { textSecurePreferences.setHasHiddenMessageRequests() diff --git a/app/src/main/java/org/thoughtcrime/securesms/messagerequests/MessageRequestsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/messagerequests/MessageRequestsActivity.kt index 4618ed0bda..60942fd72b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/messagerequests/MessageRequestsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/messagerequests/MessageRequestsActivity.kt @@ -1,6 +1,5 @@ package org.thoughtcrime.securesms.messagerequests -import android.app.AlertDialog import android.content.Intent import android.database.Cursor import android.os.Bundle @@ -20,7 +19,7 @@ import org.thoughtcrime.securesms.database.ThreadDatabase import org.thoughtcrime.securesms.database.model.ThreadRecord import org.thoughtcrime.securesms.mms.GlideApp import org.thoughtcrime.securesms.mms.GlideRequests -import org.thoughtcrime.securesms.sessionDialog +import org.thoughtcrime.securesms.showSessionDialog import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities import org.thoughtcrime.securesms.util.push import javax.inject.Inject @@ -83,7 +82,7 @@ class MessageRequestsActivity : PassphraseRequiredActionBarActivity(), Conversat LoaderManager.getInstance(this).restartLoader(0, null, this) } - sessionDialog { + showSessionDialog { title(R.string.RecipientPreferenceActivity_block_this_contact_question) text(R.string.message_requests_block_message) button(R.string.recipient_preferences__block) { doBlock() } @@ -100,7 +99,7 @@ class MessageRequestsActivity : PassphraseRequiredActionBarActivity(), Conversat } } - sessionDialog { + showSessionDialog { title(R.string.decline) text(resources.getString(R.string.message_requests_decline_message)) button(R.string.decline) { doDecline() } @@ -123,7 +122,7 @@ class MessageRequestsActivity : PassphraseRequiredActionBarActivity(), Conversat } } - sessionDialog { + showSessionDialog { text(resources.getString(R.string.message_requests_clear_all_message)) button(R.string.yes) { doDeleteAllAndBlock() } button(R.string.no) diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/PNModeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/PNModeActivity.kt index fe1139d031..42f3a85b47 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/PNModeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/PNModeActivity.kt @@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.onboarding import android.animation.ArgbEvaluator import android.animation.ValueAnimator -import android.app.AlertDialog import android.content.Intent import android.graphics.drawable.TransitionDrawable import android.net.Uri @@ -20,7 +19,7 @@ import org.session.libsession.utilities.ThemeUtil import org.thoughtcrime.securesms.ApplicationContext import org.thoughtcrime.securesms.BaseActionBarActivity import org.thoughtcrime.securesms.home.HomeActivity -import org.thoughtcrime.securesms.sessionDialog +import org.thoughtcrime.securesms.showSessionDialog import org.thoughtcrime.securesms.util.GlowViewUtilities import org.thoughtcrime.securesms.util.PNModeView import org.thoughtcrime.securesms.util.disableClipping @@ -152,7 +151,7 @@ class PNModeActivity : BaseActionBarActivity() { private fun register() { if (selectedOptionView == null) { - sessionDialog { + showSessionDialog { title(R.string.activity_pn_mode_no_option_picked_dialog_title) button(R.string.ok) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/permissions/Permissions.java b/app/src/main/java/org/thoughtcrime/securesms/permissions/Permissions.java index 2d7e6dae59..8cda4ab95b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/permissions/Permissions.java +++ b/app/src/main/java/org/thoughtcrime/securesms/permissions/Permissions.java @@ -162,15 +162,13 @@ public class Permissions { request.onResult(requestedPermissions, grantResults, new boolean[requestedPermissions.length]); } - @SuppressWarnings("ConstantConditions") private void executePermissionsRequestWithRationale(PermissionsRequest request) { - AlertDialog dialog = RationaleDialog.createFor(permissionObject.getContext(), rationaleDialogMessage, rationalDialogHeader) - .setPositiveButton(R.string.Permissions_continue, (d, which) -> executePermissionsRequest(request)) - .setNegativeButton(R.string.Permissions_not_now, (d, which) -> executeNoPermissionsRequest(request)) - .show(); - dialog.getWindow().setLayout((int)(permissionObject.getWindowWidth() * .75), ViewGroup.LayoutParams.WRAP_CONTENT); - Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); - positiveButton.setContentDescription("Continue"); + RationaleDialog.show( + permissionObject.getContext(), + rationaleDialogMessage, + () -> executePermissionsRequest(request), + () -> executeNoPermissionsRequest(request), + rationalDialogHeader); } private void executePermissionsRequest(PermissionsRequest request) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/permissions/RationaleDialog.java b/app/src/main/java/org/thoughtcrime/securesms/permissions/RationaleDialog.java deleted file mode 100644 index a346d591ac..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/permissions/RationaleDialog.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.thoughtcrime.securesms.permissions; - - -import android.app.AlertDialog; -import android.content.Context; -import android.graphics.Color; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.LinearLayout.LayoutParams; -import android.widget.TextView; - -import androidx.annotation.DrawableRes; -import androidx.annotation.NonNull; - -import org.session.libsession.utilities.ViewUtil; - -import network.loki.messenger.R; - -public class RationaleDialog { - - public static AlertDialog.Builder createFor(@NonNull Context context, @NonNull String message, @DrawableRes int... drawables) { - View view = LayoutInflater.from(context).inflate(R.layout.permissions_rationale_dialog, null); - view.setClipToOutline(true); - ViewGroup header = view.findViewById(R.id.header_container); - TextView text = view.findViewById(R.id.message); - - for (int i=0;i(R.id.header_container) + view.findViewById(R.id.message).text = message + drawables.forEach { + ImageView(context).apply { + setImageDrawable(ResourcesCompat.getDrawable(context.resources, it, context.theme)) + layoutParams = LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) + }.also(header::addView) + } + if (drawables.isNotEmpty()) { + TextView(context).apply { + text = "+" + setTextSize(TypedValue.COMPLEX_UNIT_SP, 40f) + setTextColor(Color.WHITE) + layoutParams = LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply { + ViewUtil.dpToPx(context, 20).let { setMargins(it, 0, it, 0) } + } + }.also(header::addView) + } + + return context.showSessionDialog { + view(view) + button(R.string.Permissions_continue) { onPositive.run() } + button(R.string.Permissions_not_now) { onNegative.run() } + } + } +} diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/BlockedContactsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/BlockedContactsActivity.kt index 122e1b533c..bd7aa80192 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/BlockedContactsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/BlockedContactsActivity.kt @@ -1,6 +1,5 @@ package org.thoughtcrime.securesms.preferences -import android.app.AlertDialog import android.os.Bundle import android.view.View import androidx.activity.viewModels @@ -9,7 +8,7 @@ import dagger.hilt.android.AndroidEntryPoint import network.loki.messenger.R import network.loki.messenger.databinding.ActivityBlockedContactsBinding import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity -import org.thoughtcrime.securesms.sessionDialog +import org.thoughtcrime.securesms.showSessionDialog @AndroidEntryPoint class BlockedContactsActivity: PassphraseRequiredActionBarActivity(), View.OnClickListener { @@ -52,7 +51,7 @@ class BlockedContactsActivity: PassphraseRequiredActionBarActivity(), View.OnCli getString(R.string.Unblock_dialog__message, stringBuilder.toString()) } - sessionDialog { + showSessionDialog { title(title) text(message) button(R.string.continue_2) { viewModel.unblock(contactsToUnblock) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/CallToggleListener.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/CallToggleListener.kt index da166e63f4..ea747798c8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/CallToggleListener.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/CallToggleListener.kt @@ -6,9 +6,7 @@ import androidx.preference.Preference import network.loki.messenger.R import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.TextSecurePreferences.Companion.setBooleanPreference -import org.thoughtcrime.securesms.createSessionDialog import org.thoughtcrime.securesms.permissions.Permissions -import org.thoughtcrime.securesms.sessionDialog import org.thoughtcrime.securesms.showSessionDialog internal class CallToggleListener( diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/ListPreferenceDialog.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/ListPreferenceDialog.kt index f49cfc39d8..6f0998eecb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/ListPreferenceDialog.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/ListPreferenceDialog.kt @@ -3,14 +3,14 @@ package org.thoughtcrime.securesms.preferences import android.content.Context import androidx.appcompat.app.AlertDialog import androidx.preference.ListPreference -import org.thoughtcrime.securesms.sessionDialog +import org.thoughtcrime.securesms.showSessionDialog fun listPreferenceDialog( context: Context, listPreference: ListPreference, onChange: () -> Unit ) : AlertDialog = listPreference.run { - context.sessionDialog { + context.showSessionDialog { val index = entryValues.indexOf(value) val options = entries.map(CharSequence::toString).toTypedArray() diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SeedDialog.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SeedDialog.kt index 0bdaa477ac..bae5f19605 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SeedDialog.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SeedDialog.kt @@ -13,7 +13,6 @@ import org.session.libsignal.utilities.hexEncodedPrivateKey import org.thoughtcrime.securesms.createSessionDialog import org.thoughtcrime.securesms.crypto.IdentityKeyUtil import org.thoughtcrime.securesms.crypto.MnemonicUtilities -import org.thoughtcrime.securesms.sessionDialog class SeedDialog: DialogFragment() { private val seed by lazy { diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt index a78038c3eb..71416a2ca7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt @@ -16,7 +16,6 @@ import android.view.MenuItem import android.view.View import android.view.inputmethod.InputMethodManager import android.widget.Toast -import androidx.appcompat.app.AlertDialog import androidx.core.view.isVisible import network.loki.messenger.BuildConfig import network.loki.messenger.R @@ -38,7 +37,7 @@ import org.thoughtcrime.securesms.mms.GlideRequests import org.thoughtcrime.securesms.permissions.Permissions import org.thoughtcrime.securesms.preferences.appearance.AppearanceSettingsActivity import org.thoughtcrime.securesms.profiles.ProfileMediaConstraints -import org.thoughtcrime.securesms.sessionDialog +import org.thoughtcrime.securesms.showSessionDialog import org.thoughtcrime.securesms.util.BitmapDecodingException import org.thoughtcrime.securesms.util.BitmapUtil import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities @@ -261,7 +260,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { } private fun showEditProfilePictureUI() { - sessionDialog { + showSessionDialog { title(R.string.activity_settings_set_display_picture) view(R.layout.dialog_change_avatar) button(R.string.activity_settings_upload) { startAvatarSelection() } diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/SaveAttachmentTask.kt b/app/src/main/java/org/thoughtcrime/securesms/util/SaveAttachmentTask.kt index 66dc414c4d..8b219849a0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/SaveAttachmentTask.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/SaveAttachmentTask.kt @@ -16,7 +16,7 @@ import org.session.libsession.utilities.task.ProgressDialogAsyncTask import org.session.libsignal.utilities.ExternalStorageUtil import org.session.libsignal.utilities.Log import org.thoughtcrime.securesms.mms.PartAuthority -import org.thoughtcrime.securesms.sessionDialog +import org.thoughtcrime.securesms.showSessionDialog import java.io.File import java.io.FileOutputStream import java.io.IOException @@ -46,7 +46,7 @@ class SaveAttachmentTask @JvmOverloads constructor(context: Context, count: Int @JvmStatic @JvmOverloads fun showWarningDialog(context: Context, count: Int = 1, onAcceptListener: () -> Unit = {}) { - context.sessionDialog { + context.showSessionDialog { title(R.string.ConversationFragment_save_to_sd_card) iconAttribute(R.attr.dialog_alert_icon) text(context.resources.getQuantityString(