add icons to menu headers

This commit is contained in:
Phillip Thelen 2016-03-16 20:47:42 +01:00
parent ba24517d6f
commit 6c98952e28
13 changed files with 380 additions and 42 deletions

View file

@ -52,6 +52,7 @@ dependencies {
compile('com.mikepenz:materialdrawer:5.0.9@aar') {
transitive = true
}
compile 'com.mikepenz:google-material-typeface:2.2.0.1.original@aar'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:id="@+id/material_drawer_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/material_drawer_padding" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/material_drawer_vertical_padding"
android:paddingRight="@dimen/material_drawer_vertical_padding">
<ImageView
android:id="@+id/material_drawer_icon"
android:layout_width="@dimen/material_drawer_item_primary_icon"
android:layout_height="@dimen/material_drawer_item_primary"
android:layout_gravity="center_vertical"
android:paddingBottom="@dimen/material_drawer_item_primary_icon_padding"
android:paddingEnd="@dimen/material_drawer_vertical_padding"
android:paddingLeft="0dp"
android:paddingRight="@dimen/material_drawer_vertical_padding"
android:paddingStart="0dp"
android:paddingTop="@dimen/material_drawer_item_primary_icon_padding" />
<TextView
android:id="@+id/material_drawer_name"
android:layout_width="match_parent"
android:layout_height="@dimen/material_drawer_item_primary"
android:fontFamily="sans-serif-medium"
android:gravity="center_vertical|start"
android:lines="1"
android:singleLine="true"
android:textSize="@dimen/material_drawer_item_section_text" />
</LinearLayout>
</LinearLayout>

View file

@ -231,4 +231,8 @@ Für den Anfang, welche Bereiche deines Lebens möchtest du verbessern?</string>
<string name="outfit_weapon">Waffe</string>
<string name="wear_costume">Kostüm tragen</string>
<string name="equipped">Ausgerüstet</string>
<string name="quest.pending">Ausstehend</string>
<string name="quest.accepted">Angenommen</string>
<string name="quest.rejected">Abgelehnt</string>
<string name="quest.participants">Teilnehmer</string>
</resources>

View file

@ -147,9 +147,6 @@
<string name="due_date">Fecha límite</string>
<string name="quest.accept">Aceptar</string>
<string name="quest.reject">Rechazar</string>
<string name="quest.begin">Empezar</string>
<string name="quest.cancel">Cancelar</string>
<string name="quest.abort">Abortar</string>
<string name="quest.leave">Abandonar Desafío</string>
<string name="version_info" formatted="false">Versión %s (%d)</string>
<string name="sidebar_help">Ayuda &amp; FAQ</string>

View file

@ -85,7 +85,7 @@
<string name="friday">Vendredi</string>
<string name="saturday">Samedi</string>
<string name="sunday">Dimanche</string>
<string name="levelup_header">Vous avez passé un niveau !</string>
<string name="levelup_header">Vous avez gagné un niveau !</string>
<string name="levelup_detail">En atteignant vos buts dans la vie réelle, vous avez atteint le Niveau %1$d !</string>
<string name="levelup_health">Vous avez été guéri·e complètement !</string>
<string name="levelup_button">Bravo !</string>
@ -99,15 +99,15 @@
<string name="used_skill" formatted="false">Vous avez utilisé %1$s pour %2$d points de mana.</string>
<string name="new_checklist_item">Nouvelle vérification</string>
<string name="add_checklist_item">Ajouter</string>
<string name="reminder_title">N\'oubliez pas de cocher vos tâches quotidiennes accomplies !</string>
<string name="reminder_title">N\'oubliez pas de cocher vos tâches Quotidiennes !</string>
<string name="skill_progress_title">Utiliser une compétence</string>
<string name="coming_soon">Bientôt disponible</string>
<string name="chat_flag_confirmation">Êtes-vous sûr·e de vouloir signaler ce message pour violation ?</string>
<string name="chat_flag_confirmation">Êtes-vous sûr·e de vouloir signaler ce message pour infraction ?</string>
<string name="flag_confirm">Signaler</string>
<string name="unlock_lvl_11">Disponible au niveau 11</string>
<string name="no_party_message">Vous ne faites pas partie d\'une équipe. Pour rejoindre une équipe, veuillez visiter le site Internet.</string>
<string name="no_party_message">Vous ne faites pas partie d\'une équipe. Pour rejoindre une équipe, veuillez visiter le site.</string>
<string name="forgot_pw_btn">Mot de passe oublié</string>
<string name="forgot_pw_tv">Mot de passe oublié ? Veuillez vous rendre sur la version mobile de notre site.</string>
<string name="forgot_pw_tv">Mot de passe oublié ? Veuillez vous rendre sur la version mobile du site.</string>
<string name="tavern.inn.checkOut">Quitter l\'Auberge</string>
<string name="tavern.inn.rest">Se reposer à l\'Auberge</string>
<string name="reward.dialog.buy">Acheter</string>
@ -232,4 +232,8 @@ Pour commencer, quels aspects de votre vie souhaitez-vous améliorer ?</string>
<string name="outfit_weapon">Arme</string>
<string name="wear_costume">Porter un costume</string>
<string name="equipped">Équipé</string>
<string name="quest.pending">En attente</string>
<string name="quest.accepted">Acceptée</string>
<string name="quest.rejected">Rejeté</string>
<string name="quest.participants">Participants</string>
</resources>

View file

@ -147,9 +147,6 @@
<string name="due_date">Data di scadenza</string>
<string name="quest.accept">Accetta</string>
<string name="quest.reject">Rifiuta</string>
<string name="quest.begin">Inizia</string>
<string name="quest.cancel">Annulla</string>
<string name="quest.abort">Annulla</string>
<string name="quest.leave">Abbandona Missione</string>
<string name="version_info" formatted="false">Versione %s (%d)</string>
<string name="complete_tutorial">Capito!</string>

View file

@ -147,10 +147,14 @@
<string name="due_date">Baigimo Terminas</string>
<string name="quest.accept">Sutikti</string>
<string name="quest.reject">Atmesti</string>
<string name="quest.begin">Pradėti</string>
<string name="quest.cancel">Atšaukti</string>
<string name="quest.abort">Nutraukti</string>
<string name="quest.begin">Pradėti Misiją</string>
<string name="quest.cancel">Atšaukti Pakvietimą</string>
<string name="quest.abort">Atšaukti Misiją</string>
<string name="quest.leave">Palikti Misiją</string>
<string name="quest.pending">Laukiama</string>
<string name="quest.accepted">Sutiko</string>
<string name="quest.rejected">Atsisakė</string>
<string name="quest.participants">Dalyviai</string>
<string name="version_info" formatted="false">Versija: %s (%d)</string>
<string name="sidebar_help">Pagalba &amp; DUK</string>
<string name="complete_tutorial">Supratau!</string>
@ -232,4 +236,14 @@ Pradžiai, kurias savo gyvenimo dalis norėtum tobulint?</string>
<string name="outfit_weapon">Ginklas</string>
<string name="wear_costume">Užsidėti Kostiumą</string>
<string name="equipped">Užsidėta</string>
<string name="quest_cancel_message">Ar tikrai nori atšaukti misiją? Visi pakvietimai bus nutraukti. Misijos savininkas atgaus misijos rankraštį.</string>
<string name="quest.invitation">Misijos Pakvietimas</string>
<string name="quest_begin_message">Ar tikrai nori pradėti misiją? Kai ji prasidės, kiti grupės nariai nebegalės prisijungti.</string>
<string name="quest.invitation.text">Tave pakvietė dalyvauti misijoje!</string>
<string name="ago_1day">Liko 1 diena</string>
<string name="ago_days" formatted="false">prieš %d dieną(as)</string>
<string name="ago_1Minute">prieš 1 minutę</string>
<string name="ago_minutes" formatted="false">prieš %d minutę(es)</string>
<string name="ago_hours" formatted="false">prieš %d valandą(as)</string>
<string name="ago_1hour">prieš 1 valandą</string>
</resources>

View file

@ -147,9 +147,6 @@
<string name="due_date">Termin</string>
<string name="quest.accept">Akceptuj</string>
<string name="quest.reject">Odrzuć</string>
<string name="quest.begin">Rozpocznij</string>
<string name="quest.cancel">Anuluj</string>
<string name="quest.abort">Porzuć</string>
<string name="quest.leave">Opuść Misję</string>
<string name="version_info" formatted="false">Wersja %s (%d)</string>
<string name="complete_tutorial">Jasne!</string>

View file

@ -65,6 +65,7 @@
<string name="notes">Notas</string>
<string name="text">Texto</string>
<string name="difficulty">Dificuldade</string>
<string name="tags">Rótulo</string>
<string name="trivial">Trivial</string>
<string name="easy">Fácil</string>
<string name="medium">Médio</string>
@ -103,7 +104,7 @@
<string name="coming_soon">Em Breve</string>
<string name="chat_flag_confirmation">Você tem certeza que quer reportar esta mensagem por violação?</string>
<string name="flag_confirm">Reportar Mensagem</string>
<string name="unlock_lvl_10">Desbloqueie no nv 10</string>
<string name="unlock_lvl_11">Desbloqueie no nível 11</string>
<string name="no_party_message">Você não está em um grupo. Para entrar em um grupo, por favor visite o site.</string>
<string name="forgot_pw_btn">Esqueci a senha</string>
<string name="forgot_pw_tv">Esqueceu a senha? Por favor use o Site móvel.</string>
@ -144,47 +145,53 @@
<string name="purchase_button">Comprar</string>
<string name="purchase_set_title" formatted="false">Comprar conjunto %s</string>
<string name="due_date">Data limite</string>
<string name="quest.accept">Aceitar</string>
<string name="quest.reject">Rejeitar</string>
<string name="quest.begin">Iniciar</string>
<string name="quest.cancel">Cancelar</string>
<string name="quest.abort">Abortar</string>
<string name="quest.leave">Abandonar missão</string>
<string name="version_info" formatted="false">Versão %s (%d)</string>
<string name="sidebar_help"><![CDATA[Ajuda & Perguntas frequentes]]></string>
<string name="sidebar_help">Ajuda &amp;amp: Perguntas Frequentes</string>
<string name="complete_tutorial">Entendi!</string>
<string name="dismiss_tutorial">Lembre-me novamente</string>
<string name="intro_1_title">Bem vindo(a) ao Habitica</string>
<string name="intro_1_description">Junte-se a mais de 1,100,000 pessoas que se divertem enquanto fazem as coisas acontecerem. Crie um avatar e acompanhe suas tarefas da vida real.</string>
<string name="intro_1_description">Junte-se à mais de 1.100.000 pessoas se divertindo enquanto fazem o que precisam. Crie um avatar e acompanhe suas atividades na vida real.</string>
<string name="intro_2_title">Progresso no jogo = Progresso na vida</string>
<string name="intro_2_description">Desbloqueie recursos no jogo ao completar suas tarefas da vida real. Ganhe armaduras, animais de estimação, montarias e mais para recompensá-lo por atingir suas metas!</string>
<string name="intro_3_title">Socialize e lute contra monstros</string>
<string name="intro_3_description">Mantenha suas metas sob controle com a ajuda de seus amigos. Ajudem-se na vida e na batalha enquanto melhoram juntos!</string>
<string name="intro_finish_button">Entrar</string>
<string name="intro_finish_button">Iniciar</string>
<string name="previous_button">Anterior</string>
<string name="next_button">Próximo</string>
<string name="skip_button">Pular</string>
<string name="setup_welcome_description">Bem vindo ao Habitica, onde avançar no jogo vai melhorar sua vida real! Completando metas do mundo real, você vai desbloquear equipamentos, animais de estimação, missões, e mais.</string>
<string name="setup_welcome_title">Bem vindo</string>
<string name="avatar_setup_description">Primeiramente, você precisa de um avatar no jogo para te representar! As coisas que você faz na vida real, vão afetar a saúde, nível de experiência e ouro do seu avatar.</string>
<string name="setup_welcome_description">Bem vindo ao Habitica, onde avançar no jogo vai melhorar sua vida real! Completando metas do mundo real, você vai desbloquear equipamentos, animais de estimação, missões e mais.</string>
<string name="setup_welcome_title">Bem-vindo</string>
<string name="avatar_setup_description">Primeiramente, você precisa de um avatar no jogo para te representar! As coisas que você faz na vida real, vão afetar a saúde do seu avatar, nível de experiência e ouro.</string>
<string name="task_setup_description">Esplêndido! Agora vamos configurar suas tarefas para que você comece a ganhar experiência e ouro.
Para começar, quais partes da sua vida você quer melhorar?</string>
<string name="setup_group_work">Trabalho</string>
<string name="setup_group_exercise">Exercício</string>
<string name="setup_group_heathWellness">Saúde + Bem estar</string>
<string name="setup_group_heathWellness">Saúde + Bem-estar</string>
<string name="setup_group_school">Escola</string>
<string name="setup_group_teams">Equipes</string>
<string name="setup_group_chores">Ocupações</string>
<string name="setup_group_chores">Tarefas</string>
<string name="setup_group_creativity">Criatividade</string>
<string name="setup_task_work_1">Processar seus e-mails</string>
<string name="setup_task_work_1">Processar e-mails</string>
<string name="setup_task_work_2">Tarefa mais importante</string>
<string name="setup_task_work_3">Projeto de trabalho</string>
<string name="setup_task_exercise_1">10 minutos de exercício cardiovascular</string>
<string name="setup_task_exercise_2">Alongamentos</string>
<string name="setup_task_exercise_1">10 min cardio</string>
<string name="setup_task_exercise_2">Alongamento</string>
<string name="setup_task_exercise_3">Criar agenda de atividades físicas</string>
<string name="setup_task_healthWellness_1">Comer bem / Comer besteiras</string>
<string name="setup_task_healthWellness_2">Passar fio dental</string>
<string name="setup_task_healthWellness_3">Agendar check-up médico</string>
<string name="setup_task_healthWellness_3">Agendar check-up</string>
<string name="setup_task_school_1">Estudar/Procrastinar</string>
<string name="setup_task_school_2">Fazer a lição de casa</string>
<string name="setup_task_school_3">Terminar tarefa para a aula</string>
<string name="setup_task_teams_1">\"Check in\" com a equipe</string>
<string name="setup_task_teams_2">Atualizar a equipe do status</string>
<string name="setup_task_teams_1">Confirmar com a equipe</string>
<string name="setup_task_teams_2">Atualizar a equipe sobre o status</string>
<string name="setup_task_teams_3">Completar projeto da equipe</string>
<string name="setup_task_chores_1">Limpeza de 10 minutos</string>
<string name="setup_task_chores_2">Lavar a louça</string>
@ -192,4 +199,41 @@ Para começar, quais partes da sua vida você quer melhorar?</string>
<string name="setup_task_creativity_1">Estudar um mestre no ofício</string>
<string name="setup_task_creativity_2">Trabalhar em um projeto criativo</string>
<string name="setup_task_creativity_3">Terminar um projeto criativo</string>
<string name="gem.purchase.support">Quer nos ajudar a manter o Habitica funcionando? Você pode contribuir com os desenvolvedores ao comprar gemas!\n\nGemas permitem que você compre extras divertidos para sua conta, incluindo: \n\n - Fantasias legais para seu avatar\n - Imagens de fundo incríveis\n - Missões divertidas que te recompensam com ovos\n - A habilidade de mudar de classe antes do nível 100\n\n Muito obrigado por nos ajudar a manter o Habita o melhor possível. Sua ajuda significa muito para nós!</string>
<string name="my_guilds">Minhas Guildas</string>
<string name="public_guilds">Guildas Públicas</string>
<string name="guild">Guilda</string>
<string name="leave">Sair</string>
<string name="join">Juntar-se</string>
<string name="leader">Líder</string>
<string name="gems">Gemas</string>
<string name="copy_as_todo">Copiar como Afazer</string>
<string name="send_pm">Enviar mensagem privada</string>
<string name="flag">Bandeira</string>
<string name="delete">Deletar</string>
<string name="name">Nome</string>
<string name="description">Descrição</string>
<string name="add_tag">Adicionar marcador</string>
<string name="privacy">Privacidade</string>
<string name="write_message">Escrever mensagem</string>
<string name="post">Cargo</string>
<string name="todo_due" formatted="false">Devido: %s</string>
<string name="daily_streak" formatted="false">Raia atual: %d</string>
<string name="todo_has_duedate">Tarefa com vencimento</string>
<string name="battle_gear">Equipamento de batalha</string>
<string name="costume">Traje</string>
<string name="outfit_head">Cabeça</string>
<string name="outfit_headAccessory">Acessório de cabeça</string>
<string name="outfit_eyewear">Óculos</string>
<string name="outfit_armor">Armadura</string>
<string name="outfit_back">Costas</string>
<string name="outfit_body">Corpo</string>
<string name="outfit_shield">Escudo</string>
<string name="outfit_weapon">Arma</string>
<string name="wear_costume">Vestir traje</string>
<string name="equipped">Equipado</string>
<string name="quest.pending">Pendente</string>
<string name="quest.accepted">Aceito</string>
<string name="quest.rejected">Rejeitado</string>
<string name="quest.participants">Participantes</string>
</resources>

View file

@ -232,4 +232,8 @@
<string name="outfit_weapon">武器</string>
<string name="wear_costume">穿上装扮</string>
<string name="equipped">装备</string>
<string name="quest.pending">等待中</string>
<string name="quest.accepted">接受了</string>
<string name="quest.rejected">拒绝的</string>
<string name="quest.participants">参与者</string>
</resources>

View file

@ -19,6 +19,7 @@ import com.habitrpg.android.habitica.ui.fragments.social.GuildsOverviewFragment;
import com.habitrpg.android.habitica.ui.fragments.social.TavernFragment;
import com.habitrpg.android.habitica.ui.fragments.social.party.PartyFragment;
import com.habitrpg.android.habitica.ui.fragments.tasks.TasksFragment;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.materialdrawer.AccountHeader;
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
import com.mikepenz.materialdrawer.Drawer;
@ -42,9 +43,10 @@ public class MainDrawerBuilder {
public static final int SIDEBAR_EQUIPMENT = 7;
public static final int SIDEBAR_STABLE = 8;
public static final int SIDEBAR_PURCHASE = 9;
public static final int SIDEBAR_SETTINGS = 10;
public static final int SIDEBAR_HELP = 11;
public static final int SIDEBAR_ABOUT = 12;
public static final int SIDEBAR_NEWS = 10;
public static final int SIDEBAR_SETTINGS = 11;
public static final int SIDEBAR_HELP = 12;
public static final int SIDEBAR_ABOUT = 13;
@ -79,20 +81,19 @@ public class MainDrawerBuilder {
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_tasks)).withIdentifier(SIDEBAR_TASKS),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_skills)).withIdentifier(SIDEBAR_SKILLS),
new SectionDrawerItem().withName(activity.getString(R.string.sidebar_section_social)),
new SectionIconDrawerItem().withName(activity.getString(R.string.sidebar_section_social)).withIcon(GoogleMaterial.Icon.gmd_group),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_tavern)).withIdentifier(SIDEBAR_TAVERN),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_party)).withIdentifier(SIDEBAR_PARTY),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_guilds)).withIdentifier(SIDEBAR_GUILDS),
//new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_challenges)),
new SectionDrawerItem().withName(activity.getString(R.string.sidebar_section_inventory)),
new SectionIconDrawerItem().withName(activity.getString(R.string.sidebar_section_inventory)).withIcon(GoogleMaterial.Icon.gmd_work),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_avatar)).withIdentifier(SIDEBAR_AVATAR),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_equipment)).withIdentifier(SIDEBAR_EQUIPMENT),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_stable)).withIdentifier(SIDEBAR_STABLE).withEnabled(false).withBadge(R.string.coming_soon),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_purchaseGems)).withIdentifier(SIDEBAR_PURCHASE),
new DividerDrawerItem(),
//new SecondaryDrawerItem().withName(activity.getString(R.string.sidebar_news)),
new SectionIconDrawerItem().withName(activity.getString(R.string.sidebar_section_inventory)).withIcon(GoogleMaterial.Icon.gmd_info_outline),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_news)).withIdentifier(SIDEBAR_NEWS).withSelectable(false),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_settings)).withIdentifier(SIDEBAR_SETTINGS).withSelectable(false),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_help)).withIdentifier(SIDEBAR_HELP),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_about)).withIdentifier(SIDEBAR_ABOUT).withSelectable(false)

