Search in sources :

Example 1 with ComposeOptions

use of com.keylesspalace.tusky.components.compose.ComposeActivity.ComposeOptions in project Tusky by Vavassor.

the class SFragment method showConfirmEditDialog.

private void showConfirmEditDialog(final String id, final int position, final Status status) {
    if (getActivity() == null) {
        return;
    }
    new AlertDialog.Builder(getActivity()).setMessage(R.string.dialog_redraft_toot_warning).setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
        timelineCases.delete(id).observeOn(AndroidSchedulers.mainThread()).to(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY))).subscribe(deletedStatus -> {
            removeItem(position);
            if (deletedStatus.isEmpty()) {
                deletedStatus = status.toDeletedStatus();
            }
            ComposeOptions composeOptions = new ComposeOptions();
            composeOptions.setTootText(deletedStatus.getText());
            composeOptions.setInReplyToId(deletedStatus.getInReplyToId());
            composeOptions.setVisibility(deletedStatus.getVisibility());
            composeOptions.setContentWarning(deletedStatus.getSpoilerText());
            composeOptions.setMediaAttachments(deletedStatus.getAttachments());
            composeOptions.setSensitive(deletedStatus.getSensitive());
            composeOptions.setModifiedInitialState(true);
            if (deletedStatus.getPoll() != null) {
                composeOptions.setPoll(deletedStatus.getPoll().toNewPoll(deletedStatus.getCreatedAt()));
            }
            Intent intent = ComposeActivity.startIntent(getContext(), composeOptions);
            startActivity(intent);
        }, error -> {
            Log.w("SFragment", "error deleting status", error);
            Toast.makeText(getContext(), R.string.error_generic, Toast.LENGTH_SHORT).show();
        });
    }).setNegativeButton(android.R.string.cancel, null).show();
}
Also used : ComposeOptions(com.keylesspalace.tusky.components.compose.ComposeActivity.ComposeOptions) Intent(android.content.Intent)

Example 2 with ComposeOptions

use of com.keylesspalace.tusky.components.compose.ComposeActivity.ComposeOptions in project Tusky by Vavassor.

the class SFragment method reply.

protected void reply(Status status) {
    String inReplyToId = status.getActionableId();
    Status actionableStatus = status.getActionableStatus();
    Status.Visibility replyVisibility = actionableStatus.getVisibility();
    String contentWarning = actionableStatus.getSpoilerText();
    List<Status.Mention> mentions = actionableStatus.getMentions();
    Set<String> mentionedUsernames = new LinkedHashSet<>();
    mentionedUsernames.add(actionableStatus.getAccount().getUsername());
    String loggedInUsername = null;
    AccountEntity activeAccount = accountManager.getActiveAccount();
    if (activeAccount != null) {
        loggedInUsername = activeAccount.getUsername();
    }
    for (Status.Mention mention : mentions) {
        mentionedUsernames.add(mention.getUsername());
    }
    mentionedUsernames.remove(loggedInUsername);
    ComposeOptions composeOptions = new ComposeOptions();
    composeOptions.setInReplyToId(inReplyToId);
    composeOptions.setReplyVisibility(replyVisibility);
    composeOptions.setContentWarning(contentWarning);
    composeOptions.setMentionedUsernames(mentionedUsernames);
    composeOptions.setReplyingStatusAuthor(actionableStatus.getAccount().getLocalUsername());
    composeOptions.setReplyingStatusContent(actionableStatus.getContent().toString());
    Intent intent = ComposeActivity.startIntent(getContext(), composeOptions);
    getActivity().startActivity(intent);
}
Also used : Status(com.keylesspalace.tusky.entity.Status) LinkedHashSet(java.util.LinkedHashSet) ComposeOptions(com.keylesspalace.tusky.components.compose.ComposeActivity.ComposeOptions) Intent(android.content.Intent) AccountEntity(com.keylesspalace.tusky.db.AccountEntity)

Aggregations

Intent (android.content.Intent)2 ComposeOptions (com.keylesspalace.tusky.components.compose.ComposeActivity.ComposeOptions)2 AccountEntity (com.keylesspalace.tusky.db.AccountEntity)1 Status (com.keylesspalace.tusky.entity.Status)1 LinkedHashSet (java.util.LinkedHashSet)1