fixed rounding pic

This commit is contained in:
gdlbo
2022-07-02 12:55:17 +03:00
parent 6549c3e51a
commit c3bae00331
2 changed files with 4 additions and 3 deletions
@@ -123,7 +123,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{
int vtosterXml = getIdentifier("empty", "xml");
this.addPreferencesFromResource(vtosterXml);
PreferencesUtil.addPreferenceDrawable(this, "", "Аккаунты", getUsername() + (hasVerification() ? Globals.getString("thanksfordonate") : Globals.getString("getdonate")), getDrawableFromUrl(getUserPhoto(), "ic_user_circle_outline_28"), preference -> {
PreferencesUtil.addPreferenceDrawable(this, "", "Аккаунты", getUsername() + (hasVerification() ? Globals.getString("thanksfordonate") : Globals.getString("getdonate")), getDrawableFromUrl(getUserPhoto(), "ic_user_circle_outline_28", true), preference -> {
AuthBridge.logout();
restartApplication();
return false;
@@ -171,7 +171,7 @@ public class Globals{
return extendedUserProfile.a;
}
public static Drawable getDrawableFromUrl(String url, String nopic){
public static Drawable getDrawableFromUrl(String url, String nopic, Boolean rounded){
try {
URL aryURI = new URL(url);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
@@ -181,7 +181,8 @@ public class Globals{
InputStream is = conn.getInputStream();
Bitmap bmp = BitmapFactory.decodeStream(is);
return new BitmapDrawable(getResources(), bmp);
return new BitmapDrawable(getResources(), rounded? Bitmap.createScaledBitmap(getBitmapClippedCircle(bmp), convertDpToPixel(256), convertDpToPixel(256), true) : bmp);
} catch (Exception e) {
return getDrawable(getContext(), getIdentifier(nopic, "drawable"));
}