Some fixes

This commit is contained in:
stom79 2018-10-06 15:37:44 +02:00
parent 12daa76dbd
commit d980f2e0bc
1 changed files with 9 additions and 6 deletions

View File

@ -17,9 +17,7 @@ package fr.gouv.etalab.mastodon.activities;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.IntentFilter;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.os.Environment; import android.os.Environment;
@ -195,6 +193,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
private boolean removed; private boolean removed;
private boolean restoredScheduled; private boolean restoredScheduled;
static boolean active = false; static boolean active = false;
private static Activity activity;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -218,7 +217,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
} }
setContentView(R.layout.activity_toot); setContentView(R.layout.activity_toot);
activity = this;
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
if( actionBar != null ){ if( actionBar != null ){
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@ -796,7 +795,11 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
if( uriFile == null) { if( uriFile == null) {
Toast.makeText(activityWeakReference.get(), R.string.toast_error, Toast.LENGTH_SHORT).show(); activity.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(activityWeakReference.get(), R.string.toast_error, Toast.LENGTH_SHORT).show();
}
});
return null; return null;
} }
bs = Helper.compressImage(activityWeakReference.get(), uriFile, Helper.MediaType.MEDIA); bs = Helper.compressImage(activityWeakReference.get(), uriFile, Helper.MediaType.MEDIA);
@ -1589,7 +1592,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
@Override @Override
public void onPostStatusAction(APIResponse apiResponse) { public void onPostStatusAction(APIResponse apiResponse) {
if( apiResponse.getError() != null){ if( apiResponse.getError() != null ){
toot_it.setEnabled(true); toot_it.setEnabled(true);
if( apiResponse.getError().getError().contains("422")){ if( apiResponse.getError().getError().contains("422")){
showAToast(getString(R.string.toast_error_char_limit)); showAToast(getString(R.string.toast_error_char_limit));
@ -1614,7 +1617,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
if( toot_cw_content.getText().toString().trim().length() > 0) if( toot_cw_content.getText().toString().trim().length() > 0)
toot.setSpoiler_text(toot_cw_content.getText().toString().trim()); toot.setSpoiler_text(toot_cw_content.getText().toString().trim());
toot.setVisibility(visibility); toot.setVisibility(visibility);
if( apiResponse.getStatuses() != null) if( apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0)
toot.setIn_reply_to_id(apiResponse.getStatuses().get(0).getId()); toot.setIn_reply_to_id(apiResponse.getStatuses().get(0).getId());
toot.setContent(tootContent); toot.setContent(tootContent);
new PostStatusAsyncTask(getApplicationContext(), accountReply, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostStatusAsyncTask(getApplicationContext(), accountReply, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);