mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-06 05:53:25 +01:00
added separate user timeline without replies, added status pin feature, bug fix
This commit is contained in:
parent
b1f1ed2d62
commit
0aac360547
@ -400,12 +400,13 @@ public interface Connection {
|
||||
/**
|
||||
* show the timeline of an user
|
||||
*
|
||||
* @param id ID of the user
|
||||
* @param minId get statuses with ID above the min ID
|
||||
* @param maxId get statuses with ID under the max ID
|
||||
* @param id ID of the user
|
||||
* @param minId get statuses with ID above the min ID
|
||||
* @param maxId get statuses with ID under the max ID
|
||||
* @param withReplies true to include user replies
|
||||
* @return list of statuses
|
||||
*/
|
||||
Statuses getUserTimeline(long id, long minId, long maxId) throws ConnectionException;
|
||||
Statuses getUserTimeline(long id, long minId, long maxId, boolean withReplies) throws ConnectionException;
|
||||
|
||||
/**
|
||||
* show the favorite timeline of an user
|
||||
@ -502,6 +503,22 @@ public interface Connection {
|
||||
*/
|
||||
Status removeBookmark(long id) throws ConnectionException;
|
||||
|
||||
/**
|
||||
* pin status to profile
|
||||
*
|
||||
* @param id ID of the status
|
||||
* @return updated status
|
||||
*/
|
||||
Status pinStatus(long id) throws ConnectionException;
|
||||
|
||||
/**
|
||||
* remove pinned status from profile
|
||||
*
|
||||
* @param id ID of the status
|
||||
* @return updated status
|
||||
*/
|
||||
Status unpinStatus(long id) throws ConnectionException;
|
||||
|
||||
/**
|
||||
* mute a status from conversation
|
||||
*
|
||||
|
@ -682,9 +682,11 @@ public class Mastodon implements Connection {
|
||||
|
||||
|
||||
@Override
|
||||
public Statuses getUserTimeline(long id, long minId, long maxId) throws MastodonException {
|
||||
public Statuses getUserTimeline(long id, long minId, long maxId, boolean withReplies) throws MastodonException {
|
||||
String endpoint = ENDPOINT_USER_TIMELINE + id + "/statuses";
|
||||
return getStatuses(endpoint, minId, maxId);
|
||||
List<String> param = new ArrayList<>();
|
||||
param.add("exclude_replies=" + !withReplies);
|
||||
return getStatuses(endpoint, minId, maxId, param);
|
||||
}
|
||||
|
||||
|
||||
@ -728,49 +730,49 @@ public class Mastodon implements Connection {
|
||||
|
||||
@Override
|
||||
public Status favoriteStatus(long id) throws MastodonException {
|
||||
MastodonStatus status = postStatus(ENDPOINT_STATUS + id + "/favourite");
|
||||
status.setFavorite(true);
|
||||
return status;
|
||||
return postStatus(ENDPOINT_STATUS + id + "/favourite").setFavorite(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Status unfavoriteStatus(long id) throws MastodonException {
|
||||
MastodonStatus status = postStatus(ENDPOINT_STATUS + id + "/unfavourite");
|
||||
status.setFavorite(false);
|
||||
return status;
|
||||
return postStatus(ENDPOINT_STATUS + id + "/unfavourite").setFavorite(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Status repostStatus(long id) throws MastodonException {
|
||||
MastodonStatus status = postStatus(ENDPOINT_STATUS + id + "/reblog");
|
||||
status.setRepost(true);
|
||||
return status;
|
||||
return postStatus(ENDPOINT_STATUS + id + "/reblog").setRepost(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Status removeRepost(long id) throws MastodonException {
|
||||
MastodonStatus status = postStatus(ENDPOINT_STATUS + id + "/unreblog");
|
||||
status.setRepost(false);
|
||||
return status;
|
||||
return postStatus(ENDPOINT_STATUS + id + "/unreblog").setRepost(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Status bookmarkStatus(long id) throws ConnectionException {
|
||||
MastodonStatus status = postStatus(ENDPOINT_STATUS + id + "/bookmark");
|
||||
status.setBookmark(true);
|
||||
return status;
|
||||
return postStatus(ENDPOINT_STATUS + id + "/bookmark").setBookmark(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Status removeBookmark(long id) throws ConnectionException {
|
||||
MastodonStatus status = postStatus(ENDPOINT_STATUS + id + "/unbookmark");
|
||||
status.setBookmark(false);
|
||||
return status;
|
||||
return postStatus(ENDPOINT_STATUS + id + "/unbookmark").setBookmark(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Status pinStatus(long id) throws ConnectionException {
|
||||
return postStatus(ENDPOINT_STATUS + id + "/pin").setPined(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Status unpinStatus(long id) throws ConnectionException {
|
||||
return postStatus(ENDPOINT_STATUS + id + "/unpin").setPined(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,6 +42,7 @@ public class MastodonStatus implements Status {
|
||||
private boolean sensitive;
|
||||
private boolean spoiler;
|
||||
private boolean muted;
|
||||
private boolean isPinned;
|
||||
|
||||
private String text;
|
||||
private String mentions = "";
|
||||
@ -86,6 +87,7 @@ public class MastodonStatus implements Status {
|
||||
sensitive = json.optBoolean("sensitive", false);
|
||||
spoiler = json.optBoolean("spoiler_text", false);
|
||||
bookmarked = json.optBoolean("bookmarked", false);
|
||||
isPinned = json.optBoolean("pinned", false);
|
||||
text = StringUtils.extractText(json.optString("content", ""));
|
||||
|
||||
if (!editedAtStr.isEmpty() && !editedAtStr.equals("null"))
|
||||
@ -315,6 +317,12 @@ public class MastodonStatus implements Status {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPinned() {
|
||||
return isPinned;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
return muted;
|
||||
@ -372,30 +380,44 @@ public class MastodonStatus implements Status {
|
||||
/**
|
||||
* set repost status
|
||||
*/
|
||||
public void setRepost(boolean reposted) {
|
||||
public MastodonStatus setRepost(boolean reposted) {
|
||||
this.reposted = reposted;
|
||||
if (embeddedStatus instanceof MastodonStatus) {
|
||||
((MastodonStatus) embeddedStatus).setRepost(reposted);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set favorite status
|
||||
*/
|
||||
public void setFavorite(boolean favorited) {
|
||||
public MastodonStatus setFavorite(boolean favorited) {
|
||||
this.favorited = favorited;
|
||||
if (embeddedStatus instanceof MastodonStatus) {
|
||||
((MastodonStatus) embeddedStatus).setFavorite(favorited);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set bookmark status
|
||||
*/
|
||||
public void setBookmark(boolean bookmarked) {
|
||||
public MastodonStatus setBookmark(boolean bookmarked) {
|
||||
this.bookmarked = bookmarked;
|
||||
if (embeddedStatus instanceof MastodonStatus) {
|
||||
((MastodonStatus) embeddedStatus).setBookmark(bookmarked);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set status pinned
|
||||
*/
|
||||
public MastodonStatus setPined(boolean pinned) {
|
||||
this.isPinned = pinned;
|
||||
if (embeddedStatus instanceof MastodonStatus) {
|
||||
((MastodonStatus) embeddedStatus).setPined(pinned);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
@ -98,6 +98,16 @@ public class StatusAction extends AsyncExecutor<StatusAction.Param, StatusAction
|
||||
db.hideStatus(param.id, false);
|
||||
return new Result(Result.UNHIDE, null);
|
||||
|
||||
case Param.PIN:
|
||||
status = connection.pinStatus(param.id);
|
||||
db.saveStatus(status);
|
||||
return new Result(Result.PIN, status);
|
||||
|
||||
case Param.UNPIN:
|
||||
status = connection.unpinStatus(param.id);
|
||||
db.saveStatus(status);
|
||||
return new Result(Result.UNPIN, status);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -125,7 +135,9 @@ public class StatusAction extends AsyncExecutor<StatusAction.Param, StatusAction
|
||||
public static final int UNHIDE = 8;
|
||||
public static final int BOOKMARK = 9;
|
||||
public static final int UNBOOKMARK = 10;
|
||||
public static final int DELETE = 11;
|
||||
public static final int PIN = 11;
|
||||
public static final int UNPIN = 12;
|
||||
public static final int DELETE = 13;
|
||||
|
||||
final int mode;
|
||||
final long id;
|
||||
@ -152,7 +164,9 @@ public class StatusAction extends AsyncExecutor<StatusAction.Param, StatusAction
|
||||
public static final int UNHIDE = 19;
|
||||
public static final int BOOKMARK = 20;
|
||||
public static final int UNBOOKMARK = 21;
|
||||
public static final int DELETE = 22;
|
||||
public static final int PIN = 22;
|
||||
public static final int UNPIN = 23;
|
||||
public static final int DELETE = 24;
|
||||
|
||||
public final int mode;
|
||||
@Nullable
|
||||
|
@ -52,14 +52,16 @@ public class StatusLoader extends AsyncExecutor<StatusLoader.Param, StatusLoader
|
||||
return new Result(statuses, param.pos, null);
|
||||
|
||||
case Param.USER:
|
||||
case Param.USER_ALL:
|
||||
boolean withReplies = param.type == Param.USER_ALL;
|
||||
if (param.minId == Param.NO_ID && param.maxId == Param.NO_ID) {
|
||||
statuses = db.getUserTimeline(param.id);
|
||||
if (statuses.isEmpty()) {
|
||||
statuses = connection.getUserTimeline(param.id, 0L, 0L);
|
||||
statuses = connection.getUserTimeline(param.id, 0L, 0L, withReplies);
|
||||
db.saveUserTimeline(statuses);
|
||||
}
|
||||
} else {
|
||||
statuses = connection.getUserTimeline(param.id, param.minId, param.maxId);
|
||||
statuses = connection.getUserTimeline(param.id, param.minId, param.maxId, withReplies);
|
||||
if (param.maxId == Param.NO_ID) {
|
||||
db.saveUserTimeline(statuses);
|
||||
}
|
||||
@ -148,13 +150,14 @@ public class StatusLoader extends AsyncExecutor<StatusLoader.Param, StatusLoader
|
||||
|
||||
public static final int HOME = 1;
|
||||
public static final int USER = 2;
|
||||
public static final int FAVORIT = 3;
|
||||
public static final int REPLIES = 4;
|
||||
public static final int REPLIES_LOCAL = 5;
|
||||
public static final int SEARCH = 6;
|
||||
public static final int USERLIST = 7;
|
||||
public static final int PUBLIC = 8;
|
||||
public static final int BOOKMARKS = 9;
|
||||
public static final int USER_ALL = 3;
|
||||
public static final int FAVORIT = 4;
|
||||
public static final int REPLIES = 5;
|
||||
public static final int REPLIES_LOCAL = 6;
|
||||
public static final int SEARCH = 7;
|
||||
public static final int USERLIST = 8;
|
||||
public static final int PUBLIC = 9;
|
||||
public static final int BOOKMARKS = 10;
|
||||
|
||||
final String search;
|
||||
final int type, pos;
|
||||
|
@ -99,7 +99,7 @@ public class AppDatabase {
|
||||
* SQL query to get home timeline status
|
||||
*/
|
||||
private static final String HOME_QUERY = "SELECT * FROM(" + STATUS_SUBQUERY + ")"
|
||||
+ " WHERE " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.REGISTER + "&" + StatusPropertiesTable.MASK_STATUS_HOME_TIMELINE + " IS NOT 0"
|
||||
+ " WHERE " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.FLAGS + "&" + StatusPropertiesTable.MASK_STATUS_HOME_TIMELINE + " IS NOT 0"
|
||||
+ " AND " + UserPropertiesTable.TABLE + "." + UserPropertiesTable.REGISTER + "&" + UserPropertiesTable.MASK_USER_FILTERED + " IS 0"
|
||||
+ " AND " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.OWNER + "=?"
|
||||
+ " AND " + UserPropertiesTable.TABLE + "." + UserPropertiesTable.OWNER + "=?"
|
||||
@ -110,7 +110,7 @@ public class AppDatabase {
|
||||
* SQL query to get status of an user
|
||||
*/
|
||||
private static final String USER_STATUS_QUERY = "SELECT * FROM(" + STATUS_SUBQUERY + ")"
|
||||
+ " WHERE " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.REGISTER + "&" + StatusPropertiesTable.MASK_STATUS_USER_TIMELINE + " IS NOT 0"
|
||||
+ " WHERE " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.FLAGS + "&" + StatusPropertiesTable.MASK_STATUS_USER_TIMELINE + " IS NOT 0"
|
||||
+ " AND " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.OWNER + "=?"
|
||||
+ " AND " + UserPropertiesTable.TABLE + "." + UserPropertiesTable.OWNER + "=?"
|
||||
+ " AND " + StatusTable.TABLE + "." + StatusTable.USER + "=?"
|
||||
@ -166,8 +166,8 @@ public class AppDatabase {
|
||||
+ " WHERE " + ReplyTable.TABLE + "." + ReplyTable.REPLY + "=?"
|
||||
+ " AND " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.OWNER + "=?"
|
||||
+ " AND " + UserPropertiesTable.TABLE + "." + UserPropertiesTable.OWNER + "=?"
|
||||
+ " AND " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.REGISTER + "&" + StatusPropertiesTable.MASK_STATUS_REPLY + " IS NOT 0"
|
||||
+ " AND " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.REGISTER + "&" + StatusPropertiesTable.MASK_STATUS_HIDDEN + " IS 0"
|
||||
+ " AND " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.FLAGS + "&" + StatusPropertiesTable.MASK_STATUS_REPLY + " IS NOT 0"
|
||||
+ " AND " + StatusPropertiesTable.TABLE + "." + StatusPropertiesTable.FLAGS + "&" + StatusPropertiesTable.MASK_STATUS_HIDDEN + " IS 0"
|
||||
+ " AND " + UserPropertiesTable.TABLE + "." + UserPropertiesTable.REGISTER + "&" + UserPropertiesTable.MASK_USER_FILTERED + " IS 0"
|
||||
+ " ORDER BY " + ReplyTable.TABLE + "." + ReplyTable.ORDER + " ASC"
|
||||
+ " LIMIT ?;";
|
||||
@ -297,7 +297,7 @@ public class AppDatabase {
|
||||
/**
|
||||
* column projection for status flag register
|
||||
*/
|
||||
private static final String[] COLUMNS_REGISTER_STATUS = {StatusPropertiesTable.REGISTER};
|
||||
private static final String[] COLUMNS_REGISTER_STATUS = {StatusPropertiesTable.FLAGS};
|
||||
|
||||
/**
|
||||
* default sort order for logins
|
||||
@ -916,7 +916,7 @@ public class AppDatabase {
|
||||
flags &= ~StatusPropertiesTable.MASK_STATUS_HIDDEN;
|
||||
}
|
||||
ContentValues column = new ContentValues(1);
|
||||
column.put(StatusPropertiesTable.REGISTER, flags);
|
||||
column.put(StatusPropertiesTable.FLAGS, flags);
|
||||
db.update(StatusPropertiesTable.TABLE, column, STATUS_REG_SELECT, args);
|
||||
adapter.commit();
|
||||
}
|
||||
@ -1449,6 +1449,11 @@ public class AppDatabase {
|
||||
} else {
|
||||
flags &= ~StatusPropertiesTable.MASK_STATUS_BOOKMARKED;
|
||||
}
|
||||
if (status.isPinned()) {
|
||||
flags |= StatusPropertiesTable.MASK_STATUS_PINNED;
|
||||
} else {
|
||||
flags &= ~StatusPropertiesTable.MASK_STATUS_PINNED;
|
||||
}
|
||||
switch (status.getVisibility()) {
|
||||
case Status.VISIBLE_DIRECT:
|
||||
flags |= StatusPropertiesTable.MASK_STATUS_VISIBILITY_DIRECT;
|
||||
@ -1607,7 +1612,7 @@ public class AppDatabase {
|
||||
String[] args = {Long.toString(status.getId()), Long.toString(settings.getLogin().getId())};
|
||||
|
||||
ContentValues column = new ContentValues(4);
|
||||
column.put(StatusPropertiesTable.REGISTER, flags);
|
||||
column.put(StatusPropertiesTable.FLAGS, flags);
|
||||
column.put(StatusPropertiesTable.REPOST_ID, status.getRepostId());
|
||||
column.put(StatusPropertiesTable.STATUS, status.getId());
|
||||
column.put(StatusPropertiesTable.OWNER, settings.getLogin().getId());
|
||||
|
@ -171,7 +171,7 @@ public class DatabaseAdapter {
|
||||
+ StatusPropertiesTable.TABLE + "("
|
||||
+ StatusPropertiesTable.STATUS + " INTEGER NOT NULL,"
|
||||
+ StatusPropertiesTable.OWNER + " INTEGER,"
|
||||
+ StatusPropertiesTable.REGISTER + " INTEGER,"
|
||||
+ StatusPropertiesTable.FLAGS + " INTEGER,"
|
||||
+ StatusPropertiesTable.REPOST_ID + " INTEGER,"
|
||||
+ "FOREIGN KEY(" + StatusPropertiesTable.STATUS + ")"
|
||||
+ "REFERENCES " + StatusTable.TABLE + "(" + StatusTable.ID + "));";
|
||||
@ -878,7 +878,7 @@ public class DatabaseAdapter {
|
||||
/**
|
||||
* Register with status bits
|
||||
*/
|
||||
String REGISTER = "status_flags";
|
||||
String FLAGS = "status_flags";
|
||||
|
||||
/**
|
||||
* ID of the repost of the current user (if exists)
|
||||
@ -949,6 +949,11 @@ public class DatabaseAdapter {
|
||||
* status visibility flag {@link Status#VISIBLE_DIRECT}
|
||||
*/
|
||||
int MASK_STATUS_VISIBILITY_DIRECT = 3 << 11;
|
||||
|
||||
/**
|
||||
* status is pinned to profile
|
||||
*/
|
||||
int MASK_STATUS_PINNED = 1 << 13;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ public class DatabaseStatus implements Status, StatusTable, StatusPropertiesTabl
|
||||
|
||||
private long id, time, embeddedId, replyID, replyUserId, myRepostId, locationId, pollId, editedAt;
|
||||
private int repostCount, favoriteCount, replyCount, visibility;
|
||||
private boolean reposted, favorited, bookmarked, sensitive, spoiler, isHidden;
|
||||
private boolean reposted, favorited, bookmarked, sensitive, spoiler, isHidden, isPinned;
|
||||
private Status embedded;
|
||||
private Poll poll;
|
||||
private User author;
|
||||
@ -74,20 +74,20 @@ public class DatabaseStatus implements Status, StatusTable, StatusPropertiesTabl
|
||||
String userMentions = cursor.getString(cursor.getColumnIndexOrThrow(MENTIONS));
|
||||
String mediaKeys = cursor.getString(cursor.getColumnIndexOrThrow(MEDIA));
|
||||
String emojiKeys = cursor.getString(cursor.getColumnIndexOrThrow(EMOJI));
|
||||
int register = cursor.getInt(cursor.getColumnIndexOrThrow(REGISTER));
|
||||
int flags = cursor.getInt(cursor.getColumnIndexOrThrow(FLAGS));
|
||||
|
||||
favorited = (register & MASK_STATUS_FAVORITED) != 0;
|
||||
reposted = (register & MASK_STATUS_REPOSTED) != 0;
|
||||
sensitive = (register & MASK_STATUS_SENSITIVE) != 0;
|
||||
isHidden = (register & MASK_STATUS_HIDDEN) != 0;
|
||||
bookmarked = (register & MASK_STATUS_BOOKMARKED) != 0;
|
||||
spoiler = (register & MASK_STATUS_SPOILER) != 0;
|
||||
|
||||
if ((register & MASK_STATUS_VISIBILITY_DIRECT) != 0)
|
||||
favorited = (flags & MASK_STATUS_FAVORITED) != 0;
|
||||
reposted = (flags & MASK_STATUS_REPOSTED) != 0;
|
||||
sensitive = (flags & MASK_STATUS_SENSITIVE) != 0;
|
||||
isHidden = (flags & MASK_STATUS_HIDDEN) != 0;
|
||||
bookmarked = (flags & MASK_STATUS_BOOKMARKED) != 0;
|
||||
spoiler = (flags & MASK_STATUS_SPOILER) != 0;
|
||||
isPinned = (flags & MASK_STATUS_PINNED) != 0;
|
||||
if ((flags & MASK_STATUS_VISIBILITY_DIRECT) != 0)
|
||||
visibility = VISIBLE_DIRECT;
|
||||
else if ((register & MASK_STATUS_VISIBILITY_PRIVATE) != 0)
|
||||
else if ((flags & MASK_STATUS_VISIBILITY_PRIVATE) != 0)
|
||||
visibility = VISIBLE_PRIVATE;
|
||||
else if ((register & MASK_STATUS_VISIBILITY_UNLISTED) != 0)
|
||||
else if ((flags & MASK_STATUS_VISIBILITY_UNLISTED) != 0)
|
||||
visibility = VISIBLE_UNLISTED;
|
||||
else
|
||||
visibility = VISIBLE_PUBLIC;
|
||||
@ -257,6 +257,12 @@ public class DatabaseStatus implements Status, StatusTable, StatusPropertiesTabl
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPinned() {
|
||||
return isPinned;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Location getLocation() {
|
||||
|
@ -147,6 +147,11 @@ public interface Status extends Serializable, Comparable<Status> {
|
||||
*/
|
||||
boolean isBookmarked();
|
||||
|
||||
/**
|
||||
* @return true if status is pinned to profile
|
||||
*/
|
||||
boolean isPinned();
|
||||
|
||||
/**
|
||||
* @return true if status is hidden by current user
|
||||
*/
|
||||
|
@ -59,7 +59,6 @@ import org.nuclearfog.twidda.ui.views.LockableConstraintLayout;
|
||||
import org.nuclearfog.twidda.ui.views.TabSelector;
|
||||
import org.nuclearfog.twidda.ui.views.TabSelector.OnTabSelectedListener;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation;
|
||||
@ -212,26 +211,27 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
|
||||
toolbar.setTitle("");
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
viewPager.setOffscreenPageLimit(3);
|
||||
|
||||
// get parameters
|
||||
if (savedInstanceState == null) {
|
||||
savedInstanceState = getIntent().getExtras();
|
||||
}
|
||||
if (savedInstanceState == null) {
|
||||
return;
|
||||
}
|
||||
long userId = savedInstanceState.getLong(KEY_ID, 0L);
|
||||
Serializable serializedUser = savedInstanceState.getSerializable(KEY_USER);
|
||||
Serializable serializedRelation = savedInstanceState.getSerializable(KEY_RELATION);
|
||||
// get relation data
|
||||
if (serializedRelation instanceof Relation) {
|
||||
relation = (Relation) serializedRelation;
|
||||
}
|
||||
// get user data
|
||||
if (serializedUser instanceof User) {
|
||||
user = (User) serializedUser;
|
||||
userId = user.getId();
|
||||
long userId = 0L;
|
||||
if (savedInstanceState != null) {
|
||||
Object userData = savedInstanceState.getSerializable(KEY_USER);
|
||||
Object relationData = savedInstanceState.getSerializable(KEY_RELATION);
|
||||
// get relation data
|
||||
if (relationData instanceof Relation) {
|
||||
relation = (Relation) relationData;
|
||||
}
|
||||
// get user data
|
||||
if (userData instanceof User) {
|
||||
user = (User) userData;
|
||||
userId = user.getId();
|
||||
}
|
||||
} else {
|
||||
Object userData = getIntent().getSerializableExtra(KEY_USER);
|
||||
if (userData instanceof User) {
|
||||
user = (User) userData;
|
||||
userId = user.getId();
|
||||
} else {
|
||||
userId = getIntent().getLongExtra(KEY_ID, 0L);
|
||||
}
|
||||
}
|
||||
// setup pager fragments
|
||||
adapter.setId(userId);
|
||||
@ -251,10 +251,13 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
|
||||
}
|
||||
if (userId != settings.getLogin().getId()) {
|
||||
tabSelector.addTabIcons(R.array.profile_tab_icons);
|
||||
viewPager.setOffscreenPageLimit(3);
|
||||
} else if (settings.likeEnabled()) {
|
||||
tabSelector.addTabIcons(R.array.profile_tab_icons_like);
|
||||
viewPager.setOffscreenPageLimit(5);
|
||||
} else {
|
||||
tabSelector.addTabIcons(R.array.profile_tab_icons_favorite);
|
||||
viewPager.setOffscreenPageLimit(5);
|
||||
}
|
||||
tabSelector.addOnTabSelectedListener(this);
|
||||
following.setOnClickListener(this);
|
||||
@ -279,6 +282,7 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
|
||||
relationLoader.cancel();
|
||||
userLoader.cancel();
|
||||
emojiLoader.cancel();
|
||||
domainAction.cancel();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
@ -373,20 +373,21 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
MenuItem optHide = m.findItem(R.id.menu_status_hide);
|
||||
MenuItem optCopy = m.findItem(R.id.menu_status_copy);
|
||||
MenuItem optReport = m.findItem(R.id.menu_status_report);
|
||||
MenuItem optPin = m.findItem(R.id.menu_status_pin);
|
||||
MenuItem menuBookmark = m.findItem(R.id.menu_status_bookmark);
|
||||
MenuItem editStatus = m.findItem(R.id.menu_status_edit);
|
||||
MenuItem editHistory = m.findItem(R.id.menu_status_history);
|
||||
SubMenu copyMenu = optCopy.getSubMenu();
|
||||
|
||||
// set status options
|
||||
if (status != null) {
|
||||
Status currentStatus = status;
|
||||
if (currentStatus.getEmbeddedStatus() != null) {
|
||||
currentStatus = currentStatus.getEmbeddedStatus();
|
||||
}
|
||||
// enable/disable status reply hide
|
||||
long currentUserId = settings.getLogin().getId();
|
||||
if (currentStatus.getRepliedUserId() == currentUserId && currentStatus.getAuthor().getId() != currentUserId) {
|
||||
if (currentStatus.getAuthor().getId() == settings.getLogin().getId()) {
|
||||
optPin.setTitle(status.isPinned() ? R.string.menu_status_unpin : R.string.menu_status_pin);
|
||||
optPin.setVisible(true);
|
||||
} else if (currentStatus.getRepliedUserId() == settings.getLogin().getId()) {
|
||||
optHide.setTitle(hidden ? R.string.menu_status_hide : R.string.menu_status_unhide);
|
||||
optHide.setVisible(true);
|
||||
}
|
||||
@ -429,26 +430,35 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
Status status = this.status;
|
||||
if (status.getEmbeddedStatus() != null)
|
||||
status = status.getEmbeddedStatus();
|
||||
// Delete status option
|
||||
if (item.getItemId() == R.id.menu_status_delete) {
|
||||
confirmDialog.show(ConfirmDialog.DELETE_STATUS);
|
||||
return true;
|
||||
}
|
||||
// add/remove bookmark
|
||||
else if (item.getItemId() == R.id.menu_status_bookmark) {
|
||||
Toast.makeText(getApplicationContext(), R.string.info_loading, Toast.LENGTH_SHORT).show();
|
||||
int mode = status.isBookmarked() ? StatusAction.Param.UNBOOKMARK : StatusAction.Param.BOOKMARK;
|
||||
StatusAction.Param param = new StatusAction.Param(mode, status.getId());
|
||||
statusLoader.execute(param, statusCallback);
|
||||
if (item.getItemId() == R.id.menu_status_bookmark) {
|
||||
if (statusLoader.isIdle()) {
|
||||
Toast.makeText(getApplicationContext(), R.string.info_loading, Toast.LENGTH_SHORT).show();
|
||||
int mode = status.isBookmarked() ? StatusAction.Param.UNBOOKMARK : StatusAction.Param.BOOKMARK;
|
||||
StatusAction.Param param = new StatusAction.Param(mode, status.getId());
|
||||
statusLoader.execute(param, statusCallback);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// hide status
|
||||
else if (item.getItemId() == R.id.menu_status_hide) {
|
||||
int mode = hidden ? StatusAction.Param.UNHIDE : StatusAction.Param.HIDE;
|
||||
StatusAction.Param param = new StatusAction.Param(mode, status.getId());
|
||||
statusLoader.execute(param, statusCallback);
|
||||
if (statusLoader.isIdle()) {
|
||||
Toast.makeText(getApplicationContext(), R.string.info_loading, Toast.LENGTH_SHORT).show();
|
||||
int mode = hidden ? StatusAction.Param.UNHIDE : StatusAction.Param.HIDE;
|
||||
StatusAction.Param param = new StatusAction.Param(mode, status.getId());
|
||||
statusLoader.execute(param, statusCallback);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// pin/unpin status
|
||||
else if (item.getItemId() == R.id.menu_status_pin) {
|
||||
if (statusLoader.isIdle()) {
|
||||
Toast.makeText(getApplicationContext(), R.string.info_loading, Toast.LENGTH_SHORT).show();
|
||||
int mode = status.isPinned() ? StatusAction.Param.UNPIN : StatusAction.Param.PIN;
|
||||
StatusAction.Param param = new StatusAction.Param(mode, status.getId());
|
||||
statusLoader.execute(param, statusCallback);
|
||||
}
|
||||
}
|
||||
// get status link
|
||||
else if (item.getItemId() == R.id.menu_status_browser) {
|
||||
if (!status.getUrl().isEmpty()) {
|
||||
@ -507,6 +517,11 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
// Delete status option
|
||||
else if (item.getItemId() == R.id.menu_status_delete) {
|
||||
confirmDialog.show(ConfirmDialog.DELETE_STATUS);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -979,16 +994,22 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
|
||||
case StatusAction.Result.HIDE:
|
||||
hidden = true;
|
||||
invalidateOptionsMenu();
|
||||
Toast.makeText(getApplicationContext(), R.string.info_reply_hidden, Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
case StatusAction.Result.UNHIDE:
|
||||
hidden = false;
|
||||
invalidateOptionsMenu();
|
||||
Toast.makeText(getApplicationContext(), R.string.info_reply_unhidden, Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
case StatusAction.Result.PIN:
|
||||
Toast.makeText(getApplicationContext(), R.string.info_status_pinned, Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
case StatusAction.Result.UNPIN:
|
||||
Toast.makeText(getApplicationContext(), R.string.info_status_unpinned, Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
case StatusAction.Result.DELETE:
|
||||
if (notification != null) {
|
||||
Toast.makeText(getApplicationContext(), R.string.info_status_removed, Toast.LENGTH_SHORT).show();
|
||||
|
@ -35,10 +35,10 @@ public class ProfileAdapter extends ViewPagerAdapter {
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
ListFragment fragment;
|
||||
Bundle param = new Bundle();
|
||||
switch (position) {
|
||||
default:
|
||||
case 0:
|
||||
Bundle param = new Bundle();
|
||||
param.putLong(StatusFragment.KEY_ID, userId);
|
||||
param.putInt(StatusFragment.KEY_MODE, StatusFragment.MODE_USER);
|
||||
fragment = new StatusFragment();
|
||||
@ -46,6 +46,13 @@ public class ProfileAdapter extends ViewPagerAdapter {
|
||||
break;
|
||||
|
||||
case 1:
|
||||
param.putLong(StatusFragment.KEY_ID, userId);
|
||||
param.putInt(StatusFragment.KEY_MODE, StatusFragment.MODE_USER_ALL);
|
||||
fragment = new StatusFragment();
|
||||
fragment.setArguments(param);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (getItemCount() == 2) {
|
||||
param = new Bundle();
|
||||
param.putLong(FieldFragment.KEY_ID, userId);
|
||||
@ -60,16 +67,14 @@ public class ProfileAdapter extends ViewPagerAdapter {
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
param = new Bundle();
|
||||
case 3:
|
||||
param.putLong(StatusFragment.KEY_ID, userId);
|
||||
param.putInt(StatusFragment.KEY_MODE, StatusFragment.MODE_BOOKMARK);
|
||||
fragment = new StatusFragment();
|
||||
fragment.setArguments(param);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
param = new Bundle();
|
||||
case 4:
|
||||
param.putLong(FieldFragment.KEY_ID, userId);
|
||||
fragment = new FieldFragment();
|
||||
fragment.setArguments(param);
|
||||
@ -86,9 +91,9 @@ public class ProfileAdapter extends ViewPagerAdapter {
|
||||
public void setId(long userId) {
|
||||
this.userId = userId;
|
||||
if (settings.getLogin().getId() == userId) {
|
||||
setPageCount(4);
|
||||
setPageCount(5);
|
||||
} else {
|
||||
setPageCount(2);
|
||||
setPageCount(3);
|
||||
}
|
||||
}
|
||||
}
|
@ -61,12 +61,19 @@ public class StatusFragment extends ListFragment implements StatusSelectListener
|
||||
public static final int MODE_HOME = 0xE7028B60;
|
||||
|
||||
/**
|
||||
* setup list for status timeline of a specific user
|
||||
* setup timeline to show user posts without replies
|
||||
*
|
||||
* @see #KEY_MODE
|
||||
*/
|
||||
public static final int MODE_USER = 0x4DBEF6CD;
|
||||
|
||||
/**
|
||||
* setup timeline to show all user posts
|
||||
*
|
||||
* @see #KEY_MODE
|
||||
*/
|
||||
public static final int MODE_USER_ALL = 0xfb825f97;
|
||||
|
||||
/**
|
||||
* setup list for favorite timeline of a specific user
|
||||
*
|
||||
@ -268,6 +275,10 @@ public class StatusFragment extends ListFragment implements StatusSelectListener
|
||||
request = new StatusLoader.Param(StatusLoader.Param.USER, id, sinceId, maxId, index, search);
|
||||
break;
|
||||
|
||||
case MODE_USER_ALL:
|
||||
request = new StatusLoader.Param(StatusLoader.Param.USER_ALL, id, sinceId, maxId, index, search);
|
||||
break;
|
||||
|
||||
case MODE_FAVORIT:
|
||||
request = new StatusLoader.Param(StatusLoader.Param.FAVORIT, id, sinceId, maxId, index, search);
|
||||
break;
|
||||
|
@ -24,6 +24,11 @@
|
||||
android:id="@+id/menu_status_bookmark"
|
||||
android:title="@string/menu_bookmark_add" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_status_pin"
|
||||
android:title="@string/menu_status_pin"
|
||||
android:visible="false" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_status_hide"
|
||||
android:title="@string/menu_status_hide"
|
||||
|
@ -374,4 +374,8 @@
|
||||
<string name="description_announcement_reaction">Reaktionen einer Ankündigung</string>
|
||||
<string name="info_reaction_added">Reaktion zu Ankündigung hinzugefügt</string>
|
||||
<string name="info_reaction_removed">Reaktion von Ankündigung entfernt</string>
|
||||
<string name="info_status_pinned">Status wurde am Profil angeheftet</string>
|
||||
<string name="info_status_unpinned">Status wurde vom Profil abgeheftet</string>
|
||||
<string name="menu_status_pin">an Profil anheften</string>
|
||||
<string name="menu_status_unpin">vom Profil abheften</string>
|
||||
</resources>
|
@ -42,11 +42,13 @@
|
||||
|
||||
<integer-array name="profile_tab_icons">
|
||||
<item>@drawable/home</item>
|
||||
<item>@drawable/answer</item>
|
||||
<item>@drawable/info</item>
|
||||
</integer-array>
|
||||
|
||||
<integer-array name="profile_tab_icons_favorite">
|
||||
<item>@drawable/home</item>
|
||||
<item>@drawable/answer</item>
|
||||
<item>@drawable/favorite</item>
|
||||
<item>@drawable/bookmark</item>
|
||||
<item>@drawable/info</item>
|
||||
@ -54,6 +56,7 @@
|
||||
|
||||
<integer-array name="profile_tab_icons_like">
|
||||
<item>@drawable/home</item>
|
||||
<item>@drawable/answer</item>
|
||||
<item>@drawable/like</item>
|
||||
<item>@drawable/bookmark</item>
|
||||
<item>@drawable/info</item>
|
||||
|
@ -40,6 +40,8 @@
|
||||
<string name="info_status_unbookmarked">Status removed from bookmarks</string>
|
||||
<string name="info_reply_hidden">Reply is hidden</string>
|
||||
<string name="info_reply_unhidden">Reply is visible</string>
|
||||
<string name="info_status_pinned">Status pinned to profile</string>
|
||||
<string name="info_status_unpinned">Status unpinned from profile</string>
|
||||
<string name="info_user_muted">User muted</string>
|
||||
<string name="info_user_unmuted">User unmuted</string>
|
||||
<string name="info_image_saved">Image saved</string>
|
||||
@ -154,6 +156,8 @@
|
||||
<string name="menu_block_domain">block domain</string>
|
||||
<string name="menu_bookmark_add">bookmark</string>
|
||||
<string name="menu_bookmark_remove">remove bookmark</string>
|
||||
<string name="menu_status_pin">pin to profile</string>
|
||||
<string name="menu_status_unpin">unpin from profile</string>
|
||||
<string name="menu_unmute_user">unmute</string>
|
||||
<string name="menu_status_edit">edit</string>
|
||||
<string name="menu_status_history">history</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user