Do lots of work on call notification

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-06-19 13:17:01 +02:00
Родитель f20212f6d2
Коммит 621468b81f
13 изменённых файлов: 1067 добавлений и 859 удалений

Просмотреть файл

@ -46,7 +46,9 @@
tools:replace="label, icon, roundIcon, theme, name, allowBackup">
<meta-data android:name="android.max_aspect" android:value="10" />
<meta-data
android:name="android.max_aspect"
android:value="10"/>
<activity
android:name=".activities.MainActivity"
@ -60,7 +62,7 @@
</activity>
<activity
android:name=".activities.CallActivity"
android:name=".activities.MagicCallActivity"
android:configChanges="orientation|screenSize"
android:launchMode="singleTask"/>

Просмотреть файл

@ -0,0 +1,96 @@
/*
* 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/>.
*/
package com.nextcloud.talk.activities;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
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.utils.bundle.BundleKeys;
import autodagger.AutoInjector;
import butterknife.BindView;
import butterknife.ButterKnife;
@AutoInjector(NextcloudTalkApplication.class)
public class MagicCallActivity extends AppCompatActivity {
private static final String TAG = "MagicCallActivity";
@BindView(R.id.controller_container)
ViewGroup container;
private Router router;
private static int getSystemUiVisibility() {
int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
return flags;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject (this);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
getWindow().getDecorView().setSystemUiVisibility(getSystemUiVisibility());
setContentView(R.layout.activity_magic_call);
ButterKnife.bind(this);
router = Conductor.attachRouter(this, container, savedInstanceState);
router.setPopsLastView(true);
if (!router.hasRootController()) {
if (getIntent().getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) {
router.setRoot(RouterTransaction.with(new CallNotificationController(getIntent().getExtras()))
.pushChangeHandler(new HorizontalChangeHandler())
.popChangeHandler(new HorizontalChangeHandler()));
} else {
router.setRoot(RouterTransaction.with(new CallController(getIntent().getExtras()))
.pushChangeHandler(new HorizontalChangeHandler())
.popChangeHandler(new HorizontalChangeHandler()));
}
}
}
@Override
public void onBackPressed() {
if (!router.handleBack()) {
super.onBackPressed();
}
}
}

Просмотреть файл

