Skip to content

Commit

Permalink
Some work on #223
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Danic <mario@lovelyhq.com>
  • Loading branch information
mario committed Jul 10, 2018
1 parent b9759ea commit 2374930
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 23 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ android {
versionName "2.1.0beta5"

flavorDimensions "default"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true

productFlavors {
// used for f-droid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@
package com.nextcloud.talk.controllers;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import android.support.annotation.NonNull;
import android.support.constraint.ConstraintLayout;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
Expand All @@ -40,7 +47,10 @@
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.LazyHeaders;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.load.resource.bitmap.TransformationUtils;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.nextcloud.talk.R;
import com.nextcloud.talk.api.NcApi;
import com.nextcloud.talk.application.NextcloudTalkApplication;
Expand Down Expand Up @@ -96,6 +106,9 @@ public class CallNotificationController extends BaseController {
@BindView(R.id.callAnswerCameraView)
MagicFlipView callAnswerCameraView;

@BindView(R.id.constraintLayout)
ConstraintLayout constraintLayout;

private List<Disposable> disposablesList = new ArrayList<>();
private Bundle originalBundle;
private String roomId;
Expand All @@ -104,6 +117,7 @@ public class CallNotificationController extends BaseController {
private Room currentRoom;
private MediaPlayer mediaPlayer;
private boolean leavingScreen = false;
private RenderScript renderScript;

public CallNotificationController(Bundle args) {
super(args);
Expand Down Expand Up @@ -249,6 +263,7 @@ public void onComplete() {
protected void onViewBound(@NonNull View view) {
super.onViewBound(view);

renderScript = RenderScript.create(getActivity());
handleFromNotification();

String callRingtonePreferenceString = appPreferences.getCallRingtoneUri();
Expand Down Expand Up @@ -296,8 +311,27 @@ private void loadAvatar() {
.load(glideUrl)
.centerInside()
.override(avatarSize, avatarSize)
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
.into(avatarImageView);
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
if (getActivity() != null) {
avatarImageView.setImageBitmap(TransformationUtils.circleCrop(GlideApp.get
(getActivity()).getBitmapPool(), resource, avatarSize, avatarSize));
}

final Allocation input = Allocation.createFromBitmap(renderScript, resource);
final Allocation output = Allocation.createTyped(renderScript, input.getType());
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(renderScript, Element
.U8_4(renderScript));
script.setRadius(15f);
script.setInput(input);
script.forEach(output);
output.copyTo(resource);

constraintLayout.setBackground(new BitmapDrawable(resource));
}
});


break;
case ROOM_GROUP_CALL:
Expand Down
28 changes: 28 additions & 0 deletions app/src/main/res/drawable/incoming_gradient.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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/>.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="-90"
android:endColor="@color/transparent"
android:startColor="#323232"/>
</shape>
48 changes: 28 additions & 20 deletions app/src/main/res/layout/controller_call_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,41 @@
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey950">

<TextView
android:id="@+id/incomingCallTextView"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/nc_incoming_call"
android:textAlignment="center"
android:textColor="@color/white30"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
android:background="@drawable/incoming_gradient">

<TextView
android:id="@+id/conversationNameTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="28sp"
app:layout_constraintTop_toBottomOf="@+id/incomingCallTextView"
tools:text="Victor Gregorius Magnus"/>
<TextView
android:id="@+id/incomingCallTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/nc_incoming_call"
android:textAlignment="center"
android:textColor="@color/white30"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<TextView
android:id="@+id/conversationNameTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="28sp"
android:layout_below="@+id/incomingCallTextView"
tools:text="Victor Gregorius Magnus"/>

</RelativeLayout>

<ImageView
android:id="@+id/avatarImageView"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<dimen name="avatar_size">40dp</dimen>
<dimen name="avatar_size_big">80dp</dimen>
<dimen name="avatar_size_very_big">@dimen/avatar_fetching_size_very_big</dimen>
<dimen name="avatar_fetching_size_very_big">140dp</dimen>
<dimen name="avatar_fetching_size_very_big">180dp</dimen>
<dimen name="avatar_corner_radius">20dp</dimen>

<dimen name="chat_text_size">14sp</dimen>
Expand Down

0 comments on commit 2374930

Please sign in to comment.