renamed database constants, bug fix, code cleanup, added status spoiler attribut
This commit is contained in:
parent
161ced4c7b
commit
4439b3db9c
|
@ -38,6 +38,7 @@ public class MastodonStatus implements Status {
|
||||||
private boolean reposted;
|
private boolean reposted;
|
||||||
private boolean bookmarked;
|
private boolean bookmarked;
|
||||||
private boolean sensitive;
|
private boolean sensitive;
|
||||||
|
private boolean spoiler;
|
||||||
private boolean muted;
|
private boolean muted;
|
||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
|
@ -77,6 +78,7 @@ public class MastodonStatus implements Status {
|
||||||
favorited = json.optBoolean("favourited", false);
|
favorited = json.optBoolean("favourited", false);
|
||||||
reposted = json.optBoolean("reblogged", false);
|
reposted = json.optBoolean("reblogged", false);
|
||||||
sensitive = json.optBoolean("sensitive", false);
|
sensitive = json.optBoolean("sensitive", false);
|
||||||
|
spoiler = json.optBoolean("spoiler_text", false);
|
||||||
bookmarked = json.optBoolean("bookmarked", false);
|
bookmarked = json.optBoolean("bookmarked", false);
|
||||||
text = json.optString("content", "");
|
text = json.optString("content", "");
|
||||||
text = Jsoup.parse(text).text();
|
text = Jsoup.parse(text).text();
|
||||||
|
@ -198,7 +200,7 @@ public class MastodonStatus implements Status {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getRepostId() {
|
public long getRepostId() {
|
||||||
return 0;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -246,6 +248,12 @@ public class MastodonStatus implements Status {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSpoiler() {
|
||||||
|
return spoiler;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isReposted() {
|
public boolean isReposted() {
|
||||||
return reposted;
|
return reposted;
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class TweetV1 implements Status {
|
||||||
// get retweet ID
|
// get retweet ID
|
||||||
String retweetIdStr = "-1";
|
String retweetIdStr = "-1";
|
||||||
if (currentUserJson != null) {
|
if (currentUserJson != null) {
|
||||||
retweetIdStr = currentUserJson.optString("id_str", "-1");
|
retweetIdStr = currentUserJson.optString("id_str", "0");
|
||||||
}
|
}
|
||||||
// add media
|
// add media
|
||||||
if (extEntities != null) {
|
if (extEntities != null) {
|
||||||
|
@ -252,6 +252,12 @@ public class TweetV1 implements Status {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSpoiler() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isReposted() {
|
public boolean isReposted() {
|
||||||
return isRetweeted;
|
return isRetweeted;
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class TwitterV2 extends TwitterV1 {
|
||||||
params.add(LocationV2.FIELDS_PLACE);
|
params.add(LocationV2.FIELDS_PLACE);
|
||||||
// add metrics information if the author is the current user and the tweet is not older than 28 days and not a retweet/quote
|
// add metrics information if the author is the current user and the tweet is not older than 28 days and not a retweet/quote
|
||||||
if (statusCompat.getAuthor().isCurrentUser() && System.currentTimeMillis() - statusCompat.getTimestamp() < 2419200000L
|
if (statusCompat.getAuthor().isCurrentUser() && System.currentTimeMillis() - statusCompat.getTimestamp() < 2419200000L
|
||||||
&& (statusCompat.getEmbeddedStatus() == null || statusCompat.getEmbeddedStatus().getRepostId() <= 0L)) {
|
&& (statusCompat.getEmbeddedStatus() == null || statusCompat.getEmbeddedStatus().getRepostId() == 0L)) {
|
||||||
params.add(TweetV2.FIELDS_TWEET_PRIVATE);
|
params.add(TweetV2.FIELDS_TWEET_PRIVATE);
|
||||||
} else {
|
} else {
|
||||||
params.add(TweetV2.FIELDS_TWEET);
|
params.add(TweetV2.FIELDS_TWEET);
|
||||||
|
|
|
@ -333,6 +333,12 @@ public class TweetV2 implements Status {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSpoiler() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isReposted() {
|
public boolean isReposted() {
|
||||||
return retweeted;
|
return retweeted;
|
||||||
|
|
|
@ -65,72 +65,77 @@ public class AppDatabase {
|
||||||
/**
|
/**
|
||||||
* flag indicates that a status was favorited by the current user
|
* flag indicates that a status was favorited by the current user
|
||||||
*/
|
*/
|
||||||
public static final int FAVORITE_MASK = 1;
|
public static final int MASK_STATUS_FAVORITED = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that a status was reposted by the current user
|
* flag indicates that a status was reposted by the current user
|
||||||
*/
|
*/
|
||||||
public static final int REPOST_MASK = 1 << 1;
|
public static final int MASK_STATUS_REPOSTED = 1 << 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that a status exists in the home timeline of the current user
|
* flag indicates that a status exists in the home timeline of the current user
|
||||||
*/
|
*/
|
||||||
private static final int HOME_TIMELINE_MASK = 1 << 2;
|
private static final int MASK_STATUS_HOME_TIMELINE = 1 << 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that a status exists in the notification of the current user
|
* flag indicates that a status exists in the notification of the current user
|
||||||
*/
|
*/
|
||||||
private static final int NOTIFICATION_MASK = 1 << 3;
|
private static final int MASK_STATUS_NOTIFICATION = 1 << 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that a status exists in an user timeline
|
* flag indicates that a status exists in an user timeline
|
||||||
*/
|
*/
|
||||||
private static final int USER_TIMELINE_MASK = 1 << 4;
|
private static final int MASK_STATUS_USER_TIMELINE = 1 << 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that a status exists in the reply of a status
|
* flag indicates that a status exists in the reply of a status
|
||||||
*/
|
*/
|
||||||
private static final int STATUS_REPLY_MASK = 1 << 5;
|
private static final int MASK_STATUS_REPLY = 1 << 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* flag indicates that a status contains spoiler
|
||||||
|
*/
|
||||||
|
public static final int MASK_STATUS_SPOILER = 1 << 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that a status contains sensitive media
|
* flag indicates that a status contains sensitive media
|
||||||
*/
|
*/
|
||||||
public static final int MEDIA_SENS_MASK = 1 << 8;
|
public static final int MASK_STATUS_SENSITIVE = 1 << 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that a status was hidden by the current user
|
* flag indicates that a status was hidden by the current user
|
||||||
*/
|
*/
|
||||||
public static final int HIDDEN_MASK = 1 << 9;
|
public static final int MASK_STATUS_HIDDEN = 1 << 9;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicated that a status is bookmarked by the current user
|
* flag indicated that a status is bookmarked by the current user
|
||||||
*/
|
*/
|
||||||
public static final int BOOKMARK_MASK = 1 << 10;
|
public static final int MASK_STATUS_BOOKMARKED = 1 << 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that an user is verified
|
* flag indicates that an user is verified
|
||||||
*/
|
*/
|
||||||
public static final int VERIFIED_MASK = 1;
|
public static final int MASK_USER_VERIFIED = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that an user is locked/private
|
* flag indicates that an user is locked/private
|
||||||
*/
|
*/
|
||||||
public static final int LOCKED_MASK = 1 << 1;
|
public static final int MASK_USER_PRIVATE = 1 << 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that the current user has sent a follow request to an user
|
* flag indicates that the current user has sent a follow request to an user
|
||||||
*/
|
*/
|
||||||
public static final int FOLLOW_REQUEST_MASK = 1 << 2;
|
public static final int MASK_USER_FOLLOW_REQUESTED = 1 << 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that the statuses of an user are excluded from timeline
|
* flag indicates that the statuses of an user are excluded from timeline
|
||||||
*/
|
*/
|
||||||
private static final int EXCLUDE_MASK = 1 << 3;
|
private static final int MASK_USER_FILTERED = 1 << 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag indicates that the user has a default profile image
|
* flag indicates that the user has a default profile image
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_IMAGE_MASK = 1 << 4;
|
public static final int MASK_USER_DEFAULT_IMAGE = 1 << 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* used if no ID is defined
|
* used if no ID is defined
|
||||||
|
@ -166,7 +171,7 @@ public class AppDatabase {
|
||||||
* SQL query to get home timeline status
|
* SQL query to get home timeline status
|
||||||
*/
|
*/
|
||||||
private static final String HOME_QUERY = "SELECT * FROM(" + STATUS_SUBQUERY + ")"
|
private static final String HOME_QUERY = "SELECT * FROM(" + STATUS_SUBQUERY + ")"
|
||||||
+ " WHERE " + StatusRegisterTable.NAME + "." + StatusRegisterTable.REGISTER + "&" + HOME_TIMELINE_MASK + " IS NOT 0"
|
+ " WHERE " + StatusRegisterTable.NAME + "." + StatusRegisterTable.REGISTER + "&" + MASK_STATUS_HOME_TIMELINE + " IS NOT 0"
|
||||||
+ " AND " + StatusRegisterTable.NAME + "." + StatusRegisterTable.OWNER + "=?"
|
+ " AND " + StatusRegisterTable.NAME + "." + StatusRegisterTable.OWNER + "=?"
|
||||||
+ " AND " + UserRegisterTable.NAME + "." + UserRegisterTable.OWNER + "=?"
|
+ " AND " + UserRegisterTable.NAME + "." + UserRegisterTable.OWNER + "=?"
|
||||||
+ " ORDER BY " + StatusTable.TIME + " DESC"
|
+ " ORDER BY " + StatusTable.TIME + " DESC"
|
||||||
|
@ -176,7 +181,7 @@ public class AppDatabase {
|
||||||
* SQL query to get status of an user
|
* SQL query to get status of an user
|
||||||
*/
|
*/
|
||||||
private static final String USER_STATUS_QUERY = "SELECT * FROM(" + STATUS_SUBQUERY + ")"
|
private static final String USER_STATUS_QUERY = "SELECT * FROM(" + STATUS_SUBQUERY + ")"
|
||||||
+ " WHERE " + StatusRegisterTable.NAME + "." + StatusRegisterTable.REGISTER + "&" + USER_TIMELINE_MASK + " IS NOT 0"
|
+ " WHERE " + StatusRegisterTable.NAME + "." + StatusRegisterTable.REGISTER + "&" + MASK_STATUS_USER_TIMELINE + " IS NOT 0"
|
||||||
+ " AND " + StatusRegisterTable.NAME + "." + StatusRegisterTable.OWNER + "=?"
|
+ " AND " + StatusRegisterTable.NAME + "." + StatusRegisterTable.OWNER + "=?"
|
||||||
+ " AND " + UserRegisterTable.NAME + "." + UserRegisterTable.OWNER + "=?"
|
+ " AND " + UserRegisterTable.NAME + "." + UserRegisterTable.OWNER + "=?"
|
||||||
+ " AND " + StatusTable.NAME + "." + StatusTable.USER + "=?"
|
+ " AND " + StatusTable.NAME + "." + StatusTable.USER + "=?"
|
||||||
|
@ -230,9 +235,9 @@ public class AppDatabase {
|
||||||
+ " WHERE " + StatusTable.NAME + "." + StatusTable.REPLYSTATUS + "=?"
|
+ " WHERE " + StatusTable.NAME + "." + StatusTable.REPLYSTATUS + "=?"
|
||||||
+ " AND " + StatusRegisterTable.NAME + "." + StatusRegisterTable.OWNER + "=?"
|
+ " AND " + StatusRegisterTable.NAME + "." + StatusRegisterTable.OWNER + "=?"
|
||||||
+ " AND " + UserRegisterTable.NAME + "." + UserRegisterTable.OWNER + "=?"
|
+ " AND " + UserRegisterTable.NAME + "." + UserRegisterTable.OWNER + "=?"
|
||||||
+ " AND " + StatusRegisterTable.NAME + "." + StatusRegisterTable.REGISTER + "&" + STATUS_REPLY_MASK + " IS NOT 0"
|
+ " AND " + StatusRegisterTable.NAME + "." + StatusRegisterTable.REGISTER + "&" + MASK_STATUS_REPLY + " IS NOT 0"
|
||||||
+ " AND " + StatusRegisterTable.NAME + "." + StatusRegisterTable.REGISTER + "&" + HIDDEN_MASK + " IS 0"
|
+ " AND " + StatusRegisterTable.NAME + "." + StatusRegisterTable.REGISTER + "&" + MASK_STATUS_HIDDEN + " IS 0"
|
||||||
+ " AND " + UserRegisterTable.NAME + "." + UserRegisterTable.REGISTER + "&" + EXCLUDE_MASK + " IS 0"
|
+ " AND " + UserRegisterTable.NAME + "." + UserRegisterTable.REGISTER + "&" + MASK_USER_FILTERED + " IS 0"
|
||||||
+ " ORDER BY " + StatusTable.TIME + " DESC"
|
+ " ORDER BY " + StatusTable.TIME + " DESC"
|
||||||
+ " LIMIT ?;";
|
+ " LIMIT ?;";
|
||||||
|
|
||||||
|
@ -423,7 +428,7 @@ public class AppDatabase {
|
||||||
if (!statuses.isEmpty()) {
|
if (!statuses.isEmpty()) {
|
||||||
SQLiteDatabase db = adapter.getDbWrite();
|
SQLiteDatabase db = adapter.getDbWrite();
|
||||||
for (Status status : statuses)
|
for (Status status : statuses)
|
||||||
saveStatus(status, db, HOME_TIMELINE_MASK);
|
saveStatus(status, db, MASK_STATUS_HOME_TIMELINE);
|
||||||
adapter.commit();
|
adapter.commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,7 +444,7 @@ public class AppDatabase {
|
||||||
if (!statuses.isEmpty()) {
|
if (!statuses.isEmpty()) {
|
||||||
SQLiteDatabase db = adapter.getDbWrite();
|
SQLiteDatabase db = adapter.getDbWrite();
|
||||||
for (Status status : statuses)
|
for (Status status : statuses)
|
||||||
saveStatus(status, db, USER_TIMELINE_MASK);
|
saveStatus(status, db, MASK_STATUS_USER_TIMELINE);
|
||||||
adapter.commit();
|
adapter.commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -501,7 +506,7 @@ public class AppDatabase {
|
||||||
if (!statuses.isEmpty()) {
|
if (!statuses.isEmpty()) {
|
||||||
SQLiteDatabase db = adapter.getDbWrite();
|
SQLiteDatabase db = adapter.getDbWrite();
|
||||||
for (Status status : statuses)
|
for (Status status : statuses)
|
||||||
saveStatus(status, db, STATUS_REPLY_MASK);
|
saveStatus(status, db, MASK_STATUS_REPLY);
|
||||||
adapter.commit();
|
adapter.commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,7 +529,7 @@ public class AppDatabase {
|
||||||
saveUser(notification.getUser(), db, CONFLICT_IGNORE);
|
saveUser(notification.getUser(), db, CONFLICT_IGNORE);
|
||||||
// add status
|
// add status
|
||||||
if (notification.getStatus() != null) {
|
if (notification.getStatus() != null) {
|
||||||
saveStatus(notification.getStatus(), db, NOTIFICATION_MASK);
|
saveStatus(notification.getStatus(), db, MASK_STATUS_NOTIFICATION);
|
||||||
column.put(NotificationTable.ITEM, notification.getStatus().getId());
|
column.put(NotificationTable.ITEM, notification.getStatus().getId());
|
||||||
}
|
}
|
||||||
db.insertWithOnConflict(NotificationTable.NAME, null, column, CONFLICT_REPLACE);
|
db.insertWithOnConflict(NotificationTable.NAME, null, column, CONFLICT_REPLACE);
|
||||||
|
@ -567,7 +572,7 @@ public class AppDatabase {
|
||||||
ContentValues column = new ContentValues(2);
|
ContentValues column = new ContentValues(2);
|
||||||
column.put(UserExcludeTable.ID, id);
|
column.put(UserExcludeTable.ID, id);
|
||||||
column.put(UserExcludeTable.OWNER, homeId);
|
column.put(UserExcludeTable.OWNER, homeId);
|
||||||
db.insertWithOnConflict(UserExcludeTable.NAME, null, column, SQLiteDatabase.CONFLICT_IGNORE);
|
db.insert(UserExcludeTable.NAME, null, column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
adapter.commit();
|
adapter.commit();
|
||||||
|
@ -963,9 +968,9 @@ public class AppDatabase {
|
||||||
SQLiteDatabase db = adapter.getDbWrite();
|
SQLiteDatabase db = adapter.getDbWrite();
|
||||||
int flags = getStatusFlags(db, id);
|
int flags = getStatusFlags(db, id);
|
||||||
if (hide) {
|
if (hide) {
|
||||||
flags |= HIDDEN_MASK;
|
flags |= MASK_STATUS_HIDDEN;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~HIDDEN_MASK;
|
flags &= ~MASK_STATUS_HIDDEN;
|
||||||
}
|
}
|
||||||
ContentValues column = new ContentValues(1);
|
ContentValues column = new ContentValues(1);
|
||||||
column.put(StatusRegisterTable.REGISTER, flags);
|
column.put(StatusRegisterTable.REGISTER, flags);
|
||||||
|
@ -1022,7 +1027,7 @@ public class AppDatabase {
|
||||||
SQLiteDatabase db = adapter.getDbWrite();
|
SQLiteDatabase db = adapter.getDbWrite();
|
||||||
// get status flags
|
// get status flags
|
||||||
int flags = getStatusFlags(db, status.getId());
|
int flags = getStatusFlags(db, status.getId());
|
||||||
flags &= ~FAVORITE_MASK; // unset favorite flag
|
flags &= ~MASK_STATUS_FAVORITED; // unset favorite flag
|
||||||
// update database
|
// update database
|
||||||
saveStatusFlags(db, status, flags);
|
saveStatusFlags(db, status, flags);
|
||||||
db.delete(FavoriteTable.NAME, FAVORITE_SELECT, delArgs);
|
db.delete(FavoriteTable.NAME, FAVORITE_SELECT, delArgs);
|
||||||
|
@ -1045,7 +1050,7 @@ public class AppDatabase {
|
||||||
SQLiteDatabase db = adapter.getDbWrite();
|
SQLiteDatabase db = adapter.getDbWrite();
|
||||||
// get status flags
|
// get status flags
|
||||||
int flags = getStatusFlags(db, status.getId());
|
int flags = getStatusFlags(db, status.getId());
|
||||||
flags &= ~BOOKMARK_MASK; // unset bookmark flag
|
flags &= ~MASK_STATUS_BOOKMARKED; // unset bookmark flag
|
||||||
// update database
|
// update database
|
||||||
saveStatusFlags(db, status, flags);
|
saveStatusFlags(db, status, flags);
|
||||||
db.delete(BookmarkTable.NAME, BOOKMARK_SELECT, delArgs);
|
db.delete(BookmarkTable.NAME, BOOKMARK_SELECT, delArgs);
|
||||||
|
@ -1165,9 +1170,9 @@ public class AppDatabase {
|
||||||
SQLiteDatabase db = adapter.getDbWrite();
|
SQLiteDatabase db = adapter.getDbWrite();
|
||||||
int flags = getUserFlags(db, id);
|
int flags = getUserFlags(db, id);
|
||||||
if (mute) {
|
if (mute) {
|
||||||
flags |= EXCLUDE_MASK;
|
flags |= MASK_USER_FILTERED;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~EXCLUDE_MASK;
|
flags &= ~MASK_USER_FILTERED;
|
||||||
}
|
}
|
||||||
saveUserFlags(db, id, flags);
|
saveUserFlags(db, id, flags);
|
||||||
adapter.commit();
|
adapter.commit();
|
||||||
|
@ -1416,24 +1421,24 @@ public class AppDatabase {
|
||||||
private void saveUser(User user, SQLiteDatabase db, int mode) {
|
private void saveUser(User user, SQLiteDatabase db, int mode) {
|
||||||
int flags = getUserFlags(db, user.getId());
|
int flags = getUserFlags(db, user.getId());
|
||||||
if (user.isVerified()) {
|
if (user.isVerified()) {
|
||||||
flags |= VERIFIED_MASK;
|
flags |= MASK_USER_VERIFIED;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~VERIFIED_MASK;
|
flags &= ~MASK_USER_VERIFIED;
|
||||||
}
|
}
|
||||||
if (user.isProtected()) {
|
if (user.isProtected()) {
|
||||||
flags |= LOCKED_MASK;
|
flags |= MASK_USER_PRIVATE;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~LOCKED_MASK;
|
flags &= ~MASK_USER_PRIVATE;
|
||||||
}
|
}
|
||||||
if (user.followRequested()) {
|
if (user.followRequested()) {
|
||||||
flags |= FOLLOW_REQUEST_MASK;
|
flags |= MASK_USER_FOLLOW_REQUESTED;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~FOLLOW_REQUEST_MASK;
|
flags &= ~MASK_USER_FOLLOW_REQUESTED;
|
||||||
}
|
}
|
||||||
if (user.hasDefaultProfileImage()) {
|
if (user.hasDefaultProfileImage()) {
|
||||||
flags |= DEFAULT_IMAGE_MASK;
|
flags |= MASK_USER_DEFAULT_IMAGE;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~DEFAULT_IMAGE_MASK;
|
flags &= ~MASK_USER_DEFAULT_IMAGE;
|
||||||
}
|
}
|
||||||
ContentValues column = new ContentValues(13);
|
ContentValues column = new ContentValues(13);
|
||||||
column.put(UserTable.ID, user.getId());
|
column.put(UserTable.ID, user.getId());
|
||||||
|
@ -1471,24 +1476,29 @@ public class AppDatabase {
|
||||||
}
|
}
|
||||||
flags |= getStatusFlags(db, status.getId());
|
flags |= getStatusFlags(db, status.getId());
|
||||||
if (status.isFavorited()) {
|
if (status.isFavorited()) {
|
||||||
flags |= FAVORITE_MASK;
|
flags |= MASK_STATUS_FAVORITED;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~FAVORITE_MASK;
|
flags &= ~MASK_STATUS_FAVORITED;
|
||||||
}
|
}
|
||||||
if (status.isReposted()) {
|
if (status.isReposted()) {
|
||||||
flags |= REPOST_MASK;
|
flags |= MASK_STATUS_REPOSTED;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~REPOST_MASK;
|
flags &= ~MASK_STATUS_REPOSTED;
|
||||||
}
|
}
|
||||||
if (status.isSensitive()) {
|
if (status.isSensitive()) {
|
||||||
flags |= MEDIA_SENS_MASK;
|
flags |= MASK_STATUS_SENSITIVE;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~MEDIA_SENS_MASK;
|
flags &= ~MASK_STATUS_SENSITIVE;
|
||||||
|
}
|
||||||
|
if (status.isSpoiler()) {
|
||||||
|
flags |= MASK_STATUS_SPOILER;
|
||||||
|
} else {
|
||||||
|
flags &= ~MASK_STATUS_SPOILER;
|
||||||
}
|
}
|
||||||
if (status.isBookmarked()) {
|
if (status.isBookmarked()) {
|
||||||
flags |= BOOKMARK_MASK;
|
flags |= MASK_STATUS_BOOKMARKED;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~BOOKMARK_MASK;
|
flags &= ~MASK_STATUS_BOOKMARKED;
|
||||||
}
|
}
|
||||||
ContentValues column = new ContentValues(19);
|
ContentValues column = new ContentValues(19);
|
||||||
column.put(StatusTable.ID, status.getId());
|
column.put(StatusTable.ID, status.getId());
|
||||||
|
@ -1607,7 +1617,7 @@ public class AppDatabase {
|
||||||
column.put(PollTable.LIMIT, poll.getLimit());
|
column.put(PollTable.LIMIT, poll.getLimit());
|
||||||
column.put(PollTable.EXPIRATION, poll.expirationTime());
|
column.put(PollTable.EXPIRATION, poll.expirationTime());
|
||||||
column.put(PollTable.OPTIONS, buf.toString());
|
column.put(PollTable.OPTIONS, buf.toString());
|
||||||
db.insertWithOnConflict(PollTable.NAME, "", column, CONFLICT_IGNORE);
|
db.insertWithOnConflict(PollTable.NAME, "", column, CONFLICT_REPLACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package org.nuclearfog.twidda.database.impl;
|
package org.nuclearfog.twidda.database.impl;
|
||||||
|
|
||||||
import static org.nuclearfog.twidda.database.AppDatabase.BOOKMARK_MASK;
|
import static org.nuclearfog.twidda.database.AppDatabase.MASK_STATUS_BOOKMARKED;
|
||||||
import static org.nuclearfog.twidda.database.AppDatabase.FAVORITE_MASK;
|
import static org.nuclearfog.twidda.database.AppDatabase.MASK_STATUS_FAVORITED;
|
||||||
import static org.nuclearfog.twidda.database.AppDatabase.HIDDEN_MASK;
|
import static org.nuclearfog.twidda.database.AppDatabase.MASK_STATUS_HIDDEN;
|
||||||
import static org.nuclearfog.twidda.database.AppDatabase.MEDIA_SENS_MASK;
|
import static org.nuclearfog.twidda.database.AppDatabase.MASK_STATUS_SENSITIVE;
|
||||||
import static org.nuclearfog.twidda.database.AppDatabase.REPOST_MASK;
|
import static org.nuclearfog.twidda.database.AppDatabase.MASK_STATUS_REPOSTED;
|
||||||
|
import static org.nuclearfog.twidda.database.AppDatabase.MASK_STATUS_SPOILER;
|
||||||
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@ public class DatabaseStatus implements Status {
|
||||||
private boolean favorited;
|
private boolean favorited;
|
||||||
private boolean bookmarked;
|
private boolean bookmarked;
|
||||||
private boolean sensitive;
|
private boolean sensitive;
|
||||||
|
private boolean spoiler;
|
||||||
private boolean isHidden;
|
private boolean isHidden;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,11 +98,12 @@ public class DatabaseStatus implements Status {
|
||||||
statusUrl = cursor.getString(cursor.getColumnIndexOrThrow(StatusTable.URL));
|
statusUrl = cursor.getString(cursor.getColumnIndexOrThrow(StatusTable.URL));
|
||||||
int register = cursor.getInt(cursor.getColumnIndexOrThrow(StatusRegisterTable.REGISTER));
|
int register = cursor.getInt(cursor.getColumnIndexOrThrow(StatusRegisterTable.REGISTER));
|
||||||
|
|
||||||
favorited = (register & FAVORITE_MASK) != 0;
|
favorited = (register & MASK_STATUS_FAVORITED) != 0;
|
||||||
reposted = (register & REPOST_MASK) != 0;
|
reposted = (register & MASK_STATUS_REPOSTED) != 0;
|
||||||
sensitive = (register & MEDIA_SENS_MASK) != 0;
|
sensitive = (register & MASK_STATUS_SENSITIVE) != 0;
|
||||||
isHidden = (register & HIDDEN_MASK) != 0;
|
isHidden = (register & MASK_STATUS_HIDDEN) != 0;
|
||||||
bookmarked = (register & BOOKMARK_MASK) != 0;
|
bookmarked = (register & MASK_STATUS_BOOKMARKED) != 0;
|
||||||
|
spoiler = (register & MASK_STATUS_SPOILER) != 0;
|
||||||
if (mediaKeys != null && !mediaKeys.isEmpty()) {
|
if (mediaKeys != null && !mediaKeys.isEmpty()) {
|
||||||
this.mediaKeys = MEDIA_SEPARATOR.split(mediaKeys);
|
this.mediaKeys = MEDIA_SEPARATOR.split(mediaKeys);
|
||||||
}
|
}
|
||||||
|
@ -221,6 +224,12 @@ public class DatabaseStatus implements Status {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSpoiler() {
|
||||||
|
return spoiler;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isReposted() {
|
public boolean isReposted() {
|
||||||
return reposted;
|
return reposted;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package org.nuclearfog.twidda.database.impl;
|
package org.nuclearfog.twidda.database.impl;
|
||||||
|
|
||||||
import static org.nuclearfog.twidda.database.AppDatabase.DEFAULT_IMAGE_MASK;
|
import static org.nuclearfog.twidda.database.AppDatabase.MASK_USER_DEFAULT_IMAGE;
|
||||||
import static org.nuclearfog.twidda.database.AppDatabase.FOLLOW_REQUEST_MASK;
|
import static org.nuclearfog.twidda.database.AppDatabase.MASK_USER_FOLLOW_REQUESTED;
|
||||||
import static org.nuclearfog.twidda.database.AppDatabase.LOCKED_MASK;
|
import static org.nuclearfog.twidda.database.AppDatabase.MASK_USER_PRIVATE;
|
||||||
import static org.nuclearfog.twidda.database.AppDatabase.VERIFIED_MASK;
|
import static org.nuclearfog.twidda.database.AppDatabase.MASK_USER_VERIFIED;
|
||||||
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
|
||||||
|
@ -65,10 +65,10 @@ public class DatabaseUser implements User {
|
||||||
statusCount = cursor.getInt(cursor.getColumnIndexOrThrow(UserTable.STATUSES));
|
statusCount = cursor.getInt(cursor.getColumnIndexOrThrow(UserTable.STATUSES));
|
||||||
favorCount = cursor.getInt(cursor.getColumnIndexOrThrow(UserTable.FAVORITS));
|
favorCount = cursor.getInt(cursor.getColumnIndexOrThrow(UserTable.FAVORITS));
|
||||||
int register = cursor.getInt(cursor.getColumnIndexOrThrow(UserRegisterTable.REGISTER));
|
int register = cursor.getInt(cursor.getColumnIndexOrThrow(UserRegisterTable.REGISTER));
|
||||||
isVerified = (register & VERIFIED_MASK) != 0;
|
isVerified = (register & MASK_USER_VERIFIED) != 0;
|
||||||
isLocked = (register & LOCKED_MASK) != 0;
|
isLocked = (register & MASK_USER_PRIVATE) != 0;
|
||||||
followReqSent = (register & FOLLOW_REQUEST_MASK) != 0;
|
followReqSent = (register & MASK_USER_FOLLOW_REQUESTED) != 0;
|
||||||
defaultImage = (register & DEFAULT_IMAGE_MASK) != 0;
|
defaultImage = (register & MASK_USER_DEFAULT_IMAGE) != 0;
|
||||||
isCurrentUser = account.getId() == id;
|
isCurrentUser = account.getId() == id;
|
||||||
|
|
||||||
switch (account.getConfiguration()) {
|
switch (account.getConfiguration()) {
|
||||||
|
|
|
@ -93,6 +93,11 @@ public interface Status extends Serializable, Comparable<Status> {
|
||||||
*/
|
*/
|
||||||
boolean isSensitive();
|
boolean isSensitive();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if status contains any spoiler
|
||||||
|
*/
|
||||||
|
boolean isSpoiler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if status is reposted by the current user
|
* @return true if status is reposted by the current user
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -238,6 +238,17 @@ public class ProfileActivity extends AppCompatActivity implements ActivityResult
|
||||||
}
|
}
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
setUser(user);
|
setUser(user);
|
||||||
|
if (user instanceof DatabaseUser) {
|
||||||
|
UserParam param = new UserParam(UserParam.ONLINE, userId);
|
||||||
|
userLoader.execute(param, userCallback);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UserParam param = new UserParam(UserParam.DATABASE, userId);
|
||||||
|
userLoader.execute(param, userCallback);
|
||||||
|
}
|
||||||
|
if (relation == null && userId != settings.getLogin().getId()) {
|
||||||
|
RelationParam param = new RelationParam(userId, RelationParam.LOAD);
|
||||||
|
relationLoader.execute(param, relationCallback);
|
||||||
}
|
}
|
||||||
tabLayout.addOnTabSelectedListener(this);
|
tabLayout.addOnTabSelectedListener(this);
|
||||||
following.setOnClickListener(this);
|
following.setOnClickListener(this);
|
||||||
|
@ -250,23 +261,6 @@ public class ProfileActivity extends AppCompatActivity implements ActivityResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (user == null) {
|
|
||||||
UserParam param = new UserParam(UserParam.DATABASE, userId);
|
|
||||||
userLoader.execute(param, userCallback);
|
|
||||||
} else if (user instanceof DatabaseUser) {
|
|
||||||
UserParam param = new UserParam(UserParam.ONLINE, userId);
|
|
||||||
userLoader.execute(param, userCallback);
|
|
||||||
}
|
|
||||||
if (relation == null && userId != settings.getLogin().getId()) {
|
|
||||||
RelationParam param = new RelationParam(userId, RelationParam.LOAD);
|
|
||||||
relationLoader.execute(param, relationCallback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
outState.putSerializable(KEY_PROFILE_USER, user);
|
outState.putSerializable(KEY_PROFILE_USER, user);
|
||||||
|
@ -278,11 +272,14 @@ public class ProfileActivity extends AppCompatActivity implements ActivityResult
|
||||||
@Override
|
@Override
|
||||||
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
|
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
|
||||||
Object data = savedInstanceState.getSerializable(KEY_PROFILE_USER);
|
Object data = savedInstanceState.getSerializable(KEY_PROFILE_USER);
|
||||||
if (data instanceof User)
|
if (data instanceof User) {
|
||||||
user = (User) data;
|
setUser((User) data);
|
||||||
|
}
|
||||||
data = savedInstanceState.getSerializable(KEY_PROFILE_RELATION);
|
data = savedInstanceState.getSerializable(KEY_PROFILE_RELATION);
|
||||||
if (data instanceof Relation)
|
if (data instanceof Relation) {
|
||||||
relation = (Relation) data;
|
relation = (Relation) data;
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
}
|
||||||
super.onRestoreInstanceState(savedInstanceState);
|
super.onRestoreInstanceState(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,45 +248,6 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||||
settings = GlobalSettings.getInstance(this);
|
settings = GlobalSettings.getInstance(this);
|
||||||
clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
adapter = new PreviewAdapter(settings, picasso, this);
|
adapter = new PreviewAdapter(settings, picasso, this);
|
||||||
// get parameter
|
|
||||||
long id;
|
|
||||||
String replyUsername;
|
|
||||||
Object statusObject = getIntent().getSerializableExtra(KEY_STATUS_DATA);
|
|
||||||
Object notificationObject = getIntent().getSerializableExtra(KEY_NOTIFICATION_DATA);
|
|
||||||
if (statusObject instanceof Status) {
|
|
||||||
status = (Status) statusObject;
|
|
||||||
setStatus(status);
|
|
||||||
Status embedded = status.getEmbeddedStatus();
|
|
||||||
if (embedded != null) {
|
|
||||||
id = embedded.getId();
|
|
||||||
replyUsername = embedded.getAuthor().getScreenname();
|
|
||||||
} else {
|
|
||||||
id = status.getId();
|
|
||||||
hidden = status.isHidden();
|
|
||||||
replyUsername = status.getAuthor().getScreenname();
|
|
||||||
}
|
|
||||||
} else if (notificationObject instanceof Notification) {
|
|
||||||
notification = (Notification) notificationObject;
|
|
||||||
if (notification.getStatus() != null) {
|
|
||||||
setStatus(notification.getStatus());
|
|
||||||
id = notification.getStatus().getId();
|
|
||||||
replyUsername = notification.getStatus().getAuthor().getScreenname();
|
|
||||||
} else {
|
|
||||||
id = getIntent().getLongExtra(KEY_NOTIFICATION_ID, 0L);
|
|
||||||
replyUsername = getIntent().getStringExtra(KEY_NOTIFICATION_NAME);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
id = getIntent().getLongExtra(KEY_STATUS_ID, 0L);
|
|
||||||
replyUsername = getIntent().getStringExtra(KEY_STATUS_NAME);
|
|
||||||
}
|
|
||||||
// initialize status reply list
|
|
||||||
Bundle param = new Bundle();
|
|
||||||
param.putInt(KEY_STATUS_FRAGMENT_MODE, STATUS_FRAGMENT_REPLY);
|
|
||||||
param.putString(KEY_STATUS_FRAGMENT_SEARCH, replyUsername);
|
|
||||||
param.putLong(KEY_STATUS_FRAGMENT_ID, id);
|
|
||||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
|
||||||
fragmentTransaction.replace(R.id.page_status_reply_fragment, StatusFragment.class, param);
|
|
||||||
fragmentTransaction.commit();
|
|
||||||
|
|
||||||
replyButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.answer, 0, 0, 0);
|
replyButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.answer, 0, 0, 0);
|
||||||
repostButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.repost, 0, 0, 0);
|
repostButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.repost, 0, 0, 0);
|
||||||
|
@ -307,6 +268,60 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
AppStyles.setTheme(root);
|
AppStyles.setTheme(root);
|
||||||
|
|
||||||
|
// get parameter, set information and initialize loaders
|
||||||
|
long statusId = 0L;
|
||||||
|
String replyUsername = "";
|
||||||
|
Object statusObject = getIntent().getSerializableExtra(KEY_STATUS_DATA);
|
||||||
|
Object notificationObject = getIntent().getSerializableExtra(KEY_NOTIFICATION_DATA);
|
||||||
|
if (statusObject instanceof Status) {
|
||||||
|
Status status = (Status) statusObject;
|
||||||
|
setStatus(status);
|
||||||
|
Status embedded = status.getEmbeddedStatus();
|
||||||
|
if (embedded != null) {
|
||||||
|
statusId = embedded.getId();
|
||||||
|
replyUsername = embedded.getAuthor().getScreenname();
|
||||||
|
} else {
|
||||||
|
statusId = status.getId();
|
||||||
|
hidden = status.isHidden();
|
||||||
|
replyUsername = status.getAuthor().getScreenname();
|
||||||
|
}
|
||||||
|
if (status instanceof DatabaseStatus) {
|
||||||
|
StatusParam statusParam = new StatusParam(StatusParam.ONLINE, status.getId());
|
||||||
|
statusAsync.execute(statusParam, statusCallback);
|
||||||
|
}
|
||||||
|
} else if (notificationObject instanceof Notification) {
|
||||||
|
Notification notification = (Notification) notificationObject;
|
||||||
|
if (notification.getStatus() != null) {
|
||||||
|
setNotification(notification);
|
||||||
|
statusId = notification.getStatus().getId();
|
||||||
|
replyUsername = notification.getStatus().getAuthor().getScreenname();
|
||||||
|
}
|
||||||
|
if (notification instanceof DatabaseNotification) {
|
||||||
|
NotificationActionParam notificationParam = new NotificationActionParam(NotificationActionParam.ONLINE, notification.getId());
|
||||||
|
notificationAsync.execute(notificationParam, notificationCallback);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
statusId = getIntent().getLongExtra(KEY_STATUS_ID, 0L);
|
||||||
|
long notificationId = getIntent().getLongExtra(KEY_NOTIFICATION_ID, 0L);
|
||||||
|
if (statusId != 0L) {
|
||||||
|
replyUsername = getIntent().getStringExtra(KEY_STATUS_NAME);
|
||||||
|
StatusParam statusParam = new StatusParam(StatusParam.DATABASE, statusId);
|
||||||
|
statusAsync.execute(statusParam, statusCallback);
|
||||||
|
} else if (notificationId != 0L) {
|
||||||
|
replyUsername = getIntent().getStringExtra(KEY_NOTIFICATION_NAME);
|
||||||
|
NotificationActionParam notificationParam = new NotificationActionParam(NotificationActionParam.ONLINE, notificationId);
|
||||||
|
notificationAsync.execute(notificationParam, notificationCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// initialize status reply list
|
||||||
|
Bundle param = new Bundle();
|
||||||
|
param.putInt(KEY_STATUS_FRAGMENT_MODE, STATUS_FRAGMENT_REPLY);
|
||||||
|
param.putString(KEY_STATUS_FRAGMENT_SEARCH, replyUsername);
|
||||||
|
param.putLong(KEY_STATUS_FRAGMENT_ID, statusId);
|
||||||
|
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
fragmentTransaction.replace(R.id.page_status_reply_fragment, StatusFragment.class, param);
|
||||||
|
fragmentTransaction.commit();
|
||||||
|
|
||||||
confirmDialog = new ConfirmDialog(this);
|
confirmDialog = new ConfirmDialog(this);
|
||||||
metricsDialog = new MetricsDialog(this);
|
metricsDialog = new MetricsDialog(this);
|
||||||
confirmDialog.setConfirmListener(this);
|
confirmDialog.setConfirmListener(this);
|
||||||
|
@ -324,36 +339,6 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (notification != null) {
|
|
||||||
if (notification instanceof DatabaseNotification) {
|
|
||||||
NotificationActionParam param = new NotificationActionParam(NotificationActionParam.ONLINE, notification.getId());
|
|
||||||
notificationAsync.execute(param, notificationCallback);
|
|
||||||
}
|
|
||||||
} else if (status != null) {
|
|
||||||
if (status instanceof DatabaseStatus) {
|
|
||||||
StatusParam param = new StatusParam(StatusParam.ONLINE, status.getId());
|
|
||||||
statusAsync.execute(param, statusCallback);
|
|
||||||
} else if (status.getPoll() != null) {
|
|
||||||
PollActionParam param = new PollActionParam(PollActionParam.LOAD, status.getPoll(), new int[0]);
|
|
||||||
voteAsync.execute(param, pollResult);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
long statusId = getIntent().getLongExtra(KEY_STATUS_ID, 0L);
|
|
||||||
long notificationId = getIntent().getLongExtra(KEY_NOTIFICATION_ID, 0L);
|
|
||||||
if (statusId != 0L) {
|
|
||||||
StatusParam param = new StatusParam(StatusParam.DATABASE, statusId);
|
|
||||||
statusAsync.execute(param, statusCallback);
|
|
||||||
} else if (notificationId != 0L) {
|
|
||||||
NotificationActionParam param = new NotificationActionParam(NotificationActionParam.ONLINE, notificationId);
|
|
||||||
notificationAsync.execute(param, notificationCallback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
statusAsync.cancel();
|
statusAsync.cancel();
|
||||||
|
@ -375,6 +360,30 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
outState.putSerializable(KEY_STATUS_DATA, status);
|
||||||
|
outState.putSerializable(KEY_NOTIFICATION_DATA, notification);
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
|
||||||
|
Object statusObject = getIntent().getSerializableExtra(KEY_STATUS_DATA);
|
||||||
|
Object notificationObject = getIntent().getSerializableExtra(KEY_NOTIFICATION_DATA);
|
||||||
|
if (statusObject instanceof Status) {
|
||||||
|
setStatus((Status) statusObject);
|
||||||
|
} else if (notificationObject instanceof Notification) {
|
||||||
|
notification = (Notification) notificationObject;
|
||||||
|
if (notification.getStatus() != null) {
|
||||||
|
setStatus(notification.getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.onRestoreInstanceState(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
super.onWindowFocusChanged(hasFocus);
|
super.onWindowFocusChanged(hasFocus);
|
||||||
|
@ -952,6 +961,18 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set notification containing a status
|
||||||
|
*
|
||||||
|
* @param notification notification with status
|
||||||
|
*/
|
||||||
|
private void setNotification(@NonNull Notification notification) {
|
||||||
|
this.notification = notification;
|
||||||
|
if (notification.getStatus() != null) {
|
||||||
|
setStatus(notification.getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update notification
|
* update notification
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue