Improvements for #223

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-08-02 08:14:16 +02:00
parent a245530728
commit 8b22f4c65b
5 changed files with 76 additions and 14 deletions

View File

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

View File

@ -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,6 +380,7 @@ public class CallNotificationController extends BaseController {
(getActivity()).getBitmapPool(), resource, avatarSize, avatarSize));
}
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
@ -383,7 +390,14 @@ public class CallNotificationController extends BaseController {
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();

View File

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

View File

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

View File

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