Folders n labels settings screens v4 face lift

This commit is contained in:
Zorica Stojchevska 2021-06-09 01:15:50 +02:00
parent 67974f1cdc
commit 0395735367
29 changed files with 511 additions and 720 deletions

View File

@ -24,7 +24,7 @@ import androidx.lifecycle.SavedStateHandle
import androidx.test.platform.app.InstrumentationRegistry
import androidx.work.WorkInfo
import androidx.work.WorkManager
import ch.protonmail.android.adapters.LabelsCirclesAdapter
import ch.protonmail.android.adapters.LabelsAdapter
import ch.protonmail.android.data.local.MessageDatabase
import ch.protonmail.android.data.local.model.Label
import ch.protonmail.libs.core.utils.EMPTY_STRING
@ -78,7 +78,7 @@ internal class LabelsManagerViewModelTest : CoroutinesTest {
@Test
fun verifyCheckedStateIsUpdatedCorrectlyForAdapterItems() {
val adapter = LabelsCirclesAdapter()
val adapter = LabelsAdapter()
viewModel.labels.observeDataForever(adapter::submitList)
// Assert adapter is empty

View File

@ -36,7 +36,7 @@ import ch.protonmail.android.activities.labelsManager.LabelsManagerActivity.Stat
import ch.protonmail.android.activities.labelsManager.LabelsManagerActivity.State.UNDEFINED
import ch.protonmail.android.activities.labelsManager.LabelsManagerActivity.State.UPDATE
import ch.protonmail.android.adapters.LabelColorsAdapter
import ch.protonmail.android.adapters.LabelsCirclesAdapter
import ch.protonmail.android.adapters.LabelsAdapter
import ch.protonmail.android.uiModel.LabelUiModel
import ch.protonmail.android.uiModel.LabelUiModel.Type.FOLDERS
import ch.protonmail.android.uiModel.LabelUiModel.Type.LABELS
@ -45,7 +45,6 @@ import ch.protonmail.android.utils.extensions.app
import ch.protonmail.android.utils.extensions.onTextChange
import ch.protonmail.android.utils.extensions.showToast
import ch.protonmail.android.worker.KEY_POST_LABEL_WORKER_RESULT_ERROR
import com.squareup.otto.Subscribe
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.activity_labels_manager.*
import studio.forface.viewstatestore.ViewStateActivity
@ -71,7 +70,10 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
/** Lazy instance of [LabelColorsAdapter] */
private val colorsAdapter by lazy {
LabelColorsAdapter(applicationContext, colorOptions, R.layout.label_color_item_circle)
LabelColorsAdapter(
applicationContext, colorOptions,
if (type == LABELS) R.layout.label_color_item_circle else R.layout.folder_color_item
)
}
/** [IntArray] of the available colors */
@ -85,8 +87,8 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
intent?.extras?.getBoolean(EXTRA_CREATE_ONLY, false) ?: false
}
/** [LabelsCirclesAdapter] for show `Labels` or `Folders` */
private val labelsAdapter = LabelsCirclesAdapter().apply {
/** [LabelsAdapter] for show `Labels` or `Folders` */
private val labelsAdapter = LabelsAdapter().apply {
onItemClick = ::onLabelClick
onItemSelect = ::onLabelSelectionChange
}
@ -130,15 +132,22 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
supportActionBar?.run {
if (popupStyle) hide()
else setDisplayHomeAsUpEnabled(true)
val elevation = resources.getDimensionPixelSize(R.dimen.action_bar_elevation).toFloat()
this.elevation = elevation
title = getString(
if (type == LABELS) R.string.labels_manager
else R.string.folders_manager
)
}
// Setup Views
initTexts()
delete_labels.isEnabled = false
labels_grid_view.apply {
colors_grid_view.apply {
val gridLayoutParams = layoutParams as LinearLayout.LayoutParams
val itemHeight = resources.getDimensionPixelSize(R.dimen.label_color_item_size) +
resources.getDimensionPixelSize(R.dimen.fields_default_space)
val itemHeight = resources.getDimensionPixelSize(R.dimen.settings_color_item_size) +
resources.getDimensionPixelSize(R.dimen.padding_xl)
gridLayoutParams.height = colorOptions.size * itemHeight / COLOR_PICKER_COLUMNS
adapter = colorsAdapter
@ -149,9 +158,8 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
// Set listeners
delete_labels.setOnClickListener { showDeleteConfirmation() }
label_name.onTextChange(::onLabelNameChange)
save_new_label.setOnClickListener { saveCurrentLabel() }
labels_grid_view
.setOnItemClickListener { _, _, position, _ -> onLabelColorChange(position) }
save_button.setOnClickListener { saveCurrentLabel() }
colors_grid_view.setOnItemClickListener { _, _, position, _ -> onLabelColorChange(position) }
// Setup Labels RecyclerView
labels_recycler_view.apply {
@ -167,7 +175,8 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
// Observe deleted labels
viewModel.hasSuccessfullyDeletedMessages.observe(
this, { onLabelDeletedEvent(it) }
this,
{ onLabelDeletedEvent(it) }
)
}
@ -242,7 +251,7 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
}
}
/** When Label color is changed in the [labels_grid_view] */
/** When Label color is changed in the [colors_grid_view] */
private fun onLabelColorChange(positionInColorOptions: Int) {
colorsAdapter.setChecked(positionInColorOptions)
viewModel.setLabelColor(colorOptions[positionInColorOptions])
@ -251,7 +260,7 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
/** When Label name is changed in the [label_name] `EditText` */
private fun onLabelNameChange(name: CharSequence) {
save_new_label.isVisible = name.isNotBlank()
save_button.isVisible = name.isNotBlank()
if (name.isNotEmpty() && state == UNDEFINED) {
state = CREATE
@ -276,31 +285,19 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
toggleColorPicker(false)
closeKeyboard()
label_name.setText("")
save_new_label.setText(
when (type) {
LABELS -> R.string.save_new_label
FOLDERS -> R.string.save_new_folder
}
)
save_button.setText(R.string.done)
}
CREATE -> {
selectRandomColor()
toggleColorPicker(true)
save_new_label.setText(
when (type) {
LABELS -> R.string.save_new_label
FOLDERS -> R.string.save_new_folder
}
)
save_button.setText(R.string.done)
}
UPDATE -> {
toggleColorPicker(true)
save_new_label.setText(
save_button.setText(
when (type) {
LABELS -> R.string.update_label
FOLDERS -> R.string.update_folder
@ -343,7 +340,7 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
if (success && createOnly) onBackPressed()
labels_grid_view.isVisible = true
colors_grid_view.isVisible = true
val message = when (type) {
FOLDERS -> {
@ -381,17 +378,10 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
* @see [type]
*/
private fun initTexts() {
setTitle(
save_button.setText(
when (type) {
LABELS -> R.string.labels_and_folders
FOLDERS -> R.string.folders_manager
}
)
save_new_label.setText(
when (type) {
LABELS -> R.string.save_new_label
FOLDERS -> R.string.save_new_folder
LABELS -> R.string.update_label
FOLDERS -> R.string.update_folder
}
)
@ -422,13 +412,6 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
FOLDERS -> R.string.available_folders
}
)
labels_colors_title.setText(
when (type) {
LABELS -> R.string.choose_label_color
FOLDERS -> R.string.choose_folder_color
}
)
}
private fun onLabelDeletedEvent(isSuccessful: Boolean) {
@ -441,6 +424,7 @@ class LabelsManagerActivity : BaseActivity(), ViewStateActivity {
/** The current state of the `Activity` */
enum class State {
/** State is not defined */
UNDEFINED,

View File

@ -1,45 +0,0 @@
/*
* Copyright (c) 2020 Proton Technologies AG
*
* This file is part of ProtonMail.
*
* ProtonMail 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.
*
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
*/
package ch.protonmail.android.activities.navigation
import android.database.DataSetObserver
import android.widget.LinearLayout
/**
* Created by Kamil Rajtar on 20.08.18.
*/
class LabelsViewController(private val labelsContainer:LinearLayout,
private val navigationLabelsAdapter:NavigationLabelsAdapter,
private val onLabelClick:Function1<String,Unit>):DataSetObserver() {
override fun onChanged() {
labelsContainer.removeAllViews()
val count=navigationLabelsAdapter.count
(0 until count).forEach {
val labelItemView=navigationLabelsAdapter.getView(it,null,labelsContainer)
val labelId=navigationLabelsAdapter.getItem(it)!!.label.id
labelItemView.setOnClickListener {onLabelClick.invoke(labelId)}
labelsContainer.addView(labelItemView)
}
}
override fun onInvalidated() {
labelsContainer.removeAllViews()
}
}

View File

@ -1,59 +0,0 @@
/*
* Copyright (c) 2020 Proton Technologies AG
*
* This file is part of ProtonMail.
*
* ProtonMail 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.
*
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
*/
package ch.protonmail.android.activities.navigation
import android.content.Context
import android.graphics.Color
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import ch.protonmail.android.R
import ch.protonmail.android.utils.UiUtil
import ch.protonmail.android.views.navigation.NavigationItemLabelView
/**
* Created by Kamil Rajtar on 20.08.18. */
class NavigationLabelsAdapter(context:Context):ArrayAdapter<LabelWithUnreadCounter>(
context,
android.R.layout.simple_list_item_1) {
override fun getView(position:Int,convertView:View?,parent:ViewGroup):View {
val label=getItem(position) ?: throw RuntimeException("No item at position: $position")
val labelItemView=convertView as? NavigationItemLabelView
?: NavigationItemLabelView(context)
val name=label.label.name
var color=label.label.color
if(!TextUtils.isEmpty(color)) {
color=UiUtil.normalizeColor(color)
}
val labelColor=if(color.isNotEmpty())
Color.parseColor(color)
else {
0
}
val labelDrawable=if(label.label.exclusive) {
R.drawable.ic_menu_folder
} else {
R.drawable.ic_menu_label
}
val notificationCount=label.unreadCount
labelItemView.bind(name,labelDrawable,labelColor,notificationCount)
return labelItemView
}
}

View File

@ -114,7 +114,7 @@ enum class SettingsEnum {
LABELS_MANAGER {
override fun getHint(context: Context): String = ""
override fun getHeader(context: Context): String = context.resources.getString(R.string.labels_manage)
override fun getHeader(context: Context): String = context.resources.getString(R.string.labels_manager)
},
FOLDERS_MANAGER {

View File

@ -1,110 +1,85 @@
/*
* Copyright (c) 2020 Proton Technologies AG
*
*
* This file is part of ProtonMail.
*
*
* ProtonMail 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.
*
*
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
*/
package ch.protonmail.android.adapters;
package ch.protonmail.android.adapters
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.content.Context
import android.graphics.PorterDuff
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import ch.protonmail.android.R
import ch.protonmail.android.adapters.LabelColorsAdapter.LabelColorItem
import java.util.ArrayList
import java.util.ArrayList;
import java.util.List;
class LabelColorsAdapter(context: Context, colors: IntArray, private val mLayoutResourceId: Int) :
ArrayAdapter<LabelColorItem>(
context, mLayoutResourceId
) {
import ch.protonmail.android.R;
/**
* Created by dkadrikj on 28.7.15.
*/
public class LabelColorsAdapter extends ArrayAdapter<LabelColorsAdapter.LabelColorItem> {
private List<LabelColorItem> labelColorItemList;
private int mLayoutResourceId;
public LabelColorsAdapter(Context context, int[] colors, int layoutId) {
super(context, layoutId);
mLayoutResourceId = layoutId;
labelColorItemList = new ArrayList<>();
for (int i = 0; i < colors.length; i++) {
LabelColorItem item = new LabelColorItem();
item.colorId = colors[i];
item.isChecked = false;
labelColorItemList.add(item);
private val labelColorItemList: MutableList<LabelColorItem>
fun setChecked(position: Int) {
for (item in labelColorItemList) {
item.isChecked = false
}
addAll(labelColorItemList);
setNotifyOnChange(false);
val item = getItem(position)
item!!.isChecked = true
notifyDataSetChanged()
}
public void setChecked(int position) {
for (LabelColorItem item : labelColorItemList) {
item.isChecked = false;
}
LabelColorItem item = getItem(position);
item.isChecked = true;
notifyDataSetChanged();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
var view = convertView
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(mLayoutResourceId, parent, false);
view = LayoutInflater.from(context).inflate(mLayoutResourceId, parent, false)
}
LabelColorItem item = getItem(position);
if (mLayoutResourceId == R.layout.label_color_item_circle) {
selectCircle(convertView, item);
} else {
selectRectangle(convertView, item);
}
return convertView;
val item = getItem(position)
selectItem(view, item)
return view!!
}
private void selectCircle(View view, LabelColorItem item) {
View circle = view.findViewById(R.id.circle);
Drawable background = circle.getBackground();
background.setColorFilter(item.colorId, PorterDuff.Mode.SRC_IN);
View checkView = view.findViewById(R.id.circle_selected);
private fun selectItem(view: View?, item: LabelColorItem?) {
val circle = view!!.findViewById<View>(R.id.color_item)
val background = circle.background
background.setColorFilter(item!!.colorId, PorterDuff.Mode.SRC_IN)
val checkView = view.findViewById<View>(R.id.is_checked_indicator)
if (item.isChecked) {
checkView.setVisibility(View.VISIBLE);
checkView.visibility = View.VISIBLE
} else {
checkView.setVisibility(View.GONE);
checkView.visibility = View.GONE
}
}
private void selectRectangle(View view, LabelColorItem item) {
view.setBackgroundColor(item.colorId);
View checkView = view.findViewById(R.id.label_color_check);
if (item.isChecked) {
checkView.setVisibility(View.VISIBLE);
} else {
checkView.setVisibility(View.GONE);
init {
labelColorItemList = ArrayList()
for (color in colors) {
val item = LabelColorItem()
item.colorId = color
item.isChecked = false
labelColorItemList.add(item)
}
addAll(labelColorItemList)
setNotifyOnChange(false)
}
static class LabelColorItem {
public boolean isChecked;
int colorId;
class LabelColorItem {
var isChecked = false
var colorId = 0
}
}

View File

@ -0,0 +1,97 @@
/*
* Copyright (c) 2020 Proton Technologies AG
*
* This file is part of ProtonMail.
*
* ProtonMail 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.
*
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
*/
package ch.protonmail.android.adapters
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import ch.protonmail.android.R
import ch.protonmail.android.uiModel.LabelUiModel
import ch.protonmail.android.utils.extensions.truncateToLength
import ch.protonmail.libs.core.ui.adapter.BasePagedAdapter
import ch.protonmail.libs.core.ui.adapter.SelectableAdapter
import com.google.android.material.checkbox.MaterialCheckBox
import kotlinx.android.synthetic.main.labels_list_item.view.*
import me.proton.core.presentation.utils.inflate
/**
* A [RecyclerView.Adapter] for show `Labels` or `Folders`
* Inherit from [BasePagedAdapter]
* Implement [SelectableAdapter]
*
* @author Davide Farella
*/
internal class LabelsAdapter :
BasePagedAdapter<LabelUiModel, LabelsAdapter.ViewHolder>(LabelsComparator),
SelectableAdapter<LabelUiModel, LabelsAdapter.ViewHolder> {
override var onItemSelect: (LabelUiModel, isSelected: Boolean) -> Unit = { _, _ -> }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
ViewHolder(parent.inflate(R.layout.labels_list_item))
private object LabelsComparator : DiffUtil.ItemCallback<LabelUiModel>() {
override fun areItemsTheSame(oldItem: LabelUiModel, newItem: LabelUiModel) =
oldItem.labelId == newItem.labelId
override fun areContentsTheSame(oldItem: LabelUiModel, newItem: LabelUiModel) =
oldItem == newItem
}
/**
* A [RecyclerView.ViewHolder] for [LabelsAdapter]
* Inherit from [SelectableAdapter.ViewHolder]
*/
internal class ViewHolder(itemView: View) :
SelectableAdapter.ViewHolder<LabelUiModel>(itemView) {
@Suppress("RemoveExplicitTypeArguments") // `with` needs to always return `Unit`
override fun onBind(item: LabelUiModel) = with<View, Unit>(itemView) {
super.onBind(item)
val check = itemView.findViewById<MaterialCheckBox>(R.id.label_check)
val color = itemView.findViewById<ImageView>(R.id.label_color)
val name = itemView.findViewById<TextView>(R.id.label_name)
// Selection listener
check.setOnClickListener {
itemView.label_check.toggle()
setSelected(item, !item.isChecked)
}
// Set View
if (item.type == LabelUiModel.Type.LABELS) {
color.layoutParams.height = resources.getDimensionPixelSize(R.dimen.padding_l)
color.layoutParams.width = resources.getDimensionPixelSize(R.dimen.padding_l)
color.setImageDrawable(getDrawable(R.drawable.circle_labels_selection))
} else if (item.type == LabelUiModel.Type.FOLDERS) {
color.layoutParams.height = resources.getDimensionPixelSize(R.dimen.padding_xl)
color.layoutParams.width = resources.getDimensionPixelSize(R.dimen.padding_xl)
color.setImageDrawable(getDrawable(R.drawable.ic_folder_filled))
}
color.setColorFilter(item.color)
name.text = item.name.truncateToLength(15)
check.isChecked = item.isChecked
}
}
}

View File

@ -1,83 +0,0 @@
/*
* Copyright (c) 2020 Proton Technologies AG
*
* This file is part of ProtonMail.
*
* ProtonMail 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.
*
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
*/
package ch.protonmail.android.adapters
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import ch.protonmail.android.R
import ch.protonmail.android.uiModel.LabelUiModel
import ch.protonmail.android.utils.extensions.truncateToLength
import ch.protonmail.libs.core.ui.adapter.BasePagedAdapter
import ch.protonmail.libs.core.ui.adapter.SelectableAdapter
import kotlinx.android.synthetic.main.labels_circle_list_item.view.*
import me.proton.core.presentation.utils.inflate
/**
* A [RecyclerView.Adapter] for show `Labels` or `Folders`
* Inherit from [BasePagedAdapter]
* Implement [SelectableAdapter]
*
* @author Davide Farella
*/
internal class LabelsCirclesAdapter :
BasePagedAdapter<LabelUiModel, LabelsCirclesAdapter.ViewHolder>( LabelsComparator ),
SelectableAdapter<LabelUiModel, LabelsCirclesAdapter.ViewHolder> {
override var onItemSelect: (LabelUiModel, isSelected: Boolean) -> Unit = { _, _ -> }
override fun onCreateViewHolder( parent: ViewGroup, viewType: Int ) =
ViewHolder( parent.inflate( R.layout.labels_circle_list_item ) )
private object LabelsComparator : DiffUtil.ItemCallback<LabelUiModel>() {
override fun areItemsTheSame( oldItem: LabelUiModel, newItem: LabelUiModel ) =
oldItem.labelId == newItem.labelId
override fun areContentsTheSame( oldItem: LabelUiModel, newItem: LabelUiModel ) =
oldItem == newItem
}
/**
* A [RecyclerView.ViewHolder] for [LabelsCirclesAdapter]
* Inherit from [SelectableAdapter.ViewHolder]
*/
internal class ViewHolder( itemView: View ) :
SelectableAdapter.ViewHolder<LabelUiModel>( itemView ) {
@Suppress("RemoveExplicitTypeArguments") // `with` needs to always return `Unit`
override fun onBind( item: LabelUiModel ) = with<View, Unit>( itemView ) {
super.onBind( item )
// Selection listener
label_check.setOnClickListener {
itemView.label_check.toggle()
setSelected( item, !item.isChecked )
}
// Set View
label_name.text = item.name.truncateToLength( 15 )
label_edit.setImageResource( item.image )
label_color.setColorFilter( item.color )
label_check.isChecked = item.isChecked
}
}
}

View File

@ -39,13 +39,13 @@ import ch.protonmail.android.utils.UiUtil;
import ch.protonmail.android.views.ThreeStateButton;
@Deprecated // replaced with ManageLabelsActionAdapter
public class LabelsAdapter extends ArrayAdapter<LabelsAdapter.LabelItem> {
public class LabelsDialogAdapter extends ArrayAdapter<LabelsDialogAdapter.LabelItem> {
private List<LabelItem> items;
private final int mStrokeWidth;
public LabelsAdapter(Context context, List<LabelItem> items) {
super(context, R.layout.labels_list_item);
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
@ -63,7 +63,7 @@ public class LabelsAdapter extends ArrayAdapter<LabelsAdapter.LabelItem> {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
View view = LayoutInflater.from(getContext()).inflate(R.layout.labels_list_item, 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;

View File

@ -78,7 +78,7 @@ class ColorChooserFragment : AbstractDialogFragment(), AdapterView.OnItemClickLi
private fun initColors() {
colorOptions = resources.getIntArray(R.array.label_colors)
colorsAdapter = LabelColorsAdapter(context, colorOptions, R.layout.label_color_item_circle)
colorsAdapter = LabelColorsAdapter(context!!, colorOptions, R.layout.label_color_item_circle)
colorsGrid.adapter = colorsAdapter
colorsGrid.onItemClickListener = this
}

View File

@ -26,7 +26,7 @@ import androidx.annotation.DrawableRes
*
* @author Davide Farella
*/
internal data class LabelUiModel(
data class LabelUiModel(
val labelId: String,
val name: String,
@DrawableRes val image: Int,

View File

@ -22,7 +22,7 @@ package ch.protonmail.android.viewmodel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import ch.protonmail.android.adapters.LabelsAdapter
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
@ -50,7 +50,7 @@ class ManageLabelsDialogViewModel @Inject constructor(
checkedLabelIds: List<String>,
archiveCheckboxState: Int,
labelName: String,
labelItemsList: List<LabelsAdapter.LabelItem>
labelItemsList: List<LabelsDialogAdapter.LabelItem>
) {
if (isCreationMode) {
@ -97,7 +97,7 @@ class ManageLabelsDialogViewModel @Inject constructor(
private fun createLabel(
labelName: String,
labelColor: String?,
labelItemsList: List<LabelsAdapter.LabelItem>
labelItemsList: List<LabelsDialogAdapter.LabelItem>
): ViewState {
if (labelColor.isNullOrEmpty()) {
return ShowMissingColorError

View File

@ -20,7 +20,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="?attr/colorAccent" />
<solid android:color="?attr/proton_interaction_norm" />
<size
android:width="@dimen/padding_xl"
android:height="@dimen/padding_xl" />

View File

@ -20,10 +20,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M22.5,21H1.5V3H9V6H22.5V21ZM3,19.5H21V7.5H7.5V4.5H3V19.5Z"
android:pathData="M8.5,4L6.5,2H1V14H15V4H8.5ZM14,5H8.0858L6.0858,3H2V13H14V5Z"
android:fillColor="@color/icon_norm"
android:fillType="evenOdd"/>
</vector>

View File

@ -16,14 +16,12 @@
~ You should have received a copy of the GNU General Public License
~ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M15,14H1V2H6V4H15V14Z"
android:fillColor="@color/icon_norm"
android:fillType="evenOdd"/>
android:pathData="M5.5,2H1V14H15V4H7.5L5.5,2Z" />
</vector>

View File

@ -23,7 +23,7 @@
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M1,14H15V4H6V2H1V7.1109H2V3H5V5H14V13H2V10.5H1V14ZM8.1711,9.3L6.5213,10.9498L7.2284,11.6569L9.3497,9.5355L10.0568,8.8284L9.3497,8.1213L7.2284,6L6.5213,6.7071L8.1142,8.3H0V9.3H8.1711Z"
android:pathData="M7.5,4L5.5,2H1V6.9H2V3H5.0858L7.0858,5H14V13H2V10.9H1V14H15V4H7.5ZM9.3497,8.1213L7.2284,6L6.5213,6.7071L8.1142,8.3H1V9.3H8.1711L6.5213,10.9497L7.2284,11.6569L9.3497,9.5355L10.0568,8.8284L9.3497,8.1213Z"
android:fillColor="@color/icon_norm"
android:fillType="evenOdd"/>
</vector>

View File

@ -20,14 +20,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M22.5,22.5H1.5V4.5H9V7.5H22.5V22.5ZM3,21H21V9H7.5V6H3V21Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<path
android:pathData="M10.5,3H3V1.5H12V4.5H22.5V6H10.5V3Z"
android:fillColor="#ffffff"
android:pathData="M8.2308,1L9.9231,2.6364H15H16V3.6364V10V11H15H13V14H12H2H1V13V5V4H2H4V2V1H5H8.2308ZM4,5H2L2,13H12V11H5H4V10V5ZM9.9231,3.6364H15V10H5V2H7.8264L9.228,3.3552L9.5187,3.6364H9.9231Z"
android:fillColor="@color/icon_norm"
android:fillType="evenOdd"/>
</vector>

View File

@ -32,5 +32,5 @@ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
android:top="0dp" />
<stroke
android:width="3dp"
android:color="#4F5062" />
android:color="@color/icon_inverted" />
</shape>

View File

@ -18,9 +18,8 @@ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<include
@ -37,156 +36,129 @@ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
android:layout_height="wrap_content"
android:orientation="vertical">
<ch.protonmail.android.views.CustomFontTextView
<TextView
android:id="@+id/labels_dialog_title"
style="@style/Proton.Text.DefaultSmall.Interaction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/fields_default_space_medium"
android:layout_marginTop="@dimen/fields_default_space_medium"
android:text="@string/label_add_new"
android:textColor="@color/switch_settings_item"
android:paddingEnd="@dimen/fields_default_space_medium"
android:paddingLeft="@dimen/fields_default_space_medium"
android:paddingRight="@dimen/fields_default_space_medium"
android:paddingStart="@dimen/fields_default_space_medium"
app:fontName="Roboto-Regular.ttf" />
android:layout_marginStart="@dimen/padding_l"
android:layout_marginTop="@dimen/padding_xl"
android:layout_marginEnd="@dimen/padding_l"
android:layout_marginBottom="@dimen/padding_m"
android:text="@string/label_add_new" />
<RelativeLayout
android:id="@+id/add_label_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="@dimen/fields_default_space_medium"
android:paddingLeft="@dimen/fields_default_space_medium"
android:paddingRight="@dimen/fields_default_space_medium"
android:paddingStart="@dimen/fields_default_space_medium">
android:layout_marginStart="@dimen/padding_l"
android:layout_marginEnd="@dimen/padding_l"
android:layout_marginBottom="@dimen/padding_xl">
<ch.protonmail.android.views.CustomFontEditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/label_name"
style="@style/ProtonInput.Mail"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/new_label_edittext"
android:layout_height="wrap_content"
android:hint="@string/label_name"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:textCursorDrawable="@null"
android:paddingBottom="0dp"
android:paddingTop="0dp"
android:textColorHint="@color/fog_gray"
android:textSize="@dimen/h4" />
android:textCursorDrawable="@null" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@drawable/list_divider" />
<LinearLayout
android:id="@+id/label_color_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/fields_default_space_large"
android:orientation="vertical"
android:paddingEnd="@dimen/fields_default_space_medium"
android:paddingLeft="@dimen/fields_default_space_medium"
android:paddingRight="@dimen/fields_default_space_medium"
android:paddingStart="@dimen/fields_default_space_medium"
android:paddingStart="@dimen/padding_xl"
android:paddingEnd="@dimen/padding_xl"
android:visibility="gone">
<ch.protonmail.android.views.CustomFontTextView
android:id="@+id/labels_colors_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/fields_default_space_medium"
android:layout_marginTop="@dimen/fields_default_space_medium"
android:text="@string/choose_label_color"
android:textColor="@color/switch_settings_item"
app:fontName="Roboto-Regular.ttf" />
<GridView
android:id="@+id/labels_grid_view"
android:id="@+id/colors_grid_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_horizontal_margin_small"
android:layout_marginRight="@dimen/activity_horizontal_margin_small"
android:layout_gravity="center"
android:layout_marginTop="@dimen/fields_default_space_large"
android:divider="@null"
android:dividerHeight="0dp"
android:listSelector="@android:color/transparent"
android:nestedScrollingEnabled="false"
android:numColumns="5"
android:scrollbars="none"
android:verticalSpacing="@dimen/fields_default_space" />
android:horizontalSpacing="@dimen/padding_xl"
android:verticalSpacing="@dimen/padding_xl" />
<ch.protonmail.android.views.CustomFontButton
android:id="@+id/save_new_label"
style="@style/SettingsButtonBlue"
<Button
android:id="@+id/save_button"
style="@style/ProtonButton"
android:layout_width="wrap_content"
android:layout_height="44dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/fields_default_space_medium"
android:gravity="center"
android:maxLines="1"
android:paddingEnd="@dimen/fields_default_space"
android:paddingLeft="@dimen/fields_default_space"
android:paddingRight="@dimen/fields_default_space"
android:paddingStart="@dimen/fields_default_space"
android:text="@string/save_new_label"
app:fontName="Roboto-Light.ttf" />
android:layout_marginTop="@dimen/padding_xl"
android:paddingStart="@dimen/padding_xxl"
android:paddingEnd="@dimen/padding_xxl"
android:text="@string/update_label" />
</LinearLayout>
<RelativeLayout
android:id="@+id/labels_list_view_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/fields_default_space"
android:layout_marginTop="@dimen/spacing">
android:layout_marginStart="@dimen/padding_l"
android:layout_marginEnd="@dimen/padding_l"
android:paddingBottom="@dimen/padding_xl"
android:visibility="visible">
<ch.protonmail.android.views.CustomFontTextView
<TextView
android:id="@+id/available_labels_title"
style="@style/Proton.Text.DefaultSmall.Interaction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/fields_default_space_medium"
android:text="@string/available_labels"
android:paddingEnd="@dimen/fields_default_space_medium"
android:paddingLeft="@dimen/fields_default_space_medium"
android:paddingRight="@dimen/fields_default_space_medium"
android:paddingStart="@dimen/fields_default_space_medium"
android:textColor="@color/switch_settings_item"
app:fontName="Roboto-Regular.ttf" />
android:layout_marginTop="@dimen/padding_xl"
android:layout_marginBottom="@dimen/padding_m"
android:text="@string/available_labels" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/labels_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/available_labels_title"
android:divider="@color/iron_gray"
android:divider="@color/separator_norm"
android:dividerHeight="1px"
android:paddingTop="0dp" />
<ch.protonmail.android.views.CustomFontTextView
<TextView
android:id="@+id/no_labels"
style="@style/Proton.Text.Default.Weak"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/fields_default_space_large"
android:layout_below="@id/available_labels_title"
android:layout_marginStart="@dimen/fields_default_space_large"
android:text="@string/no_labels"
android:textColor="@color/iron_gray"
android:textSize="@dimen/h4"
android:visibility="gone"
app:fontName="Roboto-Regular.ttf" />
android:visibility="gone" />
<ch.protonmail.android.views.CustomFontButton
<Button
android:id="@+id/delete_labels"
style="@style/SettingsButtonBlue"
style="@style/ProtonButton"
android:layout_width="wrap_content"
android:layout_height="38dp"
android:layout_height="wrap_content"
android:layout_below="@id/labels_recycler_view"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/padding_l"
android:enabled="false"
android:maxLines="1"
android:paddingEnd="@dimen/fields_default_space_large"
android:paddingLeft="@dimen/fields_default_space_large"
android:paddingRight="@dimen/fields_default_space_large"
android:paddingStart="@dimen/fields_default_space_large"
android:layout_marginBottom="@dimen/fields_default_space"
android:text="@string/delete_selected"
app:fontName="Roboto-Regular.ttf" />
android:paddingStart="@dimen/padding_xl"
android:paddingEnd="@dimen/padding_xl"
android:text="@string/delete_selected" />
</RelativeLayout>
</LinearLayout>
</ScrollView>

View File

@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2020 Proton Technologies AG
This file is part of ProtonMail.
ProtonMail 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.
ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/label_color_item_size"
android:layout_height="@dimen/label_color_item_size"
android:background="@android:color/transparent"
android:gravity="center"
android:clickable="false">
<View
android:id="@+id/circle"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:background="@drawable/label_color_circle" />
<FrameLayout
android:id="@+id/circle_selected"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:visibility="gone">
<View
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/label_color_circle_selected" />
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:src="@drawable/ic_done_white"
android:tint="#4F5062"/>
</FrameLayout>
</RelativeLayout>

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (c) 2020 Proton Technologies AG
This file is part of ProtonMail.
ProtonMail 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.
ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/fields_default_space_small"
android:paddingBottom="@dimen/fields_default_space_small">
<TextView
android:id="@+id/label_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/label_background"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:paddingLeft="@dimen/fields_default_space"
android:paddingRight="@dimen/fields_default_space"
android:singleLine="true"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="@dimen/h5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Label name" />
<TextView
android:id="@+id/label_selected_messages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@id/label_check"
android:paddingEnd="8dp"
android:textColor="@color/icon_purple"
android:textSize="@dimen/h2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/label_check"
app:layout_constraintTop_toTopOf="parent"
tools:text="22" />
<ch.protonmail.android.views.ThreeStateButton
android:id="@+id/label_check"
android:layout_width="@dimen/custom_check_box_size"
android:layout_height="@dimen/custom_check_box_size"
android:layout_marginStart="10dp"
android:gravity="end"
android:padding="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2020 Proton Technologies AG
~
~ This file is part of ProtonMail.
~
~ ProtonMail 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.
~
~ ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/settings_color_item_size"
android:layout_height="@dimen/settings_color_item_size"
android:layout_gravity="center"
android:clickable="false">
<View
android:id="@+id/color_item"
android:layout_width="@dimen/settings_color_item_size"
android:layout_height="@dimen/settings_color_item_size"
android:background="@drawable/ic_folder_filled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/is_checked_indicator"
android:layout_width="@dimen/settings_color_item_size"
android:layout_height="@dimen/settings_color_item_size"
android:background="@android:color/transparent"
android:padding="@dimen/padding_m"
android:src="@drawable/ic_done_white"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/icon_inverted" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (c) 2020 Proton Technologies AG
This file is part of ProtonMail.
@ -22,29 +21,27 @@ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/fields_default_space"
android:paddingRight="@dimen/fields_default_space"
android:paddingStart="@dimen/fields_default_space"
android:paddingEnd="@dimen/fields_default_space"
android:paddingTop="@dimen/fields_default_space_large">
android:paddingStart="@dimen/padding_m"
android:paddingTop="@dimen/padding_xl"
android:paddingEnd="@dimen/padding_m"
android:paddingBottom="@dimen/padding_m">
<GridView
android:id="@+id/colorsGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_horizontal_margin_small"
android:layout_marginRight="@dimen/activity_horizontal_margin_small"
android:layout_marginTop="@dimen/fields_default_space_large"
android:horizontalSpacing="@dimen/fields_default_space"
android:stretchMode="columnWidth"
android:divider="@null"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/padding_s"
android:layout_marginTop="@dimen/fields_default_space_large"
android:layout_marginRight="@dimen/padding_s"
android:divider="@null"
android:dividerHeight="0dp"
android:gravity="center"
android:horizontalSpacing="@dimen/padding_xl"
android:listSelector="@android:color/transparent"
android:numColumns="4"
android:numColumns="5"
android:scrollbars="none"
android:verticalSpacing="@dimen/fields_default_space" />
android:verticalSpacing="@dimen/padding_xl" />
<LinearLayout
android:layout_width="match_parent"
@ -53,31 +50,24 @@ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
android:minHeight="50dp"
android:orientation="horizontal">
<ch.protonmail.android.views.CustomFontTextView
<Button
android:id="@+id/cancel"
style="@style/ProtonButton.Borderless.Text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/cancel"
android:clickable="true"
android:focusable="true"
android:textColor="@color/name_gray"
android:textSize="@dimen/h2"
app:fontName="Roboto-Thin.ttf" />
android:textColor="@color/interaction_weak_selector" />
<ch.protonmail.android.views.CustomFontTextView
<Button
android:id="@+id/apply"
style="@style/ProtonButton.Borderless.Text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:text="@string/label_apply"
android:textColor="@color/new_purple_dark"
android:textSize="@dimen/h2"
app:fontName="Roboto-Regular.ttf" />
android:text="@string/label_apply" />
</LinearLayout>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (c) 2020 Proton Technologies AG
This file is part of ProtonMail.
@ -17,40 +16,34 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/label_color_item_size"
android:layout_height="@dimen/label_color_item_size"
android:background="@android:color/transparent"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/settings_color_item_size"
android:layout_height="@dimen/settings_color_item_size"
android:layout_gravity="center"
android:gravity="center"
android:clickable="false">
<View
android:id="@+id/circle"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:background="@drawable/label_color_circle" />
android:id="@+id/color_item"
android:layout_width="@dimen/settings_color_item_size"
android:layout_height="@dimen/settings_color_item_size"
android:background="@drawable/circle_labels_selection"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/circle_selected"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:visibility="gone">
<View
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/label_color_circle_selected" />
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:src="@drawable/ic_done_white"
android:tint="#4F5062"/>
</FrameLayout>
</RelativeLayout>
<ImageView
android:id="@+id/is_checked_indicator"
android:layout_width="@dimen/settings_color_item_size"
android:layout_height="@dimen/settings_color_item_size"
android:background="@android:color/transparent"
android:padding="@dimen/padding_m"
android:src="@drawable/ic_done_white"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/icon_inverted" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2020 Proton Technologies AG
This file is part of ProtonMail.
ProtonMail 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.
ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/label_item_min_height"
android:paddingBottom="@dimen/fields_default_space_small"
android:paddingEnd="@dimen/activity_horizontal_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingStart="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/fields_default_space_small">
<CheckBox
android:id="@+id/label_check"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"
android:layout_alignParentEnd="true"
android:button="@drawable/custom_labels_checkbox"
android:padding="0dp" />
<ImageView
android:id="@+id/label_edit"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toLeftOf="@id/label_check"
android:layout_toStartOf="@id/label_check"
android:gravity="right|end"
android:src="@drawable/folder_edit_active"/>
<TextView
android:id="@+id/label_selected_messages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/label_check"
android:padding="0dp"
android:textColor="@color/icon_purple"
android:textSize="@dimen/h2" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:orientation="horizontal">
<ImageView
android:id="@+id/label_color"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_label_circle" />
<ch.protonmail.android.views.CustomFontTextView
android:id="@+id/label_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:maxLines="1"
android:paddingLeft="@dimen/fields_default_space"
android:paddingRight="@dimen/fields_default_space"
android:textAllCaps="true"
android:textColor="@color/lead_gray"
android:textSize="@dimen/h5" />
</LinearLayout>
</RelativeLayout>

View File

@ -18,55 +18,55 @@ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/fields_default_space_small"
android:paddingBottom="@dimen/fields_default_space_small">
android:background="?attr/selectableItemBackground"
android:paddingTop="@dimen/padding_l"
android:paddingBottom="@dimen/padding_l">
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/label_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/padding_m"
android:minWidth="0dp"
android:minHeight="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/label_color"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/label_color"
android:layout_width="@dimen/padding_l"
android:layout_height="@dimen/padding_l"
android:src="@drawable/circle_labels_selection"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/label_name"
app:layout_constraintStart_toEndOf="@id/label_check"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/label_name"
style="@style/Proton.Text.Default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/label_background"
android:layout_height="0dp"
android:layout_marginStart="@dimen/padding_l"
android:layout_marginEnd="@dimen/padding_m"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:paddingLeft="@dimen/fields_default_space"
android:paddingRight="@dimen/fields_default_space"
android:singleLine="true"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="@dimen/h5"
android:gravity="start|center"
android:maxLines="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Label name" />
app:layout_constraintStart_toEndOf="@id/label_color"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/label_selected_messages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@id/label_check"
android:paddingEnd="8dp"
android:textColor="@color/icon_purple"
android:textSize="@dimen/h2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/label_check"
app:layout_constraintTop_toTopOf="parent"
tools:text="22" />
<ch.protonmail.android.views.ThreeStateButton
android:id="@+id/label_check"
android:layout_width="@dimen/custom_check_box_size"
android:layout_height="@dimen/custom_check_box_size"
android:layout_marginStart="10dp"
android:gravity="end"
android:padding="0dp"
<ImageView
android:id="@+id/label_edit"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="@dimen/padding_m"
android:src="@drawable/ic_pencil"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -97,15 +97,14 @@
<!-- upselling -->
<color name="upgrade_section">#9497CE</color>
<color name="lime">#C3E129</color>
<!-- edit settings screens-->
<color name="switch_background">#41404E</color>
<!-- account types -->
<color name="professional">#D4B46E</color>
<color name="visionary">#5EDEFB</color>
<color name="plus">@color/lime</color>
<color name="visionary">#6ddcfb</color>
<color name="plus">#c6e422</color>
<color name="free">@color/cornflower_blue</color>
<color name="switch_settings_item">#9199CA</color>
@ -133,50 +132,51 @@
<color name="warning">@color/red_orange</color>
<!-- labels -->
<color name="label_color_1">#7272A7</color>
<color name="label_color_2">#CF5858</color>
<color name="label_color_3">#C26CC7</color>
<color name="label_color_4">#7569D1</color>
<color name="label_color_5">#69A9D1</color>
<color name="label_color_6">#5EC7B7</color>
<color name="label_color_7">#72BB75</color>
<color name="label_color_8">#C3D261</color>
<color name="label_color_9">#E6C04C</color>
<color name="label_color_10">#E6984C</color>
<color name="label_color_11">#8989AC</color>
<color name="label_color_12">#CF7E7E</color>
<color name="label_color_13">#C793CA</color>
<color name="label_color_14">#9B94D1</color>
<color name="label_color_15">#A8C4D5</color>
<color name="label_color_16">#97C9C1</color>
<color name="label_color_17">#9DB99F</color>
<color name="label_color_18">#C6CD97</color>
<color name="label_color_19">#E7D292</color>
<color name="label_color_20">#DFB286</color>
<color name="label_buttons">#9497ce</color>
<!-- labels -->
<color name="purple_base">#7272A7</color>
<color name="heather_base">#8989AC</color>
<color name="strawberry_base">#CF5858</color>
<color name="blush_base">#CF7E7E</color>
<color name="pink_base">#C26CC7</color>
<color name="lilac_base">#C793CA</color>
<color name="slateblue_base">#7569D1</color>
<color name="kimberly_base">#9B94D1</color>
<color name="pacific_base">#69A9D1</color>
<color name="glacier_base">#A8C4D5</color>
<color name="aqua_base">#79C4B7</color>
<color name="sage_base">#A1C8C1</color>
<color name="fern_base">#72BB75</color>
<color name="moss_base">#9DB99F</color>
<color name="pear_base">#C3D261</color>
<color name="olive_base">#C6CD97</color>
<color name="mustard_base">#E6C04C</color>
<color name="sahara_base">#E7D292</color>
<color name="carrot_base">#E6984C</color>
<color name="cinnamon_base">#DFB286</color>
<array name="label_colors">
<item>@color/label_color_1</item>
<item>@color/label_color_2</item>
<item>@color/label_color_3</item>
<item>@color/label_color_4</item>
<item>@color/label_color_5</item>
<item>@color/label_color_6</item>
<item>@color/label_color_7</item>
<item>@color/label_color_8</item>
<item>@color/label_color_9</item>
<item>@color/label_color_10</item>
<item>@color/label_color_11</item>
<item>@color/label_color_12</item>
<item>@color/label_color_13</item>
<item>@color/label_color_14</item>
<item>@color/label_color_15</item>
<item>@color/label_color_16</item>
<item>@color/label_color_17</item>
<item>@color/label_color_18</item>
<item>@color/label_color_19</item>
<item>@color/label_color_20</item>
<item>@color/purple_base</item>
<item>@color/heather_base</item>
<item>@color/strawberry_base</item>
<item>@color/blush_base</item>
<item>@color/pink_base</item>
<item>@color/lilac_base</item>
<item>@color/slateblue_base</item>
<item>@color/kimberly_base</item>
<item>@color/pacific_base</item>
<item>@color/glacier_base</item>
<item>@color/aqua_base</item>
<item>@color/sage_base</item>
<item>@color/fern_base</item>
<item>@color/moss_base</item>
<item>@color/pear_base</item>
<item>@color/olive_base</item>
<item>@color/mustard_base</item>
<item>@color/sahara_base</item>
<item>@color/carrot_base</item>
<item>@color/cinnamon_base</item>
</array>

View File

@ -916,7 +916,7 @@
<string name="labels_and_folders">Labels &amp; Folders </string>
<string name="folders">Folders</string>
<string name="labels">Labels</string>
<string name="labels_manage">Labels manager</string>
<string name="labels_manager">Labels manager</string>
<string name="folders_manage">Folders manager</string>
<string name="swiping_gesture">Swiping gesture</string>

View File

@ -21,7 +21,7 @@ package ch.protonmail.android.viewmodel
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.lifecycle.Observer
import ch.protonmail.android.adapters.LabelsAdapter
import ch.protonmail.android.adapters.LabelsDialogAdapter
import ch.protonmail.android.core.UserManager
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState
import ch.protonmail.android.viewmodel.ManageLabelsDialogViewModel.ViewState.HideLabelsView
@ -99,7 +99,7 @@ class ManageLabelsDialogViewModelTest {
@Test
fun `show LabelNameDuplicatedError when creating a label with a name which is already used`() {
val labelName = "label-name-already-in-use"
val labelItem = LabelsAdapter.LabelItem(false)
val labelItem = LabelsDialogAdapter.LabelItem(false)
labelItem.name = labelName
viewModel.onDoneClicked(