Skip to content

Commit

Permalink
Improvements for #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 Aug 2, 2018
1 parent a245530 commit 8b22f4c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 15 deletions.
7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
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;
Expand Down Expand Up @@ -67,6 +69,7 @@
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;
Expand Down Expand Up @@ -117,6 +120,9 @@ public class CallNotificationController extends BaseController {
@BindView(R.id.constraintLayout)
ConstraintLayout constraintLayout;

@BindView(R.id.incomingTextRelativeLayout)
RelativeLayout incomingTextRelativeLayout;

@Inject
Cache cache;

Expand Down Expand Up @@ -374,16 +380,24 @@ public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transiti
(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)));
}
}
});

Expand Down Expand Up @@ -425,6 +439,7 @@ private void endMediaPlayer() {

@Override
public void onDestroy() {
AvatarStatusCodeHolder.getInstance().setStatusCode(0);
leavingScreen = true;
dispose();
endMediaPlayer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
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;
Expand Down Expand Up @@ -261,7 +262,13 @@ public Response intercept(@NonNull Chain chain) throws IOException {
.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;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/controller_call_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8b22f4c

Please sign in to comment.