mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
fix codacy + revert to handling name-to-color exceptions
This commit is contained in:
parent
1a32758e27
commit
7f85bffa93
6 changed files with 42 additions and 27 deletions
|
@ -97,7 +97,8 @@ public class TextDrawable extends Drawable {
|
|||
*/
|
||||
@NonNull
|
||||
@NextcloudServer(max = 12)
|
||||
public static TextDrawable createAvatar(String accountName, float radiusInDp) {
|
||||
public static TextDrawable createAvatar(String accountName, float radiusInDp) throws
|
||||
UnsupportedEncodingException, NoSuchAlgorithmException {
|
||||
String username = AccountUtils.getAccountUsername(accountName);
|
||||
return createNamedAvatar(username, radiusInDp);
|
||||
}
|
||||
|
@ -114,7 +115,8 @@ public class TextDrawable extends Drawable {
|
|||
*/
|
||||
@NonNull
|
||||
@NextcloudServer(max = 12)
|
||||
public static TextDrawable createAvatarByUserId(String userId, float radiusInDp) {
|
||||
public static TextDrawable createAvatarByUserId(String userId, float radiusInDp) throws
|
||||
UnsupportedEncodingException, NoSuchAlgorithmException {
|
||||
return createNamedAvatar(userId, radiusInDp);
|
||||
}
|
||||
|
||||
|
@ -125,9 +127,12 @@ public class TextDrawable extends Drawable {
|
|||
* @param name the name
|
||||
* @param radiusInDp the circle's radius
|
||||
* @return the avatar as a TextDrawable
|
||||
* @throws UnsupportedEncodingException if the charset is not supported when calculating the color values
|
||||
* @throws NoSuchAlgorithmException if the specified algorithm is not available when calculating the color values
|
||||
*/
|
||||
@NonNull
|
||||
public static TextDrawable createNamedAvatar(String name, float radiusInDp) {
|
||||
public static TextDrawable createNamedAvatar(String name, float radiusInDp) throws
|
||||
UnsupportedEncodingException, NoSuchAlgorithmException {
|
||||
int[] hsl = BitmapUtils.calculateHSL(name);
|
||||
int[] rgb = BitmapUtils.HSLtoRGB(hsl[0], hsl[1], hsl[2], 1);
|
||||
|
||||
|
|
|
@ -1895,11 +1895,9 @@ public class FileDisplayActivity extends HookActivity
|
|||
private void onUpdateSharePermissionsFinished(RemoteOperationResult result) {
|
||||
Fragment fileDetailFragment = getSecondFragment();
|
||||
|
||||
if (result.isSuccess()) {
|
||||
if (fileDetailFragment instanceof FileDetailFragment) {
|
||||
((FileDetailFragment) fileDetailFragment).getFileDetailSharingFragment()
|
||||
.onUpdateSharePermissionsFinished(result);
|
||||
}
|
||||
if (result.isSuccess() && fileDetailFragment instanceof FileDetailFragment) {
|
||||
((FileDetailFragment) fileDetailFragment).getFileDetailSharingFragment()
|
||||
.onUpdateSharePermissionsFinished(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author masensio
|
||||
|
@ -34,6 +34,8 @@ import com.owncloud.android.lib.resources.shares.OCShare;
|
|||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.ui.TextDrawable;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
@ -91,12 +93,25 @@ public class ShareUserListAdapter extends ArrayAdapter {
|
|||
String name = share.getSharedWithDisplayName();
|
||||
if (share.getShareType() == ShareType.GROUP) {
|
||||
name = getContext().getString(R.string.share_group_clarification, name);
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
|
||||
try {
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
|
||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
|
||||
icon.setImageResource(R.drawable.ic_group);
|
||||
}
|
||||
} else if (share.getShareType() == ShareType.EMAIL) {
|
||||
name = getContext().getString(R.string.share_email_clarification, name);
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
|
||||
try {
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
|
||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
|
||||
icon.setImageResource(R.drawable.ic_email);
|
||||
}
|
||||
} else {
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
|
||||
try {
|
||||
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
|
||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
|
||||
icon.setImageResource(R.drawable.ic_user);
|
||||
}
|
||||
}
|
||||
userName.setText(name);
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
|||
import com.owncloud.android.ui.TextDrawable;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
@ -109,10 +111,18 @@ public class UserListAdapter extends ArrayAdapter implements DisplayUtils.Avatar
|
|||
String name = share.getSharedWithDisplayName();
|
||||
if (share.getShareType() == ShareType.GROUP) {
|
||||
name = getContext().getString(R.string.share_group_clarification, name);
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, avatarRadiusDimension));
|
||||
try {
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, avatarRadiusDimension));
|
||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
|
||||
icon.setImageResource(R.drawable.ic_group);
|
||||
}
|
||||
} else if (share.getShareType() == ShareType.EMAIL) {
|
||||
name = getContext().getString(R.string.share_email_clarification, name);
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, avatarRadiusDimension));
|
||||
try {
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, avatarRadiusDimension));
|
||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
|
||||
icon.setImageResource(R.drawable.ic_email);
|
||||
}
|
||||
} else {
|
||||
icon.setTag(share.getShareWith());
|
||||
DisplayUtils.setAvatar(account, share.getShareWith(), this, avatarRadiusDimension,
|
||||
|
|
|
@ -30,44 +30,34 @@ import android.os.Bundle;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.SharePermissionsBuilder;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.ui.adapter.UserListAdapter;
|
||||
import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
|
||||
import com.owncloud.android.ui.fragment.util.FileDetailSharingFragmentHelper;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
@ -75,7 +65,6 @@ import butterknife.OnClick;
|
|||
import butterknife.Unbinder;
|
||||
|
||||
public class FileDetailSharingFragment extends Fragment implements UserListAdapter.ShareeListAdapterListener {
|
||||
private static final String TAG = FileDetailSharingFragment.class.getSimpleName();
|
||||
|
||||
private static final String ARG_FILE = "FILE";
|
||||
private static final String ARG_ACCOUNT = "ACCOUNT";
|
||||
|
|
|
@ -22,7 +22,6 @@ package com.owncloud.android.ui.fragment.util;
|
|||
|
||||
import android.app.SearchManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.view.MenuItem;
|
||||
|
@ -33,7 +32,6 @@ import android.widget.ListAdapter;
|
|||
import android.widget.ListView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
|
||||
|
|
Loading…
Reference in a new issue