mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-20 05:49:13 +00:00
Merge pull request #1312 from michaelschattgen/fix/favorites-ui
Fix shape of favorited entries
This commit is contained in:
commit
9737c85f86
3 changed files with 32 additions and 1 deletions
|
@ -47,9 +47,12 @@ import com.bumptech.glide.RequestBuilder;
|
|||
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader;
|
||||
import com.bumptech.glide.util.ViewPreloadSizeProvider;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.android.material.card.MaterialCardView;
|
||||
import com.google.android.material.chip.Chip;
|
||||
import com.google.android.material.chip.ChipGroup;
|
||||
import com.google.android.material.divider.MaterialDividerItemDecoration;
|
||||
import com.google.android.material.shape.CornerFamily;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -639,6 +642,27 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
void onEntryListTouch();
|
||||
}
|
||||
|
||||
private void decorateFavoriteEntries(@NonNull View view, @NonNull RecyclerView parent) {
|
||||
int adapterPosition = parent.getChildAdapterPosition(view);
|
||||
int entryIndex = _adapter.translateEntryPosToIndex(adapterPosition);
|
||||
int totalFavorites = _adapter.getShownFavoritesCount();
|
||||
|
||||
if (entryIndex < totalFavorites) {
|
||||
ShapeAppearanceModel model = ((MaterialCardView)view).getShapeAppearanceModel();
|
||||
ShapeAppearanceModel.Builder builder = model.toBuilder();
|
||||
if ((entryIndex == 0 && totalFavorites > 1) || (entryIndex < (totalFavorites - 1))) {
|
||||
builder.setBottomLeftCorner(CornerFamily.ROUNDED, 0);
|
||||
builder.setBottomRightCorner(CornerFamily.ROUNDED, 0);
|
||||
}
|
||||
if (entryIndex > 0) {
|
||||
builder.setTopLeftCorner(CornerFamily.ROUNDED, 0);
|
||||
builder.setTopRightCorner(CornerFamily.ROUNDED, 0);
|
||||
}
|
||||
|
||||
((MaterialCardView)view).setShapeAppearanceModel(builder.build());
|
||||
}
|
||||
}
|
||||
|
||||
private class CompactDividerDecoration extends MaterialDividerItemDecoration {
|
||||
public CompactDividerDecoration() {
|
||||
super(requireContext(), DividerItemDecoration.VERTICAL);
|
||||
|
@ -661,6 +685,8 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
decorateFavoriteEntries(view, parent);
|
||||
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
}
|
||||
}
|
||||
|
@ -713,6 +739,8 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
if (entryIndex == totalFavorites) {
|
||||
outRect.top = _height;
|
||||
}
|
||||
|
||||
decorateFavoriteEntries(view, parent);
|
||||
}
|
||||
|
||||
// The last entry should never have a bottom margin
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
android:layout_width="15dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="-11dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:backgroundTint="?attr/colorFavorite"
|
||||
android:background="@drawable/favorite_indicator" />
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/colorSurfaceContainerLow"
|
||||
android:id="@+id/rlCardEntry"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
|
@ -27,6 +26,8 @@
|
|||
android:layout_width="15dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="-11dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:backgroundTint="?attr/colorFavorite"
|
||||
android:background="@drawable/favorite_indicator" />
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue