mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 23:25:20 +03:00
add initial approach for pip mode (wip)
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
bda45d874c
commit
78384e7b55
7 changed files with 59 additions and 57 deletions
|
@ -124,7 +124,8 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.MagicCallActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:launchMode="singleTask" />
|
||||
|
||||
<activity
|
||||
|
|
|
@ -23,12 +23,15 @@
|
|||
package com.nextcloud.talk.activities
|
||||
|
||||
import android.app.KeyguardManager
|
||||
import android.app.PictureInPictureParams
|
||||
import android.content.res.Configuration
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.util.Log
|
||||
import android.util.Rational
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.annotation.RequiresApi
|
||||
import autodagger.AutoInjector
|
||||
import com.bluelinelabs.conductor.Conductor
|
||||
import com.bluelinelabs.conductor.Router
|
||||
|
@ -38,7 +41,6 @@ import com.nextcloud.talk.R
|
|||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.controllers.CallController
|
||||
import com.nextcloud.talk.controllers.CallNotificationController
|
||||
import com.nextcloud.talk.controllers.ChatController
|
||||
import com.nextcloud.talk.databinding.ActivityMagicCallBinding
|
||||
import com.nextcloud.talk.events.ConfigurationChangeEvent
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
|
@ -46,14 +48,11 @@ import com.nextcloud.talk.utils.bundle.BundleKeys
|
|||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class MagicCallActivity : BaseActivity() {
|
||||
lateinit var binding: ActivityMagicCallBinding
|
||||
|
||||
private lateinit var chatController: ChatController
|
||||
|
||||
private var router: Router? = null
|
||||
private var chatRouter: Router? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Log.d(TAG, "onCreate")
|
||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||
setTheme(R.style.CallTheme)
|
||||
|
||||
|
@ -63,7 +62,7 @@ class MagicCallActivity : BaseActivity() {
|
|||
WindowManager.LayoutParams.FLAG_FULLSCREEN or
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||
)
|
||||
window.decorView.systemUiVisibility = systemUiVisibility
|
||||
// window.decorView.systemUiVisibility = systemUiVisibility
|
||||
|
||||
binding = ActivityMagicCallBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
@ -87,30 +86,28 @@ class MagicCallActivity : BaseActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
val extras = intent.extras ?: Bundle()
|
||||
extras.putBoolean("showToggleChat", true)
|
||||
|
||||
chatController = ChatController(extras)
|
||||
chatRouter = Conductor.attachRouter(this, binding.chatControllerView, savedInstanceState)
|
||||
chatRouter!!.setRoot(
|
||||
RouterTransaction.with(chatController)
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
)
|
||||
}
|
||||
|
||||
fun showChat() {
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
fun enterPipMode() {
|
||||
enableKeyguard()
|
||||
binding.chatControllerView.visibility = View.VISIBLE
|
||||
binding.controllerContainer.visibility = View.GONE
|
||||
chatController.wasDetached = false
|
||||
chatController.pullChatMessages(1)
|
||||
enterPictureInPictureMode(getPipParams())
|
||||
}
|
||||
|
||||
fun showCall() {
|
||||
binding.controllerContainer.visibility = View.VISIBLE
|
||||
binding.chatControllerView.visibility = View.GONE
|
||||
chatController.wasDetached = true
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onUserLeaveHint() {
|
||||
enterPictureInPictureMode(getPipParams())
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private fun getPipParams(): PictureInPictureParams {
|
||||
val pipRatio = Rational(
|
||||
300,
|
||||
500
|
||||
)
|
||||
return PictureInPictureParams.Builder()
|
||||
.setAspectRatio(pipRatio)
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
|
@ -145,14 +142,25 @@ class MagicCallActivity : BaseActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean,
|
||||
newConfig: Configuration) {
|
||||
if (isInPictureInPictureMode) {
|
||||
Log.d(TAG, "Hide the full-screen UI (controls, etc.) while in picture-in-picture mode.")
|
||||
} else {
|
||||
Log.d(TAG,"Restore the full-screen UI.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
companion object {
|
||||
private val TAG = "MagicCallActivity"
|
||||
|
||||
private val systemUiVisibility: Int
|
||||
/* private val systemUiVisibility: Int
|
||||
get() {
|
||||
var flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
flags = flags or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||
return flags
|
||||
}
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ import javax.inject.Inject;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import autodagger.AutoInjector;
|
||||
import butterknife.BindView;
|
||||
|
@ -372,7 +373,9 @@ public class CallController extends BaseController {
|
|||
basicInitialization();
|
||||
initViews();
|
||||
initPipView();
|
||||
initiateCall();
|
||||
if (!isConnectionEstablished()){
|
||||
initiateCall();
|
||||
}
|
||||
}
|
||||
|
||||
private void basicInitialization() {
|
||||
|
@ -839,9 +842,10 @@ public class CallController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.callControlToggleChat)
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@OnClick(R.id.callControlEnterPip)
|
||||
void onToggleChatClick() {
|
||||
((MagicCallActivity) getActivity()).showChat();
|
||||
((MagicCallActivity) getActivity()).enterPipMode();
|
||||
}
|
||||
|
||||
@OnClick(R.id.callControlHangupView)
|
||||
|
|
|
@ -577,15 +577,6 @@ class ChatController(args: Bundle) :
|
|||
|
||||
binding.messageInputView.setPadding(0, 0, 0, 0)
|
||||
|
||||
if (args.containsKey("showToggleChat") && args.getBoolean("showToggleChat")) {
|
||||
binding.callControlToggleChat.visibility = View.VISIBLE
|
||||
wasDetached = true
|
||||
}
|
||||
|
||||
binding.callControlToggleChat.setOnClickListener {
|
||||
(activity as MagicCallActivity).showCall()
|
||||
}
|
||||
|
||||
binding.messagesListView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
super.onScrollStateChanged(recyclerView, newState)
|
||||
|
@ -1459,6 +1450,7 @@ class ChatController(args: Bundle) :
|
|||
!activity?.isChangingConfigurations!! &&
|
||||
!isLeavingForConversation
|
||||
) {
|
||||
// TODO: don't leave room when going back to call from PIP Mode!!
|
||||
wasDetached = true
|
||||
leaveRoom()
|
||||
}
|
||||
|
@ -2336,7 +2328,7 @@ class ChatController(args: Bundle) :
|
|||
menu.findItem(R.id.action_forward_message).isVisible =
|
||||
ChatMessage.MessageType.REGULAR_TEXT_MESSAGE == message.getMessageType()
|
||||
if (menu.hasVisibleItems()) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
setForceShowIcon(true)
|
||||
}
|
||||
show()
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#FFFFFF">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M19,11h-8v6h8v-6zM23,19L23,4.98C23,3.88 22.1,3 21,3L3,3c-1.1,0 -2,0.88 -2,1.98L1,19c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2zM21,19.02L3,19.02L3,4.97h18v14.05z"/>
|
||||
</vector>
|
|
@ -142,14 +142,14 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/callControlToggleChat"
|
||||
android:id="@+id/callControlEnterPip"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="40dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:elevation="10dp"
|
||||
app:backgroundImage="@color/call_buttons_background"
|
||||
app:placeholderImage="@drawable/ic_comment_white"
|
||||
app:placeholderImage="@drawable/ic_baseline_picture_in_picture_alt_24"
|
||||
app:roundAsCircle="true" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
|
|
|
@ -40,19 +40,6 @@
|
|||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/callControlToggleChat"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_margin="16dp"
|
||||
android:elevation="10dp"
|
||||
android:visibility="gone"
|
||||
app:backgroundImage="@color/call_buttons_background"
|
||||
app:placeholderImage="@drawable/ic_call_black_24dp"
|
||||
app:roundAsCircle="true"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in a new issue