mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 06:35:48 +03:00
AuthenticatorActivity: after login, immediately cache color in OCCapability
Needed to draw the next screen correctly Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
cb6a832afb
commit
2bf3cbe473
5 changed files with 22 additions and 7 deletions
|
@ -354,7 +354,7 @@ dependencies {
|
||||||
gplayImplementation "com.google.firebase:firebase-messaging:23.0.7"
|
gplayImplementation "com.google.firebase:firebase-messaging:23.0.7"
|
||||||
|
|
||||||
// TODO change back to tag before merging
|
// TODO change back to tag before merging
|
||||||
implementation 'com.github.nextcloud.android-common:ui:802c404'
|
implementation 'com.github.nextcloud.android-common:ui:8e65fb0'
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
package com.nextcloud.client.di
|
package com.nextcloud.client.di
|
||||||
|
|
||||||
import com.nextcloud.android.common.ui.theme.MaterialSchemes
|
import com.nextcloud.android.common.ui.theme.MaterialSchemes
|
||||||
import com.owncloud.android.utils.theme.ThemeColorUtils
|
|
||||||
import com.owncloud.android.utils.theme.ThemeUtils
|
|
||||||
import com.owncloud.android.utils.theme.MaterialSchemesProvider
|
import com.owncloud.android.utils.theme.MaterialSchemesProvider
|
||||||
import com.owncloud.android.utils.theme.MaterialSchemesProviderImpl
|
import com.owncloud.android.utils.theme.MaterialSchemesProviderImpl
|
||||||
|
import com.owncloud.android.utils.theme.ThemeColorUtils
|
||||||
|
import com.owncloud.android.utils.theme.ThemeUtils
|
||||||
import dagger.Binds
|
import dagger.Binds
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
|
|
|
@ -75,6 +75,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.blikoon.qrcodescanner.QrCodeActivity;
|
import com.blikoon.qrcodescanner.QrCodeActivity;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
import com.nextcloud.android.common.ui.color.ColorUtil;
|
||||||
import com.nextcloud.client.account.User;
|
import com.nextcloud.client.account.User;
|
||||||
import com.nextcloud.client.account.UserAccountManager;
|
import com.nextcloud.client.account.UserAccountManager;
|
||||||
import com.nextcloud.client.device.DeviceInfo;
|
import com.nextcloud.client.device.DeviceInfo;
|
||||||
|
@ -118,6 +119,7 @@ import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertL
|
||||||
import com.owncloud.android.utils.DisplayUtils;
|
import com.owncloud.android.utils.DisplayUtils;
|
||||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||||
import com.owncloud.android.utils.PermissionUtil;
|
import com.owncloud.android.utils.PermissionUtil;
|
||||||
|
import com.owncloud.android.utils.theme.CapabilityUtils;
|
||||||
import com.owncloud.android.utils.theme.ViewThemeUtils;
|
import com.owncloud.android.utils.theme.ViewThemeUtils;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -233,6 +235,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
@Inject DeviceInfo deviceInfo;
|
@Inject DeviceInfo deviceInfo;
|
||||||
@Inject PassCodeManager passCodeManager;
|
@Inject PassCodeManager passCodeManager;
|
||||||
@Inject ViewThemeUtils viewThemeUtils;
|
@Inject ViewThemeUtils viewThemeUtils;
|
||||||
|
@Inject ColorUtil colorUtil;
|
||||||
|
|
||||||
private boolean onlyAdd = false;
|
private boolean onlyAdd = false;
|
||||||
@SuppressLint("ResourceAsColor") @ColorInt
|
@SuppressLint("ResourceAsColor") @ColorInt
|
||||||
|
@ -1129,6 +1132,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
accountManager.setCurrentOwnCloudAccount(mAccount.name);
|
accountManager.setCurrentOwnCloudAccount(mAccount.name);
|
||||||
|
setupColorCapability();
|
||||||
if (onlyAdd) {
|
if (onlyAdd) {
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1188,6 +1192,17 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caches a fake OCCapability with only the server color, so that it is immediately available for drawing the next
|
||||||
|
* screens
|
||||||
|
*/
|
||||||
|
private void setupColorCapability() {
|
||||||
|
final OCCapability colorCapability = new OCCapability();
|
||||||
|
colorCapability.setServerColor(colorUtil.colorToHexString(primaryColor));
|
||||||
|
colorCapability.setAccountName(mAccount.name);
|
||||||
|
CapabilityUtils.updateCapability(colorCapability);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the authentication token.
|
* Updates the authentication token.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -38,6 +38,7 @@ import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.ActionBar
|
import androidx.appcompat.app.ActionBar
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
|
import com.nextcloud.android.common.ui.color.ColorUtil
|
||||||
import com.nextcloud.android.common.ui.theme.MaterialSchemes
|
import com.nextcloud.android.common.ui.theme.MaterialSchemes
|
||||||
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
|
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
|
||||||
import com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils
|
import com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils
|
||||||
|
@ -52,6 +53,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
class FilesSpecificViewThemeUtils @Inject constructor(
|
class FilesSpecificViewThemeUtils @Inject constructor(
|
||||||
schemes: MaterialSchemes,
|
schemes: MaterialSchemes,
|
||||||
|
private val colorUtil: ColorUtil,
|
||||||
private val androidViewThemeUtils: AndroidViewThemeUtils,
|
private val androidViewThemeUtils: AndroidViewThemeUtils,
|
||||||
private val androidXViewThemeUtils: AndroidXViewThemeUtils
|
private val androidXViewThemeUtils: AndroidXViewThemeUtils
|
||||||
) : ViewThemeUtilsBase(schemes) {
|
) : ViewThemeUtilsBase(schemes) {
|
||||||
|
@ -230,7 +232,7 @@ class FilesSpecificViewThemeUtils @Inject constructor(
|
||||||
|
|
||||||
fun primaryColorToHexString(context: Context): String {
|
fun primaryColorToHexString(context: Context): String {
|
||||||
return withScheme(context) { scheme ->
|
return withScheme(context) { scheme ->
|
||||||
String.format("#%06X", HEX_WHITE and scheme.primary)
|
colorUtil.colorToHexString(scheme.primary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,8 +245,6 @@ class FilesSpecificViewThemeUtils @Inject constructor(
|
||||||
companion object {
|
companion object {
|
||||||
private val TAG = FilesSpecificViewThemeUtils::class.simpleName
|
private val TAG = FilesSpecificViewThemeUtils::class.simpleName
|
||||||
|
|
||||||
private const val HEX_WHITE = 0xFFFFFF
|
|
||||||
|
|
||||||
private object AvatarPadding {
|
private object AvatarPadding {
|
||||||
@Px
|
@Px
|
||||||
const val SMALL = 4
|
const val SMALL = 4
|
||||||
|
|
|
@ -51,5 +51,5 @@ class ViewThemeUtils @Inject constructor(
|
||||||
val dialog = DialogViewThemeUtils(schemes)
|
val dialog = DialogViewThemeUtils(schemes)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val files = FilesSpecificViewThemeUtils(schemes, platform, androidx)
|
val files = FilesSpecificViewThemeUtils(schemes, colorUtil, platform, androidx)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue