Browse Source

Improvements for #223

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 years ago
parent
commit
8b22f4c65b

+ 4 - 3
app/build.gradle

@@ -83,6 +83,7 @@ dependencies {
     implementation "com.android.support:design:${supportLibraryVersion}"
     implementation 'com.android.support.constraint:constraint-layout:1.1.2'
     implementation "com.android.support:support-emoji-bundled:${supportLibraryVersion}"
+    implementation "com.android.support:palette-v7:${supportLibraryVersion}"
 
     implementation "android.arch.lifecycle:extensions:1.1.1"
 
@@ -138,9 +139,9 @@ dependencies {
     implementation 'eu.davidea:flexible-adapter:5.0.5'
     implementation 'eu.davidea:flexible-adapter-ui:1.0.0-b5'
 
-    implementation 'com.github.bumptech.glide:glide:4.3.0'
-    annotationProcessor 'com.github.bumptech.glide:compiler:4.3.0'
-    implementation 'com.github.bumptech.glide:okhttp3-integration:4.3.0@aar'
+    implementation 'com.github.bumptech.glide:glide:4.7.1'
+    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
+    implementation 'com.github.bumptech.glide:okhttp3-integration:4.7.1@aar'
     implementation 'org.webrtc:google-webrtc:1.0.23295'
     implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}"
 

+ 25 - 10
app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java

@@ -32,12 +32,14 @@ import android.renderscript.RenderScript;
 import android.renderscript.ScriptIntrinsicBlur;
 import android.support.annotation.NonNull;
 import android.support.constraint.ConstraintLayout;
+import android.support.v7.graphics.Palette;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ImageView;
+import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import com.bluelinelabs.conductor.RouterTransaction;
@@ -67,6 +69,7 @@ import com.nextcloud.talk.utils.MagicFlipView;
 import com.nextcloud.talk.utils.bundle.BundleKeys;
 import com.nextcloud.talk.utils.glide.GlideApp;
 import com.nextcloud.talk.utils.preferences.AppPreferences;
+import com.nextcloud.talk.utils.singletons.AvatarStatusCodeHolder;
 
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
@@ -117,6 +120,9 @@ public class CallNotificationController extends BaseController {
     @BindView(R.id.constraintLayout)
     ConstraintLayout constraintLayout;
 
+    @BindView(R.id.incomingTextRelativeLayout)
+    RelativeLayout incomingTextRelativeLayout;
+
     @Inject
     Cache cache;
 
@@ -374,16 +380,24 @@ public class CallNotificationController extends BaseController {
                                             (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));
+                                if (AvatarStatusCodeHolder.getInstance().getStatusCode() == 200) {
+                                    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);
+
+                                    incomingTextRelativeLayout.setBackground(getResources().getDrawable(R.drawable
+                                            .incoming_gradient));
+                                    constraintLayout.setBackground(new BitmapDrawable(resource));
+                                } else if (AvatarStatusCodeHolder.getInstance().getStatusCode() == 201) {
+                                    Palette palette = Palette.from(resource).generate();
+                                    constraintLayout.setBackgroundColor(palette.getDominantColor(
+                                            getResources().getColor(R.color.grey950)));
+                                }
                             }
                         });
 
@@ -425,6 +439,7 @@ public class CallNotificationController extends BaseController {
 
     @Override
     public void onDestroy() {
+        AvatarStatusCodeHolder.getInstance().setStatusCode(0);
         leavingScreen = true;
         dispose();
         endMediaPlayer();

+ 8 - 1
app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java

@@ -32,6 +32,7 @@ import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.utils.ApiUtils;
 import com.nextcloud.talk.utils.database.user.UserUtils;
 import com.nextcloud.talk.utils.preferences.AppPreferences;
+import com.nextcloud.talk.utils.singletons.AvatarStatusCodeHolder;
 import com.nextcloud.talk.utils.ssl.MagicKeyManager;
 import com.nextcloud.talk.utils.ssl.MagicTrustManager;
 import com.nextcloud.talk.utils.ssl.SSLSocketFactoryCompat;
@@ -261,7 +262,13 @@ public class RestModule {
                     .method(original.method(), original.body())
                     .build();
 
-            return chain.proceed(request);
+            Response response = chain.proceed(request);
+
+            if (request.url().encodedPath().contains("/avatar/")) {
+                AvatarStatusCodeHolder.getInstance().setStatusCode(response.code());
+            }
+
+            return response;
         }
     }
 

+ 39 - 0
app/src/main/java/com/nextcloud/talk/utils/singletons/AvatarStatusCodeHolder.java

@@ -0,0 +1,39 @@
+/*
+ * 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.utils.singletons;
+
+public class AvatarStatusCodeHolder {
+    private int statusCode;
+
+    private static final AvatarStatusCodeHolder holder = new AvatarStatusCodeHolder();
+
+    public static AvatarStatusCodeHolder getInstance() {
+        return holder;
+    }
+
+    public int getStatusCode() {
+        return statusCode;
+    }
+
+    public void setStatusCode(int statusCode) {
+        this.statusCode = statusCode;
+    }
+}

+ 1 - 1
app/src/main/res/layout/controller_call_notification.xml

@@ -29,7 +29,7 @@
     <RelativeLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@drawable/incoming_gradient">
+        android:id="@+id/incomingTextRelativeLayout">
 
         <TextView
             android:id="@+id/incomingCallTextView"