This commit is contained in:
parent
f53b7b38b0
commit
3d421629d9
@ -11,7 +11,7 @@ jobs:
|
|||||||
go-version: '>=1.20.1'
|
go-version: '>=1.20.1'
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- run: curl -sSL -u "$USERNAME:$PASSWORD" -o ShareWithTitle/$STORE_FILE https://cloud.crystalyx.net/remote.php/dav/files/$USERNAME/Bordel/$STORE_FILE
|
- run: curl -sSL -u "$USERNAME:$PASSWORD" -o ShareWithTitle/$STORE_FILE https://cloud.crystalyx.net/remote.php/dav/files/$USERNAME/Bordel/$STORE_FILE
|
||||||
- run: sh gradlew build bundleRelease assembleRelease --no-daemon
|
- run: sh gradlew lint build bundle assemble --no-daemon
|
||||||
- uses: https://gitea.com/actions/release-action@main
|
- uses: https://gitea.com/actions/release-action@main
|
||||||
if: startsWith(gitea.ref, 'refs/tags')
|
if: startsWith(gitea.ref, 'refs/tags')
|
||||||
with:
|
with:
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package net.crystalyx.sharewithtitle;
|
package net.crystalyx.sharewithtitle;
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -17,7 +19,25 @@ public class HttpThreadHandler implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
title = Jsoup.connect(url.toString()).get().title();
|
Document doc = Jsoup.connect(url.toString()).get();
|
||||||
|
String titleMeta = doc.title();
|
||||||
|
Element descriptionMeta = doc.select("meta[name=description]").first();
|
||||||
|
Element titleElement = doc.select("meta[property=og:title]").first();
|
||||||
|
Element descriptionElement = doc.select("meta[property=og:description]").first();
|
||||||
|
|
||||||
|
if (titleElement != null) {
|
||||||
|
title = titleElement.attr("content");
|
||||||
|
if (descriptionElement != null) {
|
||||||
|
title += "\n" + descriptionElement.attr("content");
|
||||||
|
} else if (descriptionMeta != null) {
|
||||||
|
title += "\n" + descriptionMeta.attr("content");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
title = titleMeta;
|
||||||
|
if (descriptionMeta != null) {
|
||||||
|
title += "\n" + descriptionMeta.attr("content");
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
errorMessage = e.getMessage();
|
errorMessage = e.getMessage();
|
||||||
}
|
}
|
||||||
|
@ -25,16 +25,31 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleUrl(String textUrl) {
|
private void handleUrl(String textUrl) {
|
||||||
URL url;
|
URL originalUrl;
|
||||||
|
URL fixedUrl;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
url = new URL(textUrl);
|
originalUrl = new URL(textUrl);
|
||||||
|
|
||||||
|
switch (originalUrl.getHost()) {
|
||||||
|
case "twitter.com":
|
||||||
|
case "t.co":
|
||||||
|
case "x.com":
|
||||||
|
fixedUrl = new URL(originalUrl.getProtocol(), "fxtwitter.com", originalUrl.getPort(), originalUrl.getFile());
|
||||||
|
break;
|
||||||
|
case "pixiv.net":
|
||||||
|
fixedUrl = new URL(originalUrl.getProtocol(), "ppxiv.net", originalUrl.getPort(), originalUrl.getFile());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fixedUrl = originalUrl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpThreadHandler handler = new HttpThreadHandler(url);
|
HttpThreadHandler handler = new HttpThreadHandler(fixedUrl);
|
||||||
Thread job = new Thread(handler);
|
Thread job = new Thread(handler);
|
||||||
|
|
||||||
job.start();
|
job.start();
|
||||||
@ -50,7 +65,7 @@ public class MainActivity extends Activity {
|
|||||||
if (title != null) {
|
if (title != null) {
|
||||||
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
|
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
|
||||||
sharingIntent.setType("text/plain");
|
sharingIntent.setType("text/plain");
|
||||||
sharingIntent.putExtra(Intent.EXTRA_TEXT, title + "\n\n" + url);
|
sharingIntent.putExtra(Intent.EXTRA_TEXT, title + "\n\n" + originalUrl);
|
||||||
startActivity(Intent.createChooser(sharingIntent, "Share via"));
|
startActivity(Intent.createChooser(sharingIntent, "Share via"));
|
||||||
} else if (errorMessage != null) {
|
} else if (errorMessage != null) {
|
||||||
Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT).show();
|
||||||
|
Loading…
Reference in New Issue
Block a user