From 2a2c01f09477199b7e88e8bc028b8f6fc18e17ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey?= Date: Tue, 4 Oct 2022 12:02:57 +0200 Subject: [PATCH] Use Material3 colors for loading dialogs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Brey --- .../ui/dialog/IndeterminateProgressDialog.java | 15 +++++---------- .../owncloud/android/ui/dialog/LoadingDialog.java | 6 +++--- app/src/main/res/values/styles.xml | 1 + 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java b/app/src/main/java/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java index 67b1f4e1c7..56dcb9ebdc 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java +++ b/app/src/main/java/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java @@ -29,7 +29,7 @@ import android.widget.ProgressBar; import com.nextcloud.client.di.Injectable; import com.owncloud.android.R; -import com.owncloud.android.utils.theme.ThemeColorUtils; +import com.owncloud.android.utils.theme.newm3.ViewThemeUtils; import javax.inject.Inject; @@ -42,7 +42,7 @@ public class IndeterminateProgressDialog extends DialogFragment implements Injec private static final String ARG_MESSAGE_ID = IndeterminateProgressDialog.class.getCanonicalName() + ".ARG_MESSAGE_ID"; private static final String ARG_CANCELABLE = IndeterminateProgressDialog.class.getCanonicalName() + ".ARG_CANCELABLE"; - @Inject ThemeColorUtils themeColorUtils; + @Inject ViewThemeUtils viewThemeUtils; /** * Public factory method to get dialog instances. @@ -71,14 +71,9 @@ public class IndeterminateProgressDialog extends DialogFragment implements Injec /// create indeterminate progress dialog final ProgressDialog progressDialog = new ProgressDialog(getActivity(), R.style.ProgressDialogTheme); progressDialog.setIndeterminate(true); - progressDialog.setOnShowListener(new DialogInterface.OnShowListener() { - @Override - public void onShow(DialogInterface dialog) { - ProgressBar v = progressDialog.findViewById(android.R.id.progress); - v.getIndeterminateDrawable().setColorFilter(themeColorUtils.primaryAccentColor(getContext()), - android.graphics.PorterDuff.Mode.MULTIPLY); - - } + progressDialog.setOnShowListener(dialog -> { + ProgressBar v = progressDialog.findViewById(android.R.id.progress); + viewThemeUtils.platform.tintDrawable(requireContext(), v.getIndeterminateDrawable()); }); /// set message diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/LoadingDialog.java b/app/src/main/java/com/owncloud/android/ui/dialog/LoadingDialog.java index c4eeb3b308..59da33e080 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/LoadingDialog.java +++ b/app/src/main/java/com/owncloud/android/ui/dialog/LoadingDialog.java @@ -31,6 +31,7 @@ import android.widget.TextView; import com.nextcloud.client.di.Injectable; import com.owncloud.android.R; import com.owncloud.android.utils.theme.ThemeColorUtils; +import com.owncloud.android.utils.theme.newm3.ViewThemeUtils; import javax.inject.Inject; @@ -39,7 +40,7 @@ import androidx.fragment.app.DialogFragment; public class LoadingDialog extends DialogFragment implements Injectable { - @Inject ThemeColorUtils themeColorUtils; + @Inject ViewThemeUtils viewThemeUtils; private String mMessage; @Override @@ -66,8 +67,7 @@ public class LoadingDialog extends DialogFragment implements Injectable { // set progress wheel color ProgressBar progressBar = v.findViewById(R.id.loadingBar); - progressBar.getIndeterminateDrawable().setColorFilter(themeColorUtils.primaryAccentColor(getContext()), - PorterDuff.Mode.SRC_IN); + viewThemeUtils.platform.tintDrawable(requireContext(), progressBar.getIndeterminateDrawable()); return v; } diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f1fd266752..0655798acc 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -168,6 +168,7 @@