diff options
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/android/MultiSelectedActionModeCallback.java')
-rw-r--r-- | app/src/main/java/it/niedermann/owncloud/notes/android/MultiSelectedActionModeCallback.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/MultiSelectedActionModeCallback.java b/app/src/main/java/it/niedermann/owncloud/notes/android/MultiSelectedActionModeCallback.java index 499aa212..b90be5d7 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/MultiSelectedActionModeCallback.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/MultiSelectedActionModeCallback.java @@ -1,14 +1,18 @@ package it.niedermann.owncloud.notes.android; import android.content.Context; +import android.graphics.drawable.Drawable; import android.text.TextUtils; +import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import androidx.annotation.ColorInt; import androidx.appcompat.view.ActionMode; import androidx.appcompat.view.ActionMode.Callback; import androidx.appcompat.widget.SearchView; +import androidx.core.graphics.drawable.DrawableCompat; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.RecyclerView; @@ -23,7 +27,8 @@ import java.util.List; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.android.activity.NotesListViewActivity; -import it.niedermann.owncloud.notes.android.fragment.AccountChooserDialogFragment; +import it.niedermann.owncloud.notes.android.fragment.MoveAccountDialogFragment; +import it.niedermann.owncloud.notes.branding.BrandedSnackbar; import it.niedermann.owncloud.notes.model.DBNote; import it.niedermann.owncloud.notes.model.ItemAdapter; import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper.ViewProvider; @@ -32,6 +37,9 @@ import it.niedermann.owncloud.notes.util.ShareUtil; public class MultiSelectedActionModeCallback implements Callback { + @ColorInt + private int colorAccent; + private final Context context; private final ViewProvider viewProvider; private final NotesDatabase db; @@ -51,12 +59,24 @@ public class MultiSelectedActionModeCallback implements Callback { this.refreshLists = refreshLists; this.fragmentManager = fragmentManager; this.searchView = searchView; + + final TypedValue typedValue = new TypedValue(); + context.getTheme().resolveAttribute(R.attr.colorAccent, typedValue, true); + colorAccent = typedValue.data; } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // inflate contextual menu mode.getMenuInflater().inflate(R.menu.menu_list_context_multiple, menu); + for (int i = 0; i < menu.size(); i++) { + Drawable drawable = menu.getItem(i).getIcon(); + if (drawable != null) { + drawable = DrawableCompat.wrap(drawable); + DrawableCompat.setTint(drawable, colorAccent); + menu.getItem(i).setIcon(drawable); + } + } return true; } @@ -90,7 +110,7 @@ public class MultiSelectedActionModeCallback implements Callback { String deletedSnackbarTitle = deletedNotes.size() == 1 ? context.getString(R.string.action_note_deleted, deletedNotes.get(0).getTitle()) : context.getString(R.string.bulk_notes_deleted, deletedNotes.size()); - Snackbar.make(viewProvider.getView(), deletedSnackbarTitle, Snackbar.LENGTH_LONG) + BrandedSnackbar.make(viewProvider.getView(), deletedSnackbarTitle, Snackbar.LENGTH_LONG) .setAction(R.string.action_undo, (View v) -> { db.getNoteServerSyncHelper().addCallbackPush(ssoAccount, refreshLists::run); for (DBNote deletedNote : deletedNotes) { @@ -100,7 +120,7 @@ public class MultiSelectedActionModeCallback implements Callback { String restoreSnackbarTitle = deletedNotes.size() == 1 ? context.getString(R.string.action_note_restored, deletedNotes.get(0).getTitle()) : context.getString(R.string.bulk_notes_restored, deletedNotes.size()); - Snackbar.make(viewProvider.getView(), restoreSnackbarTitle, Snackbar.LENGTH_SHORT) + BrandedSnackbar.make(viewProvider.getView(), restoreSnackbarTitle, Snackbar.LENGTH_SHORT) .show(); }) .show(); @@ -109,7 +129,7 @@ public class MultiSelectedActionModeCallback implements Callback { } return true; case R.id.menu_move: - AccountChooserDialogFragment.newInstance().show(fragmentManager, NotesListViewActivity.class.getSimpleName()); + MoveAccountDialogFragment.newInstance().show(fragmentManager, NotesListViewActivity.class.getSimpleName()); return true; case R.id.menu_share: final String subject = (adapter.getSelected().size() == 1) |