forked from mirrors/Fedilab
Fix issue #81 - Open a link when clicking content
This commit is contained in:
parent
f3722688c4
commit
321021c9dd
4 changed files with 65 additions and 45 deletions
|
@ -101,7 +101,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
private ScheduledStatus scheduledStatus;
|
private ScheduledStatus scheduledStatus;
|
||||||
private String visibility;
|
private String visibility;
|
||||||
private app.fedilab.android.client.mastodon.entities.Account accountMention;
|
private app.fedilab.android.client.mastodon.entities.Account accountMention;
|
||||||
|
private String statusReplyId;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -125,6 +125,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
statusReply = (Status) b.getSerializable(Helper.ARG_STATUS_REPLY);
|
statusReply = (Status) b.getSerializable(Helper.ARG_STATUS_REPLY);
|
||||||
statusDraft = (StatusDraft) b.getSerializable(Helper.ARG_STATUS_DRAFT);
|
statusDraft = (StatusDraft) b.getSerializable(Helper.ARG_STATUS_DRAFT);
|
||||||
scheduledStatus = (ScheduledStatus) b.getSerializable(Helper.ARG_STATUS_SCHEDULED);
|
scheduledStatus = (ScheduledStatus) b.getSerializable(Helper.ARG_STATUS_SCHEDULED);
|
||||||
|
statusReplyId = b.getString(Helper.ARG_STATUS_REPLY_ID);
|
||||||
statusMention = (Status) b.getSerializable(Helper.ARG_STATUS_MENTION);
|
statusMention = (Status) b.getSerializable(Helper.ARG_STATUS_MENTION);
|
||||||
account = (Account) b.getSerializable(Helper.ARG_ACCOUNT);
|
account = (Account) b.getSerializable(Helper.ARG_ACCOUNT);
|
||||||
instance = b.getString(Helper.ARG_INSTANCE, BaseMainActivity.currentInstance);
|
instance = b.getString(Helper.ARG_INSTANCE, BaseMainActivity.currentInstance);
|
||||||
|
@ -172,8 +173,18 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
Status status = new Status();
|
Status status = new Status();
|
||||||
statusDraftList.add(status);
|
statusDraftList.add(status);
|
||||||
|
|
||||||
//Restore a draft with all messages
|
if (statusReplyId != null && statusDraft != null) {//Delete and redraft
|
||||||
if (statusDraft != null) {
|
ArrayList<Status> statusDraftListDR = new ArrayList<>();
|
||||||
|
statusDraftListDR.add(statusDraft.statusDraftList.get(0));
|
||||||
|
statusList.addAll(statusDraftListDR);
|
||||||
|
composeAdapter = new ComposeAdapter(statusList, 0, account, accountMention, visibility);
|
||||||
|
composeAdapter.manageDrafts = this;
|
||||||
|
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
|
||||||
|
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||||
|
binding.recyclerView.setAdapter(composeAdapter);
|
||||||
|
statusesVM.getContext(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusReplyId)
|
||||||
|
.observe(ComposeActivity.this, this::initializeContextView);
|
||||||
|
} else if (statusDraft != null) {//Restore a draft with all messages
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
if (statusDraft.statusReplyList != null) {
|
if (statusDraft.statusReplyList != null) {
|
||||||
statusDraft.statusReplyList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusDraft.statusReplyList);
|
statusDraft.statusReplyList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusDraft.statusReplyList);
|
||||||
|
|
|
@ -214,24 +214,13 @@ public class QuickLoad {
|
||||||
QuickLoad localQuickLoad = getSavedValue(account, Timeline.TimeLineEnum.LOCAL, null);
|
QuickLoad localQuickLoad = getSavedValue(account, Timeline.TimeLineEnum.LOCAL, null);
|
||||||
QuickLoad publicQuickLoad = getSavedValue(account, Timeline.TimeLineEnum.PUBLIC, null);
|
QuickLoad publicQuickLoad = getSavedValue(account, Timeline.TimeLineEnum.PUBLIC, null);
|
||||||
|
|
||||||
|
if (homeQuickLoad != null && homeQuickLoad.statuses != null) {
|
||||||
for (Status status : homeQuickLoad.statuses) {
|
for (Status status : homeQuickLoad.statuses) {
|
||||||
if (status.id.equals(id)) {
|
if (status.id.equals(id)) {
|
||||||
homeQuickLoad.statuses.remove(status);
|
homeQuickLoad.statuses.remove(status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Status status : localQuickLoad.statuses) {
|
|
||||||
if (status.id.equals(id)) {
|
|
||||||
localQuickLoad.statuses.remove(status);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Status status : publicQuickLoad.statuses) {
|
|
||||||
if (status.id.equals(id)) {
|
|
||||||
publicQuickLoad.statuses.remove(status);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ContentValues valuesHome = new ContentValues();
|
ContentValues valuesHome = new ContentValues();
|
||||||
valuesHome.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(homeQuickLoad.statuses));
|
valuesHome.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(homeQuickLoad.statuses));
|
||||||
//Inserts token
|
//Inserts token
|
||||||
|
@ -242,28 +231,46 @@ public class QuickLoad {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (localQuickLoad != null && localQuickLoad.statuses != null) {
|
||||||
|
for (Status status : localQuickLoad.statuses) {
|
||||||
|
if (status.id.equals(id)) {
|
||||||
|
localQuickLoad.statuses.remove(status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
ContentValues valuesLocal = new ContentValues();
|
ContentValues valuesLocal = new ContentValues();
|
||||||
valuesLocal.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(homeQuickLoad.statuses));
|
valuesLocal.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(localQuickLoad.statuses));
|
||||||
//Inserts token
|
//Inserts token
|
||||||
try {
|
try {
|
||||||
db.update(Sqlite.TABLE_QUICK_LOAD,
|
db.update(Sqlite.TABLE_QUICK_LOAD,
|
||||||
valuesLocal, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_SLUG + "=?",
|
valuesLocal, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_SLUG + "=?",
|
||||||
new String[]{homeQuickLoad.user_id, homeQuickLoad.instance, homeQuickLoad.slug});
|
new String[]{localQuickLoad.user_id, localQuickLoad.instance, localQuickLoad.slug});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (publicQuickLoad != null && publicQuickLoad.statuses != null) {
|
||||||
|
for (Status status : publicQuickLoad.statuses) {
|
||||||
|
if (status.id.equals(id)) {
|
||||||
|
publicQuickLoad.statuses.remove(status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
ContentValues valuesPublic = new ContentValues();
|
ContentValues valuesPublic = new ContentValues();
|
||||||
valuesPublic.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(homeQuickLoad.statuses));
|
valuesPublic.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(publicQuickLoad.statuses));
|
||||||
//Inserts token
|
//Inserts token
|
||||||
try {
|
try {
|
||||||
db.update(Sqlite.TABLE_QUICK_LOAD,
|
db.update(Sqlite.TABLE_QUICK_LOAD,
|
||||||
valuesPublic, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_SLUG + "=?",
|
valuesPublic, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_SLUG + "=?",
|
||||||
new String[]{homeQuickLoad.user_id, homeQuickLoad.instance, homeQuickLoad.slug});
|
new String[]{publicQuickLoad.user_id, publicQuickLoad.instance, publicQuickLoad.slug});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves saved values
|
* Retrieves saved values
|
||||||
*
|
*
|
||||||
|
|
|
@ -188,6 +188,7 @@ public class Helper {
|
||||||
|
|
||||||
public static final String ARG_STATUS_DRAFT_ID = "ARG_STATUS_DRAFT_ID";
|
public static final String ARG_STATUS_DRAFT_ID = "ARG_STATUS_DRAFT_ID";
|
||||||
public static final String ARG_STATUS_REPLY = "ARG_STATUS_REPLY";
|
public static final String ARG_STATUS_REPLY = "ARG_STATUS_REPLY";
|
||||||
|
public static final String ARG_STATUS_REPLY_ID = "ARG_STATUS_REPLY_ID";
|
||||||
public static final String ARG_ACCOUNT = "ARG_ACCOUNT";
|
public static final String ARG_ACCOUNT = "ARG_ACCOUNT";
|
||||||
public static final String ARG_ACCOUNT_MENTION = "ARG_ACCOUNT_MENTION";
|
public static final String ARG_ACCOUNT_MENTION = "ARG_ACCOUNT_MENTION";
|
||||||
public static final String ARG_MINIFIED = "ARG_MINIFIED";
|
public static final String ARG_MINIFIED = "ARG_MINIFIED";
|
||||||
|
|
|
@ -1277,6 +1277,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
statusDeleted.id = null;
|
statusDeleted.id = null;
|
||||||
statusDraft.statusDraftList.add(statusDeleted);
|
statusDraft.statusDraftList.add(statusDeleted);
|
||||||
intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
|
intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
|
||||||
|
intent.putExtra(Helper.ARG_STATUS_REPLY_ID, statusDeleted.in_reply_to_id);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
sendAction(context, Helper.ARG_STATUS_DELETED, statusToDeal, null);
|
sendAction(context, Helper.ARG_STATUS_DELETED, statusToDeal, null);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue