Push some fixes

This commit is contained in:
tom79 2020-02-05 17:06:52 +01:00
parent 2850b2ed5a
commit 02b51f53da
6 changed files with 55 additions and 46 deletions

View File

@ -3,9 +3,11 @@ Added:
- Push notifications for Friendica & GNU Social - Push notifications for Friendica & GNU Social
- Add follow/unfollow buttons for Pixelfed - Add follow/unfollow buttons for Pixelfed
- View your own story (need to wait the endpoint) - View your own story (need to wait the endpoint)
- Increase max bio chars to 500 for Pleroma
Fixed: Fixed:
- Proxy not applied with embedded videos - Proxy not applied with embedded videos
- Fix no toots that remains displayed on Nitter timelines - Fix no toots that remains displayed on Nitter timelines
- Avoid to lose composed message when not sent - Avoid to lose composed message when not sent
- Notifications not pushed - Notifications not pushed
- Fix some crashes

View File

@ -63,6 +63,7 @@ import java.util.Map;
import app.fedilab.android.R; import app.fedilab.android.R;
import app.fedilab.android.asynctasks.RetrieveAccountInfoAsyncTask; import app.fedilab.android.asynctasks.RetrieveAccountInfoAsyncTask;
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
import app.fedilab.android.asynctasks.UpdateCredentialAsyncTask; import app.fedilab.android.asynctasks.UpdateCredentialAsyncTask;
import app.fedilab.android.client.API; import app.fedilab.android.client.API;
import app.fedilab.android.client.APIResponse; import app.fedilab.android.client.APIResponse;
@ -248,8 +249,12 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if (s.length() > 160) { int maxChar = 160;
String content = s.toString().substring(0, 160); if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){
maxChar = 500;
}
if (s.length() > maxChar) {
String content = s.toString().substring(0, maxChar);
set_profile_description.setText(content); set_profile_description.setText(content);
set_profile_description.setSelection(set_profile_description.getText().length()); set_profile_description.setSelection(set_profile_description.getText().length());
Toasty.info(getApplicationContext(), getString(R.string.note_no_space), Toast.LENGTH_LONG).show(); Toasty.info(getApplicationContext(), getString(R.string.note_no_space), Toast.LENGTH_LONG).show();
@ -348,14 +353,12 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (ContextCompat.checkSelfPermission(EditProfileActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
if (ContextCompat.checkSelfPermission(EditProfileActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(EditProfileActivity.this,
ActivityCompat.requestPermissions(EditProfileActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE_PICTURE);
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE_PICTURE); return;
return;
}
} }
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT); Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
@ -370,12 +373,14 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
} }
}); });
Glide.with(set_profile_picture.getContext()) if( !EditProfileActivity.this.isFinishing()) {
.load(account.getAvatar()) Glide.with(set_profile_picture.getContext())
.into(set_profile_picture); .load(account.getAvatar())
Glide.with(set_header_picture.getContext()) .into(set_profile_picture);
.load(account.getHeader()) Glide.with(set_header_picture.getContext())
.into(set_header_picture); .load(account.getHeader())
.into(set_header_picture);
}
if (account.getHeader() == null || account.getHeader().contains("missing.png")) if (account.getHeader() == null || account.getHeader().contains("missing.png"))
set_header_picture_overlay.setVisibility(View.VISIBLE); set_header_picture_overlay.setVisibility(View.VISIBLE);

View File

