-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Android): Added method to ensure lock screen permission on Android (
#814) * Added method to ensure lock screen permission on Android * added changelog * renamed ensure method
- Loading branch information
Showing
16 changed files
with
206 additions
and
11 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.cxx |
65 changes: 65 additions & 0 deletions
65
packages/stream_video_push_notification/android/build.gradle
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,65 @@ | ||
buildscript { | ||
ext.kotlin_version = "1.9.10" | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath("com.android.tools.build:gradle:7.3.1") | ||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
apply plugin: "com.android.library" | ||
apply plugin: "kotlin-android" | ||
|
||
android { | ||
if (project.android.hasProperty("namespace")) { | ||
namespace = "com.example.stream_video_push_notification" | ||
} | ||
|
||
compileSdk = 34 | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
sourceSets { | ||
main.java.srcDirs += "src/main/kotlin" | ||
test.java.srcDirs += "src/test/kotlin" | ||
} | ||
|
||
defaultConfig { | ||
minSdk = 21 | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.jetbrains.kotlin:kotlin-test") | ||
testImplementation("org.mockito:mockito-core:5.0.0") | ||
} | ||
|
||
testOptions { | ||
unitTests.all { | ||
useJUnitPlatform() | ||
|
||
testLogging { | ||
events "passed", "skipped", "failed", "standardOut", "standardError" | ||
outputs.upToDateWhen {false} | ||
showStandardStreams = true | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/stream_video_push_notification/android/gradle/wrapper/gradle-wrapper.properties
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,7 @@ | ||
|
||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
1 change: 1 addition & 0 deletions
1
packages/stream_video_push_notification/android/settings.gradle
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 @@ | ||
rootProject.name = 'stream_video_push_notification' |
5 changes: 5 additions & 0 deletions
5
packages/stream_video_push_notification/android/src/main/AndroidManifest.xml
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,5 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.stream_video_push_notification"> | ||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> | ||
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" /> | ||
</manifest> |
66 changes: 66 additions & 0 deletions
66
...tstream/video/flutter/stream_video_push_notification/StreamVideoPushNotificationPlugin.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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.getstream.video.flutter.stream_video_push_notification | ||
|
||
import android.app.Activity | ||
import android.app.NotificationManager | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Build | ||
import io.flutter.embedding.engine.plugins.FlutterPlugin | ||
import io.flutter.plugin.common.MethodCall | ||
import io.flutter.plugin.common.MethodChannel | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler | ||
import io.flutter.embedding.engine.plugins.activity.ActivityAware | ||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding | ||
import com.hiennv.flutter_callkit_incoming.CallkitNotificationManager | ||
|
||
/** StreamVideoPushNotificationPlugin */ | ||
class StreamVideoPushNotificationPlugin: FlutterPlugin, MethodCallHandler, ActivityAware { | ||
private lateinit var channel : MethodChannel | ||
private var activity: Activity? = null | ||
private var context: Context? = null | ||
private lateinit var callkitNotificationManager: CallkitNotificationManager | ||
|
||
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | ||
context = flutterPluginBinding.applicationContext | ||
|
||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "stream_video_push_notification") | ||
channel.setMethodCallHandler(this) | ||
|
||
callkitNotificationManager = CallkitNotificationManager(flutterPluginBinding.applicationContext) | ||
} | ||
|
||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { | ||
if (call.method == "ensureFullScreenIntentPermission") { | ||
val notificationManager = context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager | ||
if (Build.VERSION.SDK_INT >= 34) { | ||
if (!notificationManager.canUseFullScreenIntent()) { | ||
callkitNotificationManager?.requestFullIntentPermission(activity) | ||
} | ||
} | ||
result.success(true) | ||
} else { | ||
result.notImplemented() | ||
} | ||
} | ||
|
||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { | ||
channel.setMethodCallHandler(null) | ||
} | ||
|
||
override fun onAttachedToActivity(binding: ActivityPluginBinding) { | ||
activity = binding.activity | ||
} | ||
|
||
override fun onDetachedFromActivityForConfigChanges() { | ||
activity = null | ||
} | ||
|
||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { | ||
activity = binding.activity | ||
} | ||
|
||
override fun onDetachedFromActivity() { | ||
activity = null | ||
} | ||
} |
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