1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-15 19:27:31 +00:00

Fix FriendshipStatus variable names

This commit is contained in:
Ammar Githam 2021-05-23 20:17:52 +09:00
parent 51f3a348b7
commit c784ca937d
3 changed files with 26 additions and 27 deletions

View File

@ -397,7 +397,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
if (blockMenuItem != null) { if (blockMenuItem != null) {
if (isNotMe) { if (isNotMe) {
blockMenuItem.setVisible(true); blockMenuItem.setVisible(true);
blockMenuItem.setTitle(profileModel.getFriendshipStatus().isBlocking() ? R.string.unblock : R.string.block); blockMenuItem.setTitle(profileModel.getFriendshipStatus().getBlocking() ? R.string.unblock : R.string.block);
} else { } else {
blockMenuItem.setVisible(false); blockMenuItem.setVisible(false);
} }
@ -424,7 +424,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
if (mutePostsMenuItem != null) { if (mutePostsMenuItem != null) {
if (isNotMe) { if (isNotMe) {
mutePostsMenuItem.setVisible(true); mutePostsMenuItem.setVisible(true);
mutePostsMenuItem.setTitle(profileModel.getFriendshipStatus().isMuting() ? R.string.mute_posts : R.string.unmute_posts); mutePostsMenuItem.setTitle(profileModel.getFriendshipStatus().getMuting() ? R.string.mute_posts : R.string.unmute_posts);
} else { } else {
mutePostsMenuItem.setVisible(false); mutePostsMenuItem.setVisible(false);
} }
@ -435,7 +435,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
removeFollowerMenuItem = menu.findItem(R.id.remove_follower); removeFollowerMenuItem = menu.findItem(R.id.remove_follower);
if (removeFollowerMenuItem != null) { if (removeFollowerMenuItem != null) {
removeFollowerMenuItem.setVisible(isNotMe && profileModel.getFriendshipStatus().isFollowedBy()); removeFollowerMenuItem.setVisible(isNotMe && profileModel.getFriendshipStatus().getFollowedBy());
} }
} }
@ -467,7 +467,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
if (item.getItemId() == R.id.block) { if (item.getItemId() == R.id.block) {
if (!isLoggedIn) return false; if (!isLoggedIn) return false;
friendshipService.changeBlock(profileModel.getFriendshipStatus().isBlocking(), profileModel.getPk(), changeCb); friendshipService.changeBlock(profileModel.getFriendshipStatus().getBlocking(), profileModel.getPk(), changeCb);
return true; return true;
} }
if (item.getItemId() == R.id.chaining) { if (item.getItemId() == R.id.chaining) {
@ -490,9 +490,9 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
if (item.getItemId() == R.id.mute_posts) { if (item.getItemId() == R.id.mute_posts) {
if (!isLoggedIn) return false; if (!isLoggedIn) return false;
final String action = profileModel.getFriendshipStatus().isMuting() ? "Unmute stories" : "Mute stories"; final String action = profileModel.getFriendshipStatus().getMuting() ? "Unmute stories" : "Mute stories";
friendshipService.changeMute( friendshipService.changeMute(
profileModel.getFriendshipStatus().isMuting(), profileModel.getFriendshipStatus().getMuting(),
profileModel.getPk(), profileModel.getPk(),
false, false,
changeCb); changeCb);
@ -935,24 +935,23 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
profileDetailsBinding.btnFollow.setVisibility(View.VISIBLE); profileDetailsBinding.btnFollow.setVisibility(View.VISIBLE);
final Context context = getContext(); final Context context = getContext();
if (context == null) return; if (context == null) return;
if (profileModel.getFriendshipStatus().isFollowing() || profileModel.getFriendshipStatus().isFollowedBy()) { if (profileModel.getFriendshipStatus().getFollowing() || profileModel.getFriendshipStatus().getFollowedBy()) {
profileDetailsBinding.mainStatus.setVisibility(View.VISIBLE); profileDetailsBinding.mainStatus.setVisibility(View.VISIBLE);
if (!profileModel.getFriendshipStatus().isFollowing()) { if (!profileModel.getFriendshipStatus().getFollowing()) {
profileDetailsBinding.mainStatus.setChipBackgroundColor(AppCompatResources.getColorStateList(context, R.color.blue_800)); profileDetailsBinding.mainStatus.setChipBackgroundColor(AppCompatResources.getColorStateList(context, R.color.blue_800));
profileDetailsBinding.mainStatus.setText(R.string.status_follower); profileDetailsBinding.mainStatus.setText(R.string.status_follower);
} else if (!profileModel.getFriendshipStatus().isFollowedBy()) { } else if (!profileModel.getFriendshipStatus().getFollowedBy()) {
profileDetailsBinding.mainStatus.setChipBackgroundColor(AppCompatResources.getColorStateList(context, R.color.deep_orange_800)); profileDetailsBinding.mainStatus.setChipBackgroundColor(AppCompatResources.getColorStateList(context, R.color.deep_orange_800));
profileDetailsBinding.mainStatus.setText(R.string.status_following); profileDetailsBinding.mainStatus.setText(R.string.status_following);
} else { } else {
profileDetailsBinding.mainStatus.setChipBackgroundColor(AppCompatResources.getColorStateList(context, R.color.green_800)); profileDetailsBinding.mainStatus.setChipBackgroundColor(AppCompatResources.getColorStateList(context, R.color.green_800));
profileDetailsBinding.mainStatus.setText(R.string.status_mutual); profileDetailsBinding.mainStatus.setText(R.string.status_mutual);
} }
} } else profileDetailsBinding.mainStatus.setVisibility(View.GONE);
else profileDetailsBinding.mainStatus.setVisibility(View.GONE); if (profileModel.getFriendshipStatus().getFollowing()) {
if (profileModel.getFriendshipStatus().isFollowing()) {
profileDetailsBinding.btnFollow.setText(R.string.unfollow); profileDetailsBinding.btnFollow.setText(R.string.unfollow);
profileDetailsBinding.btnFollow.setChipIconResource(R.drawable.ic_outline_person_add_disabled_24); profileDetailsBinding.btnFollow.setChipIconResource(R.drawable.ic_outline_person_add_disabled_24);
} else if (profileModel.getFriendshipStatus().isOutgoingRequest()) { } else if (profileModel.getFriendshipStatus().getOutgoingRequest()) {
profileDetailsBinding.btnFollow.setText(R.string.cancel); profileDetailsBinding.btnFollow.setText(R.string.cancel);
profileDetailsBinding.btnFollow.setChipIconResource(R.drawable.ic_outline_person_add_disabled_24); profileDetailsBinding.btnFollow.setChipIconResource(R.drawable.ic_outline_person_add_disabled_24);
} else { } else {
@ -965,7 +964,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
if (blockMenuItem != null) { if (blockMenuItem != null) {
blockMenuItem.setVisible(true); blockMenuItem.setVisible(true);
blockMenuItem.setTitle(profileModel.getFriendshipStatus().isBlocking() ? R.string.unblock : R.string.block); blockMenuItem.setTitle(profileModel.getFriendshipStatus().getBlocking() ? R.string.unblock : R.string.block);
} }
if (muteStoriesMenuItem != null) { if (muteStoriesMenuItem != null) {
muteStoriesMenuItem.setVisible(true); muteStoriesMenuItem.setVisible(true);
@ -973,13 +972,13 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
if (mutePostsMenuItem != null) { if (mutePostsMenuItem != null) {
mutePostsMenuItem.setVisible(true); mutePostsMenuItem.setVisible(true);
mutePostsMenuItem.setTitle(profileModel.getFriendshipStatus().isMuting() ? R.string.unmute_posts : R.string.mute_posts); mutePostsMenuItem.setTitle(profileModel.getFriendshipStatus().getMuting() ? R.string.unmute_posts : R.string.mute_posts);
} }
if (chainingMenuItem != null) { if (chainingMenuItem != null) {
chainingMenuItem.setVisible(profileModel.hasChaining()); chainingMenuItem.setVisible(profileModel.hasChaining());
} }
if (removeFollowerMenuItem != null) { if (removeFollowerMenuItem != null) {
removeFollowerMenuItem.setVisible(profileModel.getFriendshipStatus().isFollowedBy()); removeFollowerMenuItem.setVisible(profileModel.getFriendshipStatus().getFollowedBy());
} }
} }
} }
@ -1043,7 +1042,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
private void setupCommonListeners() { private void setupCommonListeners() {
final Context context = getContext(); final Context context = getContext();
profileDetailsBinding.btnFollow.setOnClickListener(v -> { profileDetailsBinding.btnFollow.setOnClickListener(v -> {
if (profileModel.getFriendshipStatus().isFollowing() && profileModel.isPrivate()) { if (profileModel.getFriendshipStatus().getFollowing() && profileModel.isPrivate()) {
new AlertDialog.Builder(context) new AlertDialog.Builder(context)
.setTitle(R.string.priv_acc) .setTitle(R.string.priv_acc)
.setMessage(R.string.priv_acc_confirm) .setMessage(R.string.priv_acc_confirm)
@ -1051,7 +1050,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
friendshipService.unfollow(profileModel.getPk(), changeCb)) friendshipService.unfollow(profileModel.getPk(), changeCb))
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.show(); .show();
} else if (profileModel.getFriendshipStatus().isFollowing() || profileModel.getFriendshipStatus().isOutgoingRequest()) { } else if (profileModel.getFriendshipStatus().getFollowing() || profileModel.getFriendshipStatus().getOutgoingRequest()) {
friendshipService.unfollow(profileModel.getPk(), changeCb); friendshipService.unfollow(profileModel.getPk(), changeCb);
} else { } else {
friendshipService.follow(profileModel.getPk(), changeCb); friendshipService.follow(profileModel.getPk(), changeCb);
@ -1225,6 +1224,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
private boolean isReallyPrivate() { private boolean isReallyPrivate() {
if (profileModel.getPk() == myId) return false; if (profileModel.getPk() == myId) return false;
final FriendshipStatus friendshipStatus = profileModel.getFriendshipStatus(); final FriendshipStatus friendshipStatus = profileModel.getFriendshipStatus();
return !friendshipStatus.isFollowing() && profileModel.isPrivate(); return !friendshipStatus.getFollowing() && profileModel.isPrivate();
} }
} }

View File

@ -3,13 +3,13 @@ package awais.instagrabber.repositories.responses
import java.io.Serializable import java.io.Serializable
data class FriendshipStatus( data class FriendshipStatus(
val isFollowing: Boolean, val following: Boolean,
val isFollowedBy: Boolean, val followedBy: Boolean,
val isBlocking: Boolean, val blocking: Boolean,
val isMuting: Boolean, val muting: Boolean,
val isPrivate: Boolean, val isPrivate: Boolean,
val isIncomingRequest: Boolean, val incomingRequest: Boolean,
val isOutgoingRequest: Boolean, val outgoingRequest: Boolean,
val isBestie: Boolean, val isBestie: Boolean,
val isRestricted: Boolean, val isRestricted: Boolean,
val isMutingReel: Boolean val isMutingReel: Boolean

View File

@ -237,7 +237,7 @@ public class DirectSettingsViewModel extends AndroidViewModel {
)); ));
} }
final boolean blocking = user.getFriendshipStatus().isBlocking(); final boolean blocking = user.getFriendshipStatus().getBlocking();
options.add(new Option<>( options.add(new Option<>(
blocking ? getString(R.string.unblock) : getString(R.string.block), blocking ? getString(R.string.unblock) : getString(R.string.block),
blocking ? ACTION_UNBLOCK : ACTION_BLOCK blocking ? ACTION_UNBLOCK : ACTION_BLOCK