@ -22,11 +22,15 @@ import android.util.Patterns;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.net.URL;
import java.net.URLConnection;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.net.ssl.HttpsURLConnection;
import app.fedilab.android.client.HttpsConnection; import app.fedilab.android.client.HttpsConnection;
import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.Helper;
import app.fedilab.android.interfaces.OnRetrieveMetaDataInterface; import app.fedilab.android.interfaces.OnRetrieveMetaDataInterface;
@ -92,7 +96,12 @@ public class RetrieveMetaDataAsyncTask extends AsyncTask<Void, Void, Void> {
Pattern imagePattern = Pattern.compile("meta[ a-zA-Z=\"'-]+property=[\"']og:image[\"']\\s+content=[\"']([^>]*)[\"']"); Pattern imagePattern = Pattern.compile("meta[ a-zA-Z=\"'-]+property=[\"']og:image[\"']\\s+content=[\"']([^>]*)[\"']");
try { try {
if( !potentialUrl.startsWith("http")){ if( !potentialUrl.startsWith("http")){
potentialUrl = "http://" + potentialUrl; potentialUrl = "https://" + potentialUrl;
}
URLConnection conn = new URL(potentialUrl).openConnection();
if (conn instanceof HttpsURLConnection) {
error = true;
return null;
} }
String response = new HttpsConnection(this.contextWeakReference.get(), null).get(potentialUrl); String response = new HttpsConnection(this.contextWeakReference.get(), null).get(potentialUrl);
Matcher matcherTitle = titlePattern.matcher(response); Matcher matcherTitle = titlePattern.matcher(response);
@ -113,18 +122,13 @@ public class RetrieveMetaDataAsyncTask extends AsyncTask<Void, Void, Void> {
if (descriptionEncoded != null) if (descriptionEncoded != null)
description = Html.fromHtml(descriptionEncoded, Html.FROM_HTML_MODE_LEGACY).toString(); description = Html.fromHtml(descriptionEncoded, Html.FROM_HTML_MODE_LEGACY).toString();
} else { } else {
//noinspection deprecation
if (titleEncoded != null) if (titleEncoded != null)
title = Html.fromHtml(titleEncoded).toString(); title = Html.fromHtml(titleEncoded).toString();
if (descriptionEncoded != null) if (descriptionEncoded != null)
description = Html.fromHtml(descriptionEncoded).toString(); description = Html.fromHtml(descriptionEncoded).toString();
} }
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException | KeyManagementException | HttpsConnection.HttpsConnectionException e) {
e.printStackTrace(); error = true;
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
} }
} }
} catch (IOException | IndexOutOfBoundsException e) { } catch (IOException | IndexOutOfBoundsException e) {

View File

@ -2713,14 +2713,9 @@ public class API {
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e); setError(e.getStatusCode(), e);
e.printStackTrace(); e.printStackTrace();
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
setDefaultError(e);
} }
apiResponse.setStatuses(statuses); apiResponse.setStatuses(statuses);
return apiResponse; return apiResponse;

View File

@ -231,20 +231,22 @@ public class Notification implements Parcelable {
for (int startPosition = -1; (startPosition = contentSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) { for (int startPosition = -1; (startPosition = contentSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length(); final int endPosition = startPosition + targetedEmoji.length();
if (endPosition <= contentSpan.toString().length() && endPosition >= startPosition) { if (endPosition <= contentSpan.toString().length() && endPosition >= startPosition) {
ImageSpan imageSpan; try {
if (!disableAnimatedEmoji) { ImageSpan imageSpan;
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context)); if (!disableAnimatedEmoji) {
resource.setVisible(true, true); resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
imageSpan = new ImageSpan(resource); resource.setVisible(true, true);
} else { imageSpan = new ImageSpan(resource);
Bitmap bitmap = drawableToBitmap(resource); } else {
imageSpan = new ImageSpan(context, Bitmap bitmap = drawableToBitmap(resource);
Bitmap.createScaledBitmap(bitmap, (int) Helper.convertDpToPixel(20, context), imageSpan = new ImageSpan(context,
(int) Helper.convertDpToPixel(20, context), false)); Bitmap.createScaledBitmap(bitmap, (int) Helper.convertDpToPixel(20, context),
} (int) Helper.convertDpToPixel(20, context), false));
contentSpan.setSpan( }
imageSpan, startPosition, contentSpan.setSpan(
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); imageSpan, startPosition,
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}catch (Exception ignored){}
} }
} }
} }

View File

@ -275,6 +275,7 @@ public class HttpsConnection {
URL url = new URL(urlConnection); URL url = new URL(urlConnection);
if (proxy != null) if (proxy != null)
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy); httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
else else