mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
use solid color if a hex color is provided instead of an url in user info activity
This commit is contained in:
parent
cc32bd28fb
commit
2ed50a3317
1 changed files with 30 additions and 21 deletions
|
@ -32,6 +32,7 @@ import android.app.FragmentManager;
|
|||
import android.content.ContentResolver;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -45,6 +46,7 @@ import android.view.Menu;
|
|||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
@ -264,30 +266,37 @@ public class UserInfoActivity extends FileActivity {
|
|||
|
||||
private void setHeaderImage() {
|
||||
if (getStorageManager().getCapability(account.name).getServerBackground() != null) {
|
||||
String backgroundUrl = getStorageManager().getCapability(account.name).getServerBackground();
|
||||
|
||||
final AppBarLayout appBar = (AppBarLayout) findViewById(R.id.appbar);
|
||||
|
||||
if (appBar != null) {
|
||||
String background = getStorageManager().getCapability(account.name).getServerBackground();
|
||||
|
||||
if (URLUtil.isValidUrl(background)) {
|
||||
// background image
|
||||
SimpleTarget target = new SimpleTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(Drawable resource, GlideAnimation glideAnimation) {
|
||||
if (appBar != null) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||
appBar.setBackgroundDrawable(resource);
|
||||
} else {
|
||||
appBar.setBackground(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Glide.with(this)
|
||||
.load(backgroundUrl)
|
||||
.load(background)
|
||||
.centerCrop()
|
||||
.placeholder(R.drawable.background)
|
||||
.error(R.drawable.background)
|
||||
.crossFade()
|
||||
.into(target);
|
||||
} else {
|
||||
// plain color
|
||||
int color = Color.parseColor(background);
|
||||
appBar.setBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue