mirror of
https://github.com/nextcloud/talk-android
synced 2025-02-01 12:11:59 +00:00
replace CallController with CallActivity etc. (WIP)
- delete MagicCallActivity - replace butterknife with viewbinding for CallActivity TODO: - also switch CallNotificationController to Activity - check if CallActivity and CallNotificationActivity are called correctly - testing! Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
b49a1b9274
commit
251d41f7fb
@ -41,7 +41,7 @@ import com.bluelinelabs.logansquare.LoganSquare
|
||||
import com.google.firebase.messaging.FirebaseMessagingService
|
||||
import com.google.firebase.messaging.RemoteMessage
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.activities.MagicCallActivity
|
||||
import com.nextcloud.talk.activities.CallActivity
|
||||
import com.nextcloud.talk.api.NcApi
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||
@ -178,7 +178,7 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
|
||||
)
|
||||
}
|
||||
} else if (type == "call") {
|
||||
val fullScreenIntent = Intent(applicationContext, MagicCallActivity::class.java)
|
||||
val fullScreenIntent = Intent(applicationContext, CallActivity::class.java)
|
||||
val bundle = Bundle()
|
||||
bundle.putString(BundleKeys.KEY_ROOM_ID, decryptedPushMessage!!.id)
|
||||
bundle.putParcelable(KEY_USER_ENTITY, signatureVerification!!.userEntity)
|
||||
|
@ -123,7 +123,7 @@
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activities.MagicCallActivity"
|
||||
android:name=".activities.CallActivity"
|
||||
android:theme="@style/AppTheme.CallLauncher"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,184 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2021 Andy Scherzinger (infoi@andy-scherzinger.de)
|
||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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.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
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
|
||||
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.databinding.ActivityMagicCallBinding
|
||||
import com.nextcloud.talk.events.ConfigurationChangeEvent
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class MagicCallActivity : BaseActivity() {
|
||||
lateinit var binding: ActivityMagicCallBinding
|
||||
private var router: Router? = null
|
||||
var isInPipMode: Boolean = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Log.d(TAG, "onCreate")
|
||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||
setTheme(R.style.CallTheme)
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dismissKeyguard()
|
||||
window.addFlags(
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN or
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||
)
|
||||
|
||||
binding = ActivityMagicCallBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
router = Conductor.attachRouter(this, binding.controllerContainer, savedInstanceState)
|
||||
router!!.setPopsLastView(false)
|
||||
|
||||
if (!router!!.hasRootController()) {
|
||||
if (intent.getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) {
|
||||
router!!.setRoot(
|
||||
RouterTransaction.with(CallNotificationController(intent.extras))
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
.tag(CallNotificationController.TAG)
|
||||
)
|
||||
} else {
|
||||
router!!.setRoot(
|
||||
RouterTransaction.with(CallController(intent.extras))
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
.tag(CallController.TAG)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
enterPipMode()
|
||||
}
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
enterPipMode()
|
||||
}
|
||||
|
||||
fun enterPipMode() {
|
||||
enableKeyguard()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
enterPictureInPictureMode(getPipParams())
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
eventBus.post(ConfigurationChangeEvent())
|
||||
}
|
||||
|
||||
private fun dismissKeyguard() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
setShowWhenLocked(true)
|
||||
setTurnScreenOn(true)
|
||||
val keyguardManager = getSystemService(KEYGUARD_SERVICE) as KeyguardManager
|
||||
keyguardManager.requestDismissKeyguard(this, null)
|
||||
} else {
|
||||
window.addFlags(
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
||||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun enableKeyguard() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
setShowWhenLocked(false)
|
||||
} else {
|
||||
window.clearFlags(
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
||||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
||||
isInPipMode = isInPictureInPictureMode
|
||||
|
||||
if (router?.getControllerWithTag(CallNotificationController.TAG) != null) {
|
||||
val callNotificationController = router?.getControllerWithTag(CallNotificationController.TAG) as CallNotificationController
|
||||
if (isInPictureInPictureMode) {
|
||||
// callNotificationController.updateUiForPipMode()
|
||||
} else {
|
||||
// callNotificationController.updateUiForNormalMode()
|
||||
}
|
||||
} else if (router?.getControllerWithTag(CallController.TAG) != null) {
|
||||
val callController = router?.getControllerWithTag(CallController.TAG) as CallController
|
||||
if (isInPictureInPictureMode) {
|
||||
callController.updateUiForPipMode()
|
||||
} else {
|
||||
callController.updateUiForNormalMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
if (isInPipMode) {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = "MagicCallActivity"
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ package com.nextcloud.talk.controllers;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
@ -41,8 +42,6 @@ import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bluelinelabs.conductor.RouterTransaction;
|
||||
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
|
||||
import com.bluelinelabs.logansquare.LoganSquare;
|
||||
import com.facebook.common.executors.UiThreadImmediateExecutorService;
|
||||
import com.facebook.common.references.CloseableReference;
|
||||
@ -55,6 +54,7 @@ import com.facebook.imagepipeline.image.CloseableImage;
|
||||
import com.facebook.imagepipeline.postprocessors.BlurPostProcessor;
|
||||
import com.facebook.imagepipeline.request.ImageRequest;
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.activities.CallActivity;
|
||||
import com.nextcloud.talk.api.NcApi;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.controllers.base.BaseController;
|
||||
@ -173,7 +173,7 @@ public class CallNotificationController extends BaseController {
|
||||
callAnswerVoiceOnlyView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@OnClick(R.id.callControlHangupView)
|
||||
@OnClick(R.id.hangupButton)
|
||||
void hangup() {
|
||||
leavingScreen = true;
|
||||
|
||||
@ -198,10 +198,14 @@ public class CallNotificationController extends BaseController {
|
||||
originalBundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), currentConversation.getToken());
|
||||
originalBundle.putString(BundleKeys.INSTANCE.getKEY_CONVERSATION_NAME(), currentConversation.getDisplayName());
|
||||
|
||||
getRouter().replaceTopController(RouterTransaction.with(new CallController(originalBundle))
|
||||
.popChangeHandler(new HorizontalChangeHandler())
|
||||
.pushChangeHandler(new HorizontalChangeHandler())
|
||||
.tag(CallController.TAG));
|
||||
// getRouter().replaceTopController(RouterTransaction.with(new CallActivity(originalBundle))
|
||||
// .popChangeHandler(new HorizontalChangeHandler())
|
||||
// .pushChangeHandler(new HorizontalChangeHandler())
|
||||
// .tag(CallActivity.TAG));
|
||||
|
||||
Intent intent = new Intent(this.getActivity(), CallActivity.class);
|
||||
intent.putExtras(originalBundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void checkIfAnyParticipantsRemainInRoom() {
|
||||
|
@ -94,7 +94,7 @@ import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber
|
||||
import com.facebook.imagepipeline.image.CloseableImage
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.activities.MagicCallActivity
|
||||
import com.nextcloud.talk.activities.CallActivity
|
||||
import com.nextcloud.talk.activities.MainActivity
|
||||
import com.nextcloud.talk.adapters.messages.IncomingLocationMessageViewHolder
|
||||
import com.nextcloud.talk.adapters.messages.IncomingPreviewMessageViewHolder
|
||||
@ -2142,7 +2142,7 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
|
||||
return if (activity != null) {
|
||||
val callIntent = Intent(activity, MagicCallActivity::class.java)
|
||||
val callIntent = Intent(activity, CallActivity::class.java)
|
||||
callIntent.putExtras(bundle)
|
||||
callIntent
|
||||
} else {
|
||||
@ -2500,7 +2500,7 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
|
||||
override fun onNext(roomOverall: RoomOverall) {
|
||||
val conversationIntent = Intent(activity, MagicCallActivity::class.java)
|
||||
val conversationIntent = Intent(activity, CallActivity::class.java)
|
||||
val bundle = Bundle()
|
||||
bundle.putParcelable(KEY_USER_ENTITY, conversationUser)
|
||||
bundle.putString(KEY_ROOM_TOKEN, roomOverall.ocs.data.token)
|
||||
|
@ -48,7 +48,7 @@ import com.facebook.imagepipeline.image.CloseableImage;
|
||||
import com.facebook.imagepipeline.postprocessors.RoundAsCirclePostprocessor;
|
||||
import com.facebook.imagepipeline.request.ImageRequest;
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.activities.MagicCallActivity;
|
||||
import com.nextcloud.talk.activities.CallActivity;
|
||||
import com.nextcloud.talk.activities.MainActivity;
|
||||
import com.nextcloud.talk.api.NcApi;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
@ -590,7 +590,7 @@ public class NotificationWorker extends Worker {
|
||||
|
||||
boolean startACall = decryptedPushMessage.getType().equals("call");
|
||||
if (startACall) {
|
||||
intent = new Intent(context, MagicCallActivity.class);
|
||||
intent = new Intent(context, CallActivity.class);
|
||||
} else {
|
||||
intent = new Intent(context, MainActivity.class);
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ @author Mario Danic
|
||||
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".activities.MagicCallActivity">
|
||||
|
||||
<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
|
||||
android:id="@+id/controller_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</RelativeLayout>
|
@ -21,7 +21,7 @@
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/callStateRelativeLayoutView"
|
||||
android:id="@+id/callStateRelativeLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical"
|
||||
tools:context=".activities.MagicCallActivity">
|
||||
tools:context=".activities.CallActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearWrapperLayout"
|
||||
@ -37,7 +37,7 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/conversationRelativeLayoutView"
|
||||
android:id="@+id/conversationRelativeLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
@ -70,7 +70,7 @@
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/call_control_switch_camera"
|
||||
android:id="@+id/switchSelfVideoButton"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
@ -89,7 +89,7 @@
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/callVoiceOrVideoTextView"
|
||||
android:id="@+id/callModeTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
@ -122,6 +122,7 @@
|
||||
android:layout_centerVertical="true" />
|
||||
|
||||
<include
|
||||
android:id="@+id/callStates"
|
||||
layout="@layout/call_states"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -132,7 +133,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/callControlsLinearLayout"
|
||||
android:id="@+id/callControls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/call_controls_height"
|
||||
android:layout_alignBottom="@id/linearWrapperLayout"
|
||||
@ -144,7 +145,7 @@
|
||||
android:layout_marginEnd="40dp">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/callControlEnterPip"
|
||||
android:id="@+id/pictureInPictureButton"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="10dp"
|
||||
@ -154,7 +155,7 @@
|
||||
app:roundAsCircle="true" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/callControlEnableSpeaker"
|
||||
android:id="@+id/speakerButton"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
@ -164,7 +165,7 @@
|
||||
app:roundAsCircle="true" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/call_control_camera"
|
||||
android:id="@+id/cameraButton"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
@ -175,7 +176,7 @@
|
||||
app:roundAsCircle="true" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/call_control_microphone"
|
||||
android:id="@+id/microphoneButton"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
@ -186,7 +187,7 @@
|
||||
app:roundAsCircle="true" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/callControlHangupView"
|
||||
android:id="@+id/hangupButton"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
|
@ -54,7 +54,7 @@
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/callControlHangupView"
|
||||
android:id="@+id/hangupButton"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="24dp"
|
||||
|
Loading…
Reference in New Issue
Block a user