Fix issue #755
This commit is contained in:
parent
caec35ef0e
commit
fe17eae351
|
@ -55,7 +55,6 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Gravity;
|
||||
|
@ -2283,7 +2282,6 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
|
||||
@Override
|
||||
public void onCompleted(String dbName) {
|
||||
Log.v(Helper.TAG,"onCompleted");
|
||||
Toasty.success(getApplicationContext(),getString(R.string.data_import_success_simple),Toast.LENGTH_LONG).show();
|
||||
Intent changeAccount = new Intent(activity, MainActivity.class);
|
||||
changeAccount.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
|
@ -2293,8 +2291,6 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
Log.v(Helper.TAG,"onError");
|
||||
e.printStackTrace();
|
||||
Toasty.error(getApplicationContext(),getString(R.string.data_import_error_simple),Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1786,10 +1786,14 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
|
|||
toot_it.setEnabled(true);
|
||||
if( apiResponse.getError().getError().contains("422")){
|
||||
showAToast(getString(R.string.toast_error_char_limit));
|
||||
}else {
|
||||
return;
|
||||
}else if( apiResponse.getError().getStatusCode() == -33){
|
||||
storeToot(false, true);
|
||||
} else {
|
||||
showAToast(apiResponse.getError().getError());
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS, false);
|
||||
|
@ -1836,10 +1840,15 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
|
|||
isSensitive = false;
|
||||
toot_sensitive.setVisibility(View.GONE);
|
||||
currentToId = -1;
|
||||
if( scheduledstatus == null && !isScheduled)
|
||||
Toasty.success(TootActivity.this, getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Toasty.success(TootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
|
||||
if(apiResponse.getError() == null) {
|
||||
if (scheduledstatus == null && !isScheduled)
|
||||
Toasty.success(TootActivity.this, getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Toasty.success(TootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
|
||||
}else {
|
||||
if(apiResponse.getError().getStatusCode() == -33)
|
||||
Toasty.info(TootActivity.this, getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
toot_it.setEnabled(true);
|
||||
//It's a reply, so the user will be redirect to its answer
|
||||
if( tootReply != null){
|
||||
|
|
|
@ -22,9 +22,11 @@ import java.lang.ref.WeakReference;
|
|||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnPostStatusActionInterface;
|
||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||
|
@ -54,10 +56,22 @@ public class PostStatusAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
if( account == null)
|
||||
apiResponse = new API(this.contextReference.get()).postStatusAction(status);
|
||||
else
|
||||
apiResponse = new API(this.contextReference.get(), account.getInstance(), account.getToken()).postStatusAction(status);
|
||||
|
||||
|
||||
boolean isconnected = Helper.isConnectedToInternet(contextReference.get(), Helper.getLiveInstance(contextReference.get()));
|
||||
if( isconnected) {
|
||||
if (account == null) {
|
||||
apiResponse = new API(this.contextReference.get()).postStatusAction(status);
|
||||
} else
|
||||
apiResponse = new API(this.contextReference.get(), account.getInstance(), account.getToken()).postStatusAction(status);
|
||||
}else {
|
||||
apiResponse = new APIResponse();
|
||||
Error error = new Error();
|
||||
error.setError(contextReference.get().getString(R.string.no_internet));
|
||||
error.setStatusCode(-33);
|
||||
apiResponse.setError(error);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -862,6 +862,7 @@
|
|||
<string name="data_import_start">Please, don\'t kill the app while processing. That can\'t be quite long.</string>
|
||||
<string name="add_public_comment">Add a public comment</string>
|
||||
<string name="send_comment">Send comment</string>
|
||||
<string name="toast_toot_saved_error">There is no Internet connection. Your message has been stored in drafts.</string>
|
||||
<!-- end languages -->
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue