From 72c55255d4a1a9c0dd44190fadff74044ad11e81 Mon Sep 17 00:00:00 2001 From: tom79 Date: Sat, 16 Nov 2019 15:16:36 +0100 Subject: [PATCH] Disable follow button when account is blocking the current one --- .../activities/ShowAccountActivity.java | 25 ++++++++++++++++--- app/src/main/res/values/colors.xml | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/ShowAccountActivity.java b/app/src/main/java/app/fedilab/android/activities/ShowAccountActivity.java index b24c4a314..f53d30499 100644 --- a/app/src/main/java/app/fedilab/android/activities/ShowAccountActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ShowAccountActivity.java @@ -948,15 +948,34 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt private void manageButtonVisibility() { if (relationship == null) return; - account_follow.setEnabled(true); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - account_follow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(ShowAccountActivity.this, R.color.mastodonC4))); + int[][] states = new int[][] { + new int[] { android.R.attr.state_enabled}, // enabled + new int[] {-android.R.attr.state_enabled}, // disabled + new int[] {-android.R.attr.state_checked}, // unchecked + new int[] { android.R.attr.state_pressed} // pressed + }; + + int[] colors = new int[] { + ContextCompat.getColor(ShowAccountActivity.this, R.color.mastodonC4), + ContextCompat.getColor(ShowAccountActivity.this, R.color.mastodonC4___), + ContextCompat.getColor(ShowAccountActivity.this, R.color.mastodonC4), + ContextCompat.getColor(ShowAccountActivity.this, R.color.mastodonC4) + }; + account_follow.setBackgroundTintList(new ColorStateList(states, colors)); } + account_follow.setEnabled(true); if (relationship.isBlocking()) { account_follow.setImageResource(R.drawable.ic_lock_open); doAction = action.UNBLOCK; account_follow.setVisibility(View.VISIBLE); - } else if (relationship.isRequested()) { + } else if (relationship.isBlocked_by()) { + account_follow.setImageResource(R.drawable.ic_user_plus); + account_follow.setVisibility(View.VISIBLE); + account_follow.setEnabled(false); + doAction = action.NOTHING; + }else if (relationship.isRequested()) { account_follow_request.setVisibility(View.VISIBLE); account_follow.setImageResource(R.drawable.ic_hourglass_full); account_follow.setVisibility(View.VISIBLE); diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index ef430ac0b..a79d5dcb7 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -34,6 +34,7 @@ #d9e1e8 #efefef #772b90d9 + #9FBEDD #2b90d9