unify tintDrawable methods

This commit is contained in:
tobiasKaminsky 2017-05-19 17:03:34 +02:00 committed by AndyScherzinger
parent 8ba192f38a
commit a08a69faeb
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
4 changed files with 17 additions and 24 deletions

View file

@ -330,10 +330,11 @@ public class FileListListAdapter extends BaseAdapter {
) {
if (parentList.isItemChecked(position)) {
view.setBackgroundColor(mContext.getResources().getColor(R.color.selected_item_background));
checkBoxV.setImageDrawable(MimeTypeUtil.tintDrawable(R.drawable.ic_checkbox_marked, R.color.primary));
checkBoxV.setImageDrawable(DisplayUtils.tintDrawable(R.drawable.ic_checkbox_marked,
R.color.primary));
} else {
view.setBackgroundColor(Color.WHITE);
checkBoxV.setImageDrawable(MimeTypeUtil.tintDrawable(R.drawable.ic_checkbox_blank_outline,
checkBoxV.setImageDrawable(DisplayUtils.tintDrawable(R.drawable.ic_checkbox_blank_outline,
R.color.primary));
}
checkBoxV.setVisibility(View.VISIBLE);

View file

@ -23,7 +23,6 @@ package com.owncloud.android.ui.fragment;
import android.animation.LayoutTransition;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@ -31,8 +30,6 @@ import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.SearchView;
@ -71,6 +68,7 @@ import com.owncloud.android.ui.activity.UploadFilesActivity;
import com.owncloud.android.ui.adapter.FileListListAdapter;
import com.owncloud.android.ui.adapter.LocalFileListAdapter;
import com.owncloud.android.ui.events.SearchEvent;
import com.owncloud.android.utils.DisplayUtils;
import org.greenrobot.eventbus.EventBus;
import org.parceler.Parcel;
@ -644,10 +642,7 @@ public class ExtendedListFragment extends Fragment
mEmptyListHeadline.setText(headline);
mEmptyListMessage.setText(message);
Drawable drawable = ResourcesCompat.getDrawable(MainApp.getAppContext().getResources(), icon, null);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, MainApp.getAppContext().getResources().getColor(R.color.primary));
mEmptyListIcon.setImageDrawable(drawable);
mEmptyListIcon.setImageDrawable(DisplayUtils.tintDrawable(icon, R.color.primary));
mEmptyListIcon.setVisibility(View.VISIBLE);
mEmptyListProgress.setVisibility(View.GONE);

View file

@ -38,11 +38,15 @@ import android.graphics.drawable.PictureDrawable;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.format.DateUtils;
@ -677,4 +681,11 @@ public class DisplayUtils {
return text.toString();
}
public static Drawable tintDrawable(@DrawableRes int id, @ColorRes int color) {
Drawable drawable = ResourcesCompat.getDrawable(MainApp.getAppContext().getResources(), id, null);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, MainApp.getAppContext().getResources().getColor(color));
return drawable;
}
}

View file

@ -20,13 +20,8 @@ package com.owncloud.android.utils;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.webkit.MimeTypeMap;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
@ -111,22 +106,13 @@ public class MimeTypeUtil {
drawableId = R.drawable.ic_menu_archive;
}
Drawable drawable = ResourcesCompat.getDrawable(MainApp.getAppContext().getResources(), drawableId, null);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, MainApp.getAppContext().getResources().getColor(R.color.primary));
return drawable;
return DisplayUtils.tintDrawable(drawableId, R.color.primary);
}
public static Drawable getDefaultFolderIcon() {
return getFolderTypeIcon(false, false);
}
public static Drawable tintDrawable(@DrawableRes int id, @ColorRes int color) {
Drawable drawable = ResourcesCompat.getDrawable(MainApp.getAppContext().getResources(), id, null);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, MainApp.getAppContext().getResources().getColor(color));
return drawable;
}
/**
* Returns a single MIME type of all the possible, by inspection of the file extension, and taking