diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-04-20 19:10:58 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-04-20 19:10:58 +0300 |
commit | f8b0ea0c0a5e54328414ab2b0df181c19febf82e (patch) | |
tree | b2a29046c54bb83ad130457b0b0a38eea4d28fb7 | |
parent | 63535f3f4091835d5d641b40445d1103c34e252f (diff) |
#395 📦 Archived cards
7 files changed, 117 insertions, 5 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 432c2da98..081288a8f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -57,6 +57,11 @@ </activity> <activity + android:name=".ui.archivedcards.ArchivedCardsActvitiy" + android:label="@string/archived_cards" + android:theme="@style/AppTheme" /> + + <activity android:name=".ui.card.EditActivity" android:label="@string/edit" android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" @@ -94,7 +99,7 @@ android:label="@string/app_name" android:theme="@style/AppTheme"> <intent-filter> - <action android:name="android.intent.action.MAIN"/> + <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedcards/ArchivedCardsActvitiy.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedcards/ArchivedCardsActvitiy.java new file mode 100644 index 000000000..e1b46517a --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedcards/ArchivedCardsActvitiy.java @@ -0,0 +1,11 @@ +package it.niedermann.nextcloud.deck.ui.archivedcards; + +import it.niedermann.nextcloud.deck.ui.branding.BrandedActivity; + +public class ArchivedCardsActvitiy extends BrandedActivity { + + @Override + public void applyBrand(int mainColor, int textColor) { + + } +} diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedcards/ArchivedCardsAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedcards/ArchivedCardsAdapter.java new file mode 100644 index 000000000..52f6c827c --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedcards/ArchivedCardsAdapter.java @@ -0,0 +1,53 @@ +package it.niedermann.nextcloud.deck.ui.archivedcards; + +import android.content.Context; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.PopupMenu; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +import org.jetbrains.annotations.NotNull; + +import it.niedermann.nextcloud.deck.R; +import it.niedermann.nextcloud.deck.model.Account; +import it.niedermann.nextcloud.deck.model.full.FullCard; +import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; +import it.niedermann.nextcloud.deck.ui.card.CardAdapter; +import it.niedermann.nextcloud.deck.ui.card.SelectCardListener; + +public class ArchivedCardsAdapter extends CardAdapter { + public ArchivedCardsAdapter(@NonNull Context context, @NonNull Account account, long boardId, long stackId, boolean canEdit, @NonNull SyncManager syncManager, @NonNull Fragment fragment, @Nullable SelectCardListener selectCardListener) { + super(context, account, boardId, stackId, canEdit, syncManager, fragment, selectCardListener); + } + + protected void onOverflowIconClicked(@NotNull View view, FullCard card) { + final Context context = view.getContext(); + final PopupMenu popup = new PopupMenu(context, view); + popup.inflate(R.menu.card_menu); + prepareOptionsMenu(popup.getMenu(), card); + + popup.setOnMenuItemClickListener(item -> optionsItemSelected(context, item, card)); + popup.show(); + } + + protected void prepareOptionsMenu(Menu menu, @NotNull FullCard card) { + // Nothing to do + } + + protected boolean optionsItemSelected(@NonNull Context context, @NotNull MenuItem item, FullCard card) { + //noinspection SwitchStatementWithTooFewBranches + switch (item.getItemId()) { + case R.id.action_card_dearchive: { + new Thread(() -> syncManager.dearchiveCard(card)).start(); + return true; + } + default: { + return false; + } + } + } +} diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardAdapter.java index edc6ec0f9..417edffef 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardAdapter.java @@ -57,7 +57,8 @@ public class CardAdapter extends RecyclerView.Adapter<ItemCardViewHolder> implem public static final String BUNDLE_KEY_CAN_EDIT = "canEdit"; public static final Long NO_LOCAL_ID = -1L; - private final SyncManager syncManager; + protected final SyncManager syncManager; + private final Account account; private final long boardId; private final long stackId; @@ -242,7 +243,7 @@ public class CardAdapter extends RecyclerView.Adapter<ItemCardViewHolder> implem notifyItemRemoved(position); } - private void onOverflowIconClicked(@NotNull View view, FullCard card) { + protected void onOverflowIconClicked(@NotNull View view, FullCard card) { final Context context = view.getContext(); final PopupMenu popup = new PopupMenu(context, view); popup.inflate(R.menu.card_menu); @@ -252,7 +253,7 @@ public class CardAdapter extends RecyclerView.Adapter<ItemCardViewHolder> implem popup.show(); } - private void prepareOptionsMenu(Menu menu, @NotNull FullCard card) { + protected void prepareOptionsMenu(Menu menu, @NotNull FullCard card) { if (containsUser(card.getAssignedUsers(), account.getUserName())) { menu.removeItem(menu.findItem(R.id.action_card_assign).getItemId()); } else { @@ -278,7 +279,7 @@ public class CardAdapter extends RecyclerView.Adapter<ItemCardViewHolder> implem return false; } - private boolean optionsItemSelected(Context context, @NotNull MenuItem item, FullCard card) { + protected boolean optionsItemSelected(@NonNull Context context, @NotNull MenuItem item, FullCard card) { switch (item.getItemId()) { case R.id.action_card_assign: { new Thread(() -> syncManager.assignUserToCard(syncManager.getUserByUidDirectly(card.getCard().getAccountId(), account.getUserName()), card.getCard())).start(); diff --git a/app/src/main/res/layout/activity_archived_cards.xml b/app/src/main/res/layout/activity_archived_cards.xml new file mode 100644 index 000000000..7f3795c47 --- /dev/null +++ b/app/src/main/res/layout/activity_archived_cards.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <it.niedermann.nextcloud.deck.ui.view.EmptyContentView + android:id="@+id/empty_content_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="gone" + app:title="@string/no_cards" /> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/recycler_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:clipToPadding="false" + android:paddingTop="@dimen/spacer_1x" + android:paddingBottom="@dimen/spacer_1x" + android:scrollbarStyle="outsideOverlay" + android:scrollbars="vertical" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" + tools:listitem="@layout/item_card" /> +</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/menu/archived_card_menu.xml b/app/src/main/res/menu/archived_card_menu.xml new file mode 100644 index 000000000..12448e691 --- /dev/null +++ b/app/src/main/res/menu/archived_card_menu.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + <item + android:id="@+id/action_card_dearchive" + android:title="@string/action_card_dearchive" + app:showAsAction="never" /> + + <item + android:id="@+id/action_card_delete" + android:title="@string/action_card_delete" + app:showAsAction="never" /> +</menu> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1e060cfb1..11b6e7379 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -185,4 +185,6 @@ <string name="error_revoking_ac">Error while revoking the access for %1$s</string> <string name="maintenance_mode">Server in maintenance mode</string> <string name="simple_switch">Switch</string> + <string name="archived_cards">Archived cards</string> + <string name="action_card_dearchive">Dearchive card</string> </resources> |