Fixed Lint:

MissingClass: Missing registered class
Range: Outside Range
UseAppTint: app:tint attribute should be used on ImageView
UseCompatLoadingForDrawables
UseCompatTextViewDrawableXml

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2020-06-19 09:37:51 +02:00
parent a9f689044d
commit 5f185326ab
No known key found for this signature in database
GPG Key ID: 0E00D4D47D0C5AF7
21 changed files with 88 additions and 57 deletions

View File

@ -259,12 +259,9 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled true
}
viewBinding {
enabled true
buildFeatures {
dataBinding true
viewBinding true
}
}

View File

@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 94 warnings</span>
<span class="mdl-layout-title">Lint Report: 91 warnings</span>

View File

@ -66,12 +66,6 @@
</intent-filter>
</service>
<service
android:name="com.evernote.android.job.gcm.PlatformGcmService"
android:enabled="true"
tools:node="remove">
</service>
</application>
</manifest>

View File

@ -76,6 +76,7 @@ import java.util.List;
import java.util.Locale;
import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
@ -888,7 +889,7 @@ public final class ThumbnailsCacheManager {
Log_OC.e(TAG, "Out of memory");
} catch (Throwable t) {
// the app should never break due to a problem with avatars
thumbnail = mResources.getDrawable(R.drawable.account_circle_white);
thumbnail = ResourcesCompat.getDrawable(mResources, R.drawable.account_circle_white, null);
Log_OC.e(TAG, "Generation of avatar for " + mUserId + " failed", t);
}
@ -1011,7 +1012,7 @@ public final class ThumbnailsCacheManager {
try {
return TextDrawable.createAvatar(mAccount, mAvatarRadius);
} catch (Exception e1) {
return mResources.getDrawable(R.drawable.ic_user);
return ResourcesCompat.getDrawable(mResources, R.drawable.ic_user, null);
}
} else {
return BitmapUtils.bitmapToCircularBitmapDrawable(mResources, avatar);
@ -1060,17 +1061,19 @@ public final class ThumbnailsCacheManager {
return null;
}
public static Bitmap addVideoOverlay(Bitmap thumbnail){
Drawable playButtonDrawable = MainApp.getAppContext().getResources().getDrawable(R.drawable.view_play);
public static Bitmap addVideoOverlay(Bitmap thumbnail) {
Drawable playButtonDrawable = ResourcesCompat.getDrawable(MainApp.getAppContext().getResources(),
R.drawable.view_play,
null);
Bitmap playButton = BitmapUtils.drawableToBitmap(playButtonDrawable);
Bitmap resizedPlayButton = Bitmap.createScaledBitmap(playButton,
(int) (thumbnail.getWidth() * 0.3),
(int) (thumbnail.getHeight() * 0.3), true);
(int) (thumbnail.getWidth() * 0.3),
(int) (thumbnail.getHeight() * 0.3), true);
Bitmap resultBitmap = Bitmap.createBitmap(thumbnail.getWidth(),
thumbnail.getHeight(),
Bitmap.Config.ARGB_8888);
thumbnail.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(resultBitmap);

View File

@ -103,6 +103,7 @@ import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
@ -249,7 +250,9 @@ public abstract class DrawerActivity extends ToolbarActivity
mDrawerLayout.addDrawerListener(mDrawerToggle);
mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerToggle.setDrawerSlideAnimationEnabled(true);
Drawable backArrow = getResources().getDrawable(R.drawable.ic_arrow_back);
Drawable backArrow = ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_arrow_back,
null);
mDrawerToggle.setHomeAsUpIndicator(ThemeUtils.tintDrawable(backArrow, ThemeUtils.appBarPrimaryFontColor(this)));
mDrawerToggle.getDrawerArrowDrawable().setColor(ThemeUtils.appBarPrimaryFontColor(this));
}

View File

