Fix some issues

This commit is contained in:
stom79 2018-11-04 10:01:16 +01:00
parent 79111776d0
commit f9c11e3874
5 changed files with 21 additions and 6 deletions

View File

@ -21,6 +21,7 @@ import android.content.ContentResolver;
import android.content.pm.PackageManager;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
@ -311,11 +312,15 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
Bundle b = getIntent().getExtras();
ArrayList<Uri> sharedUri = new ArrayList<>();
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
restored = -1;
if(b != null) {
tootReply = b.getParcelable("tootReply");
accountReply = b.getParcelable("accountReply");
String accountReplyToken = b.getString("accountReplyToken", null);
accountReply = null;
if( accountReplyToken != null){
accountReply = new AccountDAO(getApplicationContext(),db).getAccountByToken(accountReplyToken);
}
tootMention = b.getString("tootMention", null);
urlMention = b.getString("urlMention", null);
fileMention = b.getString("fileMention", null);
@ -349,7 +354,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
toot_it.setVisibility(View.GONE);
invalidateOptionsMenu();
}
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userIdReply;
if( accountReply == null)
userIdReply = sharedpreferences.getString(Helper.PREF_KEY_ID, null);

View File

@ -59,6 +59,8 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
if( this.contextReference.get() == null)
return null;
API api = new API(this.contextReference.get());
List<fr.gouv.etalab.mastodon.client.Entities.Status> tempStatus;
APIResponse apiResponse = null;

View File

@ -691,6 +691,8 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
@Override
public void onRetrieveMissingFeeds(List<Status> statusesMissing) {
if(swipeRefreshLayout == null)
return;
swipeRefreshLayout.setRefreshing(false);
List<Status> statuses = Helper.filterToots(context, statusesMissing, mutedAccount, type);

View File

@ -26,7 +26,6 @@ import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.util.Log;
import android.widget.Toast;
import java.lang.ref.WeakReference;
@ -599,9 +598,8 @@ public class CrossActions {
@Override
public void onClick(final DialogInterface dialog, int which) {
final Account account = accountArray[which];
Intent intentToot = new Intent(context, TootActivity.class);
bundle.putParcelable("accountReply", account);
bundle.putString("accountReplyToken", account.getToken());
intentToot.putExtras(bundle);
context.startActivity(intentToot);
((BaseActivity)context).finish();

View File

@ -19,6 +19,7 @@ package fr.gouv.etalab.mastodon.helper;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
@ -1230,6 +1231,13 @@ public class Helper {
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false);
}
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
if( !account.getToken().equals(token)){
FragmentManager fm = activity.getFragmentManager();
for(int i = 0; i < fm.getBackStackEntryCount(); ++i) {
fm.popBackStack();
}
}
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken());
editor.putString(Helper.PREF_KEY_ID, account.getId());