diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-05-12 21:42:27 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-05-12 21:42:27 +0300 |
commit | 568e296a67b657b9245d7693b697affbf4ef787d (patch) | |
tree | 3c5090e0dc41a301f2594112d63dc651f9b277a0 /app | |
parent | 67e1e9f34004dbc40e3273e6ba41a8e114355223 (diff) |
#217 SingleCardWidget
Fix start of AttachmentsActivity
Diffstat (limited to 'app')
3 files changed, 14 insertions, 10 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index df3bf679e..4cdbca33c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -71,7 +71,6 @@ <activity android:name=".ui.card.EditActivity" android:label="@string/edit" - android:launchMode="singleInstance" android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" android:theme="@style/AppTheme" /> diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java index 8aa9fdbd2..ec46dcd01 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java @@ -30,6 +30,7 @@ import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import it.niedermann.nextcloud.deck.ui.exception.ExceptionHandler; import it.niedermann.nextcloud.deck.util.CardUtil; +import static android.graphics.Color.parseColor; import static it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.LiveDataHelper.observeOnce; public class EditActivity extends BrandedActivity { @@ -89,6 +90,7 @@ public class EditActivity extends BrandedActivity { super.onNewIntent(intent); setIntent(intent); loadDataFromIntent(); + applyBrand(parseColor(viewModel.getAccount().getColor()), parseColor(viewModel.getAccount().getTextColor())); } private void loadDataFromIntent() { @@ -111,13 +113,15 @@ public class EditActivity extends BrandedActivity { if (account == null) { throw new IllegalArgumentException(BUNDLE_KEY_ACCOUNT + " must not be null."); } + viewModel.setAccount(account); + final long boardId = args.getLong(BUNDLE_KEY_BOARD_ID); observeOnce(syncManager.getFullBoardById(account.getId(), boardId), EditActivity.this, (fullBoard -> { viewModel.setCanEdit(fullBoard.getBoard().isPermissionEdit()); invalidateOptionsMenu(); if (viewModel.isCreateMode()) { - viewModel.initializeNewCard(account, boardId, args.getLong(BUNDLE_KEY_STACK_ID), account.getServerDeckVersionAsObject().isSupported(this)); + viewModel.initializeNewCard(boardId, args.getLong(BUNDLE_KEY_STACK_ID), account.getServerDeckVersionAsObject().isSupported(this)); invalidateOptionsMenu(); String title = args.getString(BUNDLE_KEY_TITLE); if (!TextUtils.isEmpty(title)) { @@ -131,7 +135,7 @@ public class EditActivity extends BrandedActivity { setupTitle(); } else { observeOnce(syncManager.getCardByLocalId(account.getId(), cardId), EditActivity.this, (fullCard) -> { - viewModel.initializeExistingCard(account, boardId, fullCard, account.getServerDeckVersionAsObject().isSupported(this)); + viewModel.initializeExistingCard(boardId, fullCard, account.getServerDeckVersionAsObject().isSupported(this)); invalidateOptionsMenu(); setupViewPager(); setupTitle(); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditCardViewModel.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditCardViewModel.java index 66ec0d5d8..490c1d57d 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditCardViewModel.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditCardViewModel.java @@ -25,27 +25,23 @@ public class EditCardViewModel extends ViewModel { /** * Stores a deep copy of the given fullCard to be able to compare the state at every time in #{@link EditCardViewModel#hasChanges()} * - * @param account Must not be null * @param boardId Local ID, expecting a positive long value * @param fullCard The card that is currently edited */ - public void initializeExistingCard(@NonNull Account account, long boardId, @NonNull FullCard fullCard, boolean isSupportedVersion) { - this.account = account; + public void initializeExistingCard(long boardId, @NonNull FullCard fullCard, boolean isSupportedVersion) { this.boardId = boardId; this.fullCard = fullCard; this.originalCard = new FullCard(this.fullCard); this.isSupportedVersion = isSupportedVersion; - hasCommentsAbility = account.getServerDeckVersionAsObject().supportsComments(); } /** * Stores a deep copy of the given fullCard to be able to compare the state at every time in #{@link EditCardViewModel#hasChanges()} * - * @param account Must not be null * @param boardId Local ID, expecting a positive long value * @param stackId Local ID, expecting a positive long value where the card should be created */ - public void initializeNewCard(@NonNull Account account, long boardId, long stackId, boolean isSupportedVersion) { + public void initializeNewCard(long boardId, long stackId, boolean isSupportedVersion) { final FullCard fullCard = new FullCard(); fullCard.setLabels(new ArrayList<>()); fullCard.setAssignedUsers(new ArrayList<>()); @@ -53,7 +49,12 @@ public class EditCardViewModel extends ViewModel { final Card card = new Card(); card.setStackId(stackId); fullCard.setCard(card); - initializeExistingCard(account, boardId, fullCard, isSupportedVersion); + initializeExistingCard(boardId, fullCard, isSupportedVersion); + } + + public void setAccount(@NonNull Account account) { + this.account = account; + hasCommentsAbility = account.getServerDeckVersionAsObject().supportsComments(); } public boolean hasChanges() { |