Skip to content

Commit

Permalink
Added color overlay to subtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
sahildave committed Nov 1, 2014
1 parent 345a33c commit f44d3b1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ protected void onCreate(Bundle savedInstanceState) {
Bundle arguments = new Bundle();
arguments.putString("npName", getIntent().getStringExtra("npName"));
arguments.putString("catName", getIntent().getStringExtra("catName"));
arguments.putInt("actionBarColor", ActionBarColorId);
arguments.putString(WebsiteDetailFragment.HEADLINE_CLICKED,
getIntent().getStringExtra(WebsiteDetailFragment.HEADLINE_CLICKED));
mDetailFragment.setArguments(arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
Expand Down Expand Up @@ -50,6 +53,7 @@ public class WebsiteDetailFragment extends Fragment {
private boolean bookmarked = false;
private BookmarkDataSource dataSource;
private Button mViewInBrowser;
private int actionBarColor = Color.DKGRAY;

static interface LoadArticleCallback {
void onPreExecute(View rootView);
Expand Down Expand Up @@ -87,6 +91,7 @@ public void onCreate(Bundle savedInstanceState) {
if(getArguments()!=null){
npNameString = getArguments().getString("npName");
catNameString = getArguments().getString("catName");
actionBarColor = getArguments().getInt("actionBarColor");

if (getArguments().containsKey(HEADLINE_CLICKED)) {
mArticleHeadline = getArguments().getString(HEADLINE_CLICKED);
Expand All @@ -110,9 +115,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
Button mShareButton = (Button) rootView.findViewById(R.id.shareContent);
mViewInBrowser = (Button) rootView.findViewById(R.id.viewInBrowser);

mShareButton.setTextColor(actionBarColor);
mViewInBrowser.setTextColor(actionBarColor);

TextView categoryName = (TextView) rootView.findViewById(R.id.category);
categoryName.setText(catNameString);
categoryName.setVisibility(View.VISIBLE);
categoryName.setTextColor(actionBarColor);
TextView mArticlePubDateView = (TextView) rootView.findViewById(R.id.pubDateView);
mArticlePubDateView.setTextColor(actionBarColor);

if (npNameString.equals("The Hindu")) {
mNewspaperTile.setImageResource(R.drawable.ic_hindu);
Expand Down Expand Up @@ -164,6 +175,18 @@ public boolean onTouch(View v, MotionEvent event) {
return rootView;
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
setReadItLaterButtonColor();
}

private void setReadItLaterButtonColor() {
PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(actionBarColor, PorterDuff.Mode.SRC_ATOP);

mReadItLater.getCompoundDrawables()[0].setColorFilter(colorFilter);
mReadItLater.setTextColor(actionBarColor);
}

private void setupReadItLaterButton() {
dataSource.open();
if(dataSource.isBookmarked(mArticleURL)){
Expand Down Expand Up @@ -216,10 +239,12 @@ public void onClick(View v) {
if (bookmarked) {
dataSource.deleteBookmarkModelEntry(mArticleURL);
mReadItLater.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_bookmark, 0, 0, 0);
setReadItLaterButtonColor();
bookmarked=false;
} else if (!bookmarked) {
dataSource.createBookmarkModelEntry(getBookmarkModelObject());
mReadItLater.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_bookmark_done, 0, 0, 0);
setReadItLaterButtonColor();
bookmarked=true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public void onItemSelected(String headlineText, NewsAdapter newsAdapter) {
Bundle arguments = new Bundle();
arguments.putString("npName", npName);
arguments.putString("catName", catName);
arguments.putInt("actionBarColor", currentColor);
arguments.putString(WebsiteDetailFragment.HEADLINE_CLICKED, headlineText);
WebsiteDetailFragment detailFragment = new WebsiteDetailFragment();
detailFragment.setArguments(arguments);
Expand Down

0 comments on commit f44d3b1

Please sign in to comment.