-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shock@5678
committed
Aug 11, 2024
1 parent
8b8fb60
commit 8da3162
Showing
206 changed files
with
17,463 additions
and
6,755 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
47 changes: 46 additions & 1 deletion
47
android/app/src/main/kotlin/com/example/beacon/MainActivity.kt
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 |
---|---|---|
@@ -1,6 +1,51 @@ | ||
package com.example.beacon | ||
|
||
import android.app.PictureInPictureParams | ||
import android.os.Build | ||
import android.util.Rational | ||
import io.flutter.embedding.android.FlutterActivity | ||
import io.flutter.embedding.engine.FlutterEngine | ||
import io.flutter.plugin.common.MethodChannel | ||
|
||
class MainActivity: FlutterActivity() { | ||
class MainActivity : FlutterActivity() { | ||
private val CHANNEL = "com.example.beacon/pip" | ||
private var shouldEnterPipMode = false | ||
|
||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) { | ||
super.configureFlutterEngine(flutterEngine) | ||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result -> | ||
when (call.method) { | ||
"switchPIPMode"->{ | ||
shouldEnterPipMode = true | ||
result.success(null) | ||
} | ||
"enablePIPMode" -> { | ||
shouldEnterPipMode = true | ||
result.success(null) | ||
} | ||
"disablePIPMode" -> { | ||
shouldEnterPipMode = false | ||
result.success(null) | ||
} | ||
else -> result.notImplemented() | ||
} | ||
} | ||
} | ||
|
||
override fun onUserLeaveHint() { | ||
super.onUserLeaveHint() | ||
if (shouldEnterPipMode) { | ||
enterPIPMode() | ||
} | ||
} | ||
|
||
private fun enterPIPMode() { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
val aspectRatio = Rational(16, 9) | ||
val pipParams = PictureInPictureParams.Builder() | ||
.setAspectRatio(aspectRatio) | ||
.build() | ||
enterPictureInPictureMode(pipParams) | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.