Add dialog redirecting users to web for missing features
This commit is contained in:
parent
c463c7f48b
commit
1f93a66016
|
@ -52,6 +52,7 @@ import ch.protonmail.android.events.Status;
|
|||
import ch.protonmail.android.events.organizations.OrganizationEvent;
|
||||
import ch.protonmail.android.jobs.organizations.GetOrganizationJob;
|
||||
import ch.protonmail.android.usecase.model.FetchPaymentMethodsResult;
|
||||
import ch.protonmail.android.utils.ui.dialogs.DialogUtils;
|
||||
import ch.protonmail.android.viewmodel.AccountTypeViewModel;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
@ -233,6 +234,12 @@ public class AccountTypeActivity extends BaseActivity {
|
|||
|
||||
@OnClick(R.id.upgrade)
|
||||
public void onUpgrade() {
|
||||
DialogUtils.Companion.showInfoDialog(
|
||||
this,
|
||||
"",
|
||||
getString(R.string.info_for_missing_functionality),
|
||||
unit -> unit
|
||||
);
|
||||
/*
|
||||
Intent upgradeIntent = new Intent(this, UpsellingActivity.class);
|
||||
upgradeIntent.putExtra(UpsellingActivity.EXTRA_OPEN_UPGRADE_CONTAINER, true);
|
||||
|
|
|
@ -71,7 +71,6 @@ import ch.protonmail.android.domain.entity.user.User
|
|||
import ch.protonmail.android.events.FetchLabelsEvent
|
||||
import ch.protonmail.android.jobs.FetchByLocationJob
|
||||
import ch.protonmail.android.mailbox.data.local.ConversationDao
|
||||
import ch.protonmail.android.mailbox.presentation.MailboxActivity
|
||||
import ch.protonmail.android.servers.notification.CHANNEL_ID_EMAIL
|
||||
import ch.protonmail.android.settings.pin.PinSettingsActivity
|
||||
import ch.protonmail.android.uiModel.SettingsItemUiModel
|
||||
|
@ -82,6 +81,7 @@ import ch.protonmail.android.utils.PREF_CUSTOM_APP_LANGUAGE
|
|||
import ch.protonmail.android.utils.extensions.app
|
||||
import ch.protonmail.android.utils.extensions.showToast
|
||||
import ch.protonmail.android.utils.startMailboxActivity
|
||||
import ch.protonmail.android.utils.ui.dialogs.DialogUtils.Companion.showInfoDialog
|
||||
import ch.protonmail.android.viewmodel.ConnectivityBaseViewModel
|
||||
import com.google.gson.Gson
|
||||
import timber.log.Timber
|
||||
|
@ -136,6 +136,7 @@ abstract class BaseSettingsActivity : BaseConnectivityActivity() {
|
|||
lateinit var selectedAddress: Address
|
||||
var mDisplayName: String = ""
|
||||
var mSignature: String = ""
|
||||
|
||||
@Deprecated("Use new User model", ReplaceWith("user"))
|
||||
lateinit var legacyUser: LegacyUser
|
||||
lateinit var user: User
|
||||
|
@ -146,8 +147,11 @@ abstract class BaseSettingsActivity : BaseConnectivityActivity() {
|
|||
settingsAdapter.onItemClick = { settingItem ->
|
||||
|
||||
if (settingItem.isSection.not() &&
|
||||
(settingItem.settingType == SettingsItemUiModel.SettingsItemTypeEnum.DRILL_DOWN ||
|
||||
settingItem.settingType == SettingsItemUiModel.SettingsItemTypeEnum.BUTTON)) {
|
||||
(
|
||||
settingItem.settingType == SettingsItemUiModel.SettingsItemTypeEnum.DRILL_DOWN ||
|
||||
settingItem.settingType == SettingsItemUiModel.SettingsItemTypeEnum.BUTTON
|
||||
)
|
||||
) {
|
||||
selectItem(settingItem.settingId)
|
||||
}
|
||||
}
|
||||
|
@ -265,11 +269,15 @@ abstract class BaseSettingsActivity : BaseConnectivityActivity() {
|
|||
AppUtil.decorInAppIntent(Intent(this, AccountTypeActivity::class.java))
|
||||
startActivity(accountTypeIntent)
|
||||
}
|
||||
PASSWORD_MANAGEMENT -> {
|
||||
TODO("startChangePasswordWorkflow")
|
||||
}
|
||||
PASSWORD_MANAGEMENT,
|
||||
RECOVERY_EMAIL -> {
|
||||
TODO("startRecoverySetupWorkflow")
|
||||
showInfoDialog(
|
||||
this,
|
||||
"",
|
||||
getString(R.string.info_for_missing_functionality)
|
||||
) { unit: Unit -> unit }
|
||||
// TODO("startChangePasswordWorkflow")
|
||||
// TODO("startrecoverysetupworkflow")
|
||||
}
|
||||
DEFAULT_EMAIL -> {
|
||||
showSortAliasDialog()
|
||||
|
@ -451,7 +459,8 @@ abstract class BaseSettingsActivity : BaseConnectivityActivity() {
|
|||
SHOW_EMBEDDED_IMAGES,
|
||||
SHOW_REMOTE_IMAGES,
|
||||
SIGNATURE,
|
||||
SNOOZE -> { /* ignored */ }
|
||||
SNOOZE -> { /* ignored */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,10 @@ package ch.protonmail.android.utils.ui.dialogs
|
|||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.text.SpannableString
|
||||
import android.text.Spanned
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.util.Linkify
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.CheckBox
|
||||
|
@ -35,11 +38,33 @@ import com.google.android.material.snackbar.Snackbar
|
|||
/**
|
||||
* Created by kadrikj on 10/24/18. */
|
||||
class DialogUtils {
|
||||
|
||||
companion object {
|
||||
|
||||
fun showInfoDialog(context: Context, title: String, message: String, okListener: ((Unit) -> Unit)?) {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
|
||||
val messageWithLinks = SpannableString(message)
|
||||
Linkify.addLinks(messageWithLinks, Linkify.WEB_URLS)
|
||||
|
||||
builder.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setMessage(messageWithLinks)
|
||||
.setNeutralButton(R.string.okay) { dialog, _ ->
|
||||
run {
|
||||
okListener?.invoke(Unit)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
.create()
|
||||
|
||||
val dialog: AlertDialog = builder.show()
|
||||
(dialog.findViewById(android.R.id.message) as TextView).movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
|
||||
fun showInfoDialogWithCustomView(context: Context, title: String, view: View, okListener: ((Unit) -> Unit)?) {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
builder.setTitle(title)
|
||||
.setView(view)
|
||||
.setNeutralButton(R.string.okay) { dialog, _ ->
|
||||
run {
|
||||
okListener?.invoke(Unit)
|
||||
|
@ -50,20 +75,6 @@ class DialogUtils {
|
|||
.show()
|
||||
}
|
||||
|
||||
fun showInfoDialogWithCustomView(context: Context, title: String, view: View, okListener: ((Unit) -> Unit)?) {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
builder.setTitle(title)
|
||||
.setView(view)
|
||||
.setNeutralButton(R.string.okay) { dialog, _ ->
|
||||
run {
|
||||
okListener?.invoke(Unit)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
.create()
|
||||
.show()
|
||||
}
|
||||
|
||||
fun showDeleteConfirmationDialog(context: Context, title: String, message: String, okListener: (Unit) -> Unit) {
|
||||
showInfoDialogWithTwoButtons(
|
||||
context, title, message, context.getString(R.string.no),
|
||||
|
@ -88,10 +99,18 @@ class DialogUtils {
|
|||
)
|
||||
)
|
||||
@JvmOverloads
|
||||
fun showInfoDialogWithTwoButtons(context: Context, title: String, message: String,
|
||||
negativeBtnText: String, positiveBtnText: String,
|
||||
dismissListener: ((Unit) -> Unit)?, okListener: ((Unit) -> Unit)?,
|
||||
cancelable: Boolean, dismissible: Boolean = true, outsideClickCancellable: Boolean = true): AlertDialog {
|
||||
fun showInfoDialogWithTwoButtons(
|
||||
context: Context,
|
||||
title: String,
|
||||
message: String,
|
||||
negativeBtnText: String,
|
||||
positiveBtnText: String,
|
||||
dismissListener: ((Unit) -> Unit)?,
|
||||
okListener: ((Unit) -> Unit)?,
|
||||
cancelable: Boolean,
|
||||
dismissible: Boolean = true,
|
||||
outsideClickCancellable: Boolean = true
|
||||
): AlertDialog {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
val dialog = builder.setTitle(title)
|
||||
.setMessage(message)
|
||||
|
@ -203,9 +222,15 @@ class DialogUtils {
|
|||
")"
|
||||
)
|
||||
)
|
||||
fun showInfoDialogWithTwoButtons(context: Context, title: String, message: String,
|
||||
negativeBtnText: String, positiveBtnText: String,
|
||||
okListener: ((Unit) -> Unit)?, cancelable: Boolean) {
|
||||
fun showInfoDialogWithTwoButtons(
|
||||
context: Context,
|
||||
title: String,
|
||||
message: String,
|
||||
negativeBtnText: String,
|
||||
positiveBtnText: String,
|
||||
okListener: ((Unit) -> Unit)?,
|
||||
cancelable: Boolean
|
||||
) {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
builder.setTitle(title)
|
||||
.setMessage(message)
|
||||
|
@ -221,9 +246,17 @@ class DialogUtils {
|
|||
.show()
|
||||
}
|
||||
|
||||
fun showInfoDialogWithTwoButtonsAndCheckbox(context: Context, title: String, message: Spanned,
|
||||
negativeBtnText: String, positiveBtnText: String, checkBoxText: String,
|
||||
okListener: (Unit) -> Unit, checkedListener: (Boolean) -> Unit, cancelable: Boolean) {
|
||||
fun showInfoDialogWithTwoButtonsAndCheckbox(
|
||||
context: Context,
|
||||
title: String,
|
||||
message: Spanned,
|
||||
negativeBtnText: String,
|
||||
positiveBtnText: String,
|
||||
checkBoxText: String,
|
||||
okListener: (Unit) -> Unit,
|
||||
checkedListener: (Boolean) -> Unit,
|
||||
cancelable: Boolean
|
||||
) {
|
||||
|
||||
val builder = AlertDialog.Builder(context)
|
||||
|
||||
|
@ -234,24 +267,29 @@ class DialogUtils {
|
|||
}
|
||||
|
||||
val dialog = builder
|
||||
.setTitle(title)
|
||||
.setView(checkBoxView)
|
||||
.setMessage(message)
|
||||
.setNegativeButton(negativeBtnText) { dialog, _ -> dialog.dismiss() }
|
||||
.setPositiveButton(positiveBtnText) { dialog, _ ->
|
||||
run {
|
||||
okListener.invoke(Unit)
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setTitle(title)
|
||||
.setView(checkBoxView)
|
||||
.setMessage(message)
|
||||
.setNegativeButton(negativeBtnText) { dialog, _ -> dialog.dismiss() }
|
||||
.setPositiveButton(positiveBtnText) { dialog, _ ->
|
||||
run {
|
||||
okListener.invoke(Unit)
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setCancelable(cancelable)
|
||||
.create()
|
||||
}
|
||||
.setCancelable(cancelable)
|
||||
.create()
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
fun warningDialog(context: Context, okButtonText: String, cancelButtonText: String,
|
||||
description: String, okListener: (Unit) -> Unit) {
|
||||
fun warningDialog(
|
||||
context: Context,
|
||||
okButtonText: String,
|
||||
cancelButtonText: String,
|
||||
description: String,
|
||||
okListener: (Unit) -> Unit
|
||||
) {
|
||||
val dialog = Dialog(context)
|
||||
dialog.setContentView(R.layout.layout_dialog_warning)
|
||||
dialog.setCancelable(false)
|
||||
|
@ -270,10 +308,17 @@ class DialogUtils {
|
|||
dialog.show()
|
||||
}
|
||||
|
||||
fun showInfoDialogWithThreeButtons(context: Context, title: String, message: String,
|
||||
negativeBtnText: String, positiveBtnText: String, neultralBtnText: String,
|
||||
dismissListener: (Unit) -> Unit, okListener: (Unit) -> Unit,
|
||||
cancelable: Boolean) {
|
||||
fun showInfoDialogWithThreeButtons(
|
||||
context: Context,
|
||||
title: String,
|
||||
message: String,
|
||||
negativeBtnText: String,
|
||||
positiveBtnText: String,
|
||||
neultralBtnText: String,
|
||||
dismissListener: (Unit) -> Unit,
|
||||
okListener: (Unit) -> Unit,
|
||||
cancelable: Boolean
|
||||
) {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
builder.setTitle(title)
|
||||
.setMessage(message)
|
||||
|
@ -289,17 +334,24 @@ class DialogUtils {
|
|||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
.setNeutralButton(neultralBtnText) { dialog, _ -> dialog.dismiss()
|
||||
.setNeutralButton(neultralBtnText) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setCancelable(cancelable)
|
||||
.create()
|
||||
.show()
|
||||
}
|
||||
|
||||
fun showUndoSnackbar(context: Context, parent: View, message: String, okListener: (Unit) -> Unit, showUndo: Boolean) : Snackbar {
|
||||
fun showUndoSnackbar(
|
||||
context: Context,
|
||||
parent: View,
|
||||
message: String,
|
||||
okListener: (Unit) -> Unit,
|
||||
showUndo: Boolean
|
||||
): Snackbar {
|
||||
val undoSnack = Snackbar.make(parent, message, Snackbar.LENGTH_LONG)
|
||||
undoSnack.setColorWhite(context)
|
||||
if(showUndo) {
|
||||
if (showUndo) {
|
||||
undoSnack.setBackgroundTint(context.getColor(R.color.interaction_strong))
|
||||
undoSnack.setActionTextColor(context.getColor(R.color.text_inverted))
|
||||
undoSnack.setAction(context.getString(R.string.undo)) {
|
||||
|
|
|
@ -784,6 +784,7 @@
|
|||
|
||||
<string name="password_manager">Password management</string>
|
||||
<string name="recovery_email">Recovery email</string>
|
||||
<string name="info_for_missing_functionality">Please log in through <a href="https://www.protonmail.com/">protonmail.com</a> and access your settings to edit this information.</string>
|
||||
<string name="storage">Mailbox size</string>
|
||||
<string name="storage_used">%1$s / %2$s</string>
|
||||
|
||||
|
|
Loading…
Reference in New Issue