From 5b9534adc2643bb23245263210756483f13d7faf Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 14 Nov 2022 15:15:29 +0100 Subject: [PATCH] Fix some color issues --- .../activities/EditProfileActivity.java | 12 +++++++ .../android/activities/ProfileActivity.java | 17 ++++++---- .../fedilab/android/helper/ThemeHelper.java | 32 ++++++++++++++++++- .../android/ui/drawer/AccountAdapter.java | 5 +++ 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java b/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java index 47a20713b..008f8197a 100644 --- a/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java @@ -32,6 +32,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; import androidx.lifecycle.ViewModelProvider; import androidx.localbroadcastmanager.content.LocalBroadcastManager; @@ -181,6 +182,17 @@ public class EditProfileActivity extends BaseActivity { binding.addField.setVisibility(View.GONE); } }); + + ThemeHelper.changeColorOutlineButton(EditProfileActivity.this, binding.visibilityPublic); + ThemeHelper.changeColorOutlineButton(EditProfileActivity.this, binding.visibilityUnlisted); + ThemeHelper.changeColorOutlineButton(EditProfileActivity.this, binding.visibilityPrivate); + ThemeHelper.changeColorOutlineButton(EditProfileActivity.this, binding.visibilityDirect); + DrawableCompat.setTintList(DrawableCompat.wrap(binding.bot.getThumbDrawable()), ThemeHelper.getSwitchCompatThumbDrawable(EditProfileActivity.this)); + DrawableCompat.setTintList(DrawableCompat.wrap(binding.discoverable.getThumbDrawable()), ThemeHelper.getSwitchCompatThumbDrawable(EditProfileActivity.this)); + DrawableCompat.setTintList(DrawableCompat.wrap(binding.sensitive.getThumbDrawable()), ThemeHelper.getSwitchCompatThumbDrawable(EditProfileActivity.this)); + ThemeHelper.changeColorOutlineButton(EditProfileActivity.this, binding.locked); + ThemeHelper.changeColorOutlineButton(EditProfileActivity.this, binding.unlocked); + //Actions with the activity accountsVM = new ViewModelProvider(EditProfileActivity.this).get(AccountsVM.class); binding.headerSelect.setOnClickListener(view -> startActivityForResult(prepareIntent(), EditProfileActivity.PICK_MEDIA_HEADER)); diff --git a/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java b/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java index d3efaacc3..e62e6fd1b 100644 --- a/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java @@ -486,12 +486,7 @@ public class ProfileActivity extends BaseActivity { if (currentAccount == null || account == null) { return; } - //The value for account is from same server so id can be used - if (account.id.equals(currentAccount.user_id)) { - binding.accountFollow.setVisibility(View.GONE); - binding.headerEditProfile.setVisibility(View.VISIBLE); - binding.headerEditProfile.bringToFront(); - } + //Manage indentity proofs if not yet displayed if (identityProofList != null && identityProofList.size() > 0) { @@ -515,7 +510,7 @@ public class ProfileActivity extends BaseActivity { } } binding.accountFollow.setBackgroundTintList(ThemeHelper.getButtonActionColorStateList(ProfileActivity.this)); - binding.headerEditProfile.setBackgroundTintList(ThemeHelper.getButtonActionColorStateList(ProfileActivity.this)); + binding.accountFollow.setEnabled(true); //Visibility depending of the relationship if (relationship != null) { @@ -556,6 +551,14 @@ public class ProfileActivity extends BaseActivity { binding.accountFollow.setVisibility(View.VISIBLE); binding.accountFollow.setContentDescription(getString(R.string.action_follow)); } + //The value for account is from same server so id can be used + + if (account.id.equals(currentAccount.user_id)) { + binding.accountFollow.setVisibility(View.GONE); + binding.headerEditProfile.setVisibility(View.VISIBLE); + binding.headerEditProfile.bringToFront(); + } + binding.headerEditProfile.setBackgroundTintList(ThemeHelper.getButtonActionColorStateList(ProfileActivity.this)); if (!relationship.following) { binding.accountNotification.setVisibility(View.GONE); } else { diff --git a/app/src/main/java/app/fedilab/android/helper/ThemeHelper.java b/app/src/main/java/app/fedilab/android/helper/ThemeHelper.java index cbdab195c..3a7f9937c 100644 --- a/app/src/main/java/app/fedilab/android/helper/ThemeHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/ThemeHelper.java @@ -363,7 +363,7 @@ public class ThemeHelper { new int[]{-android.R.attr.state_checked}, }; int alphaColor = ColorUtils.setAlphaComponent(ContextCompat.getColor(context, R.color.cyanea_accent_dark_reference), 0xee); - int alphaColorUnchecked = ColorUtils.setAlphaComponent(getAttColor(context, R.attr.mTextColor), 0xaa); + int alphaColorUnchecked = ColorUtils.setAlphaComponent(getAttColor(context, R.attr.mTextColor), 0xee); int[] colors = new int[]{ alphaColor, alphaColorUnchecked @@ -409,6 +409,36 @@ public class ThemeHelper { return new ColorStateList(states, colors); } + + public static void changeColorOutlineButton(Context context, MaterialButton materialButton) { + if (materialButton != null) { + materialButton.setStrokeColor(ThemeHelper.getButtonOutlineColorStateList(context)); + materialButton.setRippleColor(ThemeHelper.getButtonOutlineColorStateList(context)); + materialButton.setIconTint(ThemeHelper.getButtonOutlineColorStateList(context)); + materialButton.setTextColor(ThemeHelper.getButtonOutlineColorStateList(context)); + } + } + + /** + * Allow to set colors for Material buttons inside a toggle group + * + * @param context - Context + * @return - ColorStateList + */ + public static ColorStateList getButtonOutlineColorStateList(Context context) { + int[][] states = new int[][]{ + new int[]{android.R.attr.state_checked}, + new int[]{-android.R.attr.state_checked}, + }; + int alphaColorUnchecked = ColorUtils.setAlphaComponent(getAttColor(context, R.attr.mTextColor), 0xaa); + int[] colors = new int[]{ + ContextCompat.getColor(context, R.color.cyanea_accent_dark_reference), + alphaColorUnchecked + }; + return new ColorStateList(states, colors); + } + + /** * Allow to set background colors for Material buttons inside a toggle group * diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java index ecd3e5833..4cab5fa89 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java @@ -48,6 +48,7 @@ import app.fedilab.android.client.entities.api.Account; import app.fedilab.android.databinding.DrawerAccountBinding; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.MastodonHelper; +import app.fedilab.android.helper.ThemeHelper; import app.fedilab.android.viewmodel.mastodon.AccountsVM; import es.dmoral.toasty.Toasty; @@ -110,6 +111,10 @@ public class AccountAdapter extends RecyclerView.Adapter