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