Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/src/main/java/com/nextcloud/client/di/ThemeModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package com.nextcloud.client.di
import com.nextcloud.android.common.ui.theme.MaterialSchemes
import com.owncloud.android.utils.theme.MaterialSchemesProvider
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.Module
Expand All @@ -25,10 +24,6 @@ internal abstract class ThemeModule {

companion object {

@Provides
@Singleton
fun themeColorUtils(): ThemeColorUtils = ThemeColorUtils()

@Provides
@Singleton
fun themeUtils(): ThemeUtils = ThemeUtils()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import com.nextcloud.android.common.core.utils.ecosystem.EcosystemApp;
import com.nextcloud.android.common.core.utils.ecosystem.EcosystemManager;
import com.nextcloud.android.common.ui.theme.utils.ColorRole;
import com.nextcloud.android.common.ui.color.ColorUtil;
import com.nextcloud.client.account.User;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.files.DeepLinkConstants;
Expand Down Expand Up @@ -406,17 +407,31 @@ private void setupQuotaElement() {

public void updateHeader() {
final var account = getAccount();
ColorUtil colorUtil = new ColorUtil(this);
boolean isClientBranded = getResources().getBoolean(R.bool.is_branded_client);
final OCCapability capability = getCapabilities();

if (capability != null && account != null && capability.getServerBackground() != null && !isClientBranded) {
int primaryColor = themeColorUtils.unchangedPrimaryColor(account, this);
String serverColor = capability.getServerColor();
int primaryColor = colorUtil.getNullSafeColorWithFallbackRes(serverColor, R.color.primary);
String serverLogoURL = capability.getServerLogo();

// set background to primary color
LinearLayout drawerHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_view);
drawerHeader.setBackgroundColor(primaryColor);

// set header server name text color to high-contrast against background
TextView serverNameView = mNavigationViewHeader.findViewById(R.id.drawer_header_server_name);
if (serverNameView != null && serverNameView.getVisibility() == View.VISIBLE) {
int fontColor;
if (Hct.fromInt(primaryColor).getTone() < 80.0) {
fontColor = Color.WHITE;
} else {
fontColor = getColor(R.color.text_color);
}
serverNameView.setTextColor(fontColor);
}

if (!TextUtils.isEmpty(serverLogoURL) && URLUtil.isValidUrl(serverLogoURL)) {
Target<Drawable> target = createSVGLogoTarget(primaryColor, capability);
getClientRepository().getNextcloudClient(nextcloudClient -> {
Expand Down Expand Up @@ -496,6 +511,7 @@ private void showTopBanner(ConstraintLayout banner) {
LinearLayout talkView = banner.findViewById(R.id.drawer_ecosystem_talk);
LinearLayout moreView = banner.findViewById(R.id.drawer_ecosystem_more);
LinearLayout assistantView = banner.findViewById(R.id.drawer_ecosystem_assistant);
final OCCapability capability = getCapabilities();

final var optionalUser = getUser();
if (optionalUser.isPresent()) {
Expand All @@ -506,7 +522,7 @@ private void showTopBanner(ConstraintLayout banner) {

moreView.setOnClickListener(v -> LinkHelper.INSTANCE.openAppStore("Nextcloud", true, this));
assistantView.setOnClickListener(v -> startAssistantScreen());
if (getCapabilities() != null && getCapabilities().getAssistant().isTrue()) {
if (capability != null && capability.getAssistant().isTrue()) {
assistantView.setVisibility(View.VISIBLE);
} else {
assistantView.setVisibility(View.GONE);
Expand All @@ -516,8 +532,10 @@ private void showTopBanner(ConstraintLayout banner) {

int iconColor;
final var account = getAccount();
ColorUtil colorUtil = new ColorUtil(this);
if (account != null) {
int primaryColor = themeColorUtils.unchangedPrimaryColor(account, this);
String serverColor = capability.getServerColor();
int primaryColor = colorUtil.getNullSafeColorWithFallbackRes(serverColor, R.color.primary);
if (Hct.fromInt(primaryColor).getTone() < 80.0) {
iconColor = Color.WHITE;
} else {
Expand Down Expand Up @@ -548,9 +566,26 @@ private void setDrawerHeaderLogo(Drawable drawable, String serverName) {
TextView serverNameView = mNavigationViewHeader.findViewById(R.id.drawer_header_server_name);
serverNameView.setVisibility(View.VISIBLE);
serverNameView.setText(serverName);
serverNameView.setTextColor(themeColorUtils.unchangedFontColor(this));
}

final var account = getAccount();
final OCCapability capability = getCapabilities();
int fontColor = getColor(R.color.text_color); // fallback

if (account != null && capability != null) {
ColorUtil colorUtil = new ColorUtil(this);
String serverColor = capability.getServerColor();
int primaryColor = colorUtil.getNullSafeColorWithFallbackRes(serverColor, R.color.primary);

// Choose an appropriate font color based on contrast/tone of primaryColor
if (Hct.fromInt(primaryColor).getTone() < 80.0) {
fontColor = Color.WHITE;
} else {
fontColor = getColor(R.color.text_color);
}
}

serverNameView.setTextColor(fontColor);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.fragment.OCFileListFragment;
import com.owncloud.android.ui.fragment.SearchType;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeUtils;
import com.owncloud.android.utils.theme.ViewThemeUtils;

Expand Down Expand Up @@ -74,7 +73,6 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
private boolean isHomeSearchToolbarShow = false;
private static final String TAG = "ToolbarActivity";

@Inject public ThemeColorUtils themeColorUtils;
@Inject public ThemeUtils themeUtils;
@Inject public ViewThemeUtils viewThemeUtils;

Expand Down

This file was deleted.

Loading