Skip to content

Commit

Permalink
wip: Copy note actions to overflow menu on each note action
Browse files Browse the repository at this point in the history
Signed-off-by: Álvaro Brey <[email protected]>
  • Loading branch information
AlvaroBrey authored and AndyScherzinger committed Apr 11, 2023
1 parent 6775a2c commit 2483dc1
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ public void onNoteClick(int position, View v) {
}
finish();
}

@Override
public void onNoteActionsClick(int position, View v) {
// TODO
Toast.makeText(v.getContext(), "Not implemented yet", Toast.LENGTH_SHORT).show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
Expand Down Expand Up @@ -773,6 +774,12 @@ public void onNoteFavoriteClick(int position, View view) {
toggleLiveData.observe(this, (next) -> toggleLiveData.removeObservers(this));
}

@Override
public void onNoteActionsClick(int position, View v) {
// TODO
Toast.makeText(v.getContext(), "Not implemented yet", Toast.LENGTH_SHORT).show();
}

@Override
public void onBackPressed() {
if (activityBinding.searchToolbar.getVisibility() == VISIBLE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;

import static com.nextcloud.android.common.ui.util.PlatformThemeUtil.isDarkMode;

import android.content.Context;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
Expand All @@ -19,17 +15,12 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.recyclerview.selection.ItemDetailsLookup;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.button.MaterialButton;
import com.google.android.material.chip.Chip;
import com.nextcloud.android.common.ui.theme.utils.ColorRole;
import com.nextcloud.android.common.ui.util.PlatformThemeUtil;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.branding.BrandingUtil;
Expand Down Expand Up @@ -99,6 +90,13 @@ protected void bindSearchableContent(@NonNull Context context, @NonNull TextView
}
}

protected void bindActions(@NonNull MaterialButton actionsButton, int color) {
final BrandingUtil util = BrandingUtil.of(color, actionsButton.getContext());
util.material.colorMaterialButtonText(actionsButton);
util.material.colorMaterialTextButton(actionsButton);
actionsButton.setOnClickListener(view -> noteClickListener.onNoteActionsClick(getLayoutPosition(), view));
}

public abstract void showSwipe(boolean left);

@Nullable
Expand All @@ -117,4 +115,4 @@ public Long getSelectionKey() {
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt().replace(EXCERPT_LINE_SEPARATOR, "\n"), color);
binding.noteExcerpt.setVisibility(TextUtils.isEmpty(note.getExcerpt()) ? GONE : VISIBLE);
bindActions(binding.noteActions, color);
}

@Nullable
public View getNoteSwipeable() {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, i
bindStatus(binding.noteStatus, note.getStatus(), color);
bindFavorite(binding.noteFavorite, note.getFavorite());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindActions(binding.noteActions, color);
}

@Nullable
public View getNoteSwipeable() {
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package it.niedermann.owncloud.notes.main.items.list;

import android.content.Context;
import android.view.View;

import androidx.annotation.ColorInt;
Expand Down Expand Up @@ -39,10 +38,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @

bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt(), color);
bindActions(binding.noteActions, color);
}

@NonNull
public View getNoteSwipeable() {
return binding.noteSwipeable;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, i
bindStatus(binding.noteStatus, note.getStatus(), color);
bindFavorite(binding.noteFavorite, note.getFavorite());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindActions(binding.noteActions, color);
}

@NonNull
public View getNoteSwipeable() {
return binding.noteSwipeable;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ public interface NoteClickListener {
void onNoteClick(int position, View v);

void onNoteFavoriteClick(int position, View v);
}

void onNoteActionsClick(int position, View v);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.widget.Toolbar;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.exception.ExceptionHandler;
Expand Down Expand Up @@ -73,4 +70,10 @@ public void onNoteClick(int position, View v) {
}
});
}

@Override
public void onNoteActionsClick(int position, View v) {
// TODO
Toast.makeText(v.getContext(), "Not implemented yet", Toast.LENGTH_SHORT).show();
}
}
1 change: 1 addition & 0 deletions app/src/main/res/drawable/ic_dots_vertical.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/dots_vertical.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z" /></vector>
13 changes: 12 additions & 1 deletion app/src/main/res/layout/item_notes_list_note_item_grid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,16 @@
tools:text="@tools:sample/lorem/random" />
</FrameLayout>
</LinearLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/noteActions"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:contentDescription="@string/note_actions"
app:icon="@drawable/ic_dots_vertical"
app:iconTint="?android:textColorPrimary"
app:rippleColor="@color/fg_secondary" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,16 @@
android:textColor="@color/fg_default"
tools:maxLength="50"
tools:text="@tools:sample/lorem/random" />

<com.google.android.material.button.MaterialButton
android:id="@+id/noteActions"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:contentDescription="@string/note_actions"
app:icon="@drawable/ic_dots_vertical"
app:iconTint="?android:textColorPrimary"
app:rippleColor="@color/fg_secondary" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
12 changes: 12 additions & 0 deletions app/src/main/res/layout/item_notes_list_note_item_with_excerpt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@
tools:text="@tools:sample/lorem/random" />
</LinearLayout>
</LinearLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/noteActions"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:contentDescription="@string/note_actions"
app:icon="@drawable/ic_dots_vertical"
app:iconTint="?android:textColorPrimary"
app:rippleColor="@color/fg_secondary" />

</LinearLayout>

</FrameLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@
android:textSize="@dimen/secondary_font_size"
tools:maxLength="15"
tools:text="@tools:sample/lorem/random" />

<com.google.android.material.button.MaterialButton
android:id="@+id/noteActions"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:contentDescription="@string/note_actions"
app:icon="@drawable/ic_dots_vertical"
app:iconTint="?android:textColorPrimary"
app:rippleColor="@color/fg_secondary" />

</LinearLayout>

</FrameLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,5 @@
<string name="switch_to_plain_editing">Switch to plain editing</string>
<string name="action_back">Back</string>
<string name="user_agent" translatable="false">Mozilla/5.0 (Android) %1$s-android/%2$s</string>
<string name="note_actions">Note actions</string>
</resources>

0 comments on commit 2483dc1

Please sign in to comment.