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.ContentResolver;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -45,6 +46,7 @@ import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.webkit.URLUtil;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
@ -264,30 +266,37 @@ public class UserInfoActivity extends FileActivity {
|
||||||
|
|
||||||
private void setHeaderImage() {
|
private void setHeaderImage() {
|
||||||
if (getStorageManager().getCapability(account.name).getServerBackground() != null) {
|
if (getStorageManager().getCapability(account.name).getServerBackground() != null) {
|
||||||
String backgroundUrl = getStorageManager().getCapability(account.name).getServerBackground();
|
|
||||||
|
|
||||||
final AppBarLayout appBar = (AppBarLayout) findViewById(R.id.appbar);
|
final AppBarLayout appBar = (AppBarLayout) findViewById(R.id.appbar);
|
||||||
|
|
||||||
SimpleTarget target = new SimpleTarget<Drawable>() {
|
if (appBar != null) {
|
||||||
@Override
|
String background = getStorageManager().getCapability(account.name).getServerBackground();
|
||||||
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)
|
if (URLUtil.isValidUrl(background)) {
|
||||||
.load(backgroundUrl)
|
// background image
|
||||||
.centerCrop()
|
SimpleTarget target = new SimpleTarget<Drawable>() {
|
||||||
.placeholder(R.drawable.background)
|
@Override
|
||||||
.error(R.drawable.background)
|
public void onResourceReady(Drawable resource, GlideAnimation glideAnimation) {
|
||||||
.crossFade()
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
.into(target);
|
appBar.setBackgroundDrawable(resource);
|
||||||
|
} else {
|
||||||
|
appBar.setBackground(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Glide.with(this)
|
||||||
|
.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