mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
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 String visibility;
|
||||
private app.fedilab.android.client.mastodon.entities.Account accountMention;
|
||||
|
||||
private String statusReplyId;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -125,6 +125,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
statusReply = (Status) b.getSerializable(Helper.ARG_STATUS_REPLY);
|
||||
statusDraft = (StatusDraft) b.getSerializable(Helper.ARG_STATUS_DRAFT);
|
||||
scheduledStatus = (ScheduledStatus) b.getSerializable(Helper.ARG_STATUS_SCHEDULED);
|
||||
statusReplyId = b.getString(Helper.ARG_STATUS_REPLY_ID);
|
||||
statusMention = (Status) b.getSerializable(Helper.ARG_STATUS_MENTION);
|
||||
account = (Account) b.getSerializable(Helper.ARG_ACCOUNT);
|
||||
instance = b.getString(Helper.ARG_INSTANCE, BaseMainActivity.currentInstance);
|
||||
|
@ -172,8 +173,18 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
Status status = new Status();
|
||||
statusDraftList.add(status);
|
||||
|
||||
//Restore a draft with all messages
|
||||
if (statusDraft != null) {
|
||||
if (statusReplyId != null && statusDraft != null) {//Delete and redraft
|
||||
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(() -> {
|
||||
if (statusDraft.statusReplyList != null) {
|
||||
statusDraft.statusReplyList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusDraft.statusReplyList);
|
||||
|
|
|
@ -214,54 +214,61 @@ public class QuickLoad {
|
|||
QuickLoad localQuickLoad = getSavedValue(account, Timeline.TimeLineEnum.LOCAL, null);
|
||||
QuickLoad publicQuickLoad = getSavedValue(account, Timeline.TimeLineEnum.PUBLIC, null);
|
||||
|
||||
for (Status status : homeQuickLoad.statuses) {
|
||||
if (status.id.equals(id)) {
|
||||
homeQuickLoad.statuses.remove(status);
|
||||
break;
|
||||
if (homeQuickLoad != null && homeQuickLoad.statuses != null) {
|
||||
for (Status status : homeQuickLoad.statuses) {
|
||||
if (status.id.equals(id)) {
|
||||
homeQuickLoad.statuses.remove(status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ContentValues valuesHome = new ContentValues();
|
||||
valuesHome.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(homeQuickLoad.statuses));
|
||||
//Inserts token
|
||||
try {
|
||||
db.update(Sqlite.TABLE_QUICK_LOAD,
|
||||
valuesHome, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_SLUG + "=?",
|
||||
new String[]{homeQuickLoad.user_id, homeQuickLoad.instance, homeQuickLoad.slug});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
for (Status status : localQuickLoad.statuses) {
|
||||
if (status.id.equals(id)) {
|
||||
localQuickLoad.statuses.remove(status);
|
||||
break;
|
||||
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();
|
||||
valuesLocal.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(localQuickLoad.statuses));
|
||||
//Inserts token
|
||||
try {
|
||||
db.update(Sqlite.TABLE_QUICK_LOAD,
|
||||
valuesLocal, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_SLUG + "=?",
|
||||
new String[]{localQuickLoad.user_id, localQuickLoad.instance, localQuickLoad.slug});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
for (Status status : publicQuickLoad.statuses) {
|
||||
if (status.id.equals(id)) {
|
||||
publicQuickLoad.statuses.remove(status);
|
||||
break;
|
||||
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();
|
||||
valuesPublic.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(publicQuickLoad.statuses));
|
||||
//Inserts token
|
||||
try {
|
||||
db.update(Sqlite.TABLE_QUICK_LOAD,
|
||||
valuesPublic, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_SLUG + "=?",
|
||||
new String[]{publicQuickLoad.user_id, publicQuickLoad.instance, publicQuickLoad.slug});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
ContentValues valuesHome = new ContentValues();
|
||||
valuesHome.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(homeQuickLoad.statuses));
|
||||
//Inserts token
|
||||
try {
|
||||
db.update(Sqlite.TABLE_QUICK_LOAD,
|
||||
valuesHome, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_SLUG + "=?",
|
||||
new String[]{homeQuickLoad.user_id, homeQuickLoad.instance, homeQuickLoad.slug});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ContentValues valuesLocal = new ContentValues();
|
||||
valuesLocal.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(homeQuickLoad.statuses));
|
||||
//Inserts token
|
||||
try {
|
||||
db.update(Sqlite.TABLE_QUICK_LOAD,
|
||||
valuesLocal, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_SLUG + "=?",
|
||||
new String[]{homeQuickLoad.user_id, homeQuickLoad.instance, homeQuickLoad.slug});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ContentValues valuesPublic = new ContentValues();
|
||||
valuesPublic.put(Sqlite.COL_STATUSES, StatusDraft.mastodonStatusListToStringStorage(homeQuickLoad.statuses));
|
||||
//Inserts token
|
||||
try {
|
||||
db.update(Sqlite.TABLE_QUICK_LOAD,
|
||||
valuesPublic, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_SLUG + "=?",
|
||||
new String[]{homeQuickLoad.user_id, homeQuickLoad.instance, homeQuickLoad.slug});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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_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_MENTION = "ARG_ACCOUNT_MENTION";
|
||||
public static final String ARG_MINIFIED = "ARG_MINIFIED";
|
||||
|
|
|
@ -1277,6 +1277,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
statusDeleted.id = null;
|
||||
statusDraft.statusDraftList.add(statusDeleted);
|
||||
intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
|
||||
intent.putExtra(Helper.ARG_STATUS_REPLY_ID, statusDeleted.in_reply_to_id);
|
||||
context.startActivity(intent);
|
||||
sendAction(context, Helper.ARG_STATUS_DELETED, statusToDeal, null);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue