Remove local icons and use core icons for v5 rebranding

MAILAND-2759
This commit is contained in:
Zorica Stojchevska 2022-03-10 14:57:54 +01:00 committed by Zorica Stojchevska
parent f1aa35268c
commit 19031ab346
279 changed files with 264 additions and 3104 deletions

View File

@ -133,7 +133,8 @@ class DefaultAddressActivity : BaseActivity() {
@OnClick(R.id.defaultAddress)
fun onDefaultAddressClicked() {
val icon = ResourcesCompat.getDrawable(
resources, if (!addressChooser.isVisible) R.drawable.ic_chevron_down else R.drawable.ic_chevron_up, null
resources,
if (!addressChooser.isVisible) R.drawable.ic_proton_chevron_down else R.drawable.ic_proton_chevron_up, null
)?.mutate()
defaultAddress.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, icon, null)

View File

@ -1262,7 +1262,7 @@ public class ComposeMessageActivity
}
private void setAdditionalRowVisibility(boolean show) {
final int icon = show ? R.drawable.ic_chevron_up : R.drawable.ic_chevron_down;
final int icon = show ? R.drawable.ic_proton_chevron_up : R.drawable.ic_proton_chevron_down;
binding.composerExpandRecipientsButton.setImageResource(icon);
final int visibility = show ? View.VISIBLE : View.GONE;
binding.composerExpandedRecipientsGroup.setVisibility(visibility);

View File

@ -1,157 +0,0 @@
/*
* Copyright (c) 2022 Proton AG
*
* This file is part of Proton Mail.
*
* Proton Mail is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Proton Mail is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proton Mail. If not, see https://www.gnu.org/licenses/.
*/
package ch.protonmail.android.adapters;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.protonmail.android.R;
import ch.protonmail.android.utils.UiUtil;
import ch.protonmail.android.views.ThreeStateButton;
@Deprecated // replaced with ManageLabelsActionAdapter
public class LabelsDialogAdapter extends ArrayAdapter<LabelsDialogAdapter.LabelItem> {
private List<LabelItem> items;
private final int mStrokeWidth;
public LabelsDialogAdapter(Context context, List<LabelItem> items) {
super(context, R.layout.dialog_labels_list_item);
this.items = items;
addAll(items);
mStrokeWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, context
.getResources().getDisplayMetrics());
setNotifyOnChange(false);
}
public List<LabelItem> getAllItems() {
if (items == null) {
return new ArrayList<>();
}
return items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_labels_list_item, null);
final ViewHolder viewHolder = new ViewHolder(view);
view.setTag(viewHolder);
convertView = view;
}
final LabelItem item = getItem(position);
String labelNameDisplay = item.name;
if (item.name.length() > 15){
labelNameDisplay = labelNameDisplay.substring(0, 14) + "...";
}
final ViewHolder viewHolder = (ViewHolder) convertView.getTag();
viewHolder.mLabelCheck.setOnStateChangedListener(null);
viewHolder.mLabelCheck.setNumberOfStates(item.states);
viewHolder.mLabelCheck.setVisibility(View.VISIBLE);
viewHolder.mLabelCheck.setState(item.isAttached ? ThreeStateButton.STATE_CHECKED
: ThreeStateButton.STATE_UNPRESSED);
if (item.states == 3) {
viewHolder.mLabelCheck.setState(ThreeStateButton.STATE_PRESSED);
}
viewHolder.mLabelName.setTag(viewHolder.mLabelCheck);
viewHolder.mLabelCheck.setOnStateChangedListener(v -> {
int labelState = ((ThreeStateButton) v).getState();
if (item.states == 3) {
item.isAttached = labelState == ThreeStateButton.STATE_CHECKED;
item.isUnchanged = labelState == ThreeStateButton.STATE_PRESSED;
} else {
item.isAttached = labelState == ThreeStateButton.STATE_CHECKED ||
labelState == ThreeStateButton.STATE_PRESSED;
}
});
viewHolder.mLabelName.setOnClickListener(v -> {
final ThreeStateButton threeStateCheckBox = (ThreeStateButton) v.getTag();
if (threeStateCheckBox != null) {
threeStateCheckBox.post(threeStateCheckBox::performClick);
}
});
viewHolder.mLabelName.setText(labelNameDisplay);
GradientDrawable gd = (GradientDrawable) viewHolder.mLabelName.getBackground().getCurrent();
String colorString = item.color;
int color;
if (!TextUtils.isEmpty(colorString)) {
colorString = UiUtil.normalizeColor(colorString);
color = Color.parseColor(colorString);
if (!TextUtils.isEmpty(colorString)) {
gd.setStroke(mStrokeWidth, color);
viewHolder.mLabelName.setTextColor(color);
}
}
if (item.numberOfSelectedMessages <= 0) {
viewHolder.mNumberSelectedMessages.setVisibility(View.GONE);
} else {
viewHolder.mNumberSelectedMessages.setVisibility(View.VISIBLE);
viewHolder.mNumberSelectedMessages.setText(String.valueOf(item.numberOfSelectedMessages));
}
return convertView;
}
static class ViewHolder {
@BindView(R.id.label_name_text_view)
TextView mLabelName;
@BindView(R.id.label_selected_messages)
TextView mNumberSelectedMessages;
@BindView(R.id.label_check_box)
ThreeStateButton mLabelCheck;
public ViewHolder(View view) {
ButterKnife.bind(this, view);
}
}
public static class LabelItem {
public boolean isAttached;
public String labelId;
public String name;
public String color;
public int display;
public int order;
public boolean isUnchanged;
public int numberOfSelectedMessages;
public int states;
public LabelItem(boolean isAttached) {
this.isAttached = isAttached;
}
}
}

View File

@ -177,7 +177,7 @@ class ContactDetailsAdapter(
}
textViewContactDetailsItem.apply {
text = item.value
setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_envelope_full, 0, 0, 0)
setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_proton_envelope, 0, 0, 0)
isClickable = true
}
}
@ -192,7 +192,7 @@ class ContactDetailsAdapter(
}
textViewContactDetailsItem.apply {
text = item.value
setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_contact_phone_dark, 0, 0, 0)
setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_proton_mobile, 0, 0, 0)
isClickable = true
}
}
@ -207,7 +207,7 @@ class ContactDetailsAdapter(
}
textViewContactDetailsItem.apply {
text = getAddressToDisplay(item)
setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_map_marker, 0, 0, 0)
setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_proton_map_pin, 0, 0, 0)
isClickable = true
}
}

View File

@ -658,10 +658,10 @@ internal class MessageDetailsActivity : BaseStoragePermissionActivity() {
val hasMultipleRecipients = message.toList.size + message.ccList.size > 1
val actionsUiModel = BottomActionsView.UiModel(
if (hasMultipleRecipients) R.drawable.ic_reply_all else R.drawable.ic_reply,
R.drawable.ic_envelope_dot,
if (viewModel.shouldShowDeleteActionInBottomActionBar()) R.drawable.ic_trash_empty else R.drawable.ic_trash,
R.drawable.ic_label
if (hasMultipleRecipients) R.drawable.ic_proton_arrows_up_and_left else R.drawable.ic_proton_arrow_up_and_left,
R.drawable.ic_proton_envelope_dot,
if (viewModel.shouldShowDeleteActionInBottomActionBar()) R.drawable.ic_proton_trash_cross else R.drawable.ic_proton_trash,
R.drawable.ic_proton_tag
)
messageDetailsActionsView.bind(actionsUiModel)
messageDetailsActionsView.setOnFourthActionClickListener {

View File

@ -44,7 +44,7 @@ class DecryptionErrorBanner @JvmOverloads constructor(
text = resources.getString(R.string.decryption_of_message_failed)
setTextColor(ContextCompat.getColor(context, R.color.text_inverted))
val warningDrawable = ContextCompat.getDrawable(context, R.drawable.ic_exclamation_triangle)
val warningDrawable = ContextCompat.getDrawable(context, R.drawable.ic_proton_exclamation_circle)
setCompoundDrawablesRelativeWithIntrinsicBounds(warningDrawable, null, null, null)
compoundDrawablePadding = resources.getDimensionPixelSize(R.dimen.message_details_banner_drawable_padding)
compoundDrawableTintList = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.icon_inverted))

View File

@ -55,7 +55,6 @@ import ch.protonmail.android.usecase.delete.DeleteMessage
import ch.protonmail.android.usecase.delete.EmptyFolder
import ch.protonmail.android.usecase.message.ChangeMessagesReadStatus
import ch.protonmail.android.usecase.message.ChangeMessagesStarredStatus
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
@ -89,11 +88,6 @@ internal class ViewModelModule {
pinFragmentViewModelFactory: PinFragmentViewModelFactory
): ViewModelProvider.NewInstanceFactory = pinFragmentViewModelFactory
@Provides
fun provideManageLabelsDialogViewModelFactory(
factory: ManageLabelsDialogViewModel.ManageLabelsDialogViewModelFactory
): ViewModelProvider.NewInstanceFactory = factory
@Suppress("LongParameterList") // Every new parameter adds a new issue and breaks the build
@Provides
fun provideMailboxViewModel(

View File

@ -107,9 +107,9 @@ internal class DrawerLabelUiModelMapper @Inject constructor(
LabelType.MESSAGE_LABEL -> R.drawable.shape_ellipse
LabelType.FOLDER -> {
if (useFolderColor) {
if (hasChildren.not()) R.drawable.ic_folder_filled else R.drawable.ic_folder_multiple_filled
if (hasChildren.not()) R.drawable.ic_proton_folder_filled else R.drawable.ic_proton_folders_filled
} else {
if (hasChildren.not()) R.drawable.ic_folder else R.drawable.ic_folder_multiple
if (hasChildren.not()) R.drawable.ic_proton_folder else R.drawable.ic_proton_folders
}
}
LabelType.CONTACT_GROUP ->

View File

@ -223,7 +223,7 @@ internal class DrawerAdapter(
override fun onBind(item: CreateItem, position: Int) {
super.onBind(item, position)
binding.drawerItemIconView.setImageResource(R.drawable.ic_plus)
binding.drawerItemIconView.setImageResource(R.drawable.ic_proton_plus)
binding.drawerItemLabelTextView.apply {
setText(item.textRes)
setTextColor(getColor(R.color.text_weak))

View File

@ -98,9 +98,9 @@ class LabelDomainActionItemUiMapper @Inject constructor(
is LabelOrFolderWithChildren.Label -> R.drawable.circle_labels_selection
is LabelOrFolderWithChildren.Folder ->
if (useFolderColor) {
if (label.children.isEmpty()) R.drawable.ic_folder_filled else R.drawable.ic_folder_multiple_filled
if (label.children.isEmpty()) R.drawable.ic_proton_folder_filled else R.drawable.ic_proton_folders_filled
} else {
if (label.children.isEmpty()) R.drawable.ic_folder else R.drawable.ic_folder_multiple
if (label.children.isEmpty()) R.drawable.ic_proton_folder else R.drawable.ic_proton_folders
}
}

View File

@ -52,14 +52,14 @@ sealed class LabelIcon {
object BlackWhite : WithChildren() {
override val colorInt = R.color.icon_norm
override val drawableRes = R.drawable.ic_folder_multiple
override val drawableRes = R.drawable.ic_proton_folders
}
data class Colored(
@ColorInt override val colorInt: Int
) : WithChildren() {
override val drawableRes = R.drawable.ic_folder_multiple_filled
override val drawableRes = R.drawable.ic_proton_folders_filled
}
}
@ -70,14 +70,14 @@ sealed class LabelIcon {
object BlackWhite : WithoutChildren() {
override val colorInt = R.color.icon_norm
override val drawableRes = R.drawable.ic_folder
override val drawableRes = R.drawable.ic_proton_folder
}
data class Colored(
@ColorInt override val colorInt: Int
) : WithChildren() {
override val drawableRes = R.drawable.ic_folder_filled
override val drawableRes = R.drawable.ic_proton_folder_filled
}
}
}

View File

@ -35,22 +35,22 @@ enum class StandardFolderLocation(
ARCHIVE(
Constants.MessageLocationType.ARCHIVE.messageLocationTypeValue.toString(),
R.drawable.ic_archive,
R.drawable.ic_proton_archive_box,
R.string.archive
),
INBOX(
Constants.MessageLocationType.INBOX.messageLocationTypeValue.toString(),
R.drawable.ic_inbox,
R.drawable.ic_proton_inbox,
R.string.inbox
),
SPAM(
Constants.MessageLocationType.SPAM.messageLocationTypeValue.toString(),
R.drawable.ic_fire,
R.drawable.ic_proton_fire,
R.string.spam
),
TRASH(
Constants.MessageLocationType.TRASH.messageLocationTypeValue.toString(),
R.drawable.ic_trash,
R.drawable.ic_proton_trash,
R.string.trash
)
}

View File

@ -175,6 +175,6 @@ private fun ItemParentPickerFolderBinding.setEnabled(isEnabled: Boolean) {
}
private fun TextView.setCheckmark(isSelected: Boolean) {
val drawable = R.drawable.ic_check.takeIf { isSelected } ?: 0
val drawable = R.drawable.ic_proton_checkmark.takeIf { isSelected } ?: 0
setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, drawable, 0)
}

View File

@ -36,7 +36,6 @@ import android.view.Gravity
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.activity.viewModels
@ -45,7 +44,6 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.postDelayed
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.isVisible
import androidx.core.view.postDelayed
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import androidx.loader.app.LoaderManager
@ -359,7 +357,7 @@ internal class MailboxActivity :
if (MessageUtils.areAllUnRead(
selectedMessages
)
) R.drawable.ic_envelope_open_text else R.drawable.ic_envelope_dot
) R.drawable.ic_proton_envelope_open_text else R.drawable.ic_proton_envelope_dot
)
}
@ -475,7 +473,7 @@ internal class MailboxActivity :
userManager.setShowStorageLimitWarning(true)
storageLimitAlert.apply {
visibility = View.VISIBLE
setIcon(getDrawable(R.drawable.inbox)!!)
setIcon(getDrawable(R.drawable.ic_proton_inbox)!!)
setText(getString(R.string.storage_limit_alert))
}
}
@ -808,17 +806,8 @@ internal class MailboxActivity :
super.onSaveInstanceState(outState)
}
private fun setUpMenuItems(composeMenuItem: MenuItem, searchMenuItem: MenuItem) {
composeMenuItem.actionView.findViewById<ImageView>(R.id.composeImageButton)
.setOnClickListener { onOptionsItemSelected(R.id.compose) }
searchMenuItem.actionView.findViewById<ImageView>(R.id.searchImageButton)
.setOnClickListener { onOptionsItemSelected(R.id.search) }
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_mailbox_options, menu)
setUpMenuItems(menu.findItem(R.id.compose), menu.findItem(R.id.search))
val mailboxLocation = mailboxViewModel.mailboxLocation.value
menu.findItem(R.id.empty).isVisible =
mailboxLocation in listOf(MessageLocationType.DRAFT, MessageLocationType.SPAM, MessageLocationType.TRASH)
@ -828,7 +817,6 @@ internal class MailboxActivity :
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
menu.clear()
menuInflater.inflate(R.menu.menu_mailbox_options, menu)
setUpMenuItems(menu.findItem(R.id.compose), menu.findItem(R.id.search))
val mailboxLocation = mailboxViewModel.mailboxLocation.value
menu.findItem(R.id.empty).isVisible =
mailboxLocation in listOf(
@ -1044,7 +1032,7 @@ internal class MailboxActivity :
private fun setUpMailboxActionsView() {
val actionsUiModel = BottomActionsView.UiModel(
R.drawable.ic_envelope_dot,
R.drawable.ic_proton_envelope_dot,
if (currentMailboxLocation in arrayOf(
MessageLocationType.DRAFT,
MessageLocationType.ALL_DRAFT,
@ -1053,9 +1041,9 @@ internal class MailboxActivity :
MessageLocationType.TRASH,
MessageLocationType.SPAM
)
) R.drawable.ic_trash_empty else R.drawable.ic_trash,
R.drawable.ic_folder_move,
R.drawable.ic_label
) R.drawable.ic_proton_trash_cross else R.drawable.ic_proton_trash,
R.drawable.ic_proton_folder_arrow_in,
R.drawable.ic_proton_tag
)
mailboxActionsView.bind(actionsUiModel)
mailboxActionsView.setOnFirstActionClickListener {

View File

@ -366,27 +366,27 @@ internal abstract class NavigationActivity : BaseActivity() {
sideDrawer.setLocationItems(
listOf(
Primary.Static(Type.INBOX, R.string.inbox, R.drawable.ic_inbox),
Primary.Static(Type.DRAFTS, R.string.drafts, R.drawable.ic_drafts),
Primary.Static(Type.SENT, R.string.sent, R.drawable.ic_paper_plane),
Primary.Static(Type.STARRED, R.string.starred, R.drawable.ic_star),
Primary.Static(Type.ARCHIVE, R.string.archive, R.drawable.ic_archive),
Primary.Static(Type.SPAM, R.string.spam, R.drawable.ic_fire),
Primary.Static(Type.TRASH, R.string.trash, R.drawable.ic_trash),
Primary.Static(Type.ALLMAIL, R.string.all_mail, R.drawable.ic_envelope_all_emails)
Primary.Static(Type.INBOX, R.string.inbox, R.drawable.ic_proton_inbox),
Primary.Static(Type.DRAFTS, R.string.drafts, R.drawable.ic_proton_file),
Primary.Static(Type.SENT, R.string.sent, R.drawable.ic_proton_paper_plane),
Primary.Static(Type.STARRED, R.string.starred, R.drawable.ic_proton_star),
Primary.Static(Type.ARCHIVE, R.string.archive, R.drawable.ic_proton_archive_box),
Primary.Static(Type.SPAM, R.string.spam, R.drawable.ic_proton_fire),
Primary.Static(Type.TRASH, R.string.trash, R.drawable.ic_proton_trash),
Primary.Static(Type.ALLMAIL, R.string.all_mail, R.drawable.ic_proton_envelopes)
)
)
sideDrawer.setMoreItems(
R.string.x_more,
listOfNotNull(
Primary.Static(Type.SETTINGS, R.string.drawer_settings, R.drawable.ic_sliders_two),
Primary.Static(Type.SUBSCRIPTION, R.string.drawer_subscription, R.drawable.ic_pencil),
Primary.Static(Type.CONTACTS, R.string.drawer_contacts, R.drawable.ic_book_contacts),
Primary.Static(Type.REPORT_BUGS, R.string.drawer_report_bug, R.drawable.ic_bug),
if (hasPin) Primary.Static(Type.LOCK, R.string.drawer_lock_the_app, R.drawable.ic_lock)
Primary.Static(Type.SETTINGS, R.string.drawer_settings, R.drawable.ic_proton_cog_wheel),
Primary.Static(Type.SUBSCRIPTION, R.string.drawer_subscription, R.drawable.ic_proton_pencil),
Primary.Static(Type.CONTACTS, R.string.drawer_contacts, R.drawable.ic_proton_users),
Primary.Static(Type.REPORT_BUGS, R.string.drawer_report_bug, R.drawable.ic_proton_bug),
if (hasPin) Primary.Static(Type.LOCK, R.string.drawer_lock_the_app, R.drawable.ic_proton_lock)
else null,
Primary.Static(Type.SIGNOUT, R.string.drawer_sign_out, R.drawable.ic_sign_out)
Primary.Static(Type.SIGNOUT, R.string.drawer_sign_out, R.drawable.ic_proton_arrow_out_from_rectangle)
)
)

View File

@ -341,14 +341,14 @@ class NotificationServer @Inject constructor(
setGroup(userId.id)
addAction(
NotificationCompat.Action(
R.drawable.archive,
R.drawable.ic_proton_archive_box,
context.getString(R.string.archive),
archiveIntent
)
)
addAction(
NotificationCompat.Action(
R.drawable.action_notification_trash,
R.drawable.ic_proton_trash,
context.getString(R.string.trash),
trashIntent
)
@ -356,7 +356,7 @@ class NotificationServer @Inject constructor(
if (replyIntent != null) {
addAction(
NotificationCompat.Action(
R.drawable.action_notification_reply,
R.drawable.ic_proton_arrow_up_and_left,
context.getString(R.string.reply),
replyIntent
)

View File

@ -1,141 +0,0 @@
/*
* Copyright (c) 2022 Proton AG
*
* This file is part of Proton Mail.
*
* Proton Mail is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Proton Mail is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proton Mail. If not, see https://www.gnu.org/licenses/.
*/
package ch.protonmail.android.viewmodel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import ch.protonmail.android.adapters.LabelsDialogAdapter
import ch.protonmail.android.core.UserManager
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.HideLabelCreationViews
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.HideLabelsView
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.SelectedLabelsArchiveEvent
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.SelectedLabelsChangedEvent
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.ShowApplicableLabelsThresholdExceededError
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.ShowLabelCreatedEvent
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.ShowLabelCreationViews
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.ShowLabelNameDuplicatedError
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.ShowMissingColorError
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.ShowMissingNameError
import ch.protonmail.android.views.ThreeStateButton
import javax.inject.Inject
@Deprecated("New implementation in [ManageLabelsActionSheetViewModel]")
class ManageLabelsDialogViewModel @Inject constructor(
private val userManager: UserManager
) : ViewModel() {
val viewState: MutableLiveData<ViewState> = MutableLiveData()
fun onDoneClicked(
isCreationMode: Boolean,
labelColor: String?,
checkedLabelIds: List<String>,
archiveCheckboxState: Int,
labelName: String,
labelItemsList: List<LabelsDialogAdapter.LabelItem>
) {
if (isCreationMode) {
viewState.value = createLabel(labelName, labelColor, labelItemsList)
return
}
if (userManager.didReachLabelsThreshold(checkedLabelIds.size)) {
liveDataShowLabelsThresholdError(userManager.getMaxLabelsAllowed())
return
}
if (isArchiveOptionSelected(archiveCheckboxState)) {
viewState.value = SelectedLabelsArchiveEvent
} else {
viewState.value = SelectedLabelsChangedEvent
}
viewState.value = HideLabelsView
}
fun onTextChanged(labelName: String, creationViewsVisible: Boolean) {
if (labelName.isNotEmpty()) {
if (creationViewsVisible) {
return
}
viewState.value = ShowLabelCreationViews
return
}
viewState.value = HideLabelCreationViews
}
private fun liveDataShowLabelsThresholdError(maxLabelsAllowed: Int) {
viewState.value = ShowApplicableLabelsThresholdExceededError(maxLabelsAllowed)
}
private fun isArchiveOptionSelected(archiveCheckboxState: Int) =
archiveCheckboxState == ThreeStateButton.STATE_CHECKED ||
archiveCheckboxState == ThreeStateButton.STATE_PRESSED
private fun createLabel(
labelName: String,
labelColor: String?,
labelItemsList: List<LabelsDialogAdapter.LabelItem>
): ViewState {
if (labelColor.isNullOrEmpty()) {
return ShowMissingColorError
}
if (labelName.isEmpty()) {
return ShowMissingNameError
}
labelItemsList
.find { it.name == labelName }
?.let {
return ShowLabelNameDuplicatedError
}
return ShowLabelCreatedEvent(labelName)
}
sealed class ViewState {
object ShowMissingColorError : ViewState()
object ShowMissingNameError : ViewState()
object ShowLabelNameDuplicatedError : ViewState()
object SelectedLabelsChangedEvent : ViewState()
object SelectedLabelsArchiveEvent : ViewState()
object HideLabelsView : ViewState()
object ShowLabelCreationViews : ViewState()
object HideLabelCreationViews : ViewState()
class ShowApplicableLabelsThresholdExceededError(val maxLabelsAllowed: Int) : ViewState()
class ShowLabelCreatedEvent(val labelName: String) : ViewState()
}
class ManageLabelsDialogViewModelFactory @Inject constructor(
private val manageLabelsViewModel: ManageLabelsDialogViewModel
) : ViewModelProvider.NewInstanceFactory() {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
require(modelClass.isAssignableFrom(ManageLabelsDialogViewModel::class.java))
return manageLabelsViewModel as T
}
}
}

View File

@ -72,14 +72,15 @@ class ListItemThumbnail @JvmOverloads constructor(
}
@DrawableRes
var iconResource = R.drawable.ic_contact_groups_filled
var iconResource = R.drawable.ic_proton_users_filled
set(value) {
iconDrawable = AppCompatResources.getDrawable(context, value)
iconDrawable?.setTint(ContextCompat.getColor(context, R.color.icon_inverted))
text = ""
}
private var iconDrawable = AppCompatResources.getDrawable(context, iconResource)
private val checkIconDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_check_white)
private val checkIconDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_proton_checkmark)?.mutate()
private var isMultiselectModeActive: Boolean = false
@ -92,7 +93,7 @@ class ListItemThumbnail @JvmOverloads constructor(
) {
val defaultCircleSize = context.resources.getDimensionPixelSize(R.dimen.padding_3xl)
circleSize = getDimensionPixelSize(R.styleable.ListItemThumbnail_circleSize, defaultCircleSize)
iconResource = getResourceId(R.styleable.ListItemThumbnail_icon, R.drawable.ic_contact_groups_filled)
iconResource = getResourceId(R.styleable.ListItemThumbnail_icon, R.drawable.ic_proton_users_filled)
}
}
@ -137,6 +138,7 @@ class ListItemThumbnail @JvmOverloads constructor(
borderPaint.style = Paint.Style.FILL
canvas.drawCircle(centerX, centerY, centerX, borderPaint)
checkIconDrawable?.setTint(ContextCompat.getColor(context, R.color.icon_inverted))
val imageWidth = checkIconDrawable?.intrinsicWidth?.div(2) ?: 0
val imageHeight = checkIconDrawable?.intrinsicHeight?.div(2) ?: 0
checkIconDrawable?.setBounds(

View File

@ -1,84 +0,0 @@
/*
* Copyright (c) 2022 Proton AG
*
* This file is part of Proton Mail.
*
* Proton Mail is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Proton Mail is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proton Mail. If not, see https://www.gnu.org/licenses/.
*/
package ch.protonmail.android.views
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import androidx.annotation.DrawableRes
import androidx.core.content.res.ResourcesCompat
import ch.protonmail.android.R
class ThreeStateButton @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
var numberOfStates = 3
var state = 0
set(value) {
field = value % numberOfStates
when (field) {
0 -> setButtonBackground(R.drawable.mail_check)
1 -> setButtonBackground(R.drawable.mail_check_active)
2 -> setButtonBackground(R.drawable.mail_check_neutral)
else -> {
throw IllegalStateException("Unsupported view state")
}
}
onStateChangedListener?.onClick(this)
}
private var onStateChangedListener: OnClickListener? = null
init {
isClickable = true
isFocusable = true
state = STATE_UNPRESSED
setButtonBackground(R.drawable.mail_check)
}
private fun setButtonBackground(@DrawableRes backgroundDrawableId: Int) {
background = ResourcesCompat.getDrawable(resources, backgroundDrawableId, null)
}
override fun onTouchEvent(event: MotionEvent): Boolean {
return if (event.action == MotionEvent.ACTION_DOWN) {
state++
performClick()
true
} else
false
}
fun setOnStateChangedListener(listener: OnClickListener?) {
onStateChangedListener = listener
}
override fun isPressed(): Boolean = state == STATE_PRESSED
companion object {
const val STATE_UNPRESSED = 0
const val STATE_CHECKED = 1
const val STATE_PRESSED = 2
}
}

View File

@ -1,36 +0,0 @@
/*
* Copyright (c) 2022 Proton AG
*
* This file is part of Proton Mail.
*
* Proton Mail is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Proton Mail is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proton Mail. If not, see https://www.gnu.org/licenses/.
*/
package ch.protonmail.android.views.messageDetails
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.appcompat.widget.AppCompatImageView
import ch.protonmail.android.R
class FolderIconView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : AppCompatImageView(context, attrs, defStyleAttr) {
init {
View.inflate(context, R.layout.view_folder_icon, null)
}
}

View File

@ -63,7 +63,9 @@ class MessageDetailsAttachmentsView @JvmOverloads constructor(
private var expanded = false
set(value) {
attachmentsListLinearLayout.isVisible = value
chevronImageView.setImageResource(if (value) R.drawable.ic_chevron_up else R.drawable.ic_chevron_down)
chevronImageView.setImageResource(
if (value) R.drawable.ic_proton_chevron_up else R.drawable.ic_proton_chevron_down
)
field = value
}

View File

@ -314,7 +314,7 @@ class MessageDetailsHeaderView @JvmOverloads constructor(
expandedHeaderGroup.isVisible = true
locationImageView.isVisible = false
expandCollapseChevronImageView.setImageDrawable(
ContextCompat.getDrawable(context, R.drawable.ic_chevron_up)
ContextCompat.getDrawable(context, R.drawable.ic_proton_chevron_up)
)
}
@ -338,16 +338,16 @@ class MessageDetailsHeaderView @JvmOverloads constructor(
}
private fun getIconForMessageLocation(messageLocation: Constants.MessageLocationType) = when (messageLocation) {
Constants.MessageLocationType.INBOX -> R.drawable.ic_inbox
Constants.MessageLocationType.SENT -> R.drawable.ic_paper_plane
Constants.MessageLocationType.DRAFT -> R.drawable.ic_pencil
Constants.MessageLocationType.ALL_DRAFT -> R.drawable.ic_pencil
Constants.MessageLocationType.ALL_SENT -> R.drawable.ic_paper_plane
Constants.MessageLocationType.ARCHIVE -> R.drawable.ic_archive
Constants.MessageLocationType.TRASH -> R.drawable.ic_trash
Constants.MessageLocationType.SPAM -> R.drawable.ic_fire
Constants.MessageLocationType.LABEL_FOLDER -> R.drawable.ic_folder_filled
Constants.MessageLocationType.LABEL -> R.drawable.ic_folder_filled
Constants.MessageLocationType.INBOX -> R.drawable.ic_proton_inbox
Constants.MessageLocationType.SENT -> R.drawable.ic_proton_paper_plane
Constants.MessageLocationType.DRAFT -> R.drawable.ic_proton_pencil
Constants.MessageLocationType.ALL_DRAFT -> R.drawable.ic_proton_pencil
Constants.MessageLocationType.ALL_SENT -> R.drawable.ic_proton_paper_plane
Constants.MessageLocationType.ARCHIVE -> R.drawable.ic_proton_archive_box
Constants.MessageLocationType.TRASH -> R.drawable.ic_proton_trash
Constants.MessageLocationType.SPAM -> R.drawable.ic_proton_fire
Constants.MessageLocationType.LABEL_FOLDER -> R.drawable.ic_proton_folder_filled
Constants.MessageLocationType.LABEL -> R.drawable.ic_proton_folder_filled
else -> null
}

View File

@ -90,14 +90,14 @@ class MailboxItemView @JvmOverloads constructor(
}
private fun getIconForMessageLocation(messageLocation: MessageLocationType) = when (messageLocation) {
MessageLocationType.INBOX -> R.drawable.ic_inbox
MessageLocationType.SENT -> R.drawable.ic_paper_plane
MessageLocationType.DRAFT -> R.drawable.ic_pencil
MessageLocationType.ALL_DRAFT -> R.drawable.ic_pencil
MessageLocationType.ALL_MAIL -> R.drawable.ic_folder
MessageLocationType.ALL_SENT -> R.drawable.ic_paper_plane
MessageLocationType.ARCHIVE -> R.drawable.ic_archive
MessageLocationType.TRASH -> R.drawable.ic_trash
MessageLocationType.INBOX -> R.drawable.ic_proton_inbox
MessageLocationType.SENT -> R.drawable.ic_proton_paper_plane
MessageLocationType.DRAFT -> R.drawable.ic_proton_pencil
MessageLocationType.ALL_DRAFT -> R.drawable.ic_proton_pencil
MessageLocationType.ALL_MAIL -> R.drawable.ic_proton_folder
MessageLocationType.ALL_SENT -> R.drawable.ic_proton_paper_plane
MessageLocationType.ARCHIVE -> R.drawable.ic_proton_archive_box
MessageLocationType.TRASH -> R.drawable.ic_proton_trash
else -> null
}

View File

@ -74,7 +74,7 @@ class SenderInitialView @JvmOverloads constructor(
if (showDraftIcon) {
senderInitialTextView.text = EMPTY_STRING
senderInitialTextView.background = context.getDrawable(R.drawable.ic_pencil)
senderInitialTextView.background = context.getDrawable(R.drawable.ic_proton_pen)
} else {
senderInitialTextView.background = context.getDrawable(R.drawable.background_sender_initial)
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 709 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 962 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 806 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Some files were not shown because too many files have changed in this diff Show More