Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17656f87 authored by korelstar's avatar korelstar
Browse files

fix wiggle, colors, refactoring

parent 420c4e65
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
package it.niedermann.owncloud.notes.android.activity;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.SearchManager;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -404,7 +402,6 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
                    case ItemTouchHelper.RIGHT: {
                        final DBNote dbNote = (DBNote) adapter.getItem(viewHolder.getAdapterPosition());
                        db.toggleFavorite(dbNote, null);
                        adapter.notifyItemChanged(viewHolder.getAdapterPosition());
                        refreshLists();
                        break;
                    }
@@ -414,8 +411,8 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
            @Override
            public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
                ItemAdapter.NoteViewHolder noteViewHolder = (ItemAdapter.NoteViewHolder) viewHolder;
                // show delete icon on the right side
                noteViewHolder.showSwipeDelete(dX>0);
                // show swipe icon on the side
                noteViewHolder.showSwipe(dX>0);
                // move only swipeable part of item (not leave-behind)
                getDefaultUIUtil().onDraw(c, recyclerView, noteViewHolder.noteSwipeable, dX, dY, actionState, isCurrentlyActive);
            }
+4 −1
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    public class NoteViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener, View.OnClickListener {
        public View noteSwipeable;
        View noteSwipeFrame;
        ImageView noteFavoriteLeft, noteDeleteRight;
        TextView noteTitle;
        TextView noteCategory;
@@ -173,6 +174,7 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

        private NoteViewHolder(View v) {
            super(v);
            this.noteSwipeFrame = v.findViewById(R.id.noteSwipeFrame);
            this.noteSwipeable = v.findViewById(R.id.noteSwipeable);
            this.noteFavoriteLeft = v.findViewById(R.id.noteFavoriteLeft);
            this.noteDeleteRight = v.findViewById(R.id.noteDeleteRight);
@@ -195,9 +197,10 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
            return noteClickListener.onNoteLongClick(getAdapterPosition(), v);
        }

        public void showSwipeDelete(boolean left) {
        public void showSwipe(boolean left) {
            noteFavoriteLeft.setVisibility(left ? View.VISIBLE : View.INVISIBLE);
            noteDeleteRight.setVisibility(left ? View.INVISIBLE : View.VISIBLE);
            noteSwipeFrame.setBackgroundResource(left ? R.color.bg_warning : R.color.bg_attention);
        }
    }

+1 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/noteSwipeFrame"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/bg_attention">
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
    <color name="bg_highlighted">#f3f3f3</color>
    <color name="bg_normal">#ffffff</color>
    <color name="bg_attention">#662020</color>
    <color name="bg_warning">#999920</color>
    <color name="fg_default">#000000</color>
    <color name="fg_default_selection">#333333</color>
    <color name="fg_default_low">#666666</color>