feat: ability to search query for suggested version (#1151)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
Co-authored-by: Ushie <ushiekane@gmail.com>
This commit is contained in:
Aditya Arora
2023-11-21 20:03:21 +05:30
committed by GitHub
parent c0516c3665
commit 9bd48c19ff
7 changed files with 240 additions and 25 deletions

View File

@ -1,5 +1,7 @@
package app.revanced.manager.flutter
import android.app.SearchManager
import android.content.Intent
import android.os.Handler
import android.os.Looper
import app.revanced.manager.flutter.utils.Aapt
@ -41,6 +43,17 @@ class MainActivity : FlutterActivity() {
val patcherChannel = "app.revanced.manager.flutter/patcher"
val installerChannel = "app.revanced.manager.flutter/installer"
val openBrowserChannel = "app.revanced.manager.flutter/browser"
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, openBrowserChannel).setMethodCallHandler { call, result ->
if (call.method == "openBrowser") {
val searchQuery = call.argument<String>("query")
openBrowser(searchQuery)
result.success(null)
} else {
result.notImplemented()
}
}
val mainChannel =
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, patcherChannel)
@ -176,6 +189,15 @@ class MainActivity : FlutterActivity() {
}
}
fun openBrowser(query: String?) {
val intent = Intent(Intent.ACTION_WEB_SEARCH).apply {
putExtra(SearchManager.QUERY, query)
}
if (intent.resolveActivity(packageManager) != null) {
startActivity(intent)
}
}
@OptIn(InternalCoroutinesApi::class)
private fun runPatcher(
result: MethodChannel.Result,