|
@@ -2,7 +2,9 @@
|
|
|
* ownCloud Android client application
|
|
|
*
|
|
|
* @author Andy Scherzinger
|
|
|
+ * @author TSI-mc
|
|
|
* Copyright (C) 2016 ownCloud Inc.
|
|
|
+ * Copyright (C) 2023 TSI-mc
|
|
|
*
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
* it under the terms of the GNU General Public License version 2,
|
|
@@ -21,10 +23,7 @@ package com.owncloud.android.ui.adapter;
|
|
|
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
-import android.content.res.Configuration;
|
|
|
import android.content.res.Resources;
|
|
|
-import android.graphics.Color;
|
|
|
-import android.graphics.PorterDuff;
|
|
|
import android.graphics.Typeface;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.net.Uri;
|
|
@@ -35,6 +34,7 @@ import android.text.style.ForegroundColorSpan;
|
|
|
import android.text.style.StyleSpan;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
@@ -46,6 +46,7 @@ import com.bumptech.glide.load.model.StreamEncoder;
|
|
|
import com.bumptech.glide.load.resource.file.FileToStreamDecoder;
|
|
|
import com.caverock.androidsvg.SVG;
|
|
|
import com.google.android.material.button.MaterialButton;
|
|
|
+import com.nextcloud.android.common.ui.theme.utils.ColorRole;
|
|
|
import com.owncloud.android.R;
|
|
|
import com.owncloud.android.databinding.NotificationListItemBinding;
|
|
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
|
@@ -68,6 +69,7 @@ import java.util.List;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
import androidx.appcompat.widget.PopupMenu;
|
|
|
+import androidx.core.content.res.ResourcesCompat;
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
/**
|
|
@@ -141,20 +143,22 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- holder.binding.message.setText(notification.getMessage());
|
|
|
+ if (notification.getMessage() != null && !notification.getMessage().isEmpty()) {
|
|
|
+ holder.binding.message.setText(notification.getMessage());
|
|
|
+ holder.binding.message.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ holder.binding.message.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
|
|
|
if (!TextUtils.isEmpty(notification.getIcon())) {
|
|
|
downloadIcon(notification.getIcon(), holder.binding.icon, notificationsActivity);
|
|
|
}
|
|
|
|
|
|
- int nightModeFlag =
|
|
|
- notificationsActivity.getResources().getConfiguration().uiMode
|
|
|
- & Configuration.UI_MODE_NIGHT_MASK;
|
|
|
- if (Configuration.UI_MODE_NIGHT_YES == nightModeFlag) {
|
|
|
- holder.binding.icon.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
|
|
|
- } else {
|
|
|
- holder.binding.icon.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
|
|
|
- }
|
|
|
+ viewThemeUtils.platform.colorImageView(holder.binding.icon, ColorRole.ON_SURFACE_VARIANT);
|
|
|
+ viewThemeUtils.platform.colorImageView(holder.binding.dismiss, ColorRole.ON_SURFACE_VARIANT);
|
|
|
+ viewThemeUtils.platform.colorTextView(holder.binding.subject, ColorRole.ON_SURFACE);
|
|
|
+ viewThemeUtils.platform.colorTextView(holder.binding.message, ColorRole.ON_SURFACE_VARIANT);
|
|
|
+ viewThemeUtils.platform.colorTextView(holder.binding.datetime, ColorRole.ON_SURFACE_VARIANT);
|
|
|
|
|
|
setButtons(holder, notification);
|
|
|
|
|
@@ -172,13 +176,19 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
|
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
|
LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
|
params.setMargins(
|
|
|
- resources.getDimensionPixelOffset(R.dimen.standard_half_margin),
|
|
|
+ resources.getDimensionPixelOffset(R.dimen.standard_quarter_margin),
|
|
|
0,
|
|
|
resources.getDimensionPixelOffset(R.dimen.standard_half_margin),
|
|
|
0);
|
|
|
|
|
|
List<Action> overflowActions = new ArrayList<>();
|
|
|
|
|
|
+ if (notification.getActions().size() > 0) {
|
|
|
+ holder.binding.buttons.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ holder.binding.buttons.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
if (notification.getActions().size() > 2) {
|
|
|
for (Action action : notification.getActions()) {
|
|
|
if (action.primary) {
|
|
@@ -217,7 +227,10 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
|
|
|
|
|
|
// further actions
|
|
|
final MaterialButton moreButton = new MaterialButton(notificationsActivity);
|
|
|
- viewThemeUtils.material.colorMaterialButtonPrimaryTonal(moreButton);
|
|
|
+ moreButton.setBackgroundColor(ResourcesCompat.getColor(resources,
|
|
|
+ android.R.color.transparent,
|
|
|
+ null));
|
|
|
+ viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(moreButton);
|
|
|
|
|
|
moreButton.setAllCaps(false);
|
|
|
|
|
@@ -262,7 +275,10 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
|
|
|
if (action.primary) {
|
|
|
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(button);
|
|
|
} else {
|
|
|
- viewThemeUtils.material.colorMaterialButtonPrimaryTonal(button);
|
|
|
+ button.setBackgroundColor(ResourcesCompat.getColor(resources,
|
|
|
+ android.R.color.transparent,
|
|
|
+ null));
|
|
|
+ viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(button);
|
|
|
}
|
|
|
|
|
|
button.setAllCaps(false);
|
|
@@ -271,7 +287,6 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
|
|
|
button.setCornerRadiusResource(R.dimen.button_corner_radius);
|
|
|
|
|
|
button.setLayoutParams(params);
|
|
|
- button.setGravity(Gravity.CENTER);
|
|
|
|
|
|
button.setOnClickListener(v -> {
|
|
|
setButtonEnabled(holder, false);
|