From 6810540a294755dcba84c2affb8a737cf78431b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey?= Date: Mon, 7 Nov 2022 15:34:06 +0100 Subject: [PATCH] Color SSO dialog buttons with primary color instead of default m3 violet color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Brey --- .../activity/SsoGrantPermissionActivity.java | 22 ++++++++++++++++++- .../android/utils/theme/ViewThemeUtils.kt | 13 +++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SsoGrantPermissionActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/SsoGrantPermissionActivity.java index 1d6929ae68..af78931244 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SsoGrantPermissionActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/SsoGrantPermissionActivity.java @@ -47,9 +47,14 @@ import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.accounts.AccountUtils; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.utils.EncryptionUtils; +import com.owncloud.android.utils.theme.ViewThemeUtils; import java.util.UUID; +import javax.inject.Inject; + +import androidx.appcompat.app.AlertDialog; + import static com.nextcloud.android.sso.Constants.DELIMITER; import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_ACCESS_DECLINED; import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_NOT_FOUND; @@ -69,10 +74,17 @@ public class SsoGrantPermissionActivity extends BaseActivity { private String packageName; private Account account; + @Inject ViewThemeUtils.Factory themeUtilsFactory; + private ViewThemeUtils viewThemeUtils; + + private AlertDialog dialog; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + viewThemeUtils = themeUtilsFactory.withDefaultSchemes(); + DialogSsoGrantPermissionBinding binding = DialogSsoGrantPermissionBinding.inflate(getLayoutInflater()); ComponentName callingActivity = getCallingActivity(); @@ -102,7 +114,8 @@ public class SsoGrantPermissionActivity extends BaseActivity { .setPositiveButton(R.string.permission_allow, (dialog, which) -> grantPermission()) .setNegativeButton(R.string.permission_deny, (dialog, which) -> exitFailed()); - builder.show(); + dialog = builder.create(); + dialog.show(); Log_OC.v(TAG, "TOKEN-REQUEST: Calling Package: " + packageName); Log_OC.v(TAG, "TOKEN-REQUEST: App Name: " + appName); @@ -113,6 +126,13 @@ public class SsoGrantPermissionActivity extends BaseActivity { } } + @Override + protected void onStart() { + super.onStart(); + viewThemeUtils.platform.colorTextButtons(dialog.getButton(AlertDialog.BUTTON_POSITIVE), + dialog.getButton(AlertDialog.BUTTON_NEGATIVE)); + } + private SpannableStringBuilder makeSpecialPartsBold(String text, String... toBeStyledText) { SpannableStringBuilder ssb = new SpannableStringBuilder(text); for (String textBlock : toBeStyledText) { diff --git a/app/src/main/java/com/owncloud/android/utils/theme/ViewThemeUtils.kt b/app/src/main/java/com/owncloud/android/utils/theme/ViewThemeUtils.kt index 38da91860b..8bb94cf4cb 100644 --- a/app/src/main/java/com/owncloud/android/utils/theme/ViewThemeUtils.kt +++ b/app/src/main/java/com/owncloud/android/utils/theme/ViewThemeUtils.kt @@ -52,4 +52,17 @@ class ViewThemeUtils @Inject constructor( @JvmField val files = FilesSpecificViewThemeUtils(schemes, colorUtil, platform, androidx) + + class Factory @Inject constructor( + private val schemesProvider: MaterialSchemesProvider, + private val colorUtil: ColorUtil + ) { + fun withSchemes(schemes: MaterialSchemes): ViewThemeUtils { + return ViewThemeUtils(schemes, colorUtil) + } + + fun withDefaultSchemes(): ViewThemeUtils { + return withSchemes(schemesProvider.getDefaultMaterialSchemes()) + } + } }