Skip to content

Commit

Permalink
fixed all material design specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ansh94 committed May 5, 2017
1 parent 33789e5 commit 9a1708c
Show file tree
Hide file tree
Showing 19 changed files with 278 additions and 225 deletions.
12 changes: 12 additions & 0 deletions .idea/libraries/design_25_3_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/libraries/transition_25_3_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion XYZReader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 19
minSdkVersion 21
targetSdkVersion 25
}
}
Expand All @@ -29,6 +29,7 @@ dependencies {
compile "com.android.support:palette-v7:$androidSupportVersion"
compile "com.android.support:recyclerview-v7:$androidSupportVersion"
compile "com.android.support:cardview-v7:$androidSupportVersion"
compile "com.android.support:design:$androidSupportVersion"
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile files('libs/volley.jar')
}
1 change: 1 addition & 0 deletions XYZReader/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

<activity
android:name=".ui.ArticleDetailActivity"
android:theme="@style/Theme.Bacon.Detail"
android:parentActivityName=".ui.ArticleListActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import android.os.Bundle;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -23,7 +23,7 @@
/**
* An activity representing a single Article detail screen, letting you swipe between articles.
*/
public class ArticleDetailActivity extends ActionBarActivity
public class ArticleDetailActivity extends AppCompatActivity
implements LoaderManager.LoaderCallbacks<Cursor> {

private Cursor mCursor;
Expand Down Expand Up @@ -120,7 +120,7 @@ public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
// Select the start ID
if (mStartId > 0) {
mCursor.moveToFirst();
// TODO: optimize

while (!mCursor.isAfterLast()) {
if (mCursor.getLong(ArticleLoader.Query._ID) == mStartId) {
final int position = mCursor.getPosition();
Expand All @@ -139,6 +139,7 @@ public void onLoaderReset(Loader<Cursor> cursorLoader) {
mPagerAdapter.notifyDataSetChanged();
}


public void onUpButtonFloorChanged(long itemId, ArticleDetailFragment fragment) {
if (itemId == mSelectedItemId) {
mSelectedItemUpButtonFloor = fragment.getUpButtonFloor();
Expand Down Expand Up @@ -177,4 +178,4 @@ public int getCount() {
return (mCursor != null) ? mCursor.getCount() : 0;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;

import android.os.Bundle;
import android.support.v4.app.ShareCompat;
import android.support.v7.graphics.Palette;
Expand Down Expand Up @@ -61,12 +54,6 @@ public class ArticleDetailFragment extends Fragment implements
private boolean mIsCard = false;
private int mStatusBarFullOpacityBottom;

private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss");
// Use default locale format
private SimpleDateFormat outputFormat = new SimpleDateFormat();
// Most time functions can only handle 1902 - 2037
private GregorianCalendar START_OF_EPOCH = new GregorianCalendar(2,1,1);

/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
Expand Down Expand Up @@ -113,7 +100,7 @@ public void onActivityCreated(Bundle savedInstanceState) {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.fragment_article_detail, container, false);
mDrawInsetsFrameLayout = (DrawInsetsFrameLayout)
mRootView.findViewById(R.id.draw_insets_frame_layout);
Expand All @@ -131,7 +118,7 @@ public void onScrollChanged() {
mScrollY = mScrollView.getScrollY();
getActivityCast().onUpButtonFloorChanged(mItemId, ArticleDetailFragment.this);
mPhotoContainerView.setTranslationY((int) (mScrollY - mScrollY / PARALLAX_FACTOR));
updateStatusBar();
//updateStatusBar();
}
});

Expand All @@ -155,6 +142,7 @@ public void onClick(View view) {
return mRootView;
}


private void updateStatusBar() {
int color = 0;
if (mPhotoView != null && mTopInset != 0 && mScrollY > 0) {
Expand Down Expand Up @@ -184,17 +172,6 @@ static float constrain(float val, float min, float max) {
}
}

private Date parsePublishedDate() {
try {
String date = mCursor.getString(ArticleLoader.Query.PUBLISHED_DATE);
return dateFormat.parse(date);
} catch (ParseException ex) {
Log.e(TAG, ex.getMessage());
Log.i(TAG, "passing today's date");
return new Date();
}
}

private void bindViews() {
if (mRootView == null) {
return;
Expand All @@ -204,35 +181,22 @@ private void bindViews() {
TextView bylineView = (TextView) mRootView.findViewById(R.id.article_byline);
bylineView.setMovementMethod(new LinkMovementMethod());
TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body);


bodyView.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf"));
//bodyView.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf"));

if (mCursor != null) {
mRootView.setAlpha(0);
mRootView.setVisibility(View.VISIBLE);
mRootView.animate().alpha(1);
titleView.setText(mCursor.getString(ArticleLoader.Query.TITLE));
Date publishedDate = parsePublishedDate();
if (!publishedDate.before(START_OF_EPOCH.getTime())) {
bylineView.setText(Html.fromHtml(
DateUtils.getRelativeTimeSpanString(
publishedDate.getTime(),
System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS,
DateUtils.FORMAT_ABBREV_ALL).toString()
+ " by <font color='#ffffff'>"
+ mCursor.getString(ArticleLoader.Query.AUTHOR)
+ "</font>"));

} else {
// If date is before 1902, just show the string
bylineView.setText(Html.fromHtml(
outputFormat.format(publishedDate) + " by <font color='#ffffff'>"
+ mCursor.getString(ArticleLoader.Query.AUTHOR)
+ "</font>"));

}
bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY).replaceAll("(\r\n|\n)", "<br />")));
bylineView.setText(Html.fromHtml(
DateUtils.getRelativeTimeSpanString(
mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS,
DateUtils.FORMAT_ABBREV_ALL).toString()
+ " by <font color='#ffffff'>"
+ mCursor.getString(ArticleLoader.Query.AUTHOR)
+ "</font>"));
bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY)));
ImageLoaderHelper.getInstance(getActivity()).getImageLoader()
.get(mCursor.getString(ArticleLoader.Query.PHOTO_URL), new ImageLoader.ImageListener() {
@Override
Expand All @@ -242,9 +206,9 @@ public void onResponse(ImageLoader.ImageContainer imageContainer, boolean b) {
Palette p = Palette.generate(bitmap, 12);
mMutedColor = p.getDarkMutedColor(0xFF333333);
mPhotoView.setImageBitmap(imageContainer.getBitmap());
mRootView.findViewById(R.id.meta_bar)
.setBackgroundColor(mMutedColor);
updateStatusBar();
mPhotoView.setScaleType(ImageView.ScaleType.CENTER_CROP);
//mRootView.findViewById(R.id.meta_bar).setBackgroundColor(mMutedColor);
//updateStatusBar();
}
}

Expand All @@ -256,7 +220,7 @@ public void onErrorResponse(VolleyError volleyError) {
} else {
mRootView.setVisibility(View.GONE);
titleView.setText("N/A");
bylineView.setText("N/A" );
bylineView.setText("N/A");
bodyView.setText("N/A");
}
}
Expand Down Expand Up @@ -301,4 +265,4 @@ public int getUpButtonFloor() {
? (int) mPhotoContainerView.getTranslationY() + mPhotoView.getHeight() - mScrollY
: mPhotoView.getHeight() - mScrollY;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.format.DateUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
Expand All @@ -27,31 +23,19 @@
import com.example.xyzreader.data.ItemsContract;
import com.example.xyzreader.data.UpdaterService;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;

/**
* An activity representing a list of Articles. This activity has different presentations for
* handset and tablet-size devices. On handsets, the activity presents a list of items, which when
* touched, lead to a {@link ArticleDetailActivity} representing item details. On tablets, the
* activity presents a grid of items as cards.
*/
public class ArticleListActivity extends ActionBarActivity implements
public class ArticleListActivity extends AppCompatActivity implements
LoaderManager.LoaderCallbacks<Cursor> {

private static final String TAG = ArticleListActivity.class.toString();
private Toolbar mToolbar;
private SwipeRefreshLayout mSwipeRefreshLayout;
private RecyclerView mRecyclerView;

private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss");
// Use default locale format
private SimpleDateFormat outputFormat = new SimpleDateFormat();
// Most time functions can only handle 1902 - 2037
private GregorianCalendar START_OF_EPOCH = new GregorianCalendar(2,1,1);

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -153,37 +137,17 @@ public void onClick(View view) {
return vh;
}

private Date parsePublishedDate() {
try {
String date = mCursor.getString(ArticleLoader.Query.PUBLISHED_DATE);
return dateFormat.parse(date);
} catch (ParseException ex) {
Log.e(TAG, ex.getMessage());
Log.i(TAG, "passing today's date");
return new Date();
}
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
mCursor.moveToPosition(position);
holder.titleView.setText(mCursor.getString(ArticleLoader.Query.TITLE));
Date publishedDate = parsePublishedDate();
if (!publishedDate.before(START_OF_EPOCH.getTime())) {

holder.subtitleView.setText(Html.fromHtml(
DateUtils.getRelativeTimeSpanString(
publishedDate.getTime(),
System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS,
DateUtils.FORMAT_ABBREV_ALL).toString()
+ "<br/>" + " by "
+ mCursor.getString(ArticleLoader.Query.AUTHOR)));
} else {
holder.subtitleView.setText(Html.fromHtml(
outputFormat.format(publishedDate)
+ "<br/>" + " by "
+ mCursor.getString(ArticleLoader.Query.AUTHOR)));
}
holder.subtitleView.setText(
DateUtils.getRelativeTimeSpanString(
mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS,
DateUtils.FORMAT_ABBREV_ALL).toString()
+ " by "
+ mCursor.getString(ArticleLoader.Query.AUTHOR));
holder.thumbnailView.setImageUrl(
mCursor.getString(ArticleLoader.Query.THUMB_URL),
ImageLoaderHelper.getInstance(ArticleListActivity.this).getImageLoader());
Expand All @@ -208,4 +172,4 @@ public ViewHolder(View view) {
subtitleView = (TextView) view.findViewById(R.id.article_subtitle);
}
}
}
}
2 changes: 1 addition & 1 deletion XYZReader/src/main/res/drawable/add_fab_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="@color/theme_accent" />
<solid android:color="@color/accent_200" />
</shape>
</item>
<item android:drawable="@drawable/white_selectable_item_background_circle" />
Expand Down
9 changes: 9 additions & 0 deletions XYZReader/src/main/res/drawable/ic_share_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
android:shape="rectangle">
<gradient
android:angle="-90"
android:startColor="#3000"
android:endColor="#0000"
android:startColor="#00000000"
android:endColor="#4d000000"
android:type="linear"
android:useLevel="false" />
</shape>
Loading

0 comments on commit 9a1708c

Please sign in to comment.