@ -39,6 +39,7 @@ import com.owncloud.android.utils.FileStorageUtils;
import java.io.File;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.res.ResourcesCompat;
/**
* @author Bartosz Przybylski
@ -212,7 +213,9 @@ public class StorageMigration {
askToStillMove();
} else {
mProgressDialog.getButton(ProgressDialog.BUTTON_POSITIVE).setVisibility(View.VISIBLE);
mProgressDialog.setIndeterminateDrawable(mContext.getResources().getDrawable(R.drawable.image_fail));
mProgressDialog.setIndeterminateDrawable(ResourcesCompat.getDrawable(mContext.getResources(),
R.drawable.image_fail,
null));
}
}

View File

@ -64,6 +64,7 @@ import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.SearchView;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.view.MenuItemCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentManager;
@ -190,10 +191,14 @@ public class UploadFilesActivity extends FileActivity implements LocalFileListFr
MaterialButton switchButton = findViewById(R.id.switch_grid_view_button);
switchButton.setOnClickListener(l -> {
if (isGridView()) {
switchButton.setIcon(getResources().getDrawable(R.drawable.ic_view_module));
switchButton.setIcon(ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_view_module,
null));
mFileListFragment.switchToListView();
} else {
switchButton.setIcon(getResources().getDrawable(R.drawable.ic_view_list));
switchButton.setIcon(ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_view_list,
null));
mFileListFragment.switchToGridView();
}

View File

@ -77,6 +77,7 @@ import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.appcompat.app.ActionBar;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
@ -253,7 +254,9 @@ public class UserInfoActivity extends FileActivity implements Injectable {
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
Drawable[] drawables = {new ColorDrawable(primaryColor),
getResources().getDrawable(R.drawable.background)};
ResourcesCompat.getDrawable(getResources(),
R.drawable.background,
null)};
LayerDrawable layerDrawable = new LayerDrawable(drawables);
backgroundImageView.setImageDrawable(layerDrawable);
}

View File

@ -30,10 +30,8 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.LinearGradient;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
@ -99,6 +97,7 @@ import java.util.Vector;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
import androidx.recyclerview.widget.RecyclerView;
@ -583,7 +582,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
placeholder = TextDrawable.createAvatarByUserId(userId, avatarRadius);
} catch (Exception e) {
Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e);
placeholder = resources.getDrawable(R.drawable.account_circle_white);
placeholder = ResourcesCompat.getDrawable(resources, R.drawable.account_circle_white, null);
}
avatar.setTag(null);

View File

@ -66,6 +66,9 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
private final List<SyncedFolderDisplayItem> filteredSyncFolderItems;
private final boolean light;
private final int VIEW_TYPE_EMPTY = Integer.MAX_VALUE;
private final int VIEW_TYPE_ITEM = 1;
private final int VIEW_TYPE_HEADER = 2;
private final int VIEW_TYPE_FOOTER = 3;
private boolean hideItems;
public SyncedFolderAdapter(Context context, Clock clock, int gridWidth, ClickListener listener, boolean light) {

View File

@ -75,6 +75,7 @@ import java.util.List;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
@ -250,11 +251,11 @@ public class FileDetailActivitiesFragment extends Fragment implements
OCCapability capability = storageManager.getCapability(account.name);
OwnCloudVersion serverVersion = accountManager.getServerVersion(account);
restoreFileVersionSupported = capability.getFilesVersioning().isTrue() &&
serverVersion.compareTo(OwnCloudVersion.nextcloud_14) >= 0;
serverVersion.compareTo(OwnCloudVersion.nextcloud_14) >= 0;
emptyContentProgressBar.getIndeterminateDrawable().setColorFilter(ThemeUtils.primaryAccentColor(getContext()),
PorterDuff.Mode.SRC_IN);
emptyContentIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_activity));
PorterDuff.Mode.SRC_IN);
emptyContentIcon.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_activity, null));
adapter = new ActivityAndVersionListAdapter(getContext(),
accountManager,
@ -414,7 +415,9 @@ public class FileDetailActivitiesFragment extends Fragment implements
private void setEmptyContent(String headline, String message) {
if (emptyContentContainer != null && emptyContentMessage != null) {
emptyContentIcon.setImageDrawable(requireContext().getResources().getDrawable(R.drawable.ic_activity));
emptyContentIcon.setImageDrawable(ResourcesCompat.getDrawable(requireContext().getResources(),
R.drawable.ic_activity,
null));
emptyContentHeadline.setText(headline);
emptyContentMessage.setText(message);
@ -427,7 +430,9 @@ public class FileDetailActivitiesFragment extends Fragment implements
private void setErrorContent(String message) {
if (emptyContentContainer != null && emptyContentMessage != null) {
emptyContentHeadline.setText(R.string.common_error);
emptyContentIcon.setImageDrawable(requireContext().getResources().getDrawable(R.drawable.ic_list_empty_error));
emptyContentIcon.setImageDrawable(ResourcesCompat.getDrawable(requireContext().getResources(),
R.drawable.ic_list_empty_error,
null));
emptyContentMessage.setText(message);
emptyContentMessage.setVisibility(View.VISIBLE);

View File

@ -75,6 +75,7 @@ import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -594,9 +595,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
private void setFavoriteIconStatus(boolean isFavorite) {
if (isFavorite) {
favoriteIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_star));
favoriteIcon.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_star, null));
} else {
favoriteIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_star_outline));
favoriteIcon.setImageDrawable(ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_star_outline,
null));
}
}

View File

@ -87,6 +87,7 @@ import javax.inject.Inject;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.FragmentStatePagerAdapter;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import pl.droidsonroids.gif.GifDrawable;
@ -811,9 +812,9 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
Drawable layerOne;
if (previewImageActivity.isSystemUIVisible()) {
layerOne = getResources().getDrawable(R.color.bg_default);
layerOne = ResourcesCompat.getDrawable(getResources(), R.color.bg_default, null);
} else {
layerOne = getResources().getDrawable(R.drawable.backrepeat);
layerOne = ResourcesCompat.getDrawable(getResources(), R.drawable.backrepeat, null);
}
layerDrawable.setDrawableByLayerId(layerDrawable.getId(0), layerOne);

View File

@ -55,6 +55,7 @@ import java.util.List;
import javax.inject.Inject;
import androidx.core.content.res.ResourcesCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import butterknife.BindString;
@ -304,7 +305,9 @@ public class TrashbinActivity extends FileActivity implements
if (emptyContentMessage != null) {
emptyContentHeadline.setText(R.string.common_error);
emptyContentIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_list_empty_error));
emptyContentIcon.setImageDrawable(ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_list_empty_error,
null));
emptyContentMessage.setText(message);
emptyContentMessage.setVisibility(View.VISIBLE);

View File

@ -34,6 +34,8 @@ import android.widget.LinearLayout;
import com.owncloud.android.R;
import androidx.core.content.res.ResourcesCompat;
/**
* Progress indicator visualizing the actual progress with dots.
*/
@ -69,7 +71,9 @@ public class ProgressIndicator extends FrameLayout {
mDotsContainer.removeAllViews();
for (int i = 0; i < steps; ++i) {
ImageView iv = new ImageView(getContext());
iv.setImageDrawable(getContext().getResources().getDrawable(R.drawable.whats_new_progress_transition));
iv.setImageDrawable(ResourcesCompat.getDrawable(getContext().getResources(),
R.drawable.whats_new_progress_transition,
null));
iv.setColorFilter(fontColor, PorterDuff.Mode.SRC_ATOP);
mDotsContainer.addView(iv);
}

View File

@ -98,6 +98,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.AppCompatDrawableManager;
import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
@ -490,7 +491,9 @@ public final class DisplayUtils {
avatar = TextDrawable.createAvatarByUserId(displayName, avatarRadius);
} catch (Exception e) {
Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e);
avatar = resources.getDrawable(R.drawable.account_circle_white);
avatar = ResourcesCompat.getDrawable(resources,
R.drawable.account_circle_white,
null);
}
}

View File

@ -347,7 +347,7 @@ public final class ThemeUtils {
return;
}
Drawable backArrow = context.getResources().getDrawable(R.drawable.ic_arrow_back);
Drawable backArrow = ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_arrow_back, null);
supportActionBar.setHomeAsUpIndicator(ThemeUtils.tintDrawable(backArrow, color));
}

View File

@ -148,7 +148,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/alternate_half_margin"
android:contentDescription="@string/auth_testing_connection"
android:drawableStart="@android:drawable/stat_notify_sync"
app:drawableStartCompat="@android:drawable/stat_notify_sync"
android:drawablePadding="@dimen/alternate_half_padding"
android:gravity="center_vertical"
android:minHeight="@dimen/display_text_min_height"
@ -185,7 +185,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/auth_unauthorized"
android:drawableStart="@android:drawable/stat_notify_sync"
app:drawableStartCompat="@android:drawable/stat_notify_sync"
android:drawablePadding="@dimen/alternate_half_padding"
android:gravity="center_vertical"
android:text="@string/auth_unauthorized"

View File

@ -149,7 +149,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/alternate_margin"
android:contentDescription="@string/auth_testing_connection"
android:drawableStart="@android:drawable/stat_notify_sync"
app:drawableStartCompat="@android:drawable/stat_notify_sync"
android:drawablePadding="@dimen/alternate_half_padding"
android:gravity="center_vertical"
android:minHeight="@dimen/display_text_min_height"
@ -187,7 +187,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/alternate_margin"
android:contentDescription="@string/auth_unauthorized"
android:drawableStart="@android:drawable/stat_notify_sync"
app:drawableStartCompat="@android:drawable/stat_notify_sync"
android:drawablePadding="@dimen/alternate_half_padding"
android:gravity="center_vertical"
android:text="@string/auth_unauthorized"

View File

@ -19,6 +19,7 @@
License along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_header_view"
android:layout_width="match_parent"
android:layout_height="@dimen/drawer_header_height"
@ -32,6 +33,6 @@
android:contentDescription="@string/empty"
android:scaleType="fitCenter"
android:src="@drawable/nextcloud_logo"
android:tint="@color/drawer_logo_color" />
app:tint="@color/drawer_logo_color" />
</FrameLayout>

View File

@ -18,22 +18,23 @@
License along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/info_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:background="@color/filelist_icon_background"
android:gravity="center"
android:padding="@dimen/standard_half_padding"
android:visibility="gone">
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/info_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:background="@color/filelist_icon_background"
android:gravity="center"
android:padding="@dimen/standard_half_padding"
android:visibility="gone">
<TextView
android:id="@+id/info_box_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/standard_half_padding"
android:drawableStart="@drawable/ic_information_outline"
app:drawableStartCompat="@drawable/ic_information_outline"
android:gravity="center"
android:paddingEnd="@dimen/standard_half_margin"
android:paddingLeft="@dimen/standard_half_padding"