From 45ae9ed0ef106e3fbf228fa04be358fbcc4b4683 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Sat, 5 Aug 2017 10:09:17 +0200 Subject: [PATCH] show if an account follows you back in AccountActivity --- .../keylesspalace/tusky/AccountActivity.java | 23 ++++++++++++------- app/src/main/res/layout/activity_account.xml | 22 ++++++++++++++---- app/src/main/res/values-de/strings.xml | 3 +++ app/src/main/res/values/strings.xml | 3 +++ 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index c0287e04..3c2fec8b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -84,6 +84,7 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit private ImageView header; private FloatingActionButton floatingBtn; private Button followBtn; + private TextView followsYouView; private TabLayout tabLayout; private ImageView accountLockedView; private View container; @@ -99,6 +100,7 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit header = (ImageView) findViewById(R.id.account_header); floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn); followBtn = (Button) findViewById(R.id.follow_btn); + followsYouView = (TextView) findViewById(R.id.account_follows_you); tabLayout = (TabLayout) findViewById(R.id.tab_layout); accountLockedView = (ImageView) findViewById(R.id.account_locked); container = findViewById(R.id.activity_account); @@ -179,6 +181,7 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit // Initialise the default UI states. floatingBtn.hide(); followBtn.setVisibility(View.GONE); + followsYouView.setVisibility(View.GONE); // Obtain information to fill out the profile. obtainAccount(); @@ -340,8 +343,7 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit Response> response) { if (response.isSuccessful()) { Relationship relationship = response.body().get(0); - onObtainRelationshipsSuccess(relationship.requested, relationship.following, - relationship.blocking, relationship.muting); + onObtainRelationshipsSuccess(relationship); } else { onObtainRelationshipsFailure(new Exception(response.message())); } @@ -354,22 +356,27 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit }); } - private void onObtainRelationshipsSuccess(boolean followRequested, boolean following, - boolean blocking, boolean muting) { - if (following) { + private void onObtainRelationshipsSuccess(Relationship relation) { + if (relation.following) { followState = FollowState.FOLLOWING; - } else if (followRequested) { + } else if (relation.requested) { followState = FollowState.REQUESTED; } else { followState = FollowState.NOT_FOLLOWING; } - this.blocking = blocking; - this.muting = muting; + this.blocking = relation.blocking; + this.muting = relation.muting; if (followState != FollowState.NOT_FOLLOWING || !blocking || !muting) { invalidateOptionsMenu(); } + if(relation.followedBy) { + followsYouView.setVisibility(View.VISIBLE); + } else { + followsYouView.setVisibility(View.GONE); + } + updateButtons(); } diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index ca81039a..e0197e9d 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -58,22 +58,34 @@ android:id="@+id/account_avatar" android:layout_width="80dp" android:layout_height="80dp" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" android:layout_marginEnd="10dp" android:layout_marginRight="10dp" - android:src="@drawable/avatar_default" - android:layout_alignParentStart="true" - android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/follow_btn" android:layout_toStartOf="@+id/follow_btn" + android:src="@drawable/avatar_default" app:shadow="true" />