Rename project

This commit is contained in:
Michel Roux 2023-07-31 22:27:37 +02:00
parent 5cc152fa30
commit 8022a1f9da
6 changed files with 59 additions and 34 deletions

View File

@ -1,10 +1,10 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
namespace "net.crystalyx.sharepixiv" namespace "net.crystalyx.fxpix"
compileSdkVersion 33 compileSdk 33
defaultConfig { defaultConfig {
applicationId "net.crystalyx.sharepixiv" applicationId "net.crystalyx.fxpix"
minSdkVersion 3 minSdkVersion 3
targetSdkVersion 33 targetSdkVersion 33
versionCode 1 versionCode 1

View File

@ -3,7 +3,7 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<application <application
android:icon="@android:drawable/ic_menu_share" android:icon="@android:drawable/ic_menu_share"
android:label="FxPics" android:label="FxPix"
android:theme="@android:style/Theme.NoDisplay"> android:theme="@android:style/Theme.NoDisplay">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"

View File

@ -1,27 +0,0 @@
package net.crystalyx.sharepixiv;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(intent.getAction()) && "text/plain".equals(type)) {
String ppxivUrl = intent.getStringExtra(Intent.EXTRA_TEXT)
.replace("pixiv", "ppxiv")
.replace("twitter", "fxtwitter");
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_TEXT, ppxivUrl);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
}
finish();
}
}

View File

@ -0,0 +1,52 @@
package net.crystalyx.fxpix;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import java.net.MalformedURLException;
import java.net.URL;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(intent.getAction()) && "text/plain".equals(type)) {
URL originalUrl;
URL fixedUrl;
try {
originalUrl = new URL(intent.getStringExtra(Intent.EXTRA_TEXT));
switch (originalUrl.getHost()) {
case "twitter.com":
case "t.co":
case "x.com":
fixedUrl = new URL(originalUrl.getProtocol(), "nitter.net", originalUrl.getPort(), originalUrl.getFile());
break;
case "pixiv.net":
fixedUrl = new URL(originalUrl.getProtocol(), "ppxiv.net", originalUrl.getPort(), originalUrl.getFile());
break;
default:
fixedUrl = originalUrl;
break;
}
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_TEXT, fixedUrl);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
} catch (MalformedURLException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
return;
}
}
finish();
}
}

View File

@ -16,10 +16,10 @@ allprojects {
} }
} }
task clean(type: Delete) { tasks.register('clean', Delete) {
delete rootProject.buildDir delete rootProject.buildDir
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile).configureEach {
options.deprecation = true options.deprecation = true
} }

View File

@ -1,3 +1,3 @@
// Boilerplate from https://transang.me/create-a-minimal-android-boilerplate-from-scratch/ // Boilerplate from https://transang.me/create-a-minimal-android-boilerplate-from-scratch/
rootProject.name = 'SharePixiv' rootProject.name = 'FxPix'
include ':app' include ':app'