mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix some color issues
This commit is contained in:
parent
e7dd79d8e0
commit
5b9534adc2
4 changed files with 58 additions and 8 deletions
|
@ -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));
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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<RecyclerView.ViewHolder
|
|||
accountViewHolder.binding.followAction.setIconResource(R.drawable.ic_baseline_person_add_24);
|
||||
accountViewHolder.binding.followAction.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(context, R.color.cyanea_accent_dark_reference)));
|
||||
}
|
||||
ThemeHelper.changeColorOutlineButton(context, accountViewHolder.binding.block);
|
||||
ThemeHelper.changeColorOutlineButton(context, accountViewHolder.binding.mute);
|
||||
ThemeHelper.changeColorOutlineButton(context, accountViewHolder.binding.muteNotification);
|
||||
ThemeHelper.changeColorOutlineButton(context, accountViewHolder.binding.muteTimed);
|
||||
|
||||
|
||||
if (account.relationShip.blocking) {
|
||||
|
|
Loading…
Reference in a new issue