bug fix
This commit is contained in:
parent
34f08f9c3b
commit
d76e5bab4e
|
@ -130,8 +130,19 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
|
||||||
database.storeUser(user);
|
database.storeUser(user);
|
||||||
|
|
||||||
if (MODE == ACTION_FOLLOW) {
|
if (MODE == ACTION_FOLLOW) {
|
||||||
isFollowing = !isFollowing;
|
if (user.isLocked()) {
|
||||||
user = mTwitter.followAction(UID, isFollowing);
|
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);
|
publishProgress(GET_USER);
|
||||||
} else if (MODE == ACTION_BLOCK) {
|
} else if (MODE == ACTION_BLOCK) {
|
||||||
isBlocked = !isBlocked;
|
isBlocked = !isBlocked;
|
||||||
|
@ -279,11 +290,12 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
|
||||||
favReload.setRefreshing(false);
|
favReload.setRefreshing(false);
|
||||||
|
|
||||||
if (MODE == ACTION_FOLLOW) {
|
if (MODE == ACTION_FOLLOW) {
|
||||||
if (isFollowing)
|
if (!user.isLocked()) {
|
||||||
Toast.makeText(ui.get(), R.string.followed, Toast.LENGTH_SHORT).show();
|
if (isFollowing)
|
||||||
else
|
Toast.makeText(ui.get(), R.string.followed, Toast.LENGTH_SHORT).show();
|
||||||
Toast.makeText(ui.get(), R.string.unfollowed, Toast.LENGTH_SHORT).show();
|
else
|
||||||
|
Toast.makeText(ui.get(), R.string.unfollowed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
} else if (MODE == ACTION_BLOCK) {
|
} else if (MODE == ACTION_BLOCK) {
|
||||||
if (isBlocked)
|
if (isBlocked)
|
||||||
Toast.makeText(ui.get(), R.string.blocked, Toast.LENGTH_SHORT).show();
|
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) {
|
if (!isHome) {
|
||||||
ui.get().setConnection(isFollowing, isMuted, isBlocked, canDm);
|
ui.get().setConnection(isFollowing, isMuted, isBlocked, canDm, user.followRequested());
|
||||||
ui.get().invalidateOptionsMenu();
|
ui.get().invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ public class TwitterUser {
|
||||||
|
|
||||||
private final boolean isVerified;
|
private final boolean isVerified;
|
||||||
private final boolean isLocked;
|
private final boolean isLocked;
|
||||||
|
private final boolean isFollowReqSent;
|
||||||
|
|
||||||
private final int following;
|
private final int following;
|
||||||
private final int follower;
|
private final int follower;
|
||||||
|
@ -41,11 +42,13 @@ public class TwitterUser {
|
||||||
follower = user.getFollowersCount();
|
follower = user.getFollowersCount();
|
||||||
tweetCount = user.getStatusesCount();
|
tweetCount = user.getStatusesCount();
|
||||||
favorCount = user.getFavouritesCount();
|
favorCount = user.getFavouritesCount();
|
||||||
|
isFollowReqSent = user.isFollowRequestSent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TwitterUser(long userID, String username, String screenname, String profileImg,
|
public TwitterUser(long userID, String username, String screenname, String profileImg, String bio, String location,
|
||||||
String bio, String location, boolean isVerified, boolean isLocked, String link,
|
boolean isVerified, boolean isLocked, boolean isFollowReqSent, String link, String bannerImg,
|
||||||
String bannerImg, long created, int following, int follower, int tweetCount, int favorCount) {
|
long created, int following, int follower, int tweetCount, int favorCount) {
|
||||||
|
|
||||||
this.userID = userID;
|
this.userID = userID;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.screenname = screenname;
|
this.screenname = screenname;
|
||||||
|
@ -61,6 +64,7 @@ public class TwitterUser {
|
||||||
this.follower = follower;
|
this.follower = follower;
|
||||||
this.tweetCount = tweetCount;
|
this.tweetCount = tweetCount;
|
||||||
this.favorCount = favorCount;
|
this.favorCount = favorCount;
|
||||||
|
this.isFollowReqSent = isFollowReqSent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,6 +166,15 @@ public class TwitterUser {
|
||||||
return isLocked;
|
return isLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* requested follow
|
||||||
|
*
|
||||||
|
* @return if a follow was requested
|
||||||
|
*/
|
||||||
|
public boolean followRequested() {
|
||||||
|
return isFollowReqSent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get following count
|
* get following count
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,15 +21,16 @@ public class DatabaseAdapter {
|
||||||
|
|
||||||
public static final int LIMIT = 100; // DATABASE ENTRY LIMIT
|
public static final int LIMIT = 100; // DATABASE ENTRY LIMIT
|
||||||
|
|
||||||
private static final int FAV_MASK = 1; // FAVORITE MASK
|
private static final int FAV_MASK = 1; // FAVORITE MASK
|
||||||
private static final int RTW_MASK = 1 << 1; // RETWEET 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 HOM_MASK = 1 << 2; // HOME TWEET MASK
|
||||||
private static final int MEN_MASK = 1 << 3; // MENTION 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 UTW_MASK = 1 << 4; // USER TWEETS
|
||||||
private static final int RPL_MASK = 1 << 5; // TWEET ANSWERS
|
private static final int RPL_MASK = 1 << 5; // TWEET ANSWERS
|
||||||
|
|
||||||
private static final int VER_MASK = 1; // USER VERIFIED 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 LCK_MASK = 1 << 1; // USER LOCKED MASK
|
||||||
|
private static final int FRQ_MASK = 1 << 2; // USER REQUEST FOLLOW
|
||||||
|
|
||||||
private AppDatabase dataHelper;
|
private AppDatabase dataHelper;
|
||||||
private long homeId;
|
private long homeId;
|
||||||
|
@ -568,8 +569,9 @@ public class DatabaseAdapter {
|
||||||
|
|
||||||
boolean isVerified = (userRegister & VER_MASK) > 0;
|
boolean isVerified = (userRegister & VER_MASK) > 0;
|
||||||
boolean isLocked = (userRegister & LCK_MASK) > 0;
|
boolean isLocked = (userRegister & LCK_MASK) > 0;
|
||||||
|
boolean isReq = (userRegister & FRQ_MASK) > 0;
|
||||||
return new TwitterUser(userId, username, screenname, profileImg, bio, location, isVerified,
|
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;
|
userRegister |= VER_MASK;
|
||||||
if (user.isLocked())
|
if (user.isLocked())
|
||||||
userRegister |= LCK_MASK;
|
userRegister |= LCK_MASK;
|
||||||
|
if (user.followRequested())
|
||||||
|
userRegister |= FRQ_MASK;
|
||||||
|
|
||||||
userColumn.put("userID", user.getId());
|
userColumn.put("userID", user.getId());
|
||||||
userColumn.put("username", user.getUsername());
|
userColumn.put("username", user.getUsername());
|
||||||
userColumn.put("scrname", user.getScreenname());
|
userColumn.put("scrname", user.getScreenname());
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class UserProfile extends AppCompatActivity implements OnRefreshListener,
|
||||||
private View lastTab, tweetIndicator, favorIndicator;
|
private View lastTab, tweetIndicator, favorIndicator;
|
||||||
private TabHost mTab;
|
private TabHost mTab;
|
||||||
private NumberFormat formatter;
|
private NumberFormat formatter;
|
||||||
private boolean home, isFollowing, isBlocked, isMuted, canDm;
|
private boolean home, isFollowing, isBlocked, isMuted, canDm, requested;
|
||||||
private String username;
|
private String username;
|
||||||
private long userId;
|
private long userId;
|
||||||
private int tabIndex = 0;
|
private int tabIndex = 0;
|
||||||
|
@ -176,6 +176,9 @@ public class UserProfile extends AppCompatActivity implements OnRefreshListener,
|
||||||
if (isFollowing) {
|
if (isFollowing) {
|
||||||
followIcon.setIcon(R.drawable.follow_enabled);
|
followIcon.setIcon(R.drawable.follow_enabled);
|
||||||
followIcon.setTitle(R.string.unfollow);
|
followIcon.setTitle(R.string.unfollow);
|
||||||
|
} else if (requested) {
|
||||||
|
followIcon.setIcon(R.drawable.follow_requested);
|
||||||
|
followIcon.setTitle(R.string.follow_requested);
|
||||||
} else {
|
} else {
|
||||||
followIcon.setIcon(R.drawable.follow);
|
followIcon.setIcon(R.drawable.follow);
|
||||||
followIcon.setTitle(R.string.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) {
|
private void openTweet(long tweetId, long userId, String username) {
|
||||||
Intent intent = new Intent(this, TweetDetail.class);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
intent.putExtra("tweetID", tweetId);
|
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) {
|
public void imageClick(String link) {
|
||||||
Intent image = new Intent(this, ImageDetail.class);
|
Intent image = new Intent(this, ImageDetail.class);
|
||||||
image.putExtra("link", new String[]{link});
|
image.putExtra("link", new String[]{link});
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<string name="favorite">favorisieren</string>
|
<string name="favorite">favorisieren</string>
|
||||||
<string name="background">Hintergrund</string>
|
<string name="background">Hintergrund</string>
|
||||||
<string name="delete_tweet">Tweet löschen?</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="enter_pin">PIN eingeben!</string>
|
||||||
<string name="pin_added">PIN eingefügt!</string>
|
<string name="pin_added">PIN eingefügt!</string>
|
||||||
<string name="false_format">Falsches Format!</string>
|
<string name="false_format">Falsches Format!</string>
|
||||||
|
@ -98,4 +98,5 @@
|
||||||
<string name="duplicate_status">Tweet wurde schon versendet!</string>
|
<string name="duplicate_status">Tweet wurde schon versendet!</string>
|
||||||
<string name="directmessage_too_long">Direktnachricht länge überschritten!</string>
|
<string name="directmessage_too_long">Direktnachricht länge überschritten!</string>
|
||||||
<string name="authentication_failed">Authentifikation fehlgeschlagen!</string>
|
<string name="authentication_failed">Authentifikation fehlgeschlagen!</string>
|
||||||
|
<string name="follow_requested">warten auf Bestätigung</string>
|
||||||
</resources>
|
</resources>
|
|
@ -106,4 +106,5 @@
|
||||||
<string name="duplicate_status">Duplicate Status!</string>
|
<string name="duplicate_status">Duplicate Status!</string>
|
||||||
<string name="directmessage_too_long">direct message text is over the limit!</string>
|
<string name="directmessage_too_long">direct message text is over the limit!</string>
|
||||||
<string name="authentication_failed">failed to authenticate!</string>
|
<string name="authentication_failed">failed to authenticate!</string>
|
||||||
|
<string name="follow_requested">follow requested</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue