Commit 1b1c3683 authored by Christophe Deschamps's avatar Christophe Deschamps
Browse files

Build 6


Former-commit-id: c3c0d345f98bcba01e8078e37aceb72fec4d25eb
parent c8a41551
......@@ -48,7 +48,7 @@ android {
applicationId "org.lindoor"
minSdkVersion 23
targetSdkVersion 29
versionCode 4
versionCode 6
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
......
......@@ -20,12 +20,14 @@
package org.lindoor.compatibility
import android.annotation.TargetApi
import android.app.Activity
import android.bluetooth.BluetoothAdapter
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import android.os.Vibrator
import android.provider.Settings
import android.view.WindowManager
@TargetApi(23)
class Api23Compatibility {
......@@ -61,6 +63,26 @@ class Api23Compatibility {
fun vibrateOneShot(v: Vibrator) {
v.vibrate(500)
}
fun setShowWhenLocked(activity: Activity, enable: Boolean) {
if (enable) {
activity.window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
} else {
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
}
}
fun setTurnScreenOn(activity: Activity, enable: Boolean) {
if (enable) {
activity.window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
} else {
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
}
}
fun requestDismissKeyguard(activity: Activity) {
activity.window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD)
}
}
......
......@@ -20,10 +20,7 @@
package org.lindoor.compatibility
import android.annotation.TargetApi
import android.app.Activity
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PictureInPictureParams
import android.app.*
import android.content.Context
import android.content.pm.PackageManager
import android.media.AudioAttributes
......@@ -79,6 +76,7 @@ class Api26Compatibility {
channel.enableVibration(true)
channel.enableLights(true)
channel.setShowBadge(true)
channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
notificationManager.createNotificationChannel(channel)
}
......
......@@ -20,7 +20,9 @@
package org.lindoor.compatibility
import android.annotation.TargetApi
import android.app.Activity
import android.app.ActivityManager
import android.app.KeyguardManager
import android.app.usage.UsageStatsManager
import android.content.Context
......@@ -38,5 +40,17 @@ class Api28Compatibility {
context.getSystemService(Context.USAGE_STATS_SERVICE) as UsageStatsManager
return usageStatsManager.appStandbyBucket
}
fun setShowWhenLocked(activity: Activity, enable: Boolean) {
activity.setShowWhenLocked(enable)
}
fun setTurnScreenOn(activity: Activity, enable: Boolean) {
activity.setTurnScreenOn(enable)
}
fun requestDismissKeyguard(activity: Activity) {
val keyguardManager = activity.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
keyguardManager.requestDismissKeyguard(activity, null)
}
}
}
......@@ -38,6 +38,7 @@ import org.lindoor.LindoorApplication
import org.lindoor.compatibility.Api23Compatibility
import org.lindoor.compatibility.Api25Compatibility
import org.lindoor.compatibility.Api26Compatibility
import org.lindoor.compatibility.Api28Compatibility
import org.linphone.mediastream.Version
import java.io.File
......@@ -125,6 +126,33 @@ class Compatibility {
}
}
/* UI */
fun setShowWhenLocked(activity: Activity, enable: Boolean) {
if (Version.sdkStrictlyBelow(Version.API27_OREO_81)) {
Api23Compatibility.setShowWhenLocked(activity, enable)
} else {
Api28Compatibility.setShowWhenLocked(activity, enable)
}
}
fun setTurnScreenOn(activity: Activity, enable: Boolean) {
if (Version.sdkStrictlyBelow(Version.API27_OREO_81)) {
Api23Compatibility.setTurnScreenOn(activity, enable)
} else {
Api28Compatibility.setTurnScreenOn(activity, enable)
}
}
fun requestDismissKeyguard(activity: Activity) {
if (Version.sdkStrictlyBelow(Version.API27_OREO_81)) {
Api23Compatibility.requestDismissKeyguard(activity)
} else {
Api28Compatibility.requestDismissKeyguard(activity)
}
}
// Lindoor
......
......@@ -52,7 +52,6 @@ import org.lindoor.store.DeviceStore
import org.lindoor.ui.call.CallInProgressActivity
import org.lindoor.ui.call.CallIncomingActivity
import org.lindoor.ui.call.CallOutgoingActivity
import org.lindoor.utils.cdlog
import org.lindoor.utils.extensions.existsAndIsNotEmpty
import org.linphone.compatibility.Compatibility
import org.linphone.core.Call
......@@ -158,7 +157,7 @@ class NotificationsManager(private val context: Context) {
0
)
Glide.with(context.applicationContext).asBitmap().load(it).into(awt)
notificationBuilder.setCustomHeadsUpContentView(
notificationBuilder.setCustomBigContentView(
notificationLayoutHeadsUp
)
val notification = notificationBuilder.build()
......@@ -336,10 +335,10 @@ class NotificationsManager(private val context: Context) {
if (hasSnapShot)
RemoteViews(
context.packageName,
R.layout.call_incoming_notification_heads_up_snapshot
R.layout.call_incoming_notification_content_with_snapshot
)
else
RemoteViews(context.packageName, R.layout.call_incoming_notification_heads_up)
RemoteViews(context.packageName, R.layout.call_incoming_notification_content)
notificationLayoutHeadsUp.setTextViewText(R.id.caller, displayName)
notificationLayoutHeadsUp.setTextViewText(R.id.sip_uri, address)
......@@ -376,6 +375,7 @@ class NotificationsManager(private val context: Context) {
.setContentText(Texts.get("notif_incoming_call_title"))
.setContentIntent(pendingIntent)
.setCategory(NotificationCompat.CATEGORY_CALL)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setWhen(System.currentTimeMillis())
.setAutoCancel(false)
......@@ -385,7 +385,8 @@ class NotificationsManager(private val context: Context) {
.setFullScreenIntent(pendingIntent, true)
.addAction(getCallDeclineAction(notifiable.notificationId))
.addAction(getCallAnswerAction(notifiable.notificationId))
.setCustomHeadsUpContentView(fillIncomingRemoteViewsForCall(call, false))
.setCustomContentView(fillIncomingRemoteViewsForCall(call, false))
.setCustomBigContentView(fillIncomingRemoteViewsForCall(call, true))
val notification = notificationBuilder.build()
......
......@@ -64,6 +64,6 @@ class AccountFragment : Fragment() {
val browserIntent =
Intent(Intent.ACTION_VIEW, Uri.parse(LindoorApplication.corePreferences.config.getString("assistant","freesip_url","www.lindoor.org")))
startActivity(browserIntent)
},confirmTextKey="continue")
})
}
}
package org.lindoor.ui.assistant
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import kotlinx.android.synthetic.main.fragment_assistant_root.view.*
import kotlinx.android.synthetic.main.widget_round_rect_button.view.*
import org.lindoor.GenericFragment
import org.lindoor.R
import org.lindoor.databinding.FragmentAssistantRootBinding
import org.lindoor.entities.Account
import org.lindoor.utils.DialogUtil
class AssistantRootFragment : GenericFragment() {
......@@ -20,18 +24,31 @@ class AssistantRootFragment : GenericFragment() {
val binding = FragmentAssistantRootBinding.inflate(inflater, container, false)
binding.root.create.root.setOnClickListener {
mainactivity.navController.navigate(R.id.navigation_assistant_create_lindoor)
navigateToCompotent(R.id.navigation_assistant_create_lindoor)
}
binding.root.use.root.setOnClickListener {
mainactivity.navController.navigate(R.id.navigation_assistant_login_lindoor)
navigateToCompotent(R.id.navigation_assistant_login_lindoor)
}
binding.root.sip.root.setOnClickListener {
mainactivity.navController.navigate(R.id.navigation_assistant_login_sip)
navigateToCompotent(R.id.navigation_assistant_login_sip)
}
binding.root.remote.root.setOnClickListener {
mainactivity.navController.navigate(R.id.navigation_assistant_remote_root)
navigateToCompotent(R.id.navigation_assistant_remote_root)
}
return binding.root
}
private fun navigateToCompotent(componentResource: Int) {
if (Account.configured()) {
DialogUtil.confirm(
"assistant_using_will_disconnect_title",
"assistant_using_will_disconnect_message",
{ _: DialogInterface, _: Int ->
Account.disconnect()
mainactivity.navController.navigate(componentResource)
})
} else
mainactivity.navController.navigate(componentResource)
}
}
......@@ -16,6 +16,8 @@ import org.lindoor.R
import org.lindoor.databinding.ActivityCallInProgressBinding
import org.lindoor.utils.DialogUtil
import org.lindoor.utils.extensions.toogleVisible
import org.lindoor.utils.stackStrace
import org.linphone.compatibility.Compatibility
import org.linphone.core.Call
import org.linphone.core.tools.Log
import permissions.dispatcher.NeedsPermission
......@@ -32,6 +34,9 @@ class CallInProgressActivity : CallGenericActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Compatibility.setShowWhenLocked(this, true)
Compatibility.setTurnScreenOn(this, true)
binding = DataBindingUtil.setContentView(
this,
R.layout.activity_call_in_progress
......@@ -91,7 +96,6 @@ class CallInProgressActivity : CallGenericActivity() {
}
override fun onPause() {
coreContext.core.nativeVideoWindowId = null
if (coreContext.core.callsNb > 0) {
coreContext.createCallOverlay()
}
......
......@@ -9,6 +9,8 @@ import kotlinx.android.synthetic.main.chunk_call_device_icon_or_video.view.*
import org.lindoor.LindoorApplication.Companion.coreContext
import org.lindoor.R
import org.lindoor.databinding.ActivityCallIncomingBinding
import org.lindoor.utils.stackStrace
import org.linphone.compatibility.Compatibility
import org.linphone.core.Call
......@@ -20,6 +22,10 @@ class CallIncomingActivity : CallGenericActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Compatibility.setShowWhenLocked(this, true)
Compatibility.setTurnScreenOn(this, true)
Compatibility.requestDismissKeyguard(this)
binding = DataBindingUtil.setContentView(
this,
R.layout.activity_call_incoming
......@@ -53,9 +59,4 @@ class CallIncomingActivity : CallGenericActivity() {
if (callViewModel.videoFullScreen.value!!) binding.root.videofullscreen else binding.root.videocollapsed
}
override fun onPause() {
coreContext.core.nativeVideoWindowId = null
super.onPause()
}
}
......@@ -89,11 +89,15 @@ class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) {
}
})
model.reset.observe(this, Observer { reached ->
if (reached)
model.resetEvent.observe(this, Observer { reset ->
if (reset)
view.timer.base = SystemClock.elapsedRealtime()
})
model.seekPosition.observe(this, Observer { p ->
view.timer.base = SystemClock.elapsedRealtime() - p
})
view.timer.setOnChronometerTickListener {
model.updatePosition()
}
......
......@@ -7,8 +7,6 @@ import org.lindoor.LindoorApplication
import org.lindoor.linphonecore.extensions.historyEvent
import org.linphone.core.Player
import org.linphone.core.PlayerListener
import org.linphone.core.tools.Log
import java.util.*
class PlayerViewModelFactory(private val callId: String, private val player: Player) :
......@@ -25,44 +23,38 @@ class PlayerViewModel(val callId: String, val player: Player) : ViewModel() {
LindoorApplication.coreContext.core.findCallLogFromCallId(callId)?.historyEvent()
val playing = MutableLiveData(false)
val position: MutableLiveData<Int> = MutableLiveData(0)
val reset = MutableLiveData(false)
val resetEvent = MutableLiveData(false)
val seekPosition = MutableLiveData(0)
lateinit var date: Date
var targetSeek: Int = 0
val duration: Int
get() {
if (isClosed())
if (historyEvent != null) {
player.open(historyEvent.mediaFileName)
}
return player.duration
}
private val listener = PlayerListener {
Log.i("[Recording] End of file reached")
playing.value = false
reset.value = true
seek(0)
resetEvent.value = true
targetSeek = 0
seek()
}
init {
player.addListener(listener)
if (historyEvent != null) {
player.open(historyEvent.mediaFileName)
}
}
override fun onCleared() {
if (!isClosed()) player.close()
player.close()
player.removeListener(listener)
super.onCleared()
}
fun togglePlay() {
if (isClosed())
if (historyEvent != null) {
player.open(historyEvent.mediaFileName)
}
if (playing.value!!)
player.pause()
else
......@@ -71,35 +63,28 @@ class PlayerViewModel(val callId: String, val player: Player) : ViewModel() {
}
fun playFromStart() {
if (isClosed())
if (historyEvent != null) {
player.open(historyEvent.mediaFileName)
}
seek(0)
targetSeek = 0
seek()
player.start()
playing.value = true
reset.value = true
resetEvent.value = true
}
fun seek(p: Int) {
if (!isClosed()) {
if (playing.value!!)
player.pause()
player.seek(p)
if (playing.value!!)
player.start()
updatePosition()
fun seek() {
player.close()
if (historyEvent != null) {
player.open(historyEvent.mediaFileName)
}
player.seek(targetSeek)
if (playing.value!!)
player.start()
updatePosition()
seekPosition.value = targetSeek
}
fun updatePosition() {
if (!isClosed()) {
position.value = player.currentPosition
}
}
private fun isClosed(): Boolean {
return player.state == Player.State.Closed
}
}
......@@ -60,9 +60,8 @@
android:id="@+id/centerbundle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/chunk_call_top"
android:layout_above="@+id/actions"
android:layout_marginTop="12dp">
android:layout_centerVertical="true">
<LinearLayout
android:id="@+id/chunk_call_name_address"
......
......@@ -32,8 +32,8 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/chunk_call_top"
android:layout_marginTop="40dp">
android:layout_centerVertical="true"
android:layout_marginTop="20dp">
<LinearLayout
android:id="@+id/chunk_call_name_address"
android:layout_width="match_parent"
......
......@@ -36,7 +36,7 @@
android:contentDescription="@null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:scaleType="centerInside"
android:adjustViewBounds="true"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_lindoor_icon"
......
......@@ -25,7 +25,7 @@
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_weight="1"
android:visibility='@{callmodel.device != null &amp;&amp; callmodel.device.actions.size()>0 ? View.VISIBLE : View.GONE}'
android:visibility='@{callmodel.device != null &amp;&amp; callmodel.device.actions.size()>0 ? View.VISIBLE : View.INVISIBLE}'
bind:backgroundeffect='@{"incall_call_button"}'
bind:icon='@{callmodel.device != null &amp;&amp; callmodel.device.actions.size()>0 ? callmodel.device.actions.get(0).iconName() : null}'
bind:onClick="@{()->callmodel.performAction(callmodel.device.actions.get(0))}"
......
......@@ -60,7 +60,8 @@
android:layout_toEndOf="@+id/play"
android:layout_marginEnd="7dp"
android:progress="@{playermodel.position}"
android:onProgressChanged="@{(seekBar, progress, fromUser) -> fromUser ? playermodel.seek(progress) : null}"
android:onProgressChanged="@{(seekBar, progress, fromUser) -> fromUser ? playermodel.setTargetSeek(progress) : null}"
android:onStopTrackingTouch="@{(seekBar) -> playermodel.seek()}"
android:thumbTint="@color/color_a" />
......
......@@ -87,7 +87,7 @@
android:focusable="true"
android:layout_width="160dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:layout_marginTop="40dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/password"
......@@ -155,7 +155,7 @@
android:focusable="true"
android:layout_width="320dp"
android:layout_height="40dp"
android:layout_marginTop="50dp"
android:layout_marginTop="55dp"
android:layout_marginBottom="40dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......
Subproject commit df20b6612f6f2907c1dc63e5d77568853c7558af
Subproject commit 62ed2e0e1772d247271b80f2ccd5dec4a8e71c38
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment