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 47a20713..008f8197 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 d3efaacc..e62e6fd1 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 cbdab195..3a7f9937 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 ecd3e583..4cab5fa8 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