diff options
author | Álvaro Brey <alvaro.brey@nextcloud.com> | 2022-10-03 13:18:21 +0300 |
---|---|---|
committer | Álvaro Brey <alvaro.brey@nextcloud.com> | 2022-10-03 13:18:21 +0300 |
commit | 09917c0a0b1de628e7df89e14b67436f1e0d86f3 (patch) | |
tree | 14f5443b4978f1c2a652c71f92a5ecf7830a5065 | |
parent | ac34206c92fc07d8e1140878ff82ac8175f12886 (diff) |
WIP: material3 for login screensm3-firstrun
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
5 files changed, 44 insertions, 8 deletions
diff --git a/app/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.java b/app/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.java index 759b0b815f..ca0a3ff39b 100644 --- a/app/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.java +++ b/app/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.java @@ -34,6 +34,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; +import com.nextcloud.android.common.ui.theme.utils.ColorRole; import com.nextcloud.client.account.UserAccountManager; import com.nextcloud.client.appinfo.AppInfo; import com.nextcloud.client.di.Injectable; @@ -47,6 +48,7 @@ import com.owncloud.android.ui.activity.BaseActivity; import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.adapter.FeaturesViewAdapter; import com.owncloud.android.utils.DisplayUtils; +import com.owncloud.android.utils.theme.newm3.ViewThemeUtils; import javax.inject.Inject; @@ -65,6 +67,10 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh @Inject AppPreferences preferences; @Inject AppInfo appInfo; @Inject OnboardingService onboarding; + @Inject ViewThemeUtils.DefaultFactory viewThemeUtilsFactory; + + private ViewThemeUtils viewThemeUtils; + private FirstRunActivityBinding binding; @@ -76,13 +82,20 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh this.binding = FirstRunActivityBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); + // this activity uses the default color from XML, not the server color + viewThemeUtils = viewThemeUtilsFactory.getDefaultViewThemeUtils(); + + + viewThemeUtils.platform.colorViewBackground(binding.container, ColorRole.PRIMARY); + boolean isProviderOrOwnInstallationVisible = getResources().getBoolean(R.bool.show_provider_or_own_installation); setSlideshowSize(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); - binding.login.setBackgroundColor(getResources().getColor(R.color.login_btn_tint)); - binding.login.setTextColor(getResources().getColor(R.color.primary)); + + viewThemeUtils.material.colorMaterialButtonFilledOnPrimary(binding.login); + binding.login.setOnClickListener(v -> { if (getIntent().getBooleanExtra(EXTRA_ALLOW_CLOSE, false)) { @@ -95,8 +108,8 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh }); - binding.signup.setBackgroundColor(getResources().getColor(R.color.primary)); - binding.signup.setTextColor(getResources().getColor(R.color.login_text_color)); + viewThemeUtils.material.colorMaterialButtonOutlinedOnPrimary(binding.signup); + binding.signup.setVisibility(isProviderOrOwnInstallationVisible ? View.VISIBLE : View.GONE); binding.signup.setOnClickListener(v -> { Intent authenticatorActivityIntent = new Intent(this, AuthenticatorActivity.class); @@ -110,7 +123,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh } }); - binding.hostOwnServer.setTextColor(getResources().getColor(R.color.login_text_color)); + viewThemeUtils.platform.colorTextView(binding.hostOwnServer, ColorRole.ON_PRIMARY); binding.hostOwnServer.setVisibility(isProviderOrOwnInstallationVisible ? View.VISIBLE : View.GONE); if (!isProviderOrOwnInstallationVisible) { diff --git a/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java b/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java index fdaf368100..ee07fffac6 100644 --- a/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -120,6 +120,7 @@ import com.owncloud.android.utils.ErrorMessageAdapter; import com.owncloud.android.utils.PermissionUtil; import com.owncloud.android.utils.theme.ThemeDrawableUtils; import com.owncloud.android.utils.theme.ThemeToolbarUtils; +import com.owncloud.android.utils.theme.newm3.ViewThemeUtils; import java.io.InputStream; import java.net.URLDecoder; diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FeatureFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/FeatureFragment.java index defed48e35..2b50ddd930 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FeatureFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FeatureFragment.java @@ -1,6 +1,7 @@ package com.owncloud.android.ui.fragment; import android.content.Context; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.text.SpannableString; import android.text.Spanned; @@ -13,6 +14,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import com.nextcloud.android.common.ui.theme.utils.ColorRole; import com.nextcloud.client.di.Injectable; import com.owncloud.android.R; import com.owncloud.android.features.FeatureItem; @@ -24,11 +26,15 @@ import javax.inject.Inject; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; +import scheme.Scheme; public class FeatureFragment extends Fragment implements Injectable { private FeatureItem item; @Inject ThemeDrawableUtils themeDrawableUtils; + @Inject ViewThemeUtils.DefaultFactory viewThemeUtilsFactory; + + private ViewThemeUtils viewThemeUtils; static public FeatureFragment newInstance(FeatureItem item) { FeatureFragment f = new FeatureFragment(); @@ -41,6 +47,8 @@ public class FeatureFragment extends Fragment implements Injectable { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + viewThemeUtils = viewThemeUtilsFactory.getDefaultViewThemeUtils(); + item = getArguments() != null ? (FeatureItem) getArguments().getParcelable("feature") : null; } @@ -49,18 +57,22 @@ public class FeatureFragment extends Fragment implements Injectable { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + + final Scheme scheme = viewThemeUtils.getScheme(requireContext()); + View view = inflater.inflate(R.layout.whats_new_element, container, false); - int fontColor = getResources().getColor(R.color.login_text_color); + int fontColor = scheme.getOnPrimary(); ImageView whatsNewImage = view.findViewById(R.id.whatsNewImage); if (item.shouldShowImage()) { - whatsNewImage.setImageDrawable(themeDrawableUtils.tintDrawable(item.getImage(), fontColor)); + final Drawable drawable = viewThemeUtils.platform.tintDrawable(getActivity(), item.getImage(), ColorRole.ON_PRIMARY); + whatsNewImage.setImageDrawable(drawable); } TextView whatsNewTitle = view.findViewById(R.id.whatsNewTitle); if (item.shouldShowTitleText()) { whatsNewTitle.setText(item.getTitleText()); - whatsNewTitle.setTextColor(fontColor); + viewThemeUtils.platform.colorTextView(whatsNewTitle, ColorRole.ON_PRIMARY); whatsNewTitle.setVisibility(View.VISIBLE); } else { whatsNewTitle.setVisibility(View.GONE); diff --git a/app/src/main/java/com/owncloud/android/utils/theme/newm3/ViewThemeUtils.kt b/app/src/main/java/com/owncloud/android/utils/theme/newm3/ViewThemeUtils.kt index eaac383043..37aea2f623 100644 --- a/app/src/main/java/com/owncloud/android/utils/theme/newm3/ViewThemeUtils.kt +++ b/app/src/main/java/com/owncloud/android/utils/theme/newm3/ViewThemeUtils.kt @@ -51,4 +51,13 @@ class ViewThemeUtils @Inject constructor( @JvmField val files = FilesSpecificViewThemeUtils(schemes, platform, androidx) + + class DefaultFactory @Inject constructor( + private val colorUtil: ColorUtil, + private val schemesProvider: MaterialSchemesProvider + ) { + fun getDefaultViewThemeUtils(): ViewThemeUtils { + return ViewThemeUtils(schemesProvider.getDefaultMaterialSchemes(), colorUtil) + } + } } diff --git a/app/src/main/res/layout/first_run_activity.xml b/app/src/main/res/layout/first_run_activity.xml index 0935b92667..2b76b2edfc 100644 --- a/app/src/main/res/layout/first_run_activity.xml +++ b/app/src/main/res/layout/first_run_activity.xml @@ -21,6 +21,7 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> |