This commit is contained in:
NudeDude 2019-01-06 23:50:07 +01:00
parent 34f08f9c3b
commit d76e5bab4e
6 changed files with 66 additions and 30 deletions

View File

@ -130,8 +130,19 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
database.storeUser(user);
if (MODE == ACTION_FOLLOW) {
isFollowing = !isFollowing;
user = mTwitter.followAction(UID, isFollowing);
if (user.isLocked()) {
if (isFollowing) {
isFollowing = false;
user = mTwitter.followAction(UID, false);
} else if (user.followRequested()) {
user = mTwitter.followAction(UID, false);
} else {
user = mTwitter.followAction(UID, true);
}
} else {
isFollowing = !isFollowing;
user = mTwitter.followAction(UID, isFollowing);
}
publishProgress(GET_USER);
} else if (MODE == ACTION_BLOCK) {
isBlocked = !isBlocked;
@ -279,11 +290,12 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
favReload.setRefreshing(false);
if (MODE == ACTION_FOLLOW) {
if (isFollowing)
Toast.makeText(ui.get(), R.string.followed, Toast.LENGTH_SHORT).show();
else
Toast.makeText(ui.get(), R.string.unfollowed, Toast.LENGTH_SHORT).show();
if (!user.isLocked()) {
if (isFollowing)
Toast.makeText(ui.get(), R.string.followed, Toast.LENGTH_SHORT).show();
else
Toast.makeText(ui.get(), R.string.unfollowed, Toast.LENGTH_SHORT).show();
}
} else if (MODE == ACTION_BLOCK) {
if (isBlocked)
Toast.makeText(ui.get(), R.string.blocked, Toast.LENGTH_SHORT).show();
@ -304,7 +316,7 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
}
}
if (!isHome) {
ui.get().setConnection(isFollowing, isMuted, isBlocked, canDm);
ui.get().setConnection(isFollowing, isMuted, isBlocked, canDm, user.followRequested());
ui.get().invalidateOptionsMenu();
}
}

View File

