From 9b2a65312aa4e927af9a2fb0d7983cbee4afff81 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Wed, 28 Feb 2024 09:27:56 +0100 Subject: [PATCH] refactor: :fire: remove X support --- .../sharewithtitle/MainActivity.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/ShareWithTitle/src/main/java/net/crystalyx/sharewithtitle/MainActivity.java b/ShareWithTitle/src/main/java/net/crystalyx/sharewithtitle/MainActivity.java index 5326317..b0b80cd 100644 --- a/ShareWithTitle/src/main/java/net/crystalyx/sharewithtitle/MainActivity.java +++ b/ShareWithTitle/src/main/java/net/crystalyx/sharewithtitle/MainActivity.java @@ -6,6 +6,7 @@ import android.os.Bundle; import android.widget.Toast; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; public class MainActivity extends Activity { @@ -26,27 +27,15 @@ public class MainActivity extends Activity { private void handleUrl(String textUrl) { URL originalUrl; - URL fixedUrl; try { - originalUrl = new URL(textUrl); - - switch (originalUrl.getHost()) { - case "twitter.com": - case "t.co": - case "x.com": - fixedUrl = new URL(originalUrl.getProtocol(), "nitter.net", originalUrl.getPort(), originalUrl.getFile()); - break; - default: - fixedUrl = originalUrl; - break; - } - } catch (MalformedURLException e) { + originalUrl = new URI(textUrl).toURL(); + } catch (Exception e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); return; } - HttpThreadHandler handler = new HttpThreadHandler(fixedUrl); + HttpThreadHandler handler = new HttpThreadHandler(originalUrl); Thread job = new Thread(handler); job.start();