Add deeplink support (#3)
Co-authored-by: wingio <wingio@users.noreply.github.com>
This commit is contained in:
parent
356ececb30
commit
e399b55877
10 changed files with 45 additions and 61 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,12 +1,7 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.idea
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
|
|
3
.idea/.gitignore
generated
vendored
3
.idea/.gitignore
generated
vendored
|
@ -1,3 +0,0 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
1
.idea/.name
generated
1
.idea/.name
generated
|
@ -1 +0,0 @@
|
|||
VencordMobile
|
6
.idea/compiler.xml
generated
6
.idea/compiler.xml
generated
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
7
.idea/discord.xml
generated
7
.idea/discord.xml
generated
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="ASK" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
20
.idea/gradle.xml
generated
20
.idea/gradle.xml
generated
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="Embedded JDK" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
10
.idea/misc.xml
generated
10
.idea/misc.xml
generated
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -15,11 +15,23 @@
|
|||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize|layoutDirection">
|
||||
android:configChanges="orientation|keyboardHidden|screenSize|layoutDirection"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="https" />
|
||||
<data android:scheme="http" />
|
||||
<data android:host="discord.com" />
|
||||
<data android:host="*.discord.com" />
|
||||
<data android:host="discordapp.com" />
|
||||
<data android:host="*.discordapp.com" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
|
|
|
@ -11,9 +11,11 @@ import android.webkit.ValueCallback;
|
|||
import android.webkit.WebView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
public static final int FILECHOOSER_RESULTCODE = 8485;
|
||||
private boolean wvInitialized = false;
|
||||
private WebView wv;
|
||||
|
||||
public ValueCallback<Uri[]> filePathCallback;
|
||||
|
@ -49,7 +51,15 @@ public class MainActivity extends Activity {
|
|||
return;
|
||||
}
|
||||
|
||||
wv.loadUrl("https://discord.com/app");
|
||||
Intent intent = getIntent();
|
||||
if (Objects.equals(intent.getAction(), Intent.ACTION_VIEW)) {
|
||||
Uri data = intent.getData();
|
||||
if (data != null) handleUrl(intent.getData());
|
||||
} else {
|
||||
wv.loadUrl("https://discord.com/app");
|
||||
}
|
||||
|
||||
wvInitialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -98,4 +108,24 @@ public class MainActivity extends Activity {
|
|||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
public void handleUrl(Uri url) {
|
||||
if (url != null) {
|
||||
if (!url.getAuthority().contains("discord")) return;
|
||||
if (!wvInitialized) {
|
||||
wv.loadUrl(url.toString());
|
||||
} else {
|
||||
wv.evaluateJavascript("Vencord.Webpack.Common.NavigationRouter.transitionTo(\"" + url.getPath() + "\")", (result) -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
Uri data = intent.getData();
|
||||
if (data != null) handleUrl(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue