From 8914ac7c3270d0b29890afd305299fae23fde577 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 10 May 2020 11:19:22 +0200 Subject: [PATCH] some changes --- app/build.gradle | 4 +- .../java/app/fedilab/android/client/API.java | 3 ++ .../android/client/Entities/Status.java | 27 ++++++++++++++ .../android/drawers/StatusListAdapter.java | 4 +- .../app/fedilab/android/helper/Helper.java | 37 +++++++++++-------- 5 files changed, 56 insertions(+), 19 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6e554190e..5d3fd286a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 29 - buildToolsVersion "29.0.2" + buildToolsVersion "29.0.3" defaultConfig { minSdkVersion 19 targetSdkVersion 29 @@ -87,7 +87,7 @@ dependencies { } annotationProcessor "com.github.bumptech.glide:compiler:4.11.0" annotationProcessor 'com.android.support:support-annotations:28.0.0' - implementation "org.conscrypt:conscrypt-android:2.2.1" + implementation "org.conscrypt:conscrypt-android:2.4.0" implementation "com.evernote:android-job:1.2.6" implementation "com.google.code.gson:gson:2.8.5" implementation "com.google.guava:guava:28.2-android" diff --git a/app/src/main/java/app/fedilab/android/client/API.java b/app/src/main/java/app/fedilab/android/client/API.java index 9d48bac3a..dd1014435 100644 --- a/app/src/main/java/app/fedilab/android/client/API.java +++ b/app/src/main/java/app/fedilab/android/client/API.java @@ -2195,6 +2195,9 @@ public class API { JSONObject resobj = new JSONObject(response); JSONObject jsonObject = resobj.getJSONObject("software"); String name = jsonObject.getString("name").toUpperCase(); + if( name.compareTo("CORGIDON") == 0 ){ + name = "MASTODON"; + } instanceNodeInfo.setName(name); instanceNodeInfo.setVersion(jsonObject.getString("version")); instanceNodeInfo.setOpenRegistrations(resobj.getBoolean("openRegistrations")); diff --git a/app/src/main/java/app/fedilab/android/client/Entities/Status.java b/app/src/main/java/app/fedilab/android/client/Entities/Status.java index cee832d47..183203e85 100644 --- a/app/src/main/java/app/fedilab/android/client/Entities/Status.java +++ b/app/src/main/java/app/fedilab/android/client/Entities/Status.java @@ -309,6 +309,33 @@ public class Status implements Parcelable { } } + matcher = Helper.ouichesPattern.matcher(content); + + while (matcher.find()) { + Attachment attachment = new Attachment(); + attachment.setType("audio"); + String tag = matcher.group(1); + attachment.setId(tag); + if( tag == null){ + continue; + } + attachment.setRemote_url("https://ouich.es/mp3/"+tag+".mp3"); + attachment.setUrl("https://ouich.es/mp3/"+tag+".mp3"); + if( status.getMedia_attachments() == null) { + status.setMedia_attachments(new ArrayList<>()); + } + boolean alreadyAdded = false; + for(Attachment at: status.getMedia_attachments()){ + if( tag.compareTo(at.getId()) == 0 ){ + alreadyAdded = true; + break; + } + } + if( !alreadyAdded) { + status.getMedia_attachments().add(attachment); + } + } + Pattern aLink = Pattern.compile("]*(((?!"); Matcher matcherALink = aLink.matcher(content); int count = 0; diff --git a/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java b/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java index 940633362..72c882333 100644 --- a/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java +++ b/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java @@ -607,9 +607,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct @SuppressLint({"SetJavaScriptEnabled", "ClickableViewAccessibility"}) @Override public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) { + + context = viewHolder.itemView.getContext(); final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); - context = viewHolder.itemView.getContext(); + if (viewHolder.getItemViewType() != HIDDEN_STATUS) { final ViewHolder holder = (ViewHolder) viewHolder; diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 1816699de..83aa1107e 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -518,6 +518,7 @@ public class Helper { public static final Pattern twitterPattern = Pattern.compile("((@[\\w]+)@twitter\\.com)"); public static final Pattern youtubePattern = Pattern.compile("(www\\.|m\\.)?(youtube\\.com|youtu\\.be|youtube-nocookie\\.com)/(((?!([\"'<])).)*)"); public static final Pattern nitterPattern = Pattern.compile("(mobile\\.|www\\.)?twitter.com([\\w-/]+)"); + public static final Pattern ouichesPattern = Pattern.compile("ouich\\.es/tag/(\\w+)"); public static final Pattern xmppPattern = Pattern.compile("xmpp:[-a-zA-Z0-9+$&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"); //Default values public final static int DEFAULT_VIDEO_WIDTH = 640; @@ -1927,27 +1928,30 @@ public class Helper { } if (!urlHeader.contains("missing.png")) { ImageView backgroundImage = headerLayout.findViewById(R.id.back_ground_image); - Glide.with(activity) - .asDrawable() - .load(urlHeader) - .into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Drawable resource, Transition transition) { + if( isValidContextForGlide(activity)){ + Glide.with(activity) + .asDrawable() + .load(urlHeader) + .into(new CustomTarget() { + @Override + public void onResourceReady(@NonNull Drawable resource, Transition transition) { + + backgroundImage.setImageDrawable(resource); + if (theme == THEME_LIGHT) { + backgroundImage.setImageAlpha(80); + } else { + backgroundImage.setImageAlpha(60); + } - backgroundImage.setImageDrawable(resource); - if (theme == THEME_LIGHT) { - backgroundImage.setImageAlpha(80); - } else { - backgroundImage.setImageAlpha(60); } - } + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { + } + }); + } - } - }); } } profilePicture.setOnClickListener(null); @@ -3210,6 +3214,7 @@ public class Helper { } } else { Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(url)); try { context.startActivity(intent);