From 35c0a4cae49f76eca53c3b523ed577c7a1302f91 Mon Sep 17 00:00:00 2001 From: Christine Emrich Date: Tue, 24 Nov 2015 21:25:27 +0100 Subject: [PATCH] Removed deprecated calls to "getResources().getColor()" # Conflicts: # News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java --- .../ListView/SubscriptionExpandableListAdapter.java | 4 ++-- .../luhmer/owncloudnewsreader/NewsDetailActivity.java | 4 ++-- .../luhmer/owncloudnewsreader/NewsDetailFragment.java | 10 ++++++---- .../owncloudnewsreader/NewsReaderDetailFragment.java | 4 ++-- .../owncloudnewsreader/NewsReaderListFragment.java | 4 ++-- .../adapter/NewsListRecyclerAdapter.java | 3 ++- .../luhmer/owncloudnewsreader/adapter/ViewHolder.java | 3 ++- 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/SubscriptionExpandableListAdapter.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/SubscriptionExpandableListAdapter.java index 104da8f0..3f4bc8dd 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/SubscriptionExpandableListAdapter.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/SubscriptionExpandableListAdapter.java @@ -26,6 +26,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.AsyncTask; import android.preference.PreferenceManager; +import android.support.v4.content.ContextCompat; import android.util.Log; import android.util.SparseArray; import android.view.LayoutInflater; @@ -114,7 +115,7 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter this.mContext = mContext; this.dbConn = dbConn; - mTextColorLightTheme = mContext.getResources().getColor(R.color.slider_listview_text_color_light_theme); + mTextColorLightTheme = ContextCompat.getColor(mContext, R.color.slider_listview_text_color_light_theme); unreadCountFeeds = new SparseArray<>(); unreadCountFolders = new SparseArray<>(); @@ -126,7 +127,6 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter this.listView = listView; } - @SuppressWarnings("deprecation") @Override public Object getChild(int groupPosition, int childPosition) { int parent_id = (int)getGroupId(groupPosition); diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailActivity.java index bc351d03..1eec63e8 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailActivity.java @@ -39,6 +39,7 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentStatePagerAdapter; +import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; import android.support.v7.widget.Toolbar; @@ -403,9 +404,8 @@ public class NewsDetailActivity extends PodcastFragmentActivity { if(isChromeDefaultBrowser() && mCustomTabsSupported) { mCustomTabsSession = getSession(); CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(mCustomTabsSession); - builder.setToolbarColor(getResources().getColor(R.color.colorPrimaryDarkTheme)); + builder.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimaryDarkTheme)); builder.setShowTitle(true); - //builder.setCloseButtonIcon(CustomTabUiBuilder.CLOSE_BUTTON_ARROW); builder.setStartAnimations(this, R.anim.slide_in_right, R.anim.slide_out_left); builder.setExitAnimations(this, R.anim.slide_in_left, R.anim.slide_out_right); builder.build().launchUrl(this, Uri.parse(link)); diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailFragment.java index ccbb11a9..9e6598c3 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailFragment.java @@ -29,6 +29,7 @@ import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; +import android.support.v4.content.ContextCompat; import android.text.format.DateUtils; import android.util.Log; import android.view.ContextMenu; @@ -261,14 +262,15 @@ public class NewsDetailFragment extends Fragment { if (progress == 100) { mProgressbarWebView.setVisibility(ProgressBar.GONE); - //The following three lines are a workaround for websites which don't use a background colour + //The following three lines are a workaround for websites which don't use a background color + int bgColor = ContextCompat.getColor(getContext(), R.color.slider_listview_text_color_dark_theme); NewsDetailActivity ndActivity = ((NewsDetailActivity) getActivity()); - mWebView.setBackgroundColor(getResources().getColor(R.color.slider_listview_text_color_dark_theme)); - ndActivity.mViewPager.setBackgroundColor(getResources().getColor(R.color.slider_listview_text_color_dark_theme)); + mWebView.setBackgroundColor(bgColor); + ndActivity.mViewPager.setBackgroundColor(bgColor); if (ThemeChooser.isDarkTheme(getActivity())) { - mWebView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + mWebView.setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); } } } diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java index 7be2d79f..92708d86 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java @@ -361,9 +361,9 @@ public class NewsReaderDetailFragment extends Fragment { @Override public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(context, attrs, savedInstanceState); - TypedArray a = context.obtainStyledAttributes(attrs,new int[]{R.attr.markasreadDrawable,R.attr.colorAccent}); + TypedArray a = context.obtainStyledAttributes(attrs, new int[]{ R.attr.markasreadDrawable, R.attr.colorAccent }); markAsReadDrawable = a.getDrawable(0); - accentColor = ContextCompat.getColor(getContext(), R.color.owncloudBlueLight); + accentColor = ContextCompat.getColor(context, R.color.owncloudBlueLight); a.recycle(); } diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListFragment.java index 8b68115a..8b7f9a4a 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListFragment.java @@ -26,6 +26,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnCreateContextMenuListener; @@ -119,7 +120,7 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM View view = inflater.inflate(R.layout.fragment_newsreader_list, container, false); if(!ThemeChooser.isDarkTheme(getActivity())) { - view.setBackgroundColor(getResources().getColor(R.color.slider_listview_background_color_light_theme)); + view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.slider_listview_background_color_light_theme)); } ButterKnife.inject(this, view); @@ -130,7 +131,6 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM eListView.setGroupIndicator(null); eListView.setOnChildClickListener(onChildClickListener); - //eListView.setSmoothScrollbarEnabled(true); eListView.setClickable(true); eListView.setAdapter(lvAdapter); diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/NewsListRecyclerAdapter.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/NewsListRecyclerAdapter.java index a4ca0dea..575133db 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/NewsListRecyclerAdapter.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/NewsListRecyclerAdapter.java @@ -4,6 +4,7 @@ import android.content.SharedPreferences; import android.os.AsyncTask; import android.preference.PreferenceManager; import android.support.v4.app.FragmentActivity; +import android.support.v4.content.ContextCompat; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.text.style.ForegroundColorSpan; @@ -78,7 +79,7 @@ public class NewsListRecyclerAdapter extends RecyclerView.Adapter { pDelayHandler = new PostDelayHandler(activity); - bodyForegroundColor = new ForegroundColorSpan(activity.getResources().getColor(android.R.color.secondary_text_dark)); + bodyForegroundColor = new ForegroundColorSpan(ContextCompat.getColor(activity, android.R.color.secondary_text_dark)); dbConn = new DatabaseConnectionOrm(activity); SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(activity); diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/ViewHolder.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/ViewHolder.java index b5d94202..1e93fd75 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/ViewHolder.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/ViewHolder.java @@ -5,6 +5,7 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.Typeface; import android.preference.PreferenceManager; +import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.text.Spannable; @@ -89,7 +90,7 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(itemView.getContext()); selectedListLayout = Integer.parseInt(mPrefs.getString(SettingsActivity.SP_FEED_LIST_LAYOUT, "0")); - bodyForegroundColor = new ForegroundColorSpan(itemView.getContext().getResources().getColor(android.R.color.secondary_text_dark)); + bodyForegroundColor = new ForegroundColorSpan(ContextCompat.getColor(itemView.getContext(), android.R.color.secondary_text_dark)); if(favIconHandler == null) favIconHandler = new FavIconHandler(itemView.getContext());