Просмотр исходного кода

Some work on #223

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 лет назад
Родитель
Сommit
9e1c2c7657

+ 2 - 0
app/build.gradle

@@ -19,6 +19,8 @@ android {
         versionName "2.1.0beta5"
 
         flavorDimensions "default"
+        renderscriptTargetApi 19
+        renderscriptSupportModeEnabled true
 
         productFlavors {
             // used for f-droid

+ 36 - 2
app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java

@@ -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;
@@ -40,7 +47,10 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
 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;
@@ -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;
@@ -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);
@@ -249,6 +263,7 @@ public class CallNotificationController extends BaseController {
     protected void onViewBound(@NonNull View view) {
         super.onViewBound(view);
 
+        renderScript = RenderScript.create(getActivity());
         handleFromNotification();
 
         String callRingtonePreferenceString = appPreferences.getCallRingtoneUri();
@@ -296,8 +311,27 @@ public class CallNotificationController extends BaseController {
                         .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:

+ 28 - 0
app/src/main/res/drawable/incoming_gradient.xml

@@ -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>

+ 28 - 20
app/src/main/res/layout/controller_call_notification.xml

@@ -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"

+ 1 - 1
app/src/main/res/values/dimens.xml

@@ -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>