[app] Fix deny list hint (#1433)

This commit is contained in:
LoveSy 2021-11-23 22:42:49 +08:00 committed by GitHub
parent 69fe97b66e
commit 14b2e5b20d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 20 deletions

View File

@ -365,24 +365,22 @@ public class ScopeAdapter extends EmptyStateRecyclerView.EmptyStateAdapter<Scope
int userId = appInfo.applicationInfo.uid / 100000; int userId = appInfo.applicationInfo.uid / 100000;
appName = android ? activity.getString(R.string.android_framework) : appInfo.label; appName = android ? activity.getString(R.string.android_framework) : appInfo.label;
holder.appName.setText(appName); holder.appName.setText(appName);
GlideApp.with(holder.appIcon) GlideApp.with(holder.appIcon).load(appInfo.packageInfo).into(new CustomTarget<Drawable>() {
.load(appInfo.packageInfo) @Override
.into(new CustomTarget<Drawable>() { public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
@Override holder.appIcon.setImageDrawable(resource);
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { }
holder.appIcon.setImageDrawable(resource);
}
@Override @Override
public void onLoadCleared(@Nullable Drawable placeholder) { public void onLoadCleared(@Nullable Drawable placeholder) {
} }
@Override @Override
public void onLoadFailed(@Nullable Drawable errorDrawable) { public void onLoadFailed(@Nullable Drawable errorDrawable) {
holder.appIcon.setImageDrawable(pm.getDefaultActivityIcon()); holder.appIcon.setImageDrawable(pm.getDefaultActivityIcon());
} }
}); });
SpannableStringBuilder sb = new SpannableStringBuilder(android ? "" : activity.getString(R.string.app_description, appInfo.packageName, appInfo.packageInfo.versionName)); SpannableStringBuilder sb = new SpannableStringBuilder(android ? "" : activity.getString(R.string.app_description, appInfo.packageName, appInfo.packageInfo.versionName));
if (android) holder.appDescription.setVisibility(View.GONE); if (android) holder.appDescription.setVisibility(View.GONE);
else { else {
@ -402,10 +400,6 @@ public class ScopeAdapter extends EmptyStateRecyclerView.EmptyStateAdapter<Scope
sb.setSpan(styleSpan, sb.length() - recommended.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); sb.setSpan(styleSpan, sb.length() - recommended.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
} }
sb.setSpan(foregroundColorSpan, sb.length() - recommended.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); sb.setSpan(foregroundColorSpan, sb.length() - recommended.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
holder.hint.setText(sb);
holder.hint.setVisibility(View.VISIBLE);
} else {
holder.hint.setVisibility(View.GONE);
} }
if (deny) { if (deny) {
if (sb.length() != 0) sb.append("\n"); if (sb.length() != 0) sb.append("\n");
@ -421,7 +415,12 @@ public class ScopeAdapter extends EmptyStateRecyclerView.EmptyStateAdapter<Scope
} }
sb.setSpan(foregroundColorSpan, sb.length() - denylist.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); sb.setSpan(foregroundColorSpan, sb.length() - denylist.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
} }
holder.hint.setText(sb); if (sb.length() == 0) {
holder.hint.setVisibility(View.GONE);
} else {
holder.hint.setText(sb);
holder.hint.setVisibility(View.VISIBLE);
}
holder.itemView.setOnCreateContextMenuListener((menu, v, menuInfo) -> { holder.itemView.setOnCreateContextMenuListener((menu, v, menuInfo) -> {
activity.getMenuInflater().inflate(R.menu.menu_app_item, menu); activity.getMenuInflater().inflate(R.menu.menu_app_item, menu);