forked from Vencord/Vendroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make back gesture close modals and similar
- Loading branch information
1 parent
924ba2b
commit 2f35908
Showing
5 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/src/main/java/dev/vendicated/vencord/VencordNative.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.vendicated.vencord; | ||
|
||
import android.app.Activity; | ||
import android.webkit.JavascriptInterface; | ||
import android.webkit.WebView; | ||
|
||
public class VencordNative { | ||
private final WebView wv; | ||
private final Activity activity; | ||
|
||
public VencordNative(Activity activity, WebView wv) { | ||
this.activity = activity; | ||
this.wv = wv; | ||
} | ||
|
||
@JavascriptInterface | ||
public void goBack() { | ||
activity.runOnUiThread(() -> { | ||
if (wv.canGoBack()) | ||
wv.goBack(); | ||
else | ||
activity.getActionBar(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
!(() => { | ||
const ModalEscapeHandler = Vencord.Util.lazyWebpack(m => m.binds?.[0] === "esc" && m.binds.length === 1); | ||
const EscapeHandler = Vencord.Util.lazyWebpack(m => m.binds?.[0] === "esc" && m.binds[1] === "shift+pagedown"); | ||
window.VencordMobile = { | ||
onBackPress() { | ||
// false implies modal closed | ||
if (ModalEscapeHandler.action() === false) return; | ||
|
||
EscapeHandler.action({target:document.activeElement}); | ||
} | ||
} | ||
})(); |