Fix crashes + improve split toots
This commit is contained in:
parent
6a6da81ccf
commit
0d8071331c
|
@ -482,10 +482,10 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRetrieveAccount(final Account account, Error error) {
|
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);
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
boolean show_error_messages = sharedpreferences.getBoolean(Helper.SET_SHOW_ERROR_MESSAGES, true);
|
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();
|
Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,10 +489,11 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
||||||
boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS, false);
|
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 split_toot_size = sharedpreferences.getInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE, Helper.SPLIT_TOOT_SIZE);
|
||||||
String tootContent;
|
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)){
|
if( !split_toot || (toot_content.getText().toString().trim().length() < split_toot_size)){
|
||||||
tootContent = toot_content.getText().toString().trim();
|
tootContent = toot_content.getText().toString().trim();
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
splitToot = Helper.splitToots(toot_content.getText().toString().trim(), split_toot_size);
|
splitToot = Helper.splitToots(toot_content.getText().toString().trim(), split_toot_size);
|
||||||
tootContent = splitToot.get(0);
|
tootContent = splitToot.get(0);
|
||||||
stepSpliToot = 1;
|
stepSpliToot = 1;
|
||||||
|
@ -1604,8 +1605,10 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
||||||
boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS, false);
|
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 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);
|
String tootContent = splitToot.get(stepSpliToot);
|
||||||
stepSpliToot += 1;
|
stepSpliToot += 1;
|
||||||
Status toot = new Status();
|
Status toot = new Status();
|
||||||
|
|
|
@ -199,13 +199,13 @@ public class HttpsConnection {
|
||||||
httpURLConnection.setRequestMethod("GET");
|
httpURLConnection.setRequestMethod("GET");
|
||||||
String response;
|
String response;
|
||||||
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
||||||
response = converToString(httpsURLConnection.getInputStream());
|
response = converToString(httpURLConnection.getInputStream());
|
||||||
}else {
|
}else {
|
||||||
String error = null;
|
String error = null;
|
||||||
if( httpsURLConnection.getErrorStream() != null) {
|
if( httpURLConnection.getErrorStream() != null) {
|
||||||
InputStream stream = httpsURLConnection.getErrorStream();
|
InputStream stream = httpURLConnection.getErrorStream();
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
stream = httpsURLConnection.getInputStream();
|
stream = httpURLConnection.getInputStream();
|
||||||
}
|
}
|
||||||
try (Scanner scanner = new Scanner(stream)) {
|
try (Scanner scanner = new Scanner(stream)) {
|
||||||
scanner.useDelimiter("\\Z");
|
scanner.useDelimiter("\\Z");
|
||||||
|
@ -270,13 +270,13 @@ public class HttpsConnection {
|
||||||
String response;
|
String response;
|
||||||
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
||||||
getSinceMaxId();
|
getSinceMaxId();
|
||||||
response = converToString(httpsURLConnection.getInputStream());
|
response = converToString(httpURLConnection.getInputStream());
|
||||||
}else {
|
}else {
|
||||||
String error = null;
|
String error = null;
|
||||||
if( httpsURLConnection.getErrorStream() != null) {
|
if( httpURLConnection.getErrorStream() != null) {
|
||||||
InputStream stream = httpsURLConnection.getErrorStream();
|
InputStream stream = httpURLConnection.getErrorStream();
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
stream = httpsURLConnection.getInputStream();
|
stream = httpURLConnection.getInputStream();
|
||||||
}
|
}
|
||||||
try (Scanner scanner = new Scanner(stream)) {
|
try (Scanner scanner = new Scanner(stream)) {
|
||||||
scanner.useDelimiter("\\Z");
|
scanner.useDelimiter("\\Z");
|
||||||
|
@ -388,13 +388,13 @@ public class HttpsConnection {
|
||||||
String response;
|
String response;
|
||||||
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
||||||
getSinceMaxId();
|
getSinceMaxId();
|
||||||
response = converToString(httpsURLConnection.getInputStream());
|
response = converToString(httpURLConnection.getInputStream());
|
||||||
} else {
|
} else {
|
||||||
String error = null;
|
String error = null;
|
||||||
if( httpsURLConnection.getErrorStream() != null) {
|
if( httpURLConnection.getErrorStream() != null) {
|
||||||
InputStream stream = httpsURLConnection.getErrorStream();
|
InputStream stream = httpURLConnection.getErrorStream();
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
stream = httpsURLConnection.getInputStream();
|
stream = httpURLConnection.getInputStream();
|
||||||
}
|
}
|
||||||
try (Scanner scanner = new Scanner(stream)) {
|
try (Scanner scanner = new Scanner(stream)) {
|
||||||
scanner.useDelimiter("\\Z");
|
scanner.useDelimiter("\\Z");
|
||||||
|
@ -865,10 +865,10 @@ public class HttpsConnection {
|
||||||
new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
|
new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
|
||||||
} else {
|
} else {
|
||||||
String error = null;
|
String error = null;
|
||||||
if( httpsURLConnection.getErrorStream() != null) {
|
if( httpURLConnection.getErrorStream() != null) {
|
||||||
InputStream stream = httpsURLConnection.getErrorStream();
|
InputStream stream = httpURLConnection.getErrorStream();
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
stream = httpsURLConnection.getInputStream();
|
stream = httpURLConnection.getInputStream();
|
||||||
}
|
}
|
||||||
try (Scanner scanner = new Scanner(stream)) {
|
try (Scanner scanner = new Scanner(stream)) {
|
||||||
scanner.useDelimiter("\\Z");
|
scanner.useDelimiter("\\Z");
|
||||||
|
@ -1010,10 +1010,10 @@ public class HttpsConnection {
|
||||||
new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
|
new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
|
||||||
} else {
|
} else {
|
||||||
String error = null;
|
String error = null;
|
||||||
if( httpsURLConnection.getErrorStream() != null) {
|
if( httpURLConnection.getErrorStream() != null) {
|
||||||
InputStream stream = httpsURLConnection.getErrorStream();
|
InputStream stream = httpURLConnection.getErrorStream();
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
stream = httpsURLConnection.getInputStream();
|
stream = httpURLConnection.getInputStream();
|
||||||
}
|
}
|
||||||
try (Scanner scanner = new Scanner(stream)) {
|
try (Scanner scanner = new Scanner(stream)) {
|
||||||
scanner.useDelimiter("\\Z");
|
scanner.useDelimiter("\\Z");
|
||||||
|
@ -1295,10 +1295,10 @@ public class HttpsConnection {
|
||||||
|
|
||||||
if (200 != httpURLConnection.getResponseCode()) {
|
if (200 != httpURLConnection.getResponseCode()) {
|
||||||
String error = null;
|
String error = null;
|
||||||
if( httpsURLConnection.getErrorStream() != null) {
|
if( httpURLConnection.getErrorStream() != null) {
|
||||||
InputStream stream = httpsURLConnection.getErrorStream();
|
InputStream stream = httpURLConnection.getErrorStream();
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
stream = httpsURLConnection.getInputStream();
|
stream = httpURLConnection.getInputStream();
|
||||||
}
|
}
|
||||||
try (Scanner scanner = new Scanner(stream)) {
|
try (Scanner scanner = new Scanner(stream)) {
|
||||||
scanner.useDelimiter("\\Z");
|
scanner.useDelimiter("\\Z");
|
||||||
|
@ -1448,13 +1448,13 @@ public class HttpsConnection {
|
||||||
String response;
|
String response;
|
||||||
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
||||||
getSinceMaxId();
|
getSinceMaxId();
|
||||||
response = converToString(httpsURLConnection.getInputStream());
|
response = converToString(httpURLConnection.getInputStream());
|
||||||
} else {
|
} else {
|
||||||
String error = null;
|
String error = null;
|
||||||
if( httpsURLConnection.getErrorStream() != null) {
|
if( httpURLConnection.getErrorStream() != null) {
|
||||||
InputStream stream = httpsURLConnection.getErrorStream();
|
InputStream stream = httpURLConnection.getErrorStream();
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
stream = httpsURLConnection.getInputStream();
|
stream = httpURLConnection.getInputStream();
|
||||||
}
|
}
|
||||||
try (Scanner scanner = new Scanner(stream)) {
|
try (Scanner scanner = new Scanner(stream)) {
|
||||||
scanner.useDelimiter("\\Z");
|
scanner.useDelimiter("\\Z");
|
||||||
|
@ -1572,10 +1572,10 @@ public class HttpsConnection {
|
||||||
return httpURLConnection.getResponseCode();
|
return httpURLConnection.getResponseCode();
|
||||||
}else {
|
}else {
|
||||||
String error = null;
|
String error = null;
|
||||||
if( httpsURLConnection.getErrorStream() != null) {
|
if( httpURLConnection.getErrorStream() != null) {
|
||||||
InputStream stream = httpsURLConnection.getErrorStream();
|
InputStream stream = httpURLConnection.getErrorStream();
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
stream = httpsURLConnection.getInputStream();
|
stream = httpURLConnection.getInputStream();
|
||||||
}
|
}
|
||||||
try (Scanner scanner = new Scanner(stream)) {
|
try (Scanner scanner = new Scanner(stream)) {
|
||||||
scanner.useDelimiter("\\Z");
|
scanner.useDelimiter("\\Z");
|
||||||
|
|
|
@ -1149,7 +1149,7 @@ public class Helper {
|
||||||
|
|
||||||
@SuppressWarnings("SameParameterValue")
|
@SuppressWarnings("SameParameterValue")
|
||||||
private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int roundPixelSize) {
|
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);
|
Canvas canvas = new Canvas(output);
|
||||||
final Paint paint = new Paint();
|
final Paint paint = new Paint();
|
||||||
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||||
|
|
Loading…
Reference in New Issue