update onboarding; add missing safe areas
This commit is contained in:
+30
@@ -115,6 +115,7 @@ class GeckoBrowserApiImpl : GeckoBrowserApi {
|
||||
companion object {
|
||||
private const val TAG = "GeckoBrowserApiImpl"
|
||||
private const val FRAGMENT_CONTAINER_ID = 0xBEEF
|
||||
private const val REQUEST_CODE_BROWSER_ROLE = 1
|
||||
|
||||
private var isGeckoInitialized = false
|
||||
}
|
||||
@@ -424,4 +425,33 @@ class GeckoBrowserApiImpl : GeckoBrowserApi {
|
||||
|
||||
logger.debug("$TAG: Opened custom tab ${tab.id} for $url (private=$`private`)")
|
||||
}
|
||||
|
||||
override fun isDefaultBrowser(): Boolean {
|
||||
val currentActivity = requireNotNull(activity) { "Activity not attached" }
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
val roleManager = currentActivity.getSystemService(android.app.role.RoleManager::class.java)
|
||||
return roleManager.isRoleHeld(android.app.role.RoleManager.ROLE_BROWSER)
|
||||
}
|
||||
val intent = android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse("http://"))
|
||||
val resolveInfo = currentActivity.packageManager.resolveActivity(intent, android.content.pm.PackageManager.MATCH_DEFAULT_ONLY)
|
||||
return resolveInfo?.activityInfo?.packageName == currentActivity.packageName
|
||||
}
|
||||
|
||||
override fun requestDefaultBrowser() {
|
||||
val currentActivity = requireNotNull(activity) { "Activity not attached" }
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
val roleManager = currentActivity.getSystemService(android.app.role.RoleManager::class.java)
|
||||
if (roleManager.isRoleAvailable(android.app.role.RoleManager.ROLE_BROWSER) &&
|
||||
!roleManager.isRoleHeld(android.app.role.RoleManager.ROLE_BROWSER)) {
|
||||
currentActivity.startActivityForResult(
|
||||
roleManager.createRequestRoleIntent(android.app.role.RoleManager.ROLE_BROWSER),
|
||||
REQUEST_CODE_BROWSER_ROLE
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
val intent = android.content.Intent(android.provider.Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
|
||||
currentActivity.startActivity(intent)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+33
@@ -4845,6 +4845,8 @@ interface GeckoBrowserApi {
|
||||
fun showNativeFragment(): Boolean
|
||||
fun onTrimMemory(level: Long)
|
||||
fun openInCustomTab(url: String, private: Boolean, contextId: String?)
|
||||
fun isDefaultBrowser(): Boolean
|
||||
fun requestDefaultBrowser()
|
||||
|
||||
companion object {
|
||||
/** The codec used by GeckoBrowserApi. */
|
||||
@@ -4947,6 +4949,37 @@ interface GeckoBrowserApi {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBrowserApi.isDefaultBrowser$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { _, reply ->
|
||||
val wrapped: List<Any?> = try {
|
||||
listOf(api.isDefaultBrowser())
|
||||
} catch (exception: Throwable) {
|
||||
GeckoPigeonUtils.wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBrowserApi.requestDefaultBrowser$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { _, reply ->
|
||||
val wrapped: List<Any?> = try {
|
||||
api.requestDefaultBrowser()
|
||||
listOf(null)
|
||||
} catch (exception: Throwable) {
|
||||
GeckoPigeonUtils.wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,4 +56,12 @@ class GeckoBrowserService {
|
||||
contextId: contextId,
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> isDefaultBrowser() {
|
||||
return _api.isDefaultBrowser();
|
||||
}
|
||||
|
||||
Future<void> requestDefaultBrowser() {
|
||||
return _api.requestDefaultBrowser();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5756,6 +5756,55 @@ class GeckoBrowserApi {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> isDefaultBrowser() async {
|
||||
final pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBrowserApi.isDefaultBrowser$pigeonVar_messageChannelSuffix';
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
||||
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else if (pigeonVar_replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as bool?)!;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> requestDefaultBrowser() async {
|
||||
final pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBrowserApi.requestDefaultBrowser$pigeonVar_messageChannelSuffix';
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
||||
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GeckoSyncApi {
|
||||
|
||||
@@ -1149,6 +1149,8 @@ abstract class GeckoBrowserApi {
|
||||
required bool private,
|
||||
required String? contextId,
|
||||
});
|
||||
bool isDefaultBrowser();
|
||||
void requestDefaultBrowser();
|
||||
}
|
||||
|
||||
enum SyncEngineValue { history, bookmarks, tabs }
|
||||
|
||||
Reference in New Issue
Block a user