@ -11,6 +11,7 @@ public class TwitterUser {
private final boolean isVerified;
private final boolean isLocked;
private final boolean isFollowReqSent;
private final int following;
private final int follower;
@ -41,11 +42,13 @@ public class TwitterUser {
follower = user.getFollowersCount();
tweetCount = user.getStatusesCount();
favorCount = user.getFavouritesCount();
isFollowReqSent = user.isFollowRequestSent();
}
public TwitterUser(long userID, String username, String screenname, String profileImg,
String bio, String location, boolean isVerified, boolean isLocked, String link,
String bannerImg, long created, int following, int follower, int tweetCount, int favorCount) {
public TwitterUser(long userID, String username, String screenname, String profileImg, String bio, String location,
boolean isVerified, boolean isLocked, boolean isFollowReqSent, String link, String bannerImg,
long created, int following, int follower, int tweetCount, int favorCount) {
this.userID = userID;
this.username = username;
this.screenname = screenname;
@ -61,6 +64,7 @@ public class TwitterUser {
this.follower = follower;
this.tweetCount = tweetCount;
this.favorCount = favorCount;
this.isFollowReqSent = isFollowReqSent;
}
/**
@ -162,6 +166,15 @@ public class TwitterUser {
return isLocked;
}
/**
* requested follow
*
* @return if a follow was requested
*/
public boolean followRequested() {
return isFollowReqSent;
}
/**
* get following count
*

View File

@ -21,15 +21,16 @@ public class DatabaseAdapter {
public static final int LIMIT = 100; // DATABASE ENTRY LIMIT
private static final int FAV_MASK = 1; // FAVORITE MASK
private static final int RTW_MASK = 1 << 1; // RETWEET MASK
private static final int HOM_MASK = 1 << 2; // HOME TWEET MASK
private static final int MEN_MASK = 1 << 3; // MENTION MASK
private static final int UTW_MASK = 1 << 4; // USER TWEETS
private static final int RPL_MASK = 1 << 5; // TWEET ANSWERS
private static final int FAV_MASK = 1; // FAVORITE MASK
private static final int RTW_MASK = 1 << 1; // RETWEET MASK
private static final int HOM_MASK = 1 << 2; // HOME TWEET MASK
private static final int MEN_MASK = 1 << 3; // MENTION MASK
private static final int UTW_MASK = 1 << 4; // USER TWEETS
private static final int RPL_MASK = 1 << 5; // TWEET ANSWERS
private static final int VER_MASK = 1; // USER VERIFIED MASK
private static final int LCK_MASK = 1 << 1; // USER LOCKED MASK
private static final int VER_MASK = 1; // USER VERIFIED MASK
private static final int LCK_MASK = 1 << 1; // USER LOCKED MASK
private static final int FRQ_MASK = 1 << 2; // USER REQUEST FOLLOW
private AppDatabase dataHelper;
private long homeId;
@ -568,8 +569,9 @@ public class DatabaseAdapter {
boolean isVerified = (userRegister & VER_MASK) > 0;
boolean isLocked = (userRegister & LCK_MASK) > 0;
boolean isReq = (userRegister & FRQ_MASK) > 0;
return new TwitterUser(userId, username, screenname, profileImg, bio, location, isVerified,
isLocked, link, banner, createdAt, following, follower, tCount, fCount);
isLocked, isReq, link, banner, createdAt, following, follower, tCount, fCount);
}
@ -580,6 +582,9 @@ public class DatabaseAdapter {
userRegister |= VER_MASK;
if (user.isLocked())
userRegister |= LCK_MASK;
if (user.followRequested())
userRegister |= FRQ_MASK;
userColumn.put("userID", user.getId());
userColumn.put("username", user.getUsername());
userColumn.put("scrname", user.getScreenname());

View File

@ -51,7 +51,7 @@ public class UserProfile extends AppCompatActivity implements OnRefreshListener,
private View lastTab, tweetIndicator, favorIndicator;
private TabHost mTab;
private NumberFormat formatter;
private boolean home, isFollowing, isBlocked, isMuted, canDm;
private boolean home, isFollowing, isBlocked, isMuted, canDm, requested;
private String username;
private long userId;
private int tabIndex = 0;
@ -176,6 +176,9 @@ public class UserProfile extends AppCompatActivity implements OnRefreshListener,
if (isFollowing) {
followIcon.setIcon(R.drawable.follow_enabled);
followIcon.setTitle(R.string.unfollow);
} else if (requested) {
followIcon.setIcon(R.drawable.follow_requested);
followIcon.setTitle(R.string.follow_requested);
} else {
followIcon.setIcon(R.drawable.follow);
followIcon.setTitle(R.string.follow);
@ -352,6 +355,15 @@ public class UserProfile extends AppCompatActivity implements OnRefreshListener,
}
public void setConnection(boolean isFollowing, boolean isMuted, boolean isBlocked, boolean canDm, boolean requested) {
this.isFollowing = isFollowing;
this.isMuted = isMuted;
this.isBlocked = isBlocked;
this.canDm = canDm;
this.requested = requested;
}
private void openTweet(long tweetId, long userId, String username) {
Intent intent = new Intent(this, TweetDetail.class);
intent.putExtra("tweetID", tweetId);
@ -388,14 +400,6 @@ public class UserProfile extends AppCompatActivity implements OnRefreshListener,
}
public void setConnection(boolean isFollowing, boolean isMuted, boolean isBlocked, boolean canDm) {
this.isFollowing = isFollowing;
this.isMuted = isMuted;
this.isBlocked = isBlocked;
this.canDm = canDm;
}
public void imageClick(String link) {
Intent image = new Intent(this, ImageDetail.class);
image.putExtra("link", new String[]{link});

View File

@ -24,7 +24,7 @@
<string name="favorite">favorisieren</string>
<string name="background">Hintergrund</string>
<string name="delete_tweet">Tweet löschen?</string>
<string name="connection_failed">Verbindung fehlgeschlagen</string>
<string name="connection_failed">Keine Internetverbindung!</string>
<string name="enter_pin">PIN eingeben!</string>
<string name="pin_added">PIN eingefügt!</string>
<string name="false_format">Falsches Format!</string>
@ -98,4 +98,5 @@
<string name="duplicate_status">Tweet wurde schon versendet!</string>
<string name="directmessage_too_long">Direktnachricht länge überschritten!</string>
<string name="authentication_failed">Authentifikation fehlgeschlagen!</string>
<string name="follow_requested">warten auf Bestätigung</string>
</resources>

View File

@ -106,4 +106,5 @@
<string name="duplicate_status">Duplicate Status!</string>
<string name="directmessage_too_long">direct message text is over the limit!</string>
<string name="authentication_failed">failed to authenticate!</string>
<string name="follow_requested">follow requested</string>
</resources>