diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java index d9aa3048f..a113a2e1c 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java @@ -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) 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 eeb9c4c63..24f0061b6 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 @@ -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"); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java index b8fb4a9d9..47533f8f6 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java @@ -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 { @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 tempStatus; APIResponse apiResponse = null; diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java index a83d0e281..73f6f925c 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java @@ -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(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java index 95020ba15..2ea7428ad 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java @@ -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 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); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index e99a306a8..8c2f178ae 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -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()){