@ -117,7 +117,10 @@ public class CallNotificationController extends BaseController {
@OnClick(R.id.callControlHangupView)
void hangup() {
leavingScreen = true;
getRouter().popCurrentController();
if (getActivity() != null) {
getActivity().finish();
}
}
@OnClick(R.id.callAnswerCameraView)
@ -135,12 +138,9 @@ public class CallNotificationController extends BaseController {
private void setBackstackAndProceed() {
originalBundle.putString(BundleKeys.KEY_ROOM_TOKEN, currentRoom.getToken());
List<RouterTransaction> routerTransactions = new ArrayList<>();
routerTransactions.add(RouterTransaction.with(new MagicBottomNavigationController())
.popChangeHandler(new HorizontalChangeHandler()).pushChangeHandler(new HorizontalChangeHandler()));
routerTransactions.add(RouterTransaction.with(new ChatController(originalBundle)).popChangeHandler(new
HorizontalChangeHandler()).pushChangeHandler(new HorizontalChangeHandler()));
getRouter().setBackstack(routerTransactions, new HorizontalChangeHandler());
getRouter().setRoot(RouterTransaction.with(new CallController(originalBundle))
.popChangeHandler(new HorizontalChangeHandler())
.pushChangeHandler(new HorizontalChangeHandler()));
}
private void checkIfAnyParticipantsRemainInRoom() {
@ -235,8 +235,6 @@ public class CallNotificationController extends BaseController {
protected void onViewBound(@NonNull View view) {
super.onViewBound(view);
getActionBar().hide();
handleFromNotification();
String callRingtonePreferenceString = appPreferences.getCallRingtoneUri();

Просмотреть файл

@ -50,7 +50,7 @@ import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler;
import com.bluelinelabs.conductor.internal.NoOpControllerChangeHandler;
import com.kennyc.bottomsheet.BottomSheet;
import com.nextcloud.talk.R;
import com.nextcloud.talk.activities.CallActivity;
import com.nextcloud.talk.activities.MagicCallActivity;
import com.nextcloud.talk.adapters.items.CallItem;
import com.nextcloud.talk.api.NcApi;
import com.nextcloud.talk.application.NextcloudTalkApplication;
@ -508,7 +508,7 @@ public class CallsListController extends BaseController implements SearchView.On
} else {
overridePushHandler(new NoOpControllerChangeHandler());
overridePopHandler(new NoOpControllerChangeHandler());
Intent callIntent = new Intent(getActivity(), CallActivity.class);
Intent callIntent = new Intent(getActivity(), MagicCallActivity.class);
callIntent.putExtras(bundle);
startActivity(callIntent);
}

Просмотреть файл

@ -56,7 +56,7 @@ import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.nextcloud.talk.R;
import com.nextcloud.talk.activities.CallActivity;
import com.nextcloud.talk.activities.MagicCallActivity;
import com.nextcloud.talk.adapters.messages.MagicIncomingTextMessageViewHolder;
import com.nextcloud.talk.adapters.messages.MagicOutcomingTextMessageViewHolder;
import com.nextcloud.talk.api.NcApi;
@ -831,7 +831,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
bundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true);
}
Intent callIntent = new Intent(getActivity(), CallActivity.class);
Intent callIntent = new Intent(getActivity(), MagicCallActivity.class);
callIntent.putExtras(bundle);
return callIntent;

Просмотреть файл

@ -51,7 +51,7 @@ import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler;
import com.kennyc.bottomsheet.BottomSheet;
import com.nextcloud.talk.R;
import com.nextcloud.talk.activities.CallActivity;
import com.nextcloud.talk.activities.MagicCallActivity;
import com.nextcloud.talk.adapters.items.ProgressItem;
import com.nextcloud.talk.adapters.items.UserHeaderItem;
import com.nextcloud.talk.adapters.items.UserItem;
@ -295,7 +295,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
@Override
public void onNext(RoomOverall roomOverall) {
Intent conversationIntent = new Intent(getActivity(), CallActivity.class);
Intent conversationIntent = new Intent(getActivity(), MagicCallActivity.class);
Bundle bundle = new Bundle();
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.getOcs().getData().getToken());
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.getOcs().getData().getRoomId());
@ -828,7 +828,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
@Override
public void onNext(RoomOverall roomOverall) {
if (getActivity() != null) {
Intent conversationIntent = new Intent(getActivity(), CallActivity.class);
Intent conversationIntent = new Intent(getActivity(), MagicCallActivity.class);
Bundle bundle = new Bundle();
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.getOcs().getData().getToken());
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.getOcs().getData().getRoomId());

Просмотреть файл

@ -92,7 +92,7 @@ public abstract class BaseController extends RefWatchingController {
@Override
protected void onAttach(@NonNull View view) {
setTitle();
if (!MagicBottomNavigationController.class.getName().equals(getClass().getName())) {
if (!MagicBottomNavigationController.class.getName().equals(getClass().getName()) && getActionBar() != null) {
getActionBar().setDisplayHomeAsUpEnabled(false);
}

Просмотреть файл

@ -40,7 +40,7 @@ import android.widget.TextView;
import com.bluelinelabs.conductor.RouterTransaction;
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
import com.nextcloud.talk.R;
import com.nextcloud.talk.activities.CallActivity;
import com.nextcloud.talk.activities.MagicCallActivity;
import com.nextcloud.talk.api.NcApi;
import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.controllers.ChatController;
@ -542,7 +542,7 @@ public class OperationsMenuController extends BaseController {
eventBus.post(new BottomSheetLockEvent(true, 0,
true, true, dismissView));
Intent conversationIntent = new Intent(getActivity(), CallActivity.class);
Intent conversationIntent = new Intent(getActivity(), MagicCallActivity.class);
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, room.getToken());
bundle.putString(BundleKeys.KEY_ROOM_ID, room.getRoomId());
bundle.putString(BundleKeys.KEY_CONVERSATION_NAME, room.getDisplayName());
@ -582,7 +582,7 @@ public class OperationsMenuController extends BaseController {
if (getActivity() != null) {
Intent callIntent = new Intent(getActivity(), CallActivity.class);
Intent callIntent = new Intent(getActivity(), MagicCallActivity.class);
callIntent.putExtras(bundle);
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);

Просмотреть файл

@ -26,10 +26,7 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
@ -40,14 +37,13 @@ import com.bluelinelabs.logansquare.LoganSquare;
import com.evernote.android.job.Job;
import com.evernote.android.job.util.support.PersistableBundleCompat;
import com.nextcloud.talk.R;
import com.nextcloud.talk.activities.CallActivity;
import com.nextcloud.talk.activities.MagicCallActivity;
import com.nextcloud.talk.activities.MainActivity;
import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.models.RingtoneSettings;
import com.nextcloud.talk.models.SignatureVerification;
import com.nextcloud.talk.models.json.push.DecryptedPushMessage;
import com.nextcloud.talk.utils.ApplicationWideCurrentRoomHolder;
import com.nextcloud.talk.utils.NotificationUtils;
import com.nextcloud.talk.utils.PushUtils;
import com.nextcloud.talk.utils.bundle.BundleKeys;
import com.nextcloud.talk.utils.database.user.UserUtils;
@ -59,8 +55,6 @@ import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.util.Calendar;
import java.util.zip.CRC32;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
@ -129,10 +123,11 @@ public class NotificationJob extends Job {
Bundle bundle = new Bundle();
if (hasChatSupport) {
intent = new Intent(context, MainActivity.class);
boolean startACall = decryptedPushMessage.getType().equals("call") || !hasChatSupport;
if (startACall) {
intent = new Intent(context, MagicCallActivity.class);
} else {
intent = new Intent(context, CallActivity.class);
intent = new Intent(context, MainActivity.class);
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@ -141,7 +136,7 @@ public class NotificationJob extends Job {
.getUserEntity()));
bundle.putBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL,
decryptedPushMessage.getType().equals("call") || !hasChatSupport);
startACall);
intent.putExtras(bundle);
@ -154,8 +149,7 @@ public class NotificationJob extends Job {
String ringtonePreferencesString;
switch (decryptedPushMessage.getType()) {
case "call":
smallIcon = R.drawable.ic_call_white_24dp;
category = Notification.CATEGORY_CALL;
getContext().startActivity(intent);
break;
case "room":
smallIcon = R.drawable.ic_notifications_white_24dp;
@ -183,7 +177,7 @@ public class NotificationJob extends Job {
smallIcon = R.drawable.ic_logo;
}
largeIcon = BitmapFactory.decodeResource(context.getResources(), smallIcon);
/*largeIcon = BitmapFactory.decodeResource(context.getResources(), smallIcon);
CRC32 crc32 = new CRC32();
Notification.Builder notificationBuilder = new Notification.Builder(context)
@ -258,7 +252,7 @@ public class NotificationJob extends Job {
mediaPlayer.setOnCompletionListener(MediaPlayer::release);
}
}
}*/
}
}

Просмотреть файл

@ -0,0 +1,34 @@
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
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>

Просмотреть файл

@ -0,0 +1,144 @@
<?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:id="@+id/relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey950"
android:fitsSystemWindows="true"
tools:context=".activities.CallActivity">
<RelativeLayout
android:id="@+id/connectingRelativeLayoutView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="@dimen/item_height"
android:layout_height="@dimen/item_height"
android:layout_centerInParent="true"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:indeterminate="true"
android:indeterminateTint="@color/colorPrimary"
android:indeterminateTintMode="src_in"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/progress_bar"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:text="@string/nc_connecting_call"
android:textAlignment="center"
android:textColor="@color/white"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/conversationRelativeLayoutView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible">
<LinearLayout
android:id="@+id/remote_renderers_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@color/grey950"
android:orientation="vertical">
</LinearLayout>
<org.webrtc.SurfaceViewRenderer
android:id="@+id/pip_video_view"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_margin="16dp"
android:visibility="invisible"/>
</RelativeLayout>
<LinearLayout
android:id="@+id/callControlsLinearLayoutView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:animateLayoutChanges="true"
android:background="@android:color/transparent"
android:gravity="center">
<com.nextcloud.talk.utils.MagicFlipView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/call_control_microphone"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginEnd="20dp"
android:alpha="0.7"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/colorPrimary"
app:frontImage="@drawable/ic_mic_off_white_24px"/>
<com.nextcloud.talk.utils.MagicFlipView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/call_control_camera"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginEnd="20dp"
android:alpha="0.7"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/colorPrimary"
app:frontImage="@drawable/ic_videocam_off_white_24px"/>
<com.nextcloud.talk.utils.MagicFlipView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/call_control_switch_camera"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginEnd="20dp"
android:visibility="gone"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/colorPrimary"
app:frontImage="@drawable/ic_switch_video_white_24px"/>
<com.nextcloud.talk.utils.MagicFlipView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/call_control_hangup"
android:layout_width="60dp"
android:layout_height="60dp"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/nc_darkRed"
app:frontImage="@drawable/ic_call_end_white_24px"/>
</LinearLayout>
</RelativeLayout>

Просмотреть файл

@ -114,6 +114,7 @@
<string name="nc_permissions_settings">Open settings</string>
<!-- Call -->
<string name="nc_connecting_call">Connecting…</string>
<string name="nc_incoming_call">Incoming call from</string>
<string name="nc_nick_guest">Guest</string>
<string name="nc_public_call">New public conversation</string>