View file

@ -0,0 +1,237 @@
package com.habitrpg.android.habitica.ui;
import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.habitrpg.android.habitica.R;
import com.mikepenz.fastadapter.utils.ViewHolderFactory;
import com.mikepenz.iconics.typeface.IIcon;
import com.mikepenz.materialdrawer.holder.ColorHolder;
import com.mikepenz.materialdrawer.holder.ImageHolder;
import com.mikepenz.materialdrawer.holder.StringHolder;
import com.mikepenz.materialdrawer.model.AbstractDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.Nameable;
import com.mikepenz.materialdrawer.model.interfaces.Typefaceable;
import com.mikepenz.materialize.util.UIUtils;
/**
* Created by mikepenz on 03.02.15.
*/
public class SectionIconDrawerItem extends AbstractDrawerItem<SectionIconDrawerItem, SectionIconDrawerItem.ViewHolder> implements Nameable<SectionIconDrawerItem>, Typefaceable<SectionIconDrawerItem> {
protected ImageHolder icon;
protected boolean iconTinted = false;
private StringHolder name;
private boolean divider = true;
private ColorHolder textColor;
protected ColorHolder iconColor;
private Typeface typeface = null;
public SectionIconDrawerItem withName(StringHolder name) {
this.name = name;
return this;
}
public SectionIconDrawerItem withName(String name) {
this.name = new StringHolder(name);
return this;
}
public SectionIconDrawerItem withName(@StringRes int nameRes) {
this.name = new StringHolder(nameRes);
return this;
}
public SectionIconDrawerItem withDivider(boolean divider) {
this.divider = divider;
return this;
}
public SectionIconDrawerItem withTextColor(int textColor) {
this.textColor = ColorHolder.fromColor(textColor);
return this;
}
public SectionIconDrawerItem withTextColorRes(int textColorRes) {
this.textColor = ColorHolder.fromColorRes(textColorRes);
return this;
}
public SectionIconDrawerItem withIcon(ImageHolder icon) {
this.icon = icon;
return this;
}
public SectionIconDrawerItem withIcon(Drawable icon) {
this.icon = new ImageHolder(icon);
return this;
}
public SectionIconDrawerItem withIcon(@DrawableRes int iconRes) {
this.icon = new ImageHolder(iconRes);
return this;
}
public SectionIconDrawerItem withIcon(IIcon iicon) {
this.icon = new ImageHolder(iicon);
return this;
}
public SectionIconDrawerItem withTypeface(Typeface typeface) {
this.typeface = typeface;
return this;
}
public boolean hasDivider() {
return divider;
}
public ColorHolder getTextColor() {
return textColor;
}
public StringHolder getName() {
return name;
}
@Override
public boolean isEnabled() {
return false;
}
@Override
public boolean isSelected() {
return false;
}
@Override
public int getType() {
return R.id.material_drawer_item_section;
}
@Override
@LayoutRes
public int getLayoutRes() {
return R.layout.material_drawer_item_section_icon;
}
@Override
public Typeface getTypeface() {
return typeface;
}
public SectionIconDrawerItem withIconColor(@ColorInt int iconColor) {
this.iconColor = ColorHolder.fromColor(iconColor);
return this;
}
public SectionIconDrawerItem withIconColorRes(@ColorRes int iconColorRes) {
this.iconColor = ColorHolder.fromColorRes(iconColorRes);
return this;
}
public SectionIconDrawerItem withIconTintingEnabled(boolean iconTintingEnabled) {
this.iconTinted = iconTintingEnabled;
return this;
}
@Deprecated
public SectionIconDrawerItem withIconTinted(boolean iconTinted) {
this.iconTinted = iconTinted;
return this;
}
public boolean isIconTinted() {
return iconTinted;
}
public ImageHolder getIcon() {
return icon;
}
public ColorHolder getIconColor() {
return iconColor;
}
public int getIconColor(Context ctx) {
return ColorHolder.color(getIconColor(), ctx, R.attr.material_drawer_primary_icon, R.color.material_drawer_primary_icon);
}
@Override
public void bindView(ViewHolder viewHolder) {
Context ctx = viewHolder.itemView.getContext();
//set the identifier from the drawerItem here. It can be used to run tests
viewHolder.itemView.setId(hashCode());
//define this item to be not clickable nor enabled
viewHolder.view.setClickable(false);
viewHolder.view.setEnabled(false);
//define the text color
viewHolder.name.setTextColor(ColorHolder.color(getTextColor(), ctx, R.attr.material_drawer_secondary_text, R.color.material_drawer_secondary_text));
//set the text for the name
StringHolder.applyTo(this.getName(), viewHolder.name);
//define the typeface for our textViews
if (getTypeface() != null) {
viewHolder.name.setTypeface(getTypeface());
}
//hide the divider if we do not need one
if (this.hasDivider()) {
viewHolder.divider.setVisibility(View.VISIBLE);
} else {
viewHolder.divider.setVisibility(View.GONE);
}
//set the color for the divider
viewHolder.divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_divider, R.color.material_drawer_divider));
viewHolder.icon.setImageDrawable(getIcon().decideIcon(ctx, ctx.getResources().getColor(R.color.material_drawer_secondary_text), true, 0));
//call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
onPostBindView(this, viewHolder.itemView);
}
@Override
public ViewHolderFactory<ViewHolder> getFactory() {
return new ItemFactory();
}
public static class ItemFactory implements ViewHolderFactory<ViewHolder> {
public ViewHolder create(View v) {
return new ViewHolder(v);
}
}
protected static class ViewHolder extends RecyclerView.ViewHolder {
private View view;
private View divider;
private TextView name;
protected ImageView icon;
private ViewHolder(View view) {
super(view);
this.view = view;
this.divider = view.findViewById(R.id.material_drawer_divider);
this.name = (TextView) view.findViewById(R.id.material_drawer_name);
this.icon = (ImageView) view.findViewById(R.id.material_drawer_icon);
}
}
}

View file

@ -481,13 +481,12 @@ public class TasksFragment extends BaseMainFragment implements OnCheckedChangeLi
//endregion Events
public void fillTagFilterDrawer(List<Tag> tagList) {
if (this.activity.filterDrawer != null) {
if (this.activity.filterDrawer != null && this.tagsHelper != null) {
this.activity.filterDrawer.removeAllItems();
this.activity.filterDrawer.addItems(
new SectionDrawerItem().withName("Filter by Tag"),
new EditTextDrawer()
);
for (Tag t : tagList) {
this.activity.filterDrawer.addItem(new SwitchDrawerItem()
.withName(t.getName())