Skip to content

Commit

Permalink
Merge pull request #45 from webex/3.6.0
Browse files Browse the repository at this point in the history
3.6.0 Release
  • Loading branch information
rohits5-cisco authored Aug 24, 2022
2 parents 5a8f073 + 32ddcd6 commit 7258234
Show file tree
Hide file tree
Showing 45 changed files with 1,761 additions and 459 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId "com.cisco.sdk_android"
minSdkVersion Versions.minSdk
targetSdkVersion Versions.targetSdk
versionCode 35000
versionName "3.5.0"
versionCode 36000
versionName "3.6.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "CLIENT_ID", "${CLIENT_ID}"
Expand Down Expand Up @@ -63,7 +63,7 @@ android {
}

dependencies {
implementation 'com.ciscowebex:androidsdk:3.5.0'
implementation 'com.ciscowebex:androidsdk:3.6.0'

implementation fileTree(dir: "libs", include: ["*.jar"])
implementation Dependencies.kotlinStdLib
Expand Down
28 changes: 18 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- Camera/Microphone -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<uses-feature
android:name="android.hardware.bluetooth"
android:required="false" />
Expand Down Expand Up @@ -63,13 +64,13 @@
<application
android:name=".KitchenSinkApp"
android:allowBackup="false"
android:extractNativeLibs="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:extractNativeLibs="true"
android:theme="@style/AppTheme"
android:requestLegacyExternalStorage="true">
android:theme="@style/AppTheme">

<provider
android:name="androidx.core.content.FileProvider"
Expand Down Expand Up @@ -123,11 +124,15 @@
</activity>
<activity
android:name=".calling.CallActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|smallestScreenSize"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:showOnLockScreen="true"
android:showWhenLocked="true"
android:supportsPictureInPicture="true"
android:turnScreenOn="true"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
tools:ignore="UnusedAttribute" />

<activity
android:name=".search.SearchActivity"
android:screenOrientation="portrait" />
Expand All @@ -149,20 +154,21 @@
<activity
android:name=".messaging.teams.membership.TeamMembershipActivity"
android:screenOrientation="portrait" />

<activity
android:name=".messaging.spaces.detail.FileViewerActivity"
android:screenOrientation="portrait" />

<activity
android:name=".messaging.composer.MessageComposerActivity"
android:screenOrientation="portrait" />

<activity
android:name=".webhooks.WebhooksActivity"
android:screenOrientation="portrait" />
<activity
android:name=".calling.calendarMeeting.details.CalendarMeetingDetailsActivity"
android:screenOrientation="portrait" />

<activity android:name=".calling.calendarMeeting.details.CalendarMeetingDetailsActivity"
<activity
android:name=".calling.CucmCallActivity"
android:screenOrientation="portrait" />

<service
Expand All @@ -172,18 +178,20 @@
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name=".KitchenSinkForegroundService"
android:exported="false" />

<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/app_notification_icon" />

<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />

<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id" />

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class HomeActivity : BaseActivity() {
webexViewModel.setLogLevel(webexViewModel.logFilter)
webexViewModel.enableConsoleLogger(webexViewModel.isConsoleLoggerEnabled)

if(SharedPrefUtils.isAppBackgroundRunningPreferred(this)) {
KitchenSinkForegroundService.startForegroundService(this)
}

Log.d(tag, "Service URls METRICS: ${webexViewModel.getServiceUrl(Phone.ServiceUrlType.METRICS)}" +
"\nCLIENT_LOGS: ${webexViewModel.getServiceUrl(Phone.ServiceUrlType.CLIENT_LOGS)}" +
"\nKMS: ${webexViewModel.getServiceUrl(Phone.ServiceUrlType.KMS)}")
Expand All @@ -72,6 +76,7 @@ class HomeActivity : BaseActivity() {
if (it) {
clearLoginTypePref(this)
(application as KitchenSinkApp).unloadKoinModules()
KitchenSinkForegroundService.stopForegroundService(this)
finish()
}
else {
Expand Down Expand Up @@ -174,10 +179,6 @@ class HomeActivity : BaseActivity() {
webexViewModel.setCalendarMeetingObserver()
}

override fun onBackPressed() {
(application as KitchenSinkApp).closeApplication()
}

private fun showMessageIfCameFromNotification() {

if("ACTION" == intent?.action){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.ciscowebex.androidsdk.kitchensink.messaging.messagingModule
import com.ciscowebex.androidsdk.kitchensink.messaging.search.searchPeopleModule
import com.ciscowebex.androidsdk.kitchensink.person.personModule
import com.ciscowebex.androidsdk.kitchensink.search.searchModule
import com.ciscowebex.androidsdk.kitchensink.utils.SharedPrefUtils
import com.ciscowebex.androidsdk.kitchensink.webhooks.webhooksModule
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
Expand All @@ -38,6 +39,13 @@ class KitchenSinkApp : Application(), LifecycleObserver {
}

var inForeground: Boolean = false


// App level boolean to keep track of if the CUCM login is of type SSO Login
var isUCSSOLogin = false

var isKoinModulesLoaded : Boolean = false

}

override fun onCreate() {
Expand Down Expand Up @@ -70,6 +78,17 @@ class KitchenSinkApp : Application(), LifecycleObserver {
android.os.Process.killProcess(android.os.Process.myPid())
}


fun loadModules(): Boolean {
val type = SharedPrefUtils.getLoginTypePref(this@KitchenSinkApp)
if(type != null) {
loadKoinModules(LoginActivity.LoginType.valueOf(type))
return true
}
return false
}


fun loadKoinModules(type: LoginActivity.LoginType) {
when (type) {
LoginActivity.LoginType.JWT -> {
Expand All @@ -82,9 +101,11 @@ class KitchenSinkApp : Application(), LifecycleObserver {
loadKoinModules(listOf(mainAppModule, webexModule, loginModule, OAuthWebexModule, searchModule, callModule, messagingModule, personModule, searchPeopleModule, webhooksModule, extrasModule, calendarMeetingsModule))
}
}
isKoinModulesLoaded = true
}

fun unloadKoinModules() {
unloadKoinModules(listOf(mainAppModule, webexModule, loginModule, JWTWebexModule, AccessTokenWebexModule, OAuthWebexModule, searchModule, callModule, messagingModule, personModule, searchPeopleModule, webhooksModule, extrasModule, calendarMeetingsModule))
isKoinModulesLoaded = false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package com.ciscowebex.androidsdk.kitchensink

import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.Service
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.IBinder
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import com.ciscowebex.androidsdk.kitchensink.auth.LoginActivity

class KitchenSinkForegroundService : Service() {

private var mNotificationManager: NotificationManager? = null;


override fun onBind(intent: Intent): IBinder? {
return null
}

override fun onCreate() {
super.onCreate()
mNotificationManager = this.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (IsForegroundServiceSupported()) {
startForeground(0x111111, getServiceOngoingNotification(this))
}
}

override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
intent?.let {
if (it.getBooleanExtra(KitchenSinkForegroundService.STOP_REQUEST, false)) {
stopSelf()
}
}
return START_STICKY
}

fun IsForegroundServiceSupported(): Boolean {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
}


override fun onDestroy() {
if (IsForegroundServiceSupported()) {
stopForeground(true)
}
super.onDestroy()
}

@RequiresApi(Build.VERSION_CODES.O)
private fun getServiceOngoingNotification(context: Context): Notification {
val notificationChannel =
NotificationChannel("ks_01", "Service Notifications",
NotificationManager.IMPORTANCE_MIN)
notificationChannel.enableLights(false)
notificationChannel.lockscreenVisibility = Notification.VISIBILITY_SECRET
mNotificationManager?.createNotificationChannel(notificationChannel)

val title = context.getString(R.string.app_running_in_background_notification_title)
val mainActivity = Intent(this, LoginActivity::class.java)
val pendingIntent =
PendingIntent.getActivity(this, 0, mainActivity, 0)
return NotificationCompat.Builder(
context,
"ks_01"
).setSmallIcon(R.drawable.app_notification_icon)
.setWhen(0)
.setContentTitle(title)
.setOngoing(true)
.setContentIntent(pendingIntent)
.build()
}


companion object {

fun startForegroundService(context: Context) {
Log.d(TAG, "Starting foreground service")
if (SERVICE_START_CALLED) {
return
}
SERVICE_START_CALLED = true
val intent = Intent(context, KitchenSinkForegroundService::class.java)
intent.putExtra(STOP_REQUEST, false)
ContextCompat.startForegroundService(context, intent)
}

fun stopForegroundService(context: Context) {
Log.d(TAG, "Stopping foreground service")
if (SERVICE_START_CALLED) {
val intent = Intent(context, KitchenSinkForegroundService::class.java)
intent.putExtra(STOP_REQUEST, true)
ContextCompat.startForegroundService(context, intent)
SERVICE_START_CALLED = false
}
}

private var SERVICE_START_CALLED = false
private const val STOP_REQUEST = "STOP_REQUEST"
private val TAG = "KitchenSinkForegroundService"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.ciscowebex.androidsdk.space.Space
import com.ciscowebex.androidsdk.CompletionHandler
import com.ciscowebex.androidsdk.auth.PhoneServiceRegistrationFailureReason
import com.ciscowebex.androidsdk.auth.UCLoginServerConnectionStatus
import com.ciscowebex.androidsdk.auth.UCSSOFailureReason
import com.ciscowebex.androidsdk.kitchensink.utils.CallObjectStorage
import com.ciscowebex.androidsdk.calendarMeeting.CalendarMeetingObserver
import com.ciscowebex.androidsdk.kitchensink.messaging.spaces.listeners.SpaceEventListener
Expand Down Expand Up @@ -39,7 +40,10 @@ class WebexRepository(val webex: Webex) : WebexUCLoginDelegate {
ShowNonSSOLogin,
OnUCLoginFailed,
OnUCLoggedIn,
OnUCServerConnectionStateChanged
OnUCServerConnectionStateChanged,
ShowUCSSOBrowser,
HideUCSSOBrowser,
OnSSOLoginFailed
}

enum class LogLevel {
Expand Down Expand Up @@ -341,7 +345,7 @@ class WebexRepository(val webex: Webex) : WebexUCLoginDelegate {
}

// Callbacks
override fun showUCSSOLoginView(ssoUrl: String) {
override fun loadUCSSOViewInBackground(ssoUrl: String) {
_cucmLiveData?.postValue(Pair(CucmEvent.ShowSSOLogin, ssoUrl))
Log.d(tag, "showUCSSOLoginView")
}
Expand All @@ -364,9 +368,24 @@ class WebexRepository(val webex: Webex) : WebexUCLoginDelegate {
}

override fun onUCServerConnectionStateChanged(status: UCLoginServerConnectionStatus, failureReason: PhoneServiceRegistrationFailureReason) {
_cucmLiveData?.postValue(Pair(CucmEvent.OnUCServerConnectionStateChanged, ""))
Log.d(tag, "onUCServerConnectionStateChanged status: $status failureReason: $failureReason")
ucServerConnectionStatus = status
ucServerConnectionFailureReason = failureReason
_cucmLiveData?.postValue(Pair(CucmEvent.OnUCServerConnectionStateChanged, ""))
}

override fun showUCSSOBrowser() {
_cucmLiveData?.postValue(Pair(CucmEvent.ShowUCSSOBrowser, ""))
Log.d(tag, "showUCSSOBrowser")
}

override fun hideUCSSOBrowser() {
_cucmLiveData?.postValue(Pair(CucmEvent.HideUCSSOBrowser, ""))
Log.d(tag, "hideUCSSOBrowser")
}

override fun onUCSSOLoginFailed(failureReason: UCSSOFailureReason) {
_cucmLiveData?.postValue(Pair(CucmEvent.OnSSOLoginFailed, failureReason.name))
Log.d(tag, "onUCSSOLoginFailed : reason = ${failureReason.name}")
}
}
Loading

0 comments on commit 7258234

Please sign in to comment.