Color SSO dialog buttons with primary color instead of default m3 violet color

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-11-07 15:34:06 +01:00
parent 005cae2072
commit 6810540a29
No known key found for this signature in database
GPG key ID: 2585783189A62105
2 changed files with 34 additions and 1 deletions

View file

@ -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) {

View file

@ -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())
}
}
}