Some fixes crashes and filters

This commit is contained in:
stom79 2018-09-22 19:13:55 +02:00
parent 89d89f8c53
commit 1ba66e2a00
6 changed files with 25 additions and 16 deletions

View File

@ -440,15 +440,17 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
@Override
public void onDownloaded(String path, String originUrl, Error error) {
File response = new File(path);
File dir = getCacheDir();
File from = new File(dir, response.getName());
File to = new File(dir, Helper.md5(originUrl) + ".mp4");
if (from.exists())
//noinspection ResultOfMethodCallIgnored
from.renameTo(to);
fileVideo = to;
downloadedImage = null;
if( path != null) {
File response = new File(path);
File dir = getCacheDir();
File from = new File(dir, response.getName());
File to = new File(dir, Helper.md5(originUrl) + ".mp4");
if (from.exists())
//noinspection ResultOfMethodCallIgnored
from.renameTo(to);
fileVideo = to;
downloadedImage = null;
}
if( progress != null)
progress.setVisibility(View.GONE);
if( loader != null)

View File

@ -1846,7 +1846,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
toRemove.clear();
}
String content = status.getContent();
Pattern mentionLink = Pattern.compile("(<\\s?a\\s?href=\"https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})\\/(@[\\/\\w._-]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
Pattern mentionLink = Pattern.compile("(<\\s?a\\s?href=\"https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,10})\\/(@[\\/\\w._-]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
Matcher matcher = mentionLink.matcher(content);
if (matcher.find()) {
content = matcher.replaceAll("$3@$2");

View File

@ -23,6 +23,7 @@ import java.util.List;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMissingFeedsInterface;
@ -58,6 +59,9 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
boolean connectectedToInternet = Helper.isConnectedToInternet(contextReference.get(),Helper.getLiveInstance(contextReference.get()));
if(!connectectedToInternet)
return null;
API api = new API(this.contextReference.get());
List<fr.gouv.etalab.mastodon.client.Entities.Status> tempStatus;
APIResponse apiResponse = null;

View File

@ -2300,11 +2300,13 @@ public class API {
private Filters parseFilter(JSONObject resobj){
Filters filter = new fr.gouv.etalab.mastodon.client.Entities.Filters();
try {
filter.setId(resobj.get("id").toString());
if( resobj.get("phrase").toString() == null)
return null;
filter.setPhrase(resobj.get("phrase").toString());
filter.setSetExpires_at(Helper.mstStringToDate(context, resobj.get("expires_at").toString()));
if( resobj.get("expires_at") != null && !resobj.get("expires_at").toString().equals("null"))
filter.setSetExpires_at(Helper.mstStringToDate(context, resobj.get("expires_at").toString()));
filter.setWhole_word(Boolean.parseBoolean(resobj.get("whole_word").toString()));
filter.setIrreversible(Boolean.parseBoolean(resobj.get("irreversible").toString()));
String contextString = resobj.get("context").toString();

View File

@ -690,7 +690,7 @@ public class Status implements Parcelable{
}
String currentInstance = Helper.getLiveInstance(context);
//Get url to account that are unknown
Pattern aLink = Pattern.compile("(<\\s?a\\s?href=\"https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})\\/(@[\\/\\w._-]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
Pattern aLink = Pattern.compile("(<\\s?a\\s?href=\"https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,10})\\/(@[\\/\\w._-]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
Matcher matcherALink = aLink.matcher(spannableString.toString());
ArrayList<Account> accountsMentionUnknown = new ArrayList<>();
while (matcherALink.find()){
@ -715,7 +715,7 @@ public class Status implements Parcelable{
accountsMentionUnknown.add(account);
}
}
aLink = Pattern.compile("(<\\s?a\\s?href=\"(https?:\\/\\/[\\da-z\\.-]+\\.[a-z\\.]{2,6}[\\/]?[^\"@(\\/tags\\/)]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
aLink = Pattern.compile("(<\\s?a\\s?href=\"(https?:\\/\\/[\\da-z\\.-]+\\.[a-z\\.]{2,10}[\\/]?[^\"@(\\/tags\\/)]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
matcherALink = aLink.matcher(spannableString.toString());
while (matcherALink.find()){
@ -830,7 +830,7 @@ public class Status implements Parcelable{
@Override
public void onClick(View textView) {
String finalUrl = url;
Pattern link = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})\\/(@[\\w._-]*[0-9]*)(\\/[0-9]{1,})?$");
Pattern link = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,10})\\/(@[\\w._-]*[0-9]*)(\\/[0-9]{1,})?$");
Matcher matcherLink = link.matcher(url);
if( matcherLink.find()){
Intent intent = new Intent(context, MainActivity.class);

View File

@ -1296,6 +1296,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
}
notifyStatusChanged(status);
}catch (Exception e){
e.printStackTrace();
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_LONG).show();
}
}else {
@ -1608,7 +1609,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
if (targetedId == null || !targetedId.equals(status.getAccount().getId())) {
Account account = status.getAccount();
Pattern instanceHost = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})");
Pattern instanceHost = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,10})");
Matcher matcher = instanceHost.matcher(status.getUrl());
String instance = null;
while (matcher.find()){
@ -1624,7 +1625,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
public void onClick(View v) {
if (targetedId == null || !targetedId.equals(status.getReblog().getAccount().getId())) {
Account account = status.getReblog().getAccount();
Pattern instanceHost = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})");
Pattern instanceHost = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,10})");
Matcher matcher = instanceHost.matcher(status.getUrl());
String instance = null;
while (matcher.find()){