mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-01-07 00:20:08 +02:00
some fixes
This commit is contained in:
parent
b3ed8661c4
commit
d27faa3113
5 changed files with 40 additions and 3 deletions
|
@ -182,6 +182,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
.setAction(getString(R.string.open_draft), view -> {
|
||||
Intent intentCompose = new Intent(context, ComposeActivity.class);
|
||||
intentCompose.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
|
||||
intentCompose.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intentCompose);
|
||||
})
|
||||
.setTextColor(ThemeHelper.getAttColor(BaseMainActivity.this, R.attr.mTextColor))
|
||||
|
|
|
@ -110,6 +110,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
private StatusDraft statusDraft;
|
||||
private ComposeAdapter composeAdapter;
|
||||
|
||||
|
||||
private final BroadcastReceiver imageReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(android.content.Context context, Intent intent) {
|
||||
|
@ -513,6 +514,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
statusDraft = new StatusDraft();
|
||||
List<Status> statuses = new ArrayList<>();
|
||||
Status status = new Status();
|
||||
status.id = Helper.generateIdString();
|
||||
status.text = scheduledStatus.params.text;
|
||||
status.in_reply_to_id = scheduledStatus.params.in_reply_to_id;
|
||||
status.poll = scheduledStatus.params.poll;
|
||||
|
@ -567,6 +569,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
//Empty compose
|
||||
List<Status> statusDraftList = new ArrayList<>();
|
||||
Status status = new Status();
|
||||
status.id = Helper.generateIdString();
|
||||
statusDraftList.add(status);
|
||||
|
||||
if (statusReplyId != null && statusDraft != null) {//Delete and redraft
|
||||
|
@ -713,6 +716,8 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
@Override
|
||||
public void onItemDraftAdded(int position) {
|
||||
Status status = new Status();
|
||||
|
||||
status.id = Helper.generateIdString();
|
||||
status.mentions = statusList.get(position).mentions;
|
||||
status.visibility = statusList.get(position).visibility;
|
||||
status.spoiler_text = statusList.get(position).spoiler_text;
|
||||
|
@ -750,7 +755,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
List<Status> statusDrafts = new ArrayList<>();
|
||||
List<Status> statusReplies = new ArrayList<>();
|
||||
for (Status status : statusList) {
|
||||
if (status.id == null) {
|
||||
if (status.id == null || status.id.startsWith("@fedilab_compose_")) {
|
||||
statusDrafts.add(status);
|
||||
} else {
|
||||
statusReplies.add(status);
|
||||
|
|
|
@ -1628,6 +1628,11 @@ public class Helper {
|
|||
return "@fedilab_fetch_more_" + uuid;
|
||||
}
|
||||
|
||||
public static String generateIdString() {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
return "@fedilab_compose_" + uuid;
|
||||
}
|
||||
|
||||
public static Gson getDateBuilder() {
|
||||
SimpleDateFormat[] formats = new SimpleDateFormat[]{
|
||||
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault()),
|
||||
|
|
|
@ -124,7 +124,7 @@ public class ComposeWorker extends Worker {
|
|||
//Check if previous messages in thread have already been published (ie: when resending after a fail)
|
||||
int startingPosition = 0;
|
||||
for (PostState.Post post : dataPost.statusDraft.state.posts) {
|
||||
if (post.id == null) {
|
||||
if (post.id == null || post.id.startsWith("@fedilab_compose_")) {
|
||||
break;
|
||||
}
|
||||
startingPosition++;
|
||||
|
|
|
@ -278,6 +278,12 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage the actions when picking up a media
|
||||
*
|
||||
* @param type - type of media in the list of {@link ComposeActivity.mediaType}
|
||||
* @param position - int position of the media in the message
|
||||
*/
|
||||
private void pickupMedia(ComposeActivity.mediaType type, int position) {
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) !=
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
|
@ -475,6 +481,13 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
notifyItemChanged(statusList.size() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display attachment for a holder
|
||||
*
|
||||
* @param holder - view related to a compose element {@link ComposeViewHolder}
|
||||
* @param position - int position of the message in the thread
|
||||
* @param scrollToMediaPosition - int the position to scroll to media
|
||||
*/
|
||||
private void displayAttachments(ComposeViewHolder holder, int position, int scrollToMediaPosition) {
|
||||
if (statusList.size() > position && statusList.get(position).media_attachments != null) {
|
||||
holder.binding.attachmentsList.removeAllViews();
|
||||
|
@ -1345,6 +1358,12 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the emoji picker in the current message
|
||||
*
|
||||
* @param holder - view for the message {@link ComposeViewHolder}
|
||||
* @throws DBException
|
||||
*/
|
||||
private void displayEmojiPicker(ComposeViewHolder holder) throws DBException {
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context, Helper.dialogStyle());
|
||||
|
@ -1372,7 +1391,14 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
alertDialogEmoji = builder.show();
|
||||
}
|
||||
|
||||
private void displayPollPopup(ComposeAdapter.ComposeViewHolder holder, Status statusDraft, int position) {
|
||||
/**
|
||||
* Display the popup to attach a poll to message
|
||||
*
|
||||
* @param holder - view for the message {@link ComposeViewHolder}
|
||||
* @param statusDraft - Status message instance {@link Status} linked to the view
|
||||
* @param position - int position
|
||||
*/
|
||||
private void displayPollPopup(ComposeViewHolder holder, Status statusDraft, int position) {
|
||||
AlertDialog.Builder alertPoll = new AlertDialog.Builder(context, Helper.dialogStyle());
|
||||
alertPoll.setTitle(R.string.create_poll);
|
||||
ComposePollBinding composePollBinding = ComposePollBinding.inflate(LayoutInflater.from(context), new LinearLayout(context), false);
|
||||
|
|
Loading…
Reference in a new issue