diff options
10 files changed, 124 insertions, 19 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 081288a8f..3de20e21a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -59,6 +59,7 @@ <activity android:name=".ui.archivedcards.ArchivedCardsActvitiy" android:label="@string/archived_cards" + android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" android:theme="@style/AppTheme" /> <activity @@ -69,6 +70,7 @@ <activity android:name=".ui.attachments.AttachmentsActivity" + android:label="@string/attachments" android:parentActivityName="it.niedermann.nextcloud.deck.ui.card.EditActivity" android:theme="@style/TransparentTheme" /> diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java index 8585c8fe5..1254d3515 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java @@ -615,7 +615,9 @@ public class SyncManager { // TODO implement, see https://github.com/stefan-niedermann/nextcloud-deck/issues/395 public LiveData<List<FullCard>> getArchivedFullCardsForBoard(long accountId, long localBoardId) { - return null; + MutableLiveData<List<FullCard>> dummyData = new MutableLiveData<>(); + dummyData.postValue(new ArrayList<>()); + return dummyData; } public LiveData<FullCard> createCard(long accountId, long localBoardId, long localStackId, Card card) { diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index db2620bb0..0ec775c31 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -71,6 +71,7 @@ import it.niedermann.nextcloud.deck.model.ocs.Version; import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.WrappedLiveData; import it.niedermann.nextcloud.deck.ui.about.AboutActivity; +import it.niedermann.nextcloud.deck.ui.archivedcards.ArchivedCardsActvitiy; import it.niedermann.nextcloud.deck.ui.board.DeleteBoardListener; import it.niedermann.nextcloud.deck.ui.board.EditBoardDialogFragment; import it.niedermann.nextcloud.deck.ui.board.EditBoardListener; @@ -102,6 +103,7 @@ import static it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.Liv import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_ACCOUNT; import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_ACCOUNT_ID; import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_BOARD_ID; +import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_CAN_EDIT; import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_LOCAL_ID; import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_STACK_ID; import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.NO_LOCAL_ID; @@ -631,6 +633,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener } else { menu.clear(); } + inflater.inflate(R.menu.main_menu, menu); return super.onCreateOptionsMenu(menu); } @@ -638,6 +641,12 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener public boolean onOptionsItemSelected(MenuItem item) { final long stackId = stackAdapter.getItem(binding.viewPager.getCurrentItem()).getLocalId(); switch (item.getItemId()) { + case R.id.archived_cards: + startActivity(new Intent(this, ArchivedCardsActvitiy.class) + .putExtra(BUNDLE_KEY_ACCOUNT, currentAccount) + .putExtra(BUNDLE_KEY_BOARD_ID, currentBoardId) + .putExtra(BUNDLE_KEY_CAN_EDIT, currentBoardHasEditPermission)); + return true; case R.id.delete_list: DeleteStackDialogFragment.newInstance(stackId).show(getSupportFragmentManager(), DeleteStackDialogFragment.class.getCanonicalName()); return true; @@ -769,14 +778,14 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener throwable.printStackTrace(); final String debugInfos = ExceptionUtil.getDebugInfos(context, throwable); AlertDialog dialog = new BrandedAlertDialogBuilder(context) - .setTitle(R.string.server_misconfigured) - .setMessage(context.getString(R.string.server_misconfigured_explanation) + "\n\n\n" + debugInfos) - .setPositiveButton(android.R.string.copy, (a, b) -> { - copyToClipboard(context, context.getString(R.string.simple_exception), "```\n" + debugInfos + "\n```"); - a.dismiss(); - }) - .setNegativeButton(R.string.simple_close, null) - .create(); + .setTitle(R.string.server_misconfigured) + .setMessage(context.getString(R.string.server_misconfigured_explanation) + "\n\n\n" + debugInfos) + .setPositiveButton(android.R.string.copy, (a, b) -> { + copyToClipboard(context, context.getString(R.string.simple_exception), "```\n" + debugInfos + "\n```"); + a.dismiss(); + }) + .setNegativeButton(R.string.simple_close, null) + .create(); dialog.show(); ((TextView) Objects.requireNonNull(dialog.findViewById(android.R.id.message))).setTypeface(Typeface.MONOSPACE); } 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 index e1b46517a..9a534624a 100644 --- 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 @@ -1,11 +1,68 @@ package it.niedermann.nextcloud.deck.ui.archivedcards; +import android.os.Bundle; + +import androidx.annotation.Nullable; + +import it.niedermann.nextcloud.deck.databinding.ActivityArchivedCardsBinding; +import it.niedermann.nextcloud.deck.model.Account; +import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; import it.niedermann.nextcloud.deck.ui.branding.BrandedActivity; +import it.niedermann.nextcloud.deck.ui.exception.ExceptionHandler; + +import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_ACCOUNT; +import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_BOARD_ID; +import static it.niedermann.nextcloud.deck.ui.card.CardAdapter.BUNDLE_KEY_CAN_EDIT; public class ArchivedCardsActvitiy extends BrandedActivity { + private ActivityArchivedCardsBinding binding; + private ArchivedCardsAdapter adapter; + private SyncManager syncManager; + + private Account account; + private long boardId; + private boolean canEdit = false; + @Override - public void applyBrand(int mainColor, int textColor) { + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); + + final Bundle args = getIntent().getExtras(); + if (args == null || !args.containsKey(BUNDLE_KEY_ACCOUNT) || !args.containsKey(BUNDLE_KEY_BOARD_ID)) { + throw new IllegalArgumentException("Please provide at least " + BUNDLE_KEY_ACCOUNT + " and " + BUNDLE_KEY_BOARD_ID); + } + + this.account = (Account) args.getSerializable(BUNDLE_KEY_ACCOUNT); + this.boardId = args.getLong(BUNDLE_KEY_BOARD_ID); + canEdit = args.getBoolean(BUNDLE_KEY_CAN_EDIT); + + if (this.account == null) { + throw new IllegalArgumentException(BUNDLE_KEY_ACCOUNT + " must not be null."); + } + if (this.boardId <= 0) { + throw new IllegalArgumentException(BUNDLE_KEY_BOARD_ID + " must a positive long value."); + } + binding = ActivityArchivedCardsBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + setSupportActionBar(binding.toolbar); + + syncManager = new SyncManager(this); + + adapter = new ArchivedCardsAdapter(this, account, boardId, false, syncManager, this); + binding.recyclerView.setAdapter(adapter); + + syncManager.getArchivedFullCardsForBoard(account.getId(), boardId).observe(this, (fullCards) -> { + + }); + + } + + @Override + public void applyBrand(int mainColor, int textColor) { + applyBrandToPrimaryToolbar(mainColor, textColor, binding.toolbar); } } 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 index 52f6c827c..847db5f1c 100644 --- 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 @@ -7,8 +7,7 @@ import android.view.View; import android.widget.PopupMenu; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; +import androidx.lifecycle.LifecycleOwner; import org.jetbrains.annotations.NotNull; @@ -17,11 +16,20 @@ 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; +import it.niedermann.nextcloud.deck.ui.card.ItemCardViewHolder; 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); + + @SuppressWarnings("WeakerAccess") + public ArchivedCardsAdapter(@NonNull Context context, @NonNull Account account, long boardId, boolean canEdit, @NonNull SyncManager syncManager, @NonNull LifecycleOwner lifecycleOwner) { + super(context, account, boardId, 0L, canEdit, syncManager, lifecycleOwner, null); + } + + @Override + public void onBindViewHolder(@NonNull ItemCardViewHolder viewHolder, int position) { + super.onBindViewHolder(viewHolder, position); + viewHolder.binding.card.setOnClickListener(null); + viewHolder.binding.card.setOnLongClickListener(null); } protected void onOverflowIconClicked(@NotNull View view, FullCard card) { 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 417edffef..3c420c37c 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 @@ -15,7 +15,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.graphics.drawable.DrawableCompat; -import androidx.fragment.app.Fragment; import androidx.lifecycle.LifecycleOwner; import androidx.recyclerview.widget.RecyclerView; @@ -74,9 +73,9 @@ public class CardAdapter extends RecyclerView.Adapter<ItemCardViewHolder> implem private int mainColor; - public CardAdapter(@NonNull Context context, @NonNull Account account, long boardId, long stackId, boolean canEdit, @NonNull SyncManager syncManager, @NonNull Fragment fragment, @Nullable SelectCardListener selectCardListener) { + public CardAdapter(@NonNull Context context, @NonNull Account account, long boardId, long stackId, boolean canEdit, @NonNull SyncManager syncManager, @NonNull LifecycleOwner lifecycleOwner, @Nullable SelectCardListener selectCardListener) { this.context = context; - this.lifecycleOwner = fragment; + this.lifecycleOwner = lifecycleOwner; this.account = account; this.boardId = boardId; this.stackId = stackId; @@ -84,7 +83,7 @@ public class CardAdapter extends RecyclerView.Adapter<ItemCardViewHolder> implem this.syncManager = syncManager; this.selectCardListener = selectCardListener; this.mainColor = context.getResources().getColor(R.color.primary); - syncManager.getStacksForBoard(account.getId(), boardId).observe(lifecycleOwner, (stacks) -> { + syncManager.getStacksForBoard(account.getId(), boardId).observe(this.lifecycleOwner, (stacks) -> { availableStacks.clear(); availableStacks.addAll(stacks); }); diff --git a/app/src/main/res/drawable/ic_archive_white_24dp.xml b/app/src/main/res/drawable/ic_archive_white_24dp.xml new file mode 100644 index 000000000..9503d04c2 --- /dev/null +++ b/app/src/main/res/drawable/ic_archive_white_24dp.xml @@ -0,0 +1,5 @@ +<vector android:autoMirrored="true" android:height="24dp" + android:tint="#FFFFFF" android:viewportHeight="24.0" + android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#FF000000" android:pathData="M20.54,5.23l-1.39,-1.68C18.88,3.21 18.47,3 18,3H6c-0.47,0 -0.88,0.21 -1.16,0.55L3.46,5.23C3.17,5.57 3,6.02 3,6.5V19c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V6.5c0,-0.48 -0.17,-0.93 -0.46,-1.27zM12,17.5L6.5,12H10v-2h4v2h3.5L12,17.5zM5.12,5l0.81,-1h12l0.94,1H5.12z"/> +</vector> diff --git a/app/src/main/res/layout/activity_archived_cards.xml b/app/src/main/res/layout/activity_archived_cards.xml index 7f3795c47..fd03521fd 100644 --- a/app/src/main/res/layout/activity_archived_cards.xml +++ b/app/src/main/res/layout/activity_archived_cards.xml @@ -6,6 +6,19 @@ android:layout_height="wrap_content" android:orientation="vertical"> + <com.google.android.material.appbar.AppBarLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <androidx.appcompat.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="?android:actionBarSize" + app:navigationIcon="@drawable/ic_arrow_back_white_24dp" + app:titleTextColor="@android:color/white" + tools:title="@string/archived_cards" /> + </com.google.android.material.appbar.AppBarLayout> + <it.niedermann.nextcloud.deck.ui.view.EmptyContentView android:id="@+id/empty_content_view" android:layout_width="match_parent" diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml new file mode 100644 index 000000000..04449a5f0 --- /dev/null +++ b/app/src/main/res/menu/main_menu.xml @@ -0,0 +1,9 @@ +<?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/archived_cards" + android:icon="@drawable/ic_archive_white_24dp" + android:title="@string/action_archived_cards" + app:showAsAction="ifRoom" /> +</menu> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 11b6e7379..a0163ac45 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -187,4 +187,5 @@ <string name="simple_switch">Switch</string> <string name="archived_cards">Archived cards</string> <string name="action_card_dearchive">Dearchive card</string> + <string name="action_archived_cards">Browse archived cards</string> </resources> |