diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java index 4c47dab82..37c9dadb0 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java @@ -482,10 +482,10 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt @Override public void onRetrieveAccount(final Account account, Error error) { - if( error != null){ + if( error != null || account.getAcct() == null){ final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); boolean show_error_messages = sharedpreferences.getBoolean(Helper.SET_SHOW_ERROR_MESSAGES, true); - if( show_error_messages) + if( show_error_messages && error != null) Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show(); return; } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java index 33470b445..cad507c63 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java @@ -489,10 +489,11 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS, false); int split_toot_size = sharedpreferences.getInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE, Helper.SPLIT_TOOT_SIZE); String tootContent; + if( toot_cw_content.getText() != null && toot_cw_content.getText().toString().trim().length() > 0 ) + split_toot_size -= toot_cw_content.getText().toString().trim().length(); if( !split_toot || (toot_content.getText().toString().trim().length() < split_toot_size)){ tootContent = toot_content.getText().toString().trim(); }else{ - splitToot = Helper.splitToots(toot_content.getText().toString().trim(), split_toot_size); tootContent = splitToot.get(0); stepSpliToot = 1; @@ -1604,8 +1605,10 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS, false); int split_toot_size = sharedpreferences.getInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE, Helper.SPLIT_TOOT_SIZE); + int cwSize = toot_cw_content.getText().toString().trim().length(); + int size = toot_content.getText().toString().trim().length() + cwSize; - if( split_toot && (toot_content.getText().toString().trim().length() >= split_toot_size) && stepSpliToot < splitToot.size()){ + if( split_toot && (size >= split_toot_size) && stepSpliToot < splitToot.size()){ String tootContent = splitToot.get(stepSpliToot); stepSpliToot += 1; Status toot = new Status(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/HttpsConnection.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/HttpsConnection.java index 2a129c404..e18da8a3f 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/HttpsConnection.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/HttpsConnection.java @@ -199,13 +199,13 @@ public class HttpsConnection { httpURLConnection.setRequestMethod("GET"); String response; if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) { - response = converToString(httpsURLConnection.getInputStream()); + response = converToString(httpURLConnection.getInputStream()); }else { String error = null; - if( httpsURLConnection.getErrorStream() != null) { - InputStream stream = httpsURLConnection.getErrorStream(); + if( httpURLConnection.getErrorStream() != null) { + InputStream stream = httpURLConnection.getErrorStream(); if (stream == null) { - stream = httpsURLConnection.getInputStream(); + stream = httpURLConnection.getInputStream(); } try (Scanner scanner = new Scanner(stream)) { scanner.useDelimiter("\\Z"); @@ -270,13 +270,13 @@ public class HttpsConnection { String response; if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) { getSinceMaxId(); - response = converToString(httpsURLConnection.getInputStream()); + response = converToString(httpURLConnection.getInputStream()); }else { String error = null; - if( httpsURLConnection.getErrorStream() != null) { - InputStream stream = httpsURLConnection.getErrorStream(); + if( httpURLConnection.getErrorStream() != null) { + InputStream stream = httpURLConnection.getErrorStream(); if (stream == null) { - stream = httpsURLConnection.getInputStream(); + stream = httpURLConnection.getInputStream(); } try (Scanner scanner = new Scanner(stream)) { scanner.useDelimiter("\\Z"); @@ -388,13 +388,13 @@ public class HttpsConnection { String response; if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) { getSinceMaxId(); - response = converToString(httpsURLConnection.getInputStream()); + response = converToString(httpURLConnection.getInputStream()); } else { String error = null; - if( httpsURLConnection.getErrorStream() != null) { - InputStream stream = httpsURLConnection.getErrorStream(); + if( httpURLConnection.getErrorStream() != null) { + InputStream stream = httpURLConnection.getErrorStream(); if (stream == null) { - stream = httpsURLConnection.getInputStream(); + stream = httpURLConnection.getInputStream(); } try (Scanner scanner = new Scanner(stream)) { scanner.useDelimiter("\\Z"); @@ -865,10 +865,10 @@ public class HttpsConnection { new String(ByteStreams.toByteArray(httpURLConnection.getInputStream())); } else { String error = null; - if( httpsURLConnection.getErrorStream() != null) { - InputStream stream = httpsURLConnection.getErrorStream(); + if( httpURLConnection.getErrorStream() != null) { + InputStream stream = httpURLConnection.getErrorStream(); if (stream == null) { - stream = httpsURLConnection.getInputStream(); + stream = httpURLConnection.getInputStream(); } try (Scanner scanner = new Scanner(stream)) { scanner.useDelimiter("\\Z"); @@ -1010,10 +1010,10 @@ public class HttpsConnection { new String(ByteStreams.toByteArray(httpURLConnection.getInputStream())); } else { String error = null; - if( httpsURLConnection.getErrorStream() != null) { - InputStream stream = httpsURLConnection.getErrorStream(); + if( httpURLConnection.getErrorStream() != null) { + InputStream stream = httpURLConnection.getErrorStream(); if (stream == null) { - stream = httpsURLConnection.getInputStream(); + stream = httpURLConnection.getInputStream(); } try (Scanner scanner = new Scanner(stream)) { scanner.useDelimiter("\\Z"); @@ -1295,10 +1295,10 @@ public class HttpsConnection { if (200 != httpURLConnection.getResponseCode()) { String error = null; - if( httpsURLConnection.getErrorStream() != null) { - InputStream stream = httpsURLConnection.getErrorStream(); + if( httpURLConnection.getErrorStream() != null) { + InputStream stream = httpURLConnection.getErrorStream(); if (stream == null) { - stream = httpsURLConnection.getInputStream(); + stream = httpURLConnection.getInputStream(); } try (Scanner scanner = new Scanner(stream)) { scanner.useDelimiter("\\Z"); @@ -1448,13 +1448,13 @@ public class HttpsConnection { String response; if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) { getSinceMaxId(); - response = converToString(httpsURLConnection.getInputStream()); + response = converToString(httpURLConnection.getInputStream()); } else { String error = null; - if( httpsURLConnection.getErrorStream() != null) { - InputStream stream = httpsURLConnection.getErrorStream(); + if( httpURLConnection.getErrorStream() != null) { + InputStream stream = httpURLConnection.getErrorStream(); if (stream == null) { - stream = httpsURLConnection.getInputStream(); + stream = httpURLConnection.getInputStream(); } try (Scanner scanner = new Scanner(stream)) { scanner.useDelimiter("\\Z"); @@ -1572,10 +1572,10 @@ public class HttpsConnection { return httpURLConnection.getResponseCode(); }else { String error = null; - if( httpsURLConnection.getErrorStream() != null) { - InputStream stream = httpsURLConnection.getErrorStream(); + if( httpURLConnection.getErrorStream() != null) { + InputStream stream = httpURLConnection.getErrorStream(); if (stream == null) { - stream = httpsURLConnection.getInputStream(); + stream = httpURLConnection.getInputStream(); } try (Scanner scanner = new Scanner(stream)) { scanner.useDelimiter("\\Z"); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index 22cf62e37..6d61df623 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -1149,7 +1149,7 @@ public class Helper { @SuppressWarnings("SameParameterValue") private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int roundPixelSize) { - Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); + Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.RGB_565); Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());