Fixes issue #161 - Cannot reply with different account
This commit is contained in:
parent
1978beab7d
commit
9d0b4847e5
|
@ -187,6 +187,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
|||
private AlertDialog dialogTrans;
|
||||
private AlertDialog alertDialogEmoji;
|
||||
private String mentionAccount;
|
||||
private String idRedirect;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -274,6 +275,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
|||
sharedContentIni = b.getString("sharedContent", null);
|
||||
sharedSubject = b.getString("sharedSubject", null);
|
||||
mentionAccount = b.getString("mentionAccount", null);
|
||||
idRedirect = b.getString("idRedirect", null);
|
||||
restoredScheduled = b.getBoolean("restoredScheduled", false);
|
||||
// ACTION_SEND route
|
||||
if (b.getInt("uriNumberMast", 0) == 1) {
|
||||
|
@ -1506,7 +1508,10 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
|||
if( status != null ) {
|
||||
Intent intent = new Intent(getApplicationContext(), ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("statusId", status.getId());
|
||||
if( idRedirect == null)
|
||||
b.putString("statusId", status.getId());
|
||||
else
|
||||
b.putString("statusId", idRedirect);
|
||||
intent.putExtras(b);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
|
|
@ -26,6 +26,8 @@ import android.os.Bundle;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -36,6 +38,7 @@ import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
|||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.drawers.AccountsSearchAdapter;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||
|
@ -210,25 +213,48 @@ public class CrossActions {
|
|||
});
|
||||
builderSingle.setAdapter(accountsSearchAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Account account = accountArray[which];
|
||||
Intent intent = new Intent(context, TootActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if( status.getReblog() != null )
|
||||
b.putParcelable("tootReply", status.getReblog());
|
||||
else
|
||||
b.putParcelable("tootReply", status);
|
||||
b.putParcelable("accountReply", account);
|
||||
intent.putExtras(b); //Put your id to your next Intent
|
||||
context.startActivity(intent);
|
||||
if( type == RetrieveFeedsAsyncTask.Type.CONTEXT ){
|
||||
try {
|
||||
//Avoid to open multi activities when replying in a conversation
|
||||
((ShowConversationActivity)context).finish();
|
||||
}catch (Exception ignored){}
|
||||
public void onClick(final DialogInterface dialog, int which) {
|
||||
final Account account = accountArray[which];
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
private List<fr.gouv.etalab.mastodon.client.Entities.Status> remoteStatuses;
|
||||
private WeakReference<Context> contextReference = new WeakReference<>(context);
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
API api = new API(contextReference.get(), account.getInstance(), account.getToken());
|
||||
Results search = api.search(status.getReblog()!=null?status.getReblog().getUri():status.getUri());
|
||||
if( search != null){
|
||||
remoteStatuses = search.getStatuses();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
Intent intent = new Intent(contextReference.get(), TootActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if( remoteStatuses.get(0).getReblog() != null ) {
|
||||
b.putParcelable("tootReply", remoteStatuses.get(0).getReblog());
|
||||
b.putString("idRedirect", status.getReblog().getId());
|
||||
}else {
|
||||
b.putParcelable("tootReply", remoteStatuses.get(0));
|
||||
b.putString("idRedirect", status.getId());
|
||||
}
|
||||
b.putParcelable("accountReply", account);
|
||||
intent.putExtras(b); //Put your id to your next Intent
|
||||
contextReference.get().startActivity(intent);
|
||||
if( type == RetrieveFeedsAsyncTask.Type.CONTEXT ){
|
||||
try {
|
||||
//Avoid to open multi activities when replying in a conversation
|
||||
((ShowConversationActivity)contextReference.get()).finish();
|
||||
}catch (Exception ignored){}
|
||||
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR );
|
||||
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderSingle.show();
|
||||
|
|
Loading…
Reference in New Issue