Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2023-03-24 16:00:20 +0300
committerStefan Niedermann <info@niedermann.it>2023-03-24 16:26:53 +0300
commit3ef86d96c298e191cf6869de26f09331a689da8d (patch)
tree93bfd5de831cc4492615ab10b7a27477537c2662 /app/src/main/java/it/niedermann/nextcloud
parent4f31f75f6098ad2c1e3f418e8d7f7d8902a0d273 (diff)
feat: Align theming with Nextcloud Files app
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/PickStackActivity.java7
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java15
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/about/AboutActivity.java4
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsActivity.java23
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/attachments/AttachmentViewHolder.java2
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java4
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/card/NewCardDialog.java2
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/card/activities/CardActivityFragment.java13
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java4
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsFragment.java9
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java2
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/ExceptionActivity.java6
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java4
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsViewHolder.java5
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java16
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/main/MainActivity.java7
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/main/MainActivityNavigationHandler.java28
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/manageaccounts/ManageAccountsActivity.java16
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/manageaccounts/ManageAccountsViewModel.java6
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/PreferencesViewModel.java4
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsActivity.java15
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java41
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java12
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java22
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java6
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/upcomingcards/UpcomingCardsActivity.java31
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java3
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/view/EmptyContentView.java23
28 files changed, 210 insertions, 120 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/PickStackActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/PickStackActivity.java
index c5b92e7d8..93902d9f8 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/PickStackActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/PickStackActivity.java
@@ -47,10 +47,7 @@ public abstract class PickStackActivity extends AppCompatActivity implements The
hasAccounts$
.filter(hasAccounts -> !hasAccounts)
- .observe(this, () -> {
- startActivity(ImportAccountActivity.createIntent(this));
- finish();
- });
+ .observe(this, () -> startActivity(ImportAccountActivity.createIntent(this)));
hasAccounts$
.filter(hasAccounts -> hasAccounts)
@@ -109,6 +106,8 @@ public abstract class PickStackActivity extends AppCompatActivity implements The
public void applyTheme(int color) {
final var utils = ThemeUtils.of(color, this);
+ utils.platform.themeStatusBar(this);
+ utils.material.themeToolbar(binding.toolbar);
utils.material.colorMaterialButtonText(binding.cancel);
utils.material.colorMaterialButtonPrimaryFilled(binding.submit);
utils.material.colorTextInputLayout(binding.inputWrapper);
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java
index 3b2332e7e..f62af8c79 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java
@@ -5,7 +5,6 @@ import android.content.Intent;
import android.net.Uri;
import android.view.View;
-import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
@@ -22,12 +21,13 @@ import it.niedermann.nextcloud.deck.ui.card.EditActivity;
import it.niedermann.nextcloud.deck.ui.exception.ExceptionDialogFragment;
import it.niedermann.nextcloud.deck.ui.exception.ExceptionHandler;
import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
+import it.niedermann.nextcloud.deck.ui.theme.Themed;
/**
* Warning: Do not move this class to another package or folder!
* The integration of the Nextcloud Android app <a href="https://github.com/nextcloud/android/blob/master/src/main/java/com/nextcloud/client/integrations/deck/DeckApiImpl.java#L42">assumes it to be at this location</a>.
*/
-public class PushNotificationActivity extends AppCompatActivity {
+public class PushNotificationActivity extends AppCompatActivity implements Themed {
private ActivityPushNotificationBinding binding;
private PushNotificationViewModel viewModel;
@@ -52,7 +52,7 @@ public class PushNotificationActivity extends AppCompatActivity {
setSupportActionBar(binding.toolbar);
binding.progress.setIndeterminate(true);
- viewModel.getAccount().observe(this, this::applyThemeToSubmitButton);
+ viewModel.getAccount().observe(this, this::applyTheme);
executor.submit(() -> viewModel.getCardInformation(intent.getExtras(), new PushNotificationViewModel.PushNotificationCallback() {
@Override
public void onResponse(@NonNull PushNotificationViewModel.CardInformation cardInformation) {
@@ -88,7 +88,7 @@ public class PushNotificationActivity extends AppCompatActivity {
private void fallbackToBrowser(@NonNull Uri uri) {
DeckLog.warn("Falling back to browser as push notification handler:", uri);
- binding.submit.setOnClickListener((v) -> startActivity(new Intent(Intent.ACTION_VIEW, uri)));
+ binding.submit.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW, uri)));
viewModel.extractSubject(intent.getExtras()).ifPresent(binding.subject::setText);
viewModel.extractMessage(intent.getExtras()).ifPresent(message -> {
@@ -119,11 +119,12 @@ public class PushNotificationActivity extends AppCompatActivity {
return true;
}
- // TODO implement Branded interface
- // TODO apply branding based on board color
- public void applyThemeToSubmitButton(@ColorInt int color) {
+ @Override
+ public void applyTheme(int color) {
final var utils = ThemeUtils.of(color, this);
+ utils.platform.themeStatusBar(this);
+ utils.material.themeToolbar(binding.toolbar);
utils.platform.themeHorizontalProgressBar(binding.progress);
Stream.of(binding.submit, binding.showError)
.forEach(utils.material::colorMaterialButtonPrimaryFilled);
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/about/AboutActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/about/AboutActivity.java
index dc5de960f..67552b2d7 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/about/AboutActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/about/AboutActivity.java
@@ -64,7 +64,9 @@ public class AboutActivity extends AppCompatActivity implements Themed {
public void applyTheme(int color) {
final var utils = ThemeUtils.of(color, this);
- utils.deck.themeTabLayout(binding.tabLayout);
+ utils.platform.themeStatusBar(this);
+ utils.material.themeToolbar(binding.toolbar);
+ utils.material.themeTabLayoutOnSurface(binding.tabLayout);
}
private static class TabsPagerAdapter extends FragmentStateAdapter {
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsActivity.java
index 0a794aa91..58237dbd5 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/archivedboards/ArchivedBoardsActivity.java
@@ -23,6 +23,7 @@ import it.niedermann.nextcloud.deck.ui.board.DeleteBoardListener;
import it.niedermann.nextcloud.deck.ui.board.edit.EditBoardListener;
import it.niedermann.nextcloud.deck.ui.exception.ExceptionDialogFragment;
import it.niedermann.nextcloud.deck.ui.exception.ExceptionHandler;
+import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
import it.niedermann.nextcloud.deck.ui.theme.Themed;
import it.niedermann.nextcloud.deck.ui.viewmodel.SyncViewModel;
@@ -46,12 +47,13 @@ public class ArchivedBoardsActivity extends AppCompatActivity implements Themed,
}
account = (Account) args.getSerializable(KEY_ACCOUNT);
-
binding = ActivityArchivedBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
+ applyTheme(account.getColor());
+
archivedBoardsViewModel = new SyncViewModel.Provider(this, getApplication(), account).get(ArchivedBoardsViewModel.class);
adapter = new ArchivedBoardsAdapter(account, getSupportFragmentManager(), this::onArchive);
@@ -144,13 +146,6 @@ public class ArchivedBoardsActivity extends AppCompatActivity implements Themed,
.show(getSupportFragmentManager(), ExceptionDialogFragment.class.getSimpleName());
}
- @NonNull
- public static Intent createIntent(@NonNull Context context, @NonNull Account account) {
- return new Intent(context, ArchivedBoardsActivity.class)
- .putExtra(KEY_ACCOUNT, account)
- .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- }
-
@Override
public void onDismiss(DialogInterface dialog) {
@@ -158,6 +153,16 @@ public class ArchivedBoardsActivity extends AppCompatActivity implements Themed,
@Override
public void applyTheme(int color) {
- binding.emptyContentView.applyTheme(color);
+ final var utils = ThemeUtils.of(color, this);
+
+ utils.platform.themeStatusBar(this);
+ utils.material.themeToolbar(binding.toolbar);
+ }
+
+ @NonNull
+ public static Intent createIntent(@NonNull Context context, @NonNull Account account) {
+ return new Intent(context, ArchivedBoardsActivity.class)
+ .putExtra(KEY_ACCOUNT, account)
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/attachments/AttachmentViewHolder.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/attachments/AttachmentViewHolder.java
index f633cd534..bfc21b787 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/attachments/AttachmentViewHolder.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/attachments/AttachmentViewHolder.java
@@ -2,7 +2,6 @@ package it.niedermann.nextcloud.deck.ui.attachments;
import android.content.Context;
import android.graphics.drawable.Drawable;
-import android.view.MotionEvent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -15,7 +14,6 @@ import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
-import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.R;
import it.niedermann.nextcloud.deck.databinding.ItemAttachmentBinding;
import it.niedermann.nextcloud.deck.model.Account;
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 b3b539614..7edd10bbf 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
@@ -287,8 +287,10 @@ public class EditActivity extends AppCompatActivity {
final var utils = ThemeUtils.of(color, this);
+ utils.platform.themeStatusBar(this);
+ utils.material.themeToolbar(binding.toolbar);
utils.platform.colorEditText(binding.title);
- utils.deck.themeTabLayout(binding.tabLayout);
+ utils.material.themeTabLayoutOnSurface(binding.tabLayout);
}
@NonNull
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/NewCardDialog.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/NewCardDialog.java
index efe974598..b6ce18f13 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/NewCardDialog.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/NewCardDialog.java
@@ -22,7 +22,6 @@ import androidx.lifecycle.ViewModelProvider;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.nextcloud.android.common.ui.theme.utils.ColorRole;
-import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.R;
import it.niedermann.nextcloud.deck.databinding.DialogNewCardBinding;
import it.niedermann.nextcloud.deck.exceptions.OfflineException;
@@ -67,7 +66,6 @@ public class NewCardDialog extends ThemedDialogFragment implements DialogInterfa
this.account = (Account) getArguments().getSerializable(KEY_ACCOUNT);
newCardViewModel = new SyncViewModel.Provider(requireActivity(), requireActivity().getApplication(), account).get(NewCardViewModel.class);
- DeckLog.log(newCardViewModel);
viewModel = new ViewModelProvider(requireActivity()).get(PrepareCreateViewModel.class);
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/activities/CardActivityFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/activities/CardActivityFragment.java
index c204b1658..d301968c4 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/activities/CardActivityFragment.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/activities/CardActivityFragment.java
@@ -12,8 +12,10 @@ import androidx.lifecycle.ViewModelProvider;
import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.databinding.FragmentCardEditTabActivitiesBinding;
import it.niedermann.nextcloud.deck.ui.card.EditCardViewModel;
+import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
+import it.niedermann.nextcloud.deck.ui.theme.Themed;
-public class CardActivityFragment extends Fragment {
+public class CardActivityFragment extends Fragment implements Themed {
private FragmentCardEditTabActivitiesBinding binding;
@@ -36,6 +38,8 @@ public class CardActivityFragment extends Fragment {
return binding.getRoot();
}
+ viewModel.getBoardColor().observe(getViewLifecycleOwner(), this::applyTheme);
+
viewModel.syncActivitiesForCard(viewModel.getFullCard().getCard()).observe(getViewLifecycleOwner(), (activities -> {
if (activities == null || activities.size() == 0) {
binding.emptyContentView.setVisibility(View.VISIBLE);
@@ -54,4 +58,11 @@ public class CardActivityFragment extends Fragment {
super.onDestroy();
this.binding = null;
}
+
+ @Override
+ public void applyTheme(int color) {
+ final var utils = ThemeUtils.of(color, requireContext());
+
+ utils.deck.themeEmptyContentView(binding.emptyContentView);
+ }
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java
index 96292ecff..ea4e3c9a4 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java
@@ -517,10 +517,10 @@ public class CardAttachmentsFragment extends Fragment implements AttachmentDelet
private void applyTheme(@ColorInt int color) {
final var utils = ThemeUtils.of(color, requireContext());
+ utils.deck.themeEmptyContentView(binding.emptyContentView);
utils.material.themeFAB(binding.fab);
utils.platform.colorBottomNavigationView(binding.bottomNavigation);
- utils.platform.colorViewBackground(binding.pickerHeader, ColorRole.SURFACE);
- utils.platform.colorViewBackground(binding.pickerRecyclerView, ColorRole.SURFACE);
+ utils.platform.colorViewBackground(binding.bottomSheetParent, ColorRole.SURFACE);
adapter.applyTheme(color);
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsFragment.java
index f46aafd1c..4704ea45a 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsFragment.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsFragment.java
@@ -13,6 +13,7 @@ import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.Toast;
+import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
@@ -36,10 +37,11 @@ import it.niedermann.nextcloud.deck.ui.card.EditActivity;
import it.niedermann.nextcloud.deck.ui.card.EditCardViewModel;
import it.niedermann.nextcloud.deck.ui.exception.ExceptionDialogFragment;
import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
+import it.niedermann.nextcloud.deck.ui.theme.Themed;
import it.niedermann.nextcloud.deck.ui.viewmodel.SyncViewModel;
import it.niedermann.nextcloud.deck.util.KeyboardUtils;
-public class CardCommentsFragment extends Fragment implements CommentEditedListener, CommentDeletedListener, CommentSelectAsReplyListener {
+public class CardCommentsFragment extends Fragment implements Themed, CommentEditedListener, CommentDeletedListener, CommentSelectAsReplyListener {
private static final String KEY_ACCOUNT = "account";
private FragmentCardEditTabCommentsBinding binding;
@@ -185,9 +187,12 @@ public class CardCommentsFragment extends Fragment implements CommentEditedListe
});
}
- private void applyTheme(int color) {
+ @Override
+ public void applyTheme(@ColorInt int color) {
final var utils = ThemeUtils.of(color, requireContext());
+ utils.deck.themeEmptyContentView(binding.emptyContentView);
+ utils.platform.colorViewBackground(binding.addCommentLayout);
utils.material.themeFAB(binding.fab);
utils.material.colorTextInputLayout(binding.messageWrapper);
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java
index 49a0b33ae..76c99abe9 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java
@@ -330,7 +330,7 @@ public class CardDetailsFragment extends Fragment implements OnDateSetListener,
}
private void setupAssignees() {
- adapter = new AssigneeAdapter(user -> CardAssigneeDialog.newInstance(user).show(getChildFragmentManager(), CardAssigneeDialog.class.getSimpleName()), viewModel.getAccount());
+ adapter = new AssigneeAdapter((user) -> CardAssigneeDialog.newInstance(user).show(getChildFragmentManager(), CardAssigneeDialog.class.getSimpleName()), viewModel.getAccount());
binding.assignees.setAdapter(adapter);
binding.assignees.post(() -> {
@Px final int gutter = DimensionUtil.INSTANCE.dpToPx(requireContext(), R.dimen.spacer_1x);
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/ExceptionActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/ExceptionActivity.java
index e6a62c4e0..0e558fb85 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/ExceptionActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/ExceptionActivity.java
@@ -13,6 +13,7 @@ import it.niedermann.nextcloud.deck.BuildConfig;
import it.niedermann.nextcloud.deck.R;
import it.niedermann.nextcloud.deck.databinding.ActivityExceptionBinding;
import it.niedermann.nextcloud.deck.ui.exception.tips.TipsAdapter;
+import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
import it.niedermann.nextcloud.exception.ExceptionUtil;
public class ExceptionActivity extends AppCompatActivity {
@@ -46,6 +47,11 @@ public class ExceptionActivity extends AppCompatActivity {
binding.copy.setOnClickListener((v) -> ClipboardUtil.INSTANCE.copyToClipboard(this, getString(R.string.simple_exception), "```\n" + debugInfo + "\n```"));
binding.close.setOnClickListener((v) -> finish());
+ final var utils = ThemeUtils.defaultBrand(this);
+
+ utils.material.colorMaterialButtonText(binding.close);
+ utils.material.colorMaterialButtonPrimaryFilled(binding.copy);
+
adapter.setThrowable(this, null, throwable);
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java
index c57c80d24..5dc89e46d 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java
@@ -163,9 +163,9 @@ public class TipsAdapter extends RecyclerView.Adapter<TipsViewHolder> {
add(R.string.error_dialog_tip_clear_storage, INTENT_APP_INFO);
} else if (throwable instanceof RuntimeException) {
if (throwable.getMessage() != null && throwable.getMessage().toLowerCase().contains("database")) {
- Intent reportIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(context.getString(R.string.url_report_bug)))
+ final var intent = new Intent(Intent.ACTION_VIEW, Uri.parse(context.getString(R.string.url_report_bug)))
.putExtra(INTENT_EXTRA_BUTTON_TEXT, R.string.error_action_report_issue);
- add(R.string.error_dialog_tip_database_upgrade_failed, reportIntent);
+ add(R.string.error_dialog_tip_database_upgrade_failed, intent);
add(R.string.error_dialog_tip_clear_storage, INTENT_APP_INFO);
}
} else if (throwable instanceof UnknownErrorException) {
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsViewHolder.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsViewHolder.java
index 8a66c8cbf..4c6e52c60 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsViewHolder.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsViewHolder.java
@@ -10,6 +10,7 @@ import androidx.core.util.Consumer;
import androidx.recyclerview.widget.RecyclerView;
import it.niedermann.nextcloud.deck.databinding.ItemTipBinding;
+import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
public class TipsViewHolder extends RecyclerView.ViewHolder {
private final ItemTipBinding binding;
@@ -27,6 +28,10 @@ public class TipsViewHolder extends RecyclerView.ViewHolder {
binding.actionButton.setVisibility(View.VISIBLE);
binding.actionButton.setText(actionIntent.getIntExtra(INTENT_EXTRA_BUTTON_TEXT, 0));
binding.actionButton.setOnClickListener((v) -> actionButtonClickedListener.accept(actionIntent));
+
+ final var utils = ThemeUtils.defaultBrand(itemView.getContext());
+
+ utils.material.colorMaterialButtonPrimaryOutlined(binding.actionButton);
} else {
binding.actionButton.setVisibility(View.GONE);
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java
index 582303476..8eac0dbb4 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java
@@ -72,15 +72,13 @@ public class FilterDialogFragment extends ThemedDialogFragment {
tab.setText(tabTitles[position]);
}).attach();
- binding.viewPager.post(() -> {
- binding.viewPager.setCurrentItem(filterViewModel.getCurrentFilterTab(), false);
- binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
- @Override
- public void onPageSelected(int position) {
- super.onPageSelected(position);
- filterViewModel.setCurrentFilterTab(position);
- }
- });
+ binding.viewPager.setCurrentItem(filterViewModel.getCurrentFilterTab(), false);
+ binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
+ @Override
+ public void onPageSelected(int position) {
+ super.onPageSelected(position);
+ filterViewModel.setCurrentFilterTab(position);
+ }
});
filterViewModel.createFilterInformationDraft();
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/main/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/main/MainActivity.java
index 3e4eed845..4d76c7aea 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/main/MainActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/main/MainActivity.java
@@ -492,16 +492,19 @@ public class MainActivity extends AppCompatActivity implements DeleteStackListen
utils.deck.themeSearchBar(binding.toolbar);
utils.deck.themeSearchView(binding.searchView);
utils.deck.themeTabLayoutOnTransparent(binding.stackTitles);
+ utils.deck.themeEmptyContentView(binding.emptyContentViewStacks);
+ utils.deck.themeEmptyContentView(binding.emptyContentViewSearchNoTerm);
+ utils.deck.themeEmptyContentView(binding.emptyContentViewSearchNoResults);
utils.material.themeExtendedFAB(binding.fab);
utils.androidx.themeSwipeRefreshLayout(binding.swipeRefreshLayout);
- binding.emptyContentViewStacks.applyTheme(color);
+
}
private void applyAccountTheme(@ColorInt int accountColor) {
final var utils = ThemeUtils.of(accountColor, this);
+ utils.deck.themeEmptyContentView(binding.emptyContentViewBoards);
utils.platform.colorNavigationView(binding.navigationView, false);
- binding.emptyContentViewBoards.applyTheme(accountColor);
@ColorInt final int headerTextColor = ColorUtil.INSTANCE.getForegroundColorForBackgroundColor(accountColor);
headerBinding.headerView.setBackgroundColor(accountColor);
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/main/MainActivityNavigationHandler.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/main/MainActivityNavigationHandler.java
index 6850b70fb..88425e846 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/main/MainActivityNavigationHandler.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/main/MainActivityNavigationHandler.java
@@ -65,46 +65,32 @@ public class MainActivityNavigationHandler implements NavigationView.OnNavigatio
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
+ if (account == null) {
+ DeckLog.warn("Current account is null, can handle selected navigation item #" + item.getItemId() + ": \"" + item.getTitle() + "\"");
+ return false;
+ }
+
switch (item.getItemId()) {
case MENU_ID_ABOUT:
- if (account == null) {
- DeckLog.warn("Current account is null, can not launch dialog to create board.");
- return false;
- }
activity.startActivity(AboutActivity.createIntent(activity, account));
break;
case MENU_ID_SETTINGS:
- if (account == null) {
- DeckLog.warn("Current account is null, can not launch dialog to create board.");
- return false;
- }
settingsLauncher.launch(SettingsActivity.createIntent(activity, account));
break;
case MENU_ID_ADD_BOARD:
- if (account == null) {
- DeckLog.warn("Current account is null, can not launch dialog to create board.");
- return false;
- }
EditBoardDialogFragment.newInstance(account).show(activity.getSupportFragmentManager(), EditBoardDialogFragment.class.getSimpleName());
break;
case MENU_ID_ARCHIVED_BOARDS:
- if (account == null) {
- DeckLog.warn("Current account is null, can not launch dialog to create board.");
- return false;
- }
activity.startActivity(ArchivedBoardsActivity.createIntent(activity, account));
break;
case MENU_ID_UPCOMING_CARDS:
- activity.startActivity(UpcomingCardsActivity.createIntent(activity));
+ activity.startActivity(UpcomingCardsActivity.createIntent(activity, account));
break;
default:
- if (account == null) {
- DeckLog.warn("Current account is null, can not launch dialog to create board.");
- return false;
- }
onBoardSelected.accept(account.getId(), navigationMap.get(item.getItemId()));
break;
}
+
drawerLayout.closeDrawer(GravityCompat.START);
return true;
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/manageaccounts/ManageAccountsActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/manageaccounts/ManageAccountsActivity.java
index d1ce2e14e..cd9840ec7 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/manageaccounts/ManageAccountsActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/manageaccounts/ManageAccountsActivity.java
@@ -14,8 +14,10 @@ import androidx.lifecycle.ViewModelProvider;
import it.niedermann.android.reactivelivedata.ReactiveLiveData;
import it.niedermann.nextcloud.deck.databinding.ActivityManageAccountsBinding;
import it.niedermann.nextcloud.deck.model.Account;
+import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
+import it.niedermann.nextcloud.deck.ui.theme.Themed;
-public class ManageAccountsActivity extends AppCompatActivity {
+public class ManageAccountsActivity extends AppCompatActivity implements Themed {
private static final String TAG = ManageAccountsActivity.class.getSimpleName();
@@ -33,7 +35,7 @@ public class ManageAccountsActivity extends AppCompatActivity {
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
- adapter = new ManageAccountAdapter((account) -> viewModel.saveCurrentAccount(account), (accountPair) -> {
+ adapter = new ManageAccountAdapter(account -> viewModel.saveCurrentAccount(account), accountPair -> {
if (accountPair.first != null) {
viewModel.deleteAccount(accountPair.first.getId());
} else {
@@ -48,6 +50,8 @@ public class ManageAccountsActivity extends AppCompatActivity {
});
binding.accounts.setAdapter(adapter);
+ viewModel.getCurrentAccountColor().observe(this, this::applyTheme);
+
viewModel.getCurrentAccountId().thenAcceptAsync(accountId -> new ReactiveLiveData<>(viewModel.readAccount(accountId))
.observeOnce(this, account -> {
adapter.setCurrentAccount(account);
@@ -68,6 +72,14 @@ public class ManageAccountsActivity extends AppCompatActivity {
this.binding = null;
}
+ @Override
+ public void applyTheme(int color) {
+ final var utils = ThemeUtils.of(color, this);
+
+ utils.platform.themeStatusBar(this);
+ utils.material.themeToolbar(binding.toolbar);
+ }
+
public static Intent createIntent(@NonNull Context context) {
return new Intent(context, ManageAccountsActivity.class);
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/manageaccounts/ManageAccountsViewModel.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/manageaccounts/ManageAccountsViewModel.java
index 567732ddf..632a7cd15 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/manageaccounts/ManageAccountsViewModel.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/manageaccounts/ManageAccountsViewModel.java
@@ -8,6 +8,7 @@ import androidx.lifecycle.LiveData;
import java.util.List;
import java.util.concurrent.CompletableFuture;
+import it.niedermann.android.reactivelivedata.ReactiveLiveData;
import it.niedermann.nextcloud.deck.model.Account;
import it.niedermann.nextcloud.deck.ui.viewmodel.BaseViewModel;
@@ -18,6 +19,11 @@ public class ManageAccountsViewModel extends BaseViewModel {
super(application);
}
+ public LiveData<Integer> getCurrentAccountColor() {
+ return new ReactiveLiveData<>(baseRepository.getCurrentAccountId$())
+ .flatMap(baseRepository::getAccountColor);
+ }
+
public LiveData<Account> readAccount(long id) {
return baseRepository.readAccount(id);
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/PreferencesViewModel.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/PreferencesViewModel.java
index c1e6857f8..9ab461523 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/PreferencesViewModel.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/PreferencesViewModel.java
@@ -25,10 +25,6 @@ public class PreferencesViewModel extends BaseViewModel {
return baseRepository.getCurrentAccountId$();
}
- public LiveData<Integer> getAccountColor(long accountId) {
- return baseRepository.getAccountColor(accountId);
- }
-
public void setAppTheme(int setting) {
preferencesRepository.setAppTheme(setting);
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsActivity.java
index 0ca0739fe..86f43b482 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsActivity.java
@@ -32,12 +32,15 @@ public class SettingsActivity extends AppCompatActivity implements Themed {
binding = ActivitySettingsBinding.inflate(getLayoutInflater());
- applyTheme(account.getColor());
- setSupportActionBar(binding.toolbar);
setContentView(binding.getRoot());
+ setSupportActionBar(binding.toolbar);
+ applyTheme(account.getColor());
+ setResult(RESULT_CANCELED);
- // TODO We should only set this if a preference has changed that influences the MainActivity
- setResult(RESULT_OK);
+ getSupportFragmentManager()
+ .beginTransaction()
+ .add(binding.settingsFragment.getId(), SettingsFragment.newInstance(account))
+ .commit();
}
@Override
@@ -56,8 +59,8 @@ public class SettingsActivity extends AppCompatActivity implements Themed {
public void applyTheme(int color) {
final var utils = ThemeUtils.of(color, this);
-// utils.platform.themeStatusBar(this);
-// utils.material.themeToolbar(binding.toolbar);
+ utils.platform.themeStatusBar(this);
+ utils.material.themeToolbar(binding.toolbar);
}
@NonNull
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java
index 44cfe5410..229c61afc 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java
@@ -1,25 +1,29 @@
package it.niedermann.nextcloud.deck.ui.settings;
+import android.content.Context;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
+import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import java.util.stream.Stream;
-import it.niedermann.android.reactivelivedata.ReactiveLiveData;
import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.R;
+import it.niedermann.nextcloud.deck.model.Account;
import it.niedermann.nextcloud.deck.remote.SyncWorker;
import it.niedermann.nextcloud.deck.ui.theme.ThemedSwitchPreference;
public class SettingsFragment extends PreferenceFragmentCompat {
+ private static final String KEY_ACCOUNT = "account";
+ private Account account;
private PreferencesViewModel preferencesViewModel;
private ThemedSwitchPreference wifiOnlyPref;
private ThemedSwitchPreference compactPref;
@@ -29,6 +33,18 @@ public class SettingsFragment extends PreferenceFragmentCompat {
private ThemedSwitchPreference eTagPref;
@Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+
+ final var args = getArguments();
+ if (args == null || !args.containsKey(KEY_ACCOUNT)) {
+ throw new IllegalArgumentException(KEY_ACCOUNT + " must be provided");
+ }
+
+ account = (Account) args.getSerializable(KEY_ACCOUNT);
+ }
+
+ @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.settings, rootKey);
@@ -77,15 +93,18 @@ public class SettingsFragment extends PreferenceFragmentCompat {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- new ReactiveLiveData<>(preferencesViewModel.getCurrentAccountId$())
- .flatMap(preferencesViewModel::getAccountColor)
- .observe(getViewLifecycleOwner(), color -> Stream.of(
- wifiOnlyPref,
- compactPref,
- coverImagesPref,
- compressImageAttachmentsPref,
- debuggingPref,
- eTagPref)
- .forEach(pref -> pref.applyTheme(color)));
+ Stream.of(wifiOnlyPref, compactPref, coverImagesPref, compressImageAttachmentsPref, debuggingPref, eTagPref)
+ .forEach(pref -> pref.applyTheme(account.getColor()));
+ }
+
+ @NonNull
+ public static Fragment newInstance(@NonNull Account account) {
+ final var fragment = new SettingsFragment();
+
+ final var args = new Bundle();
+ args.putSerializable(KEY_ACCOUNT, account);
+ fragment.setArguments(args);
+
+ return fragment;
}
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java
index 9ccf8818c..33925a8f5 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java
@@ -19,6 +19,8 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+import com.nextcloud.android.common.ui.theme.utils.ColorRole;
+
import it.niedermann.android.crosstabdnd.DragAndDropTab;
import it.niedermann.android.reactivelivedata.ReactiveLiveData;
import it.niedermann.nextcloud.deck.DeckLog;
@@ -37,6 +39,7 @@ import it.niedermann.nextcloud.deck.ui.exception.ExceptionDialogFragment;
import it.niedermann.nextcloud.deck.ui.filter.FilterViewModel;
import it.niedermann.nextcloud.deck.ui.movecard.MoveCardDialogFragment;
import it.niedermann.nextcloud.deck.ui.movecard.MoveCardListener;
+import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
import it.niedermann.nextcloud.deck.ui.theme.Themed;
import it.niedermann.nextcloud.deck.ui.viewmodel.SyncViewModel;
import it.niedermann.nextcloud.deck.util.CardUtil;
@@ -92,8 +95,6 @@ public class StackFragment extends Fragment implements Themed, DragAndDropTab<Ca
binding = FragmentStackBinding.inflate(inflater, container, false);
stackViewModel = new SyncViewModel.Provider(requireActivity(), requireActivity().getApplication(), account).get(StackViewModel.class);
- applyTheme(account.getColor());
-
final var filterViewModel = new ViewModelProvider(activity).get(FilterViewModel.class);
if (onScrollListener != null) {
@@ -124,6 +125,8 @@ public class StackFragment extends Fragment implements Themed, DragAndDropTab<Ca
adapter = new CardAdapter(activity, this, selectCardListener);
binding.recyclerView.setAdapter(adapter);
+ stackViewModel.getBoardColor$(account.getId(), boardId).observe(getViewLifecycleOwner(), this::applyTheme);
+
new ReactiveLiveData<>(stackViewModel.getAccount(account.getId()))
.tap(() -> binding.loadingSpinner.show())
.tap(account -> adapter.setAccount(account))
@@ -292,7 +295,10 @@ public class StackFragment extends Fragment implements Themed, DragAndDropTab<Ca
@Override
public void applyTheme(int color) {
- binding.emptyContentView.applyTheme(color);
+ final var utils = ThemeUtils.of(color, requireContext());
+
+ utils.platform.colorCircularProgressBar(binding.loadingSpinner, ColorRole.PRIMARY);
+ utils.deck.themeEmptyContentView(binding.emptyContentView);
}
public static Fragment newInstance(@NonNull Account account, long boardId, long stackId) {
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java
index b325388b2..7b8c81ab4 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java
@@ -39,6 +39,7 @@ import java.time.LocalDate;
import java.util.Optional;
import it.niedermann.nextcloud.deck.R;
+import it.niedermann.nextcloud.deck.ui.view.EmptyContentView;
import kotlin.Pair;
/**
@@ -69,18 +70,6 @@ public class DeckViewThemeUtils extends ViewThemeUtilsBase {
tabLayout.setBackground(null);
}
- /**
- * Convenience method for calling {@link #themeTabLayout(TabLayout, int)} with the primary color
- */
- public void themeTabLayout(@NonNull TabLayout tabLayout) {
- themeTabLayout(tabLayout, ContextCompat.getColor(tabLayout.getContext(), R.color.primary));
- }
-
- public void themeTabLayout(@NonNull TabLayout tabLayout, @ColorInt int backgroundColor) {
- this.material.themeTabLayout(tabLayout);
- tabLayout.setBackgroundColor(backgroundColor);
- }
-
public void themeSearchBar(@NonNull SearchBar searchBar) {
withScheme(searchBar.getContext(), scheme -> {
final var colorStateList = ColorStateList.valueOf(
@@ -101,6 +90,15 @@ public class DeckViewThemeUtils extends ViewThemeUtilsBase {
});
}
+ public void themeEmptyContentView(@NonNull EmptyContentView emptyContentView) {
+ withScheme(emptyContentView.getContext(), scheme -> {
+ platform.colorImageView(emptyContentView.getImage(), ColorRole.SURFACE_VARIANT);
+ platform.colorTextView(emptyContentView.getTitle(), ColorRole.ON_BACKGROUND);
+ platform.colorTextView(emptyContentView.getDescription(), ColorRole.ON_BACKGROUND);
+ return emptyContentView;
+ });
+ }
+
public void themeSearchView(@NonNull SearchView searchView) {
withScheme(searchView.getContext(), scheme -> {
searchView.setBackgroundTintList(ColorStateList.valueOf(scheme.getSurface()));
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java
index 45d4e25c1..956d84e0b 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java
@@ -6,6 +6,7 @@ import android.content.Context;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
+import androidx.core.content.ContextCompat;
import com.nextcloud.android.common.ui.color.ColorUtil;
import com.nextcloud.android.common.ui.theme.MaterialSchemes;
@@ -18,6 +19,7 @@ import com.nextcloud.android.common.ui.theme.utils.MaterialViewThemeUtils;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import it.niedermann.nextcloud.deck.R;
import scheme.Scheme;
public class ThemeUtils extends ViewThemeUtilsBase {
@@ -50,6 +52,10 @@ public class ThemeUtils extends ViewThemeUtilsBase {
));
}
+ public static ThemeUtils defaultBrand(@NonNull Context context) {
+ return of(ContextCompat.getColor(context, R.color.defaultBrand), context);
+ }
+
@Deprecated
public static Scheme createScheme(@ColorInt int color, @NonNull Context context) {
return isDarkMode(context) ? Scheme.dark(color) : Scheme.light(color);
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/upcomingcards/UpcomingCardsActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/upcomingcards/UpcomingCardsActivity.java
index 9f92f1128..1d2e68633 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/upcomingcards/UpcomingCardsActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/upcomingcards/UpcomingCardsActivity.java
@@ -10,10 +10,12 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
+import com.nextcloud.android.common.ui.theme.utils.ColorRole;
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException;
import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.databinding.ActivityUpcomingCardsBinding;
+import it.niedermann.nextcloud.deck.model.Account;
import it.niedermann.nextcloud.deck.model.Card;
import it.niedermann.nextcloud.deck.model.Stack;
import it.niedermann.nextcloud.deck.model.full.FullCard;
@@ -22,9 +24,13 @@ import it.niedermann.nextcloud.deck.repository.SyncRepository;
import it.niedermann.nextcloud.deck.ui.exception.ExceptionDialogFragment;
import it.niedermann.nextcloud.deck.ui.exception.ExceptionHandler;
import it.niedermann.nextcloud.deck.ui.movecard.MoveCardListener;
+import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
+import it.niedermann.nextcloud.deck.ui.theme.Themed;
-public class UpcomingCardsActivity extends AppCompatActivity implements MoveCardListener {
+public class UpcomingCardsActivity extends AppCompatActivity implements Themed, MoveCardListener {
+ private static final String KEY_ACCOUNT = "account";
+ private Account account;
private UpcomingCardsViewModel viewModel;
private ActivityUpcomingCardsBinding binding;
@@ -34,11 +40,18 @@ public class UpcomingCardsActivity extends AppCompatActivity implements MoveCard
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
+ if (!getIntent().hasExtra(KEY_ACCOUNT)) {
+ throw new IllegalArgumentException(KEY_ACCOUNT + " must be provided");
+ }
+
+ account = (Account) getIntent().getSerializableExtra(KEY_ACCOUNT);
+
binding = ActivityUpcomingCardsBinding.inflate(getLayoutInflater());
viewModel = new ViewModelProvider(this).get(UpcomingCardsViewModel.class);
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
+ applyTheme(account.getColor());
binding.loadingSpinner.show();
@@ -57,7 +70,7 @@ public class UpcomingCardsActivity extends AppCompatActivity implements MoveCard
ExceptionDialogFragment.newInstance(e, a).show(getSupportFragmentManager(), ExceptionDialogFragment.class.getSimpleName());
}
},
- (fullCard) -> viewModel.archiveCard(fullCard, new IResponseCallback<>() {
+ fullCard -> viewModel.archiveCard(fullCard, new IResponseCallback<>() {
@Override
public void onResponse(FullCard response) {
DeckLog.info("Successfully archived", Card.class.getSimpleName(), fullCard.getCard().getTitle());
@@ -69,7 +82,7 @@ public class UpcomingCardsActivity extends AppCompatActivity implements MoveCard
runOnUiThread(() -> ExceptionDialogFragment.newInstance(throwable, null).show(getSupportFragmentManager(), ExceptionDialogFragment.class.getSimpleName()));
}
}),
- (card) -> viewModel.deleteCard(card, new IResponseCallback<>() {
+ card -> viewModel.deleteCard(card, new IResponseCallback<>() {
@Override
public void onResponse(Void response) {
DeckLog.info("Successfully deleted card", card.getTitle());
@@ -105,8 +118,9 @@ public class UpcomingCardsActivity extends AppCompatActivity implements MoveCard
}
@NonNull
- public static Intent createIntent(@NonNull Context context) {
+ public static Intent createIntent(@NonNull Context context, @NonNull Account account) {
return new Intent(context, UpcomingCardsActivity.class)
+ .putExtra(KEY_ACCOUNT, account)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
@@ -127,4 +141,13 @@ public class UpcomingCardsActivity extends AppCompatActivity implements MoveCard
}
});
}
+
+ @Override
+ public void applyTheme(int color) {
+ final var utils = ThemeUtils.of(color, this);
+
+ utils.platform.colorCircularProgressBar(binding.loadingSpinner, ColorRole.PRIMARY);
+ utils.platform.themeStatusBar(this);
+ utils.material.themeToolbar(binding.toolbar);
+ }
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java
index 326979744..ae520cf91 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java
@@ -89,7 +89,8 @@ public class ColorChooser extends LinearLayout {
previouslySelectedImageView.setImageDrawable(DeckViewThemeUtils.getTintedImageView(this.context, R.drawable.circle_grey600_36dp, previouslySelectedColor));
previouslySelectedImageView = null;
}
- @ColorInt final int customColor = envelope.getColor();
+ @ColorInt
+ final int customColor = envelope.getColor();
selectedColor = customColor;
previouslySelectedColor = customColor;
binding.customColorChooser.setImageDrawable(DeckViewThemeUtils.getTintedImageView(context, R.drawable.circle_alpha_colorize_36dp, selectedColor));
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/EmptyContentView.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/EmptyContentView.java
index 2b3557694..281d0f68f 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/EmptyContentView.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/EmptyContentView.java
@@ -4,19 +4,17 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
+import android.widget.ImageView;
import android.widget.RelativeLayout;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
-import com.nextcloud.android.common.ui.theme.utils.ColorRole;
-
import it.niedermann.nextcloud.deck.R;
import it.niedermann.nextcloud.deck.databinding.WidgetEmptyContentViewBinding;
-import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
-import it.niedermann.nextcloud.deck.ui.theme.Themed;
-public class EmptyContentView extends RelativeLayout implements Themed {
+public class EmptyContentView extends RelativeLayout {
private static final int NO_DESCRIPTION = -1;
@@ -47,12 +45,15 @@ public class EmptyContentView extends RelativeLayout implements Themed {
binding.description.setVisibility(View.VISIBLE);
}
- @Override
- public void applyTheme(int color) {
- final var utils = ThemeUtils.of(color, getContext());
+ public ImageView getImage() {
+ return binding.image;
+ }
+
+ public TextView getTitle() {
+ return binding.title;
+ }
-// utils.platform.colorImageView(binding.image, ColorRole.SECONDARY_CONTAINER);
- utils.platform.colorTextView(binding.title, ColorRole.ON_SURFACE);
- utils.platform.colorTextView(binding.description, ColorRole.ON_SURFACE);
+ public TextView getDescription() {
+ return binding.description;
}
}