Loading app/src/main/java/it/niedermann/owncloud/notes/model/ItemAdapter.java +11 −1 Original line number Diff line number Diff line package it.niedermann.owncloud.notes.model; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Color; import android.text.TextUtils; import android.util.Log; Loading @@ -10,6 +11,8 @@ import android.view.ViewGroup; import androidx.annotation.ColorInt; import androidx.annotation.IntRange; import androidx.annotation.NonNull; import androidx.annotation.Px; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; Loading @@ -22,6 +25,7 @@ import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemWithExcerpt import it.niedermann.owncloud.notes.databinding.ItemNotesListSectionItemBinding; import static it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemWithoutExcerptBinding.inflate; import static it.niedermann.owncloud.notes.util.NoteUtil.getFontSizeFromPreferences; public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Branded { Loading @@ -37,6 +41,9 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i private boolean showCategory = true; private CharSequence searchQuery; private final List<Integer> selected = new ArrayList<>(); @Px private final float fontSize; private final boolean monospace; @ColorInt private int mainColor; @ColorInt Loading @@ -47,6 +54,9 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i this.gridView = gridView; this.mainColor = context.getResources().getColor(R.color.defaultBrand); this.textColor = Color.WHITE; final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); this.fontSize = getFontSizeFromPreferences(context, sp); this.monospace = sp.getBoolean(context.getString(R.string.pref_key_font), false); // FIXME see getItemId() // setHasStableIds(true); } Loading Loading @@ -101,7 +111,7 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i } case TYPE_NOTE_WITH_EXCERPT: case TYPE_NOTE_WITHOUT_EXCERPT: { return new NoteViewGridHolder(ItemNotesListNoteItemGridBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false), noteClickListener); return new NoteViewGridHolder(ItemNotesListNoteItemGridBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false), noteClickListener, monospace, fontSize); } default: { throw new IllegalArgumentException("Not supported viewType: " + viewType); Loading app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java +11 −1 Original line number Diff line number Diff line package it.niedermann.owncloud.notes.model; import android.content.Context; import android.graphics.Typeface; import android.text.TextUtils; import android.util.TypedValue; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.Px; import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemGridBinding; Loading @@ -17,9 +20,16 @@ public class NoteViewGridHolder extends NoteViewHolder { @NonNull private final ItemNotesListNoteItemGridBinding binding; public NoteViewGridHolder(@NonNull ItemNotesListNoteItemGridBinding binding, @NonNull NoteClickListener noteClickListener) { public NoteViewGridHolder(@NonNull ItemNotesListNoteItemGridBinding binding, @NonNull NoteClickListener noteClickListener, boolean monospace, @Px float fontSize) { super(binding.getRoot(), noteClickListener); this.binding = binding; binding.noteTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 1.1f); binding.noteExcerpt.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * .8f); if (monospace) { binding.noteTitle.setTypeface(Typeface.MONOSPACE); binding.noteExcerpt.setTypeface(Typeface.MONOSPACE); } } public void showSwipe(boolean left) { Loading app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java +14 −6 Original line number Diff line number Diff line package it.niedermann.owncloud.notes.model; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.drawable.GradientDrawable; import android.os.Build; Loading @@ -19,6 +20,8 @@ import androidx.annotation.Nullable; import androidx.core.graphics.drawable.DrawableCompat; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.chip.Chip; import java.util.regex.Matcher; import java.util.regex.Pattern; Loading Loading @@ -74,6 +77,11 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder { } } noteCategory.setTextColor(categoryForeground); if (noteCategory instanceof Chip) { ((Chip) noteCategory).setChipStrokeColor(ColorStateList.valueOf(categoryBackground)); ((Chip) noteCategory).setChipBackgroundColor(ColorStateList.valueOf(isDarkThemeActive ? categoryBackground : Color.TRANSPARENT)); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { DrawableCompat.setTint(noteCategory.getBackground(), categoryBackground); } else { Loading @@ -81,7 +89,7 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder { drawable.setStroke(1, categoryBackground); drawable.setColor(isDarkThemeActive ? categoryBackground : Color.TRANSPARENT); } noteCategory.setTextColor(categoryForeground); } } protected void bindFavorite(@NonNull ImageView noteFavorite, boolean isFavorite) { Loading app/src/main/res/layout/item_notes_list_note_item_grid.xml +43 −48 Original line number Diff line number Diff line Loading @@ -15,59 +15,69 @@ android:orientation="vertical" android:paddingBottom="@dimen/spacer_1x"> <TextView android:id="@+id/noteTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/spacer_2x" android:layout_marginLeft="@dimen/spacer_2x" android:layout_marginTop="@dimen/spacer_2x" android:layout_marginEnd="@dimen/spacer_2x" android:layout_marginRight="@dimen/spacer_2x" android:layout_marginBottom="@dimen/spacer_1x" android:textAppearance="?attr/textAppearanceHeadline5" android:textColor="@color/fg_default" tools:maxLength="50" tools:text="@tools:sample/lorem/random" /> <TextView android:id="@+id/noteExcerpt" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/spacer_2x" android:layout_marginLeft="@dimen/spacer_2x" android:layout_marginEnd="@dimen/spacer_2x" android:layout_marginRight="@dimen/spacer_2x" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/fg_default" tools:maxLength="200" tools:text="@tools:sample/lorem/random" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:baselineAligned="false" android:gravity="center_vertical" android:orientation="horizontal"> <LinearLayout <FrameLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> android:layout_weight="1"> <TextView <com.google.android.material.chip.Chip android:id="@+id/noteCategory" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="@dimen/spacer_1x" android:layout_marginLeft="@dimen/spacer_1x" android:layout_marginTop="@dimen/spacer_1x" android:background="@drawable/border" android:maxLines="1" android:paddingLeft="@dimen/spacer_1x" android:paddingTop="1dp" android:paddingRight="@dimen/spacer_1x" android:paddingBottom="1dp" android:singleLine="true" android:textColor="?android:textColorPrimary" android:textSize="@dimen/secondary_font_size" tools:maxLength="15" tools:text="@tools:sample/lorem/random" /> <TextView android:id="@+id/noteTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/spacer_2x" android:layout_marginLeft="@dimen/spacer_2x" android:layout_marginTop="@dimen/spacer_1x" android:layout_marginEnd="0dp" android:layout_marginRight="0dp" android:layout_marginBottom="@dimen/spacer_1x" android:textAppearance="?attr/textAppearanceHeadline5" android:textColor="@color/fg_default" android:theme="@style/textViewStyle" android:ellipsize="middle" android:textColor="?android:textColorPrimary" android:textSize="@dimen/secondary_font_size" app:chipBackgroundColor="@color/primary" app:chipStrokeColor="@color/defaultBrand" app:chipStrokeWidth="1dp" tools:maxLength="50" tools:text="@tools:sample/lorem/random" /> </LinearLayout> </FrameLayout> <FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top"> android:layout_height="wrap_content"> <ImageView android:id="@+id/noteFavorite" Loading @@ -75,7 +85,7 @@ android:layout_height="wrap_content" android:background="?attr/selectableItemBackgroundBorderless" android:contentDescription="@string/menu_favorite" android:padding="@dimen/spacer_1x" android:padding="@dimen/spacer_2x" tools:src="@drawable/ic_star_yellow_24dp" /> <androidx.appcompat.widget.AppCompatImageView Loading @@ -90,20 +100,5 @@ app:srcCompat="@drawable/ic_sync_blue_18dp" /> </FrameLayout> </LinearLayout> <TextView android:id="@+id/noteExcerpt" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/spacer_2x" android:layout_marginLeft="@dimen/spacer_2x" android:layout_marginEnd="@dimen/spacer_2x" android:layout_marginRight="@dimen/spacer_2x" android:layout_marginBottom="@dimen/spacer_1x" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/fg_default" android:theme="@style/textViewStyle" tools:maxLength="200" tools:text="@tools:sample/lorem/random" /> </LinearLayout> </com.google.android.material.card.MaterialCardView> No newline at end of file Loading
app/src/main/java/it/niedermann/owncloud/notes/model/ItemAdapter.java +11 −1 Original line number Diff line number Diff line package it.niedermann.owncloud.notes.model; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Color; import android.text.TextUtils; import android.util.Log; Loading @@ -10,6 +11,8 @@ import android.view.ViewGroup; import androidx.annotation.ColorInt; import androidx.annotation.IntRange; import androidx.annotation.NonNull; import androidx.annotation.Px; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; Loading @@ -22,6 +25,7 @@ import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemWithExcerpt import it.niedermann.owncloud.notes.databinding.ItemNotesListSectionItemBinding; import static it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemWithoutExcerptBinding.inflate; import static it.niedermann.owncloud.notes.util.NoteUtil.getFontSizeFromPreferences; public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Branded { Loading @@ -37,6 +41,9 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i private boolean showCategory = true; private CharSequence searchQuery; private final List<Integer> selected = new ArrayList<>(); @Px private final float fontSize; private final boolean monospace; @ColorInt private int mainColor; @ColorInt Loading @@ -47,6 +54,9 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i this.gridView = gridView; this.mainColor = context.getResources().getColor(R.color.defaultBrand); this.textColor = Color.WHITE; final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); this.fontSize = getFontSizeFromPreferences(context, sp); this.monospace = sp.getBoolean(context.getString(R.string.pref_key_font), false); // FIXME see getItemId() // setHasStableIds(true); } Loading Loading @@ -101,7 +111,7 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i } case TYPE_NOTE_WITH_EXCERPT: case TYPE_NOTE_WITHOUT_EXCERPT: { return new NoteViewGridHolder(ItemNotesListNoteItemGridBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false), noteClickListener); return new NoteViewGridHolder(ItemNotesListNoteItemGridBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false), noteClickListener, monospace, fontSize); } default: { throw new IllegalArgumentException("Not supported viewType: " + viewType); Loading
app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java +11 −1 Original line number Diff line number Diff line package it.niedermann.owncloud.notes.model; import android.content.Context; import android.graphics.Typeface; import android.text.TextUtils; import android.util.TypedValue; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.Px; import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemGridBinding; Loading @@ -17,9 +20,16 @@ public class NoteViewGridHolder extends NoteViewHolder { @NonNull private final ItemNotesListNoteItemGridBinding binding; public NoteViewGridHolder(@NonNull ItemNotesListNoteItemGridBinding binding, @NonNull NoteClickListener noteClickListener) { public NoteViewGridHolder(@NonNull ItemNotesListNoteItemGridBinding binding, @NonNull NoteClickListener noteClickListener, boolean monospace, @Px float fontSize) { super(binding.getRoot(), noteClickListener); this.binding = binding; binding.noteTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 1.1f); binding.noteExcerpt.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * .8f); if (monospace) { binding.noteTitle.setTypeface(Typeface.MONOSPACE); binding.noteExcerpt.setTypeface(Typeface.MONOSPACE); } } public void showSwipe(boolean left) { Loading
app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java +14 −6 Original line number Diff line number Diff line package it.niedermann.owncloud.notes.model; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.drawable.GradientDrawable; import android.os.Build; Loading @@ -19,6 +20,8 @@ import androidx.annotation.Nullable; import androidx.core.graphics.drawable.DrawableCompat; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.chip.Chip; import java.util.regex.Matcher; import java.util.regex.Pattern; Loading Loading @@ -74,6 +77,11 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder { } } noteCategory.setTextColor(categoryForeground); if (noteCategory instanceof Chip) { ((Chip) noteCategory).setChipStrokeColor(ColorStateList.valueOf(categoryBackground)); ((Chip) noteCategory).setChipBackgroundColor(ColorStateList.valueOf(isDarkThemeActive ? categoryBackground : Color.TRANSPARENT)); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { DrawableCompat.setTint(noteCategory.getBackground(), categoryBackground); } else { Loading @@ -81,7 +89,7 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder { drawable.setStroke(1, categoryBackground); drawable.setColor(isDarkThemeActive ? categoryBackground : Color.TRANSPARENT); } noteCategory.setTextColor(categoryForeground); } } protected void bindFavorite(@NonNull ImageView noteFavorite, boolean isFavorite) { Loading
app/src/main/res/layout/item_notes_list_note_item_grid.xml +43 −48 Original line number Diff line number Diff line Loading @@ -15,59 +15,69 @@ android:orientation="vertical" android:paddingBottom="@dimen/spacer_1x"> <TextView android:id="@+id/noteTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/spacer_2x" android:layout_marginLeft="@dimen/spacer_2x" android:layout_marginTop="@dimen/spacer_2x" android:layout_marginEnd="@dimen/spacer_2x" android:layout_marginRight="@dimen/spacer_2x" android:layout_marginBottom="@dimen/spacer_1x" android:textAppearance="?attr/textAppearanceHeadline5" android:textColor="@color/fg_default" tools:maxLength="50" tools:text="@tools:sample/lorem/random" /> <TextView android:id="@+id/noteExcerpt" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/spacer_2x" android:layout_marginLeft="@dimen/spacer_2x" android:layout_marginEnd="@dimen/spacer_2x" android:layout_marginRight="@dimen/spacer_2x" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/fg_default" tools:maxLength="200" tools:text="@tools:sample/lorem/random" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:baselineAligned="false" android:gravity="center_vertical" android:orientation="horizontal"> <LinearLayout <FrameLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> android:layout_weight="1"> <TextView <com.google.android.material.chip.Chip android:id="@+id/noteCategory" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="@dimen/spacer_1x" android:layout_marginLeft="@dimen/spacer_1x" android:layout_marginTop="@dimen/spacer_1x" android:background="@drawable/border" android:maxLines="1" android:paddingLeft="@dimen/spacer_1x" android:paddingTop="1dp" android:paddingRight="@dimen/spacer_1x" android:paddingBottom="1dp" android:singleLine="true" android:textColor="?android:textColorPrimary" android:textSize="@dimen/secondary_font_size" tools:maxLength="15" tools:text="@tools:sample/lorem/random" /> <TextView android:id="@+id/noteTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/spacer_2x" android:layout_marginLeft="@dimen/spacer_2x" android:layout_marginTop="@dimen/spacer_1x" android:layout_marginEnd="0dp" android:layout_marginRight="0dp" android:layout_marginBottom="@dimen/spacer_1x" android:textAppearance="?attr/textAppearanceHeadline5" android:textColor="@color/fg_default" android:theme="@style/textViewStyle" android:ellipsize="middle" android:textColor="?android:textColorPrimary" android:textSize="@dimen/secondary_font_size" app:chipBackgroundColor="@color/primary" app:chipStrokeColor="@color/defaultBrand" app:chipStrokeWidth="1dp" tools:maxLength="50" tools:text="@tools:sample/lorem/random" /> </LinearLayout> </FrameLayout> <FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top"> android:layout_height="wrap_content"> <ImageView android:id="@+id/noteFavorite" Loading @@ -75,7 +85,7 @@ android:layout_height="wrap_content" android:background="?attr/selectableItemBackgroundBorderless" android:contentDescription="@string/menu_favorite" android:padding="@dimen/spacer_1x" android:padding="@dimen/spacer_2x" tools:src="@drawable/ic_star_yellow_24dp" /> <androidx.appcompat.widget.AppCompatImageView Loading @@ -90,20 +100,5 @@ app:srcCompat="@drawable/ic_sync_blue_18dp" /> </FrameLayout> </LinearLayout> <TextView android:id="@+id/noteExcerpt" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/spacer_2x" android:layout_marginLeft="@dimen/spacer_2x" android:layout_marginEnd="@dimen/spacer_2x" android:layout_marginRight="@dimen/spacer_2x" android:layout_marginBottom="@dimen/spacer_1x" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/fg_default" android:theme="@style/textViewStyle" tools:maxLength="200" tools:text="@tools:sample/lorem/random" /> </LinearLayout> </com.google.android.material.card.MaterialCardView> No newline at end of file