From 5a8f45b0bd4abcd59243d9ddc1992afc51123bd1 Mon Sep 17 00:00:00 2001 From: "David R. Smith" Date: Wed, 29 Jul 2020 08:48:43 -0400 Subject: [PATCH 1/6] fixed compiler errors; refactored to AndroidX --- .gitignore | 1 + XYZReader/build.gradle | 28 +++++++++---------- .../xyzreader/ui/ArticleDetailActivity.java | 9 +++--- .../xyzreader/ui/ArticleDetailFragment.java | 4 +-- .../xyzreader/ui/ArticleListActivity.java | 15 +++++----- .../xyzreader/ui/DividerItemDecoration.java | 4 +-- .../xyzreader/ui/ImageLoaderHelper.java | 2 +- .../res/layout/activity_article_detail.xml | 2 +- .../main/res/layout/activity_article_list.xml | 10 +++---- .../src/main/res/layout/list_item_article.xml | 4 +-- build.gradle | 4 ++- gradle.properties | 2 ++ gradle/wrapper/gradle-wrapper.properties | 4 +-- 13 files changed, 47 insertions(+), 42 deletions(-) create mode 100644 gradle.properties diff --git a/.gitignore b/.gitignore index f6b286cea..e3253b85f 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ captures/ # Keystore files *.jks +/.idea/ diff --git a/XYZReader/build.gradle b/XYZReader/build.gradle index 93b2ea3e5..921f0e1f6 100755 --- a/XYZReader/build.gradle +++ b/XYZReader/build.gradle @@ -1,34 +1,34 @@ buildscript { repositories { - mavenCentral() + jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.0' + classpath 'com.android.tools.build:gradle:4.0.1' } } apply plugin: 'com.android.application' repositories { - mavenCentral() + jcenter() } android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 29 defaultConfig { minSdkVersion 19 - targetSdkVersion 25 + targetSdkVersion 29 } } dependencies { - compile "com.android.support:support-v4:$androidSupportVersion" - compile "com.android.support:support-v13:$androidSupportVersion" - compile "com.android.support:appcompat-v7:$androidSupportVersion" - compile "com.android.support:palette-v7:$androidSupportVersion" - compile "com.android.support:recyclerview-v7:$androidSupportVersion" - compile "com.android.support:cardview-v7:$androidSupportVersion" - compile 'com.squareup.okhttp3:okhttp:3.1.2' - compile files('libs/volley.jar') + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.legacy:legacy-support-v13:1.0.0' + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.palette:palette:1.0.0' + implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'androidx.cardview:cardview:1.0.0' + implementation 'com.squareup.okhttp3:okhttp:3.1.2' + implementation files('libs/volley.jar') } diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailActivity.java b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailActivity.java index 0de370f6d..b10a60a65 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailActivity.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailActivity.java @@ -8,14 +8,15 @@ import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.os.Bundle; -import android.support.v13.app.FragmentStatePagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.ActionBarActivity; import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; +import androidx.appcompat.app.AppCompatActivity; +import androidx.legacy.app.FragmentStatePagerAdapter; +import androidx.viewpager.widget.ViewPager; + import com.example.xyzreader.R; import com.example.xyzreader.data.ArticleLoader; import com.example.xyzreader.data.ItemsContract; @@ -23,7 +24,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 { private Cursor mCursor; diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java index 357646044..eafed0a71 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java @@ -17,8 +17,8 @@ import java.util.GregorianCalendar; import android.os.Bundle; -import android.support.v4.app.ShareCompat; -import android.support.v7.graphics.Palette; +import androidx.core.app.ShareCompat; +import androidx.palette.graphics.Palette; import android.text.Html; import android.text.format.DateUtils; import android.text.method.LinkMovementMethod; diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleListActivity.java b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleListActivity.java index 8538d9ce1..f879c9541 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleListActivity.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleListActivity.java @@ -8,20 +8,19 @@ import android.content.Loader; import android.database.Cursor; import android.os.Bundle; -import android.support.v4.widget.SwipeRefreshLayout; -import android.support.v7.app.ActionBarActivity; -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; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + import com.example.xyzreader.R; import com.example.xyzreader.data.ArticleLoader; import com.example.xyzreader.data.ItemsContract; @@ -38,7 +37,7 @@ * 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 { private static final String TAG = ArticleListActivity.class.toString(); diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/DividerItemDecoration.java b/XYZReader/src/main/java/com/example/xyzreader/ui/DividerItemDecoration.java index e1cb4cf95..8dd280f38 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/DividerItemDecoration.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/DividerItemDecoration.java @@ -19,8 +19,8 @@ import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.view.View; public class DividerItemDecoration extends RecyclerView.ItemDecoration { diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/ImageLoaderHelper.java b/XYZReader/src/main/java/com/example/xyzreader/ui/ImageLoaderHelper.java index e6f34b832..a18ba207c 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/ImageLoaderHelper.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/ImageLoaderHelper.java @@ -2,7 +2,7 @@ import android.content.Context; import android.graphics.Bitmap; -import android.support.v4.util.LruCache; +import androidx.collection.LruCache; import com.android.volley.RequestQueue; import com.android.volley.toolbox.ImageLoader; diff --git a/XYZReader/src/main/res/layout/activity_article_detail.xml b/XYZReader/src/main/res/layout/activity_article_detail.xml index 6151b44dc..9b6d8ce52 100755 --- a/XYZReader/src/main/res/layout/activity_article_detail.xml +++ b/XYZReader/src/main/res/layout/activity_article_detail.xml @@ -2,7 +2,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - diff --git a/XYZReader/src/main/res/layout/activity_article_list.xml b/XYZReader/src/main/res/layout/activity_article_list.xml index 9259aac11..8612ca7dc 100755 --- a/XYZReader/src/main/res/layout/activity_article_list.xml +++ b/XYZReader/src/main/res/layout/activity_article_list.xml @@ -4,12 +4,12 @@ android:layout_height="match_parent" android:orientation="vertical"> - - - + - - + \ No newline at end of file diff --git a/XYZReader/src/main/res/layout/list_item_article.xml b/XYZReader/src/main/res/layout/list_item_article.xml index 858d2468c..752f4f14e 100755 --- a/XYZReader/src/main/res/layout/list_item_article.xml +++ b/XYZReader/src/main/res/layout/list_item_article.xml @@ -1,4 +1,4 @@ - - + diff --git a/build.gradle b/build.gradle index 64b789d7f..2e2073b1a 100755 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,10 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:4.0.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,6 +16,7 @@ buildscript { allprojects { repositories { jcenter() + google() } ext { diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 000000000..5465fec0e --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +android.enableJetifier=true +android.useAndroidX=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5fd3d46c5..561d036a2 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Mar 26 16:58:07 PDT 2017 +#Wed Jul 29 07:37:27 EDT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip From 950148b683ba7a34e6bcc0aaa5eef8b365bb305c Mon Sep 17 00:00:00 2001 From: "David R. Smith" Date: Wed, 29 Jul 2020 18:28:19 -0400 Subject: [PATCH 2/6] fixed crash on startup --- XYZReader/build.gradle | 7 ++++++- XYZReader/src/main/AndroidManifest.xml | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/XYZReader/build.gradle b/XYZReader/build.gradle index 921f0e1f6..65f908fcc 100755 --- a/XYZReader/build.gradle +++ b/XYZReader/build.gradle @@ -20,6 +20,11 @@ android { minSdkVersion 19 targetSdkVersion 29 } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } dependencies { @@ -29,6 +34,6 @@ dependencies { implementation 'androidx.palette:palette:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'androidx.cardview:cardview:1.0.0' - implementation 'com.squareup.okhttp3:okhttp:3.1.2' + implementation 'com.squareup.okhttp3:okhttp:3.9.0' implementation files('libs/volley.jar') } diff --git a/XYZReader/src/main/AndroidManifest.xml b/XYZReader/src/main/AndroidManifest.xml index 5a720d35f..dc90d321f 100755 --- a/XYZReader/src/main/AndroidManifest.xml +++ b/XYZReader/src/main/AndroidManifest.xml @@ -14,6 +14,8 @@ android:label="@string/app_name" android:theme="@style/Theme.Bacon"> + + From 0741820196f19f94cbf398cb8c9ad8b25ea90d3e Mon Sep 17 00:00:00 2001 From: "David R. Smith" Date: Wed, 29 Jul 2020 19:28:02 -0400 Subject: [PATCH 3/6] added Material library and material.io generated colors.xml; --- XYZReader/build.gradle | 3 ++- XYZReader/src/main/AndroidManifest.xml | 3 +++ .../xyzreader/ui/ArticleDetailFragment.java | 4 ++-- .../xyzreader/ui/DrawInsetsFrameLayout.java | 3 +++ .../xyzreader/ui/MaxWidthLinearLayout.java | 4 ++++ XYZReader/src/main/res/font/rosario.xml | 7 ++++++ .../main/res/layout/activity_article_list.xml | 24 ++++++++++--------- .../res/layout/fragment_article_detail.xml | 21 +++++++++------- .../src/main/res/layout/list_item_article.xml | 15 +++++++----- .../src/main/res/values-sw600dp/dimens.xml | 2 +- XYZReader/src/main/res/values-v21/styles.xml | 7 ++++++ XYZReader/src/main/res/values/colors.xml | 9 +++++++ XYZReader/src/main/res/values/dimens.xml | 2 +- XYZReader/src/main/res/values/font_certs.xml | 17 +++++++++++++ .../src/main/res/values/preloaded_fonts.xml | 6 +++++ XYZReader/src/main/res/values/strings.xml | 1 + XYZReader/src/main/res/values/styles.xml | 6 ++--- 17 files changed, 100 insertions(+), 34 deletions(-) create mode 100644 XYZReader/src/main/res/font/rosario.xml create mode 100644 XYZReader/src/main/res/values-v21/styles.xml create mode 100644 XYZReader/src/main/res/values/font_certs.xml create mode 100644 XYZReader/src/main/res/values/preloaded_fonts.xml diff --git a/XYZReader/build.gradle b/XYZReader/build.gradle index 65f908fcc..0e3a917cb 100755 --- a/XYZReader/build.gradle +++ b/XYZReader/build.gradle @@ -34,6 +34,7 @@ dependencies { implementation 'androidx.palette:palette:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'androidx.cardview:cardview:1.0.0' - implementation 'com.squareup.okhttp3:okhttp:3.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.8.0' implementation files('libs/volley.jar') + implementation 'com.google.android.material:material:1.1.0' } diff --git a/XYZReader/src/main/AndroidManifest.xml b/XYZReader/src/main/AndroidManifest.xml index dc90d321f..a39bf74f8 100755 --- a/XYZReader/src/main/AndroidManifest.xml +++ b/XYZReader/src/main/AndroidManifest.xml @@ -44,6 +44,9 @@ + diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java index eafed0a71..43aba4329 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java @@ -205,8 +205,8 @@ private void bindViews() { bylineView.setMovementMethod(new LinkMovementMethod()); TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body); - - bodyView.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf")); + //Replaced with downloadable font + //bodyView.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf")); if (mCursor != null) { mRootView.setAlpha(0); diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/DrawInsetsFrameLayout.java b/XYZReader/src/main/java/com/example/xyzreader/ui/DrawInsetsFrameLayout.java index dfe3875a3..6e643038e 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/DrawInsetsFrameLayout.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/DrawInsetsFrameLayout.java @@ -26,6 +26,8 @@ import android.view.WindowInsets; import android.widget.FrameLayout; +import androidx.annotation.RequiresApi; + import com.example.xyzreader.R; @@ -100,6 +102,7 @@ public void setOnInsetsCallback(OnInsetsCallback onInsetsCallback) { mOnInsetsCallback = onInsetsCallback; } + @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { insets = super.onApplyWindowInsets(insets); diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/MaxWidthLinearLayout.java b/XYZReader/src/main/java/com/example/xyzreader/ui/MaxWidthLinearLayout.java index 0c50d38ee..364e662bc 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/MaxWidthLinearLayout.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/MaxWidthLinearLayout.java @@ -18,9 +18,12 @@ import android.content.Context; import android.content.res.TypedArray; +import android.os.Build; import android.util.AttributeSet; import android.widget.LinearLayout; +import androidx.annotation.RequiresApi; + /** * A simple {@link LinearLayout} subclass that has a maxWidth */ @@ -46,6 +49,7 @@ public MaxWidthLinearLayout(Context context, AttributeSet attrs, int defStyle) { init(context, attrs, defStyle, 0); } + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public MaxWidthLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); init(context, attrs, defStyleAttr, defStyleRes); diff --git a/XYZReader/src/main/res/font/rosario.xml b/XYZReader/src/main/res/font/rosario.xml new file mode 100644 index 000000000..57120c48f --- /dev/null +++ b/XYZReader/src/main/res/font/rosario.xml @@ -0,0 +1,7 @@ + + + diff --git a/XYZReader/src/main/res/layout/activity_article_list.xml b/XYZReader/src/main/res/layout/activity_article_list.xml index 8612ca7dc..c7437316d 100755 --- a/XYZReader/src/main/res/layout/activity_article_list.xml +++ b/XYZReader/src/main/res/layout/activity_article_list.xml @@ -1,5 +1,6 @@ @@ -14,34 +15,35 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:clipToPadding="false" - android:scrollbarStyle="outsideOverlay" - android:paddingTop="116dp" android:paddingLeft="@dimen/list_side_margin" + android:paddingTop="116dp" android:paddingRight="@dimen/list_side_margin" - android:paddingBottom="28dp" /> + android:paddingBottom="28dp" + android:scrollbarStyle="outsideOverlay" + tools:listitem="@layout/list_item_article" /> + android:background="@color/primaryColor" + app:elevation="8dp"> + android:layout_gravity="bottom" + android:layout_marginLeft="@dimen/list_toolbar_side_margin" + android:layout_marginRight="@dimen/list_toolbar_side_margin" + app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> + android:contentDescription="@string/app_name" + android:src="@drawable/logo" /> diff --git a/XYZReader/src/main/res/layout/fragment_article_detail.xml b/XYZReader/src/main/res/layout/fragment_article_detail.xml index e5daf0544..38d63b057 100755 --- a/XYZReader/src/main/res/layout/fragment_article_detail.xml +++ b/XYZReader/src/main/res/layout/fragment_article_detail.xml @@ -1,5 +1,6 @@ @@ -39,7 +40,7 @@ android:layout_gravity="center_horizontal" android:maxWidth="@dimen/detail_card_max_width" android:background="#fff" - android:elevation="2dp" + app:elevation="2dp" android:layout_marginTop="@dimen/detail_card_top_margin"> + android:textColor="@color/dark_grey_subtitle" /> + android:textSize="@dimen/detail_body_text_size" /> @@ -96,12 +101,12 @@ android:stateListAnimator="@anim/fab_state_list_anim" android:background="@drawable/add_fab_background" android:layout_gravity="bottom|end" - android:layout_marginRight="@dimen/fab_margin" + android:layout_marginEnd="@dimen/fab_margin" android:layout_marginBottom="@dimen/fab_margin" android:layout_width="56dp" android:layout_height="56dp" android:src="@drawable/ic_share" - android:elevation="@dimen/fab_elevation" + app:elevation="@dimen/fab_elevation" android:contentDescription="@string/action_share" /> diff --git a/XYZReader/src/main/res/layout/list_item_article.xml b/XYZReader/src/main/res/layout/list_item_article.xml index 752f4f14e..4fa56ab2a 100755 --- a/XYZReader/src/main/res/layout/list_item_article.xml +++ b/XYZReader/src/main/res/layout/list_item_article.xml @@ -1,5 +1,6 @@ + android:textColor="@color/primaryTextColor" /> + android:textColor="@color/primaryTextColor" /> diff --git a/XYZReader/src/main/res/values-sw600dp/dimens.xml b/XYZReader/src/main/res/values-sw600dp/dimens.xml index b2cf6aec0..a61616b25 100755 --- a/XYZReader/src/main/res/values-sw600dp/dimens.xml +++ b/XYZReader/src/main/res/values-sw600dp/dimens.xml @@ -1,7 +1,7 @@ 42sp - 20sp + 24sp 1.3 24dp \ No newline at end of file diff --git a/XYZReader/src/main/res/values-v21/styles.xml b/XYZReader/src/main/res/values-v21/styles.xml new file mode 100644 index 000000000..1938fb7fc --- /dev/null +++ b/XYZReader/src/main/res/values-v21/styles.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/XYZReader/src/main/res/values/colors.xml b/XYZReader/src/main/res/values/colors.xml index 247642b32..d87799b6e 100755 --- a/XYZReader/src/main/res/values/colors.xml +++ b/XYZReader/src/main/res/values/colors.xml @@ -22,4 +22,13 @@ #04561A #04561A #ffe0e0e0 + #f1521f + #ff854d + #b71700 + #0d47a1 + #5472d3 + #002171 + #000000 + #ffffff + #8fff diff --git a/XYZReader/src/main/res/values/dimens.xml b/XYZReader/src/main/res/values/dimens.xml index f8bad8cb3..f38578e70 100755 --- a/XYZReader/src/main/res/values/dimens.xml +++ b/XYZReader/src/main/res/values/dimens.xml @@ -1,7 +1,7 @@ 32sp - 22sp + 18sp 1.25 2dp diff --git a/XYZReader/src/main/res/values/font_certs.xml b/XYZReader/src/main/res/values/font_certs.xml new file mode 100644 index 000000000..d2226ac01 --- /dev/null +++ b/XYZReader/src/main/res/values/font_certs.xml @@ -0,0 +1,17 @@ + + + + @array/com_google_android_gms_fonts_certs_dev + @array/com_google_android_gms_fonts_certs_prod + + + + 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 + + + diff --git a/XYZReader/src/main/res/values/preloaded_fonts.xml b/XYZReader/src/main/res/values/preloaded_fonts.xml new file mode 100644 index 000000000..287cd97a9 --- /dev/null +++ b/XYZReader/src/main/res/values/preloaded_fonts.xml @@ -0,0 +1,6 @@ + + + + @font/rosario + + diff --git a/XYZReader/src/main/res/values/strings.xml b/XYZReader/src/main/res/values/strings.xml index e120fcdbc..4b537b209 100755 --- a/XYZReader/src/main/res/values/strings.xml +++ b/XYZReader/src/main/res/values/strings.xml @@ -8,5 +8,6 @@ Share Up + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. diff --git a/XYZReader/src/main/res/values/styles.xml b/XYZReader/src/main/res/values/styles.xml index bce9969d7..ebea3f655 100755 --- a/XYZReader/src/main/res/values/styles.xml +++ b/XYZReader/src/main/res/values/styles.xml @@ -17,12 +17,10 @@ - - + From 907f4156aa7e4bd91a839d1448939c4f171a12df Mon Sep 17 00:00:00 2001 From: "David R. Smith" Date: Thu, 30 Jul 2020 09:01:50 -0400 Subject: [PATCH 4/6] implemented ViewBinding --- XYZReader/build.gradle | 5 + .../xyzreader/ui/ArticleDetailFragment.java | 113 +++++++----------- 2 files changed, 46 insertions(+), 72 deletions(-) diff --git a/XYZReader/build.gradle b/XYZReader/build.gradle index 0e3a917cb..63086c916 100755 --- a/XYZReader/build.gradle +++ b/XYZReader/build.gradle @@ -21,6 +21,10 @@ android { targetSdkVersion 29 } + buildFeatures { + viewBinding true + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -37,4 +41,5 @@ dependencies { implementation 'com.squareup.okhttp3:okhttp:4.8.0' implementation files('libs/volley.jar') implementation 'com.google.android.material:material:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' } diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java index 43aba4329..1c8d5efb8 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java @@ -7,18 +7,8 @@ import android.database.Cursor; 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 androidx.core.app.ShareCompat; -import androidx.palette.graphics.Palette; import android.text.Html; import android.text.format.DateUtils; import android.text.method.LinkMovementMethod; @@ -26,13 +16,20 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; + +import androidx.core.app.ShareCompat; +import androidx.palette.graphics.Palette; import com.android.volley.VolleyError; import com.android.volley.toolbox.ImageLoader; import com.example.xyzreader.R; import com.example.xyzreader.data.ArticleLoader; +import com.example.xyzreader.databinding.FragmentArticleDetailBinding; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.GregorianCalendar; /** * A fragment representing a single Article detail screen. This fragment is @@ -46,17 +43,14 @@ public class ArticleDetailFragment extends Fragment implements public static final String ARG_ITEM_ID = "item_id"; private static final float PARALLAX_FACTOR = 1.25f; + private FragmentArticleDetailBinding binding; + private Cursor mCursor; private long mItemId; - private View mRootView; private int mMutedColor = 0xFF333333; - private ObservableScrollView mScrollView; - private DrawInsetsFrameLayout mDrawInsetsFrameLayout; private ColorDrawable mStatusBarColorDrawable; private int mTopInset; - private View mPhotoContainerView; - private ImageView mPhotoView; private int mScrollY; private boolean mIsCard = false; private int mStatusBarFullOpacityBottom; @@ -114,50 +108,33 @@ public void onActivityCreated(Bundle savedInstanceState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - mRootView = inflater.inflate(R.layout.fragment_article_detail, container, false); - mDrawInsetsFrameLayout = (DrawInsetsFrameLayout) - mRootView.findViewById(R.id.draw_insets_frame_layout); - mDrawInsetsFrameLayout.setOnInsetsCallback(new DrawInsetsFrameLayout.OnInsetsCallback() { - @Override - public void onInsetsChanged(Rect insets) { - mTopInset = insets.top; - } - }); + binding = FragmentArticleDetailBinding.inflate(inflater, container, false); - mScrollView = (ObservableScrollView) mRootView.findViewById(R.id.scrollview); - mScrollView.setCallbacks(new ObservableScrollView.Callbacks() { - @Override - public void onScrollChanged() { - mScrollY = mScrollView.getScrollY(); - getActivityCast().onUpButtonFloorChanged(mItemId, ArticleDetailFragment.this); - mPhotoContainerView.setTranslationY((int) (mScrollY - mScrollY / PARALLAX_FACTOR)); - updateStatusBar(); - } - }); + binding.drawInsetsFrameLayout.setOnInsetsCallback(insets -> mTopInset = insets.top); - mPhotoView = (ImageView) mRootView.findViewById(R.id.photo); - mPhotoContainerView = mRootView.findViewById(R.id.photo_container); + binding.scrollview.setCallbacks(() -> { + mScrollY = binding.scrollview.getScrollY(); + getActivityCast().onUpButtonFloorChanged(mItemId, ArticleDetailFragment.this); + binding.photoContainer.setTranslationY((int) (mScrollY - mScrollY / PARALLAX_FACTOR)); + updateStatusBar(); + }); mStatusBarColorDrawable = new ColorDrawable(0); - mRootView.findViewById(R.id.share_fab).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { + binding.shareFab.setOnClickListener(view -> startActivity(Intent.createChooser(ShareCompat.IntentBuilder.from(getActivity()) .setType("text/plain") .setText("Some sample text") - .getIntent(), getString(R.string.action_share))); - } - }); + .getIntent(), getString(R.string.action_share)))); bindViews(); updateStatusBar(); - return mRootView; + return binding.getRoot(); } private void updateStatusBar() { int color = 0; - if (mPhotoView != null && mTopInset != 0 && mScrollY > 0) { + if (binding.photo != null && mTopInset != 0 && mScrollY > 0) { float f = progress(mScrollY, mStatusBarFullOpacityBottom - mTopInset * 3, mStatusBarFullOpacityBottom - mTopInset); @@ -167,7 +144,7 @@ private void updateStatusBar() { (int) (Color.blue(mMutedColor) * 0.9)); } mStatusBarColorDrawable.setColor(color); - mDrawInsetsFrameLayout.setInsetBackground(mStatusBarColorDrawable); + binding.drawInsetsFrameLayout.setInsetBackground(mStatusBarColorDrawable); } static float progress(float v, float min, float max) { @@ -196,26 +173,19 @@ private Date parsePublishedDate() { } private void bindViews() { - if (mRootView == null) { - return; - } - - TextView titleView = (TextView) mRootView.findViewById(R.id.article_title); - TextView bylineView = (TextView) mRootView.findViewById(R.id.article_byline); - bylineView.setMovementMethod(new LinkMovementMethod()); - TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body); + binding.articleByline.setMovementMethod(new LinkMovementMethod()); //Replaced with downloadable font //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)); + binding.getRoot().setAlpha(0); + binding.getRoot().setVisibility(View.VISIBLE); + binding.getRoot().animate().alpha(1); + binding.articleTitle.setText(mCursor.getString(ArticleLoader.Query.TITLE)); Date publishedDate = parsePublishedDate(); if (!publishedDate.before(START_OF_EPOCH.getTime())) { - bylineView.setText(Html.fromHtml( + binding.articleByline.setText(Html.fromHtml( DateUtils.getRelativeTimeSpanString( publishedDate.getTime(), System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS, @@ -226,13 +196,13 @@ private void bindViews() { } else { // If date is before 1902, just show the string - bylineView.setText(Html.fromHtml( + binding.articleByline.setText(Html.fromHtml( outputFormat.format(publishedDate) + " by " + mCursor.getString(ArticleLoader.Query.AUTHOR) + "")); } - bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY).replaceAll("(\r\n|\n)", "
"))); + binding.articleBody.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY).replaceAll("(\r\n|\n)", "
"))); ImageLoaderHelper.getInstance(getActivity()).getImageLoader() .get(mCursor.getString(ArticleLoader.Query.PHOTO_URL), new ImageLoader.ImageListener() { @Override @@ -241,9 +211,8 @@ public void onResponse(ImageLoader.ImageContainer imageContainer, boolean b) { if (bitmap != null) { Palette p = Palette.generate(bitmap, 12); mMutedColor = p.getDarkMutedColor(0xFF333333); - mPhotoView.setImageBitmap(imageContainer.getBitmap()); - mRootView.findViewById(R.id.meta_bar) - .setBackgroundColor(mMutedColor); + binding.photo.setImageBitmap(imageContainer.getBitmap()); + binding.metaBar.setBackgroundColor(mMutedColor); updateStatusBar(); } } @@ -254,10 +223,10 @@ public void onErrorResponse(VolleyError volleyError) { } }); } else { - mRootView.setVisibility(View.GONE); - titleView.setText("N/A"); - bylineView.setText("N/A" ); - bodyView.setText("N/A"); + binding.getRoot().setVisibility(View.GONE); + binding.articleTitle.setText("N/A"); + binding.articleByline.setText("N/A" ); + binding.articleBody.setText("N/A"); } } @@ -292,13 +261,13 @@ public void onLoaderReset(Loader cursorLoader) { } public int getUpButtonFloor() { - if (mPhotoContainerView == null || mPhotoView.getHeight() == 0) { + if (binding.photo.getHeight() == 0) { return Integer.MAX_VALUE; } // account for parallax return mIsCard - ? (int) mPhotoContainerView.getTranslationY() + mPhotoView.getHeight() - mScrollY - : mPhotoView.getHeight() - mScrollY; + ? (int) binding.photoContainer.getTranslationY() + binding.photo.getHeight() - mScrollY + : binding.photo.getHeight() - mScrollY; } } From e87216c4e3dae103796369fb18cbf17a7c72f8b9 Mon Sep 17 00:00:00 2001 From: "David R. Smith" Date: Thu, 30 Jul 2020 09:24:06 -0400 Subject: [PATCH 5/6] refactor --- .../xyzreader/ui/ArticleDetailActivity.java | 16 ++-- .../xyzreader/ui/ArticleDetailFragment.java | 18 ++-- .../res/layout/fragment_article_detail.xml | 15 ++-- XYZReader/src/main/res/values/dimens.xml | 5 +- XYZReader/src/main/res/values/strings.xml | 89 +++++++++++++++++++ 5 files changed, 117 insertions(+), 26 deletions(-) diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailActivity.java b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailActivity.java index b10a60a65..b3db11773 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailActivity.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailActivity.java @@ -11,7 +11,6 @@ import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; -import android.view.WindowInsets; import androidx.appcompat.app.AppCompatActivity; import androidx.legacy.app.FragmentStatePagerAdapter; @@ -88,15 +87,12 @@ public void onClick(View view) { }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - mUpButtonContainer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { - @Override - public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) { - view.onApplyWindowInsets(windowInsets); - mTopInset = windowInsets.getSystemWindowInsetTop(); - mUpButtonContainer.setTranslationY(mTopInset); - updateUpButtonPosition(); - return windowInsets; - } + mUpButtonContainer.setOnApplyWindowInsetsListener((view, windowInsets) -> { + view.onApplyWindowInsets(windowInsets); + mTopInset = windowInsets.getSystemWindowInsetTop(); + mUpButtonContainer.setTranslationY(mTopInset); + updateUpButtonPosition(); + return windowInsets; }); } diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java index 1c8d5efb8..6f9bd9d8a 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java @@ -134,7 +134,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, private void updateStatusBar() { int color = 0; - if (binding.photo != null && mTopInset != 0 && mScrollY > 0) { + if (mTopInset != 0 && mScrollY > 0) { float f = progress(mScrollY, mStatusBarFullOpacityBottom - mTopInset * 3, mStatusBarFullOpacityBottom - mTopInset); @@ -261,13 +261,17 @@ public void onLoaderReset(Loader cursorLoader) { } public int getUpButtonFloor() { - if (binding.photo.getHeight() == 0) { + try { + if (binding.photo.getHeight() == 0) { + return Integer.MAX_VALUE; + } + + // account for parallax + return mIsCard + ? (int) binding.photoContainer.getTranslationY() + binding.photo.getHeight() - mScrollY + : binding.photo.getHeight() - mScrollY; + } catch (NullPointerException ignored) { return Integer.MAX_VALUE; } - - // account for parallax - return mIsCard - ? (int) binding.photoContainer.getTranslationY() + binding.photo.getHeight() - mScrollY - : binding.photo.getHeight() - mScrollY; } } diff --git a/XYZReader/src/main/res/layout/fragment_article_detail.xml b/XYZReader/src/main/res/layout/fragment_article_detail.xml index 38d63b057..e2f0a8beb 100755 --- a/XYZReader/src/main/res/layout/fragment_article_detail.xml +++ b/XYZReader/src/main/res/layout/fragment_article_detail.xml @@ -97,16 +97,17 @@ - + android:stateListAnimator="@anim/fab_state_list_anim" + app:backgroundTint="@color/secondaryLightColor" + app:elevation="@dimen/fab_elevation" /> diff --git a/XYZReader/src/main/res/values/dimens.xml b/XYZReader/src/main/res/values/dimens.xml index f38578e70..c1a2d599f 100755 --- a/XYZReader/src/main/res/values/dimens.xml +++ b/XYZReader/src/main/res/values/dimens.xml @@ -2,10 +2,11 @@ 32sp 18sp - 1.25 - 2dp + 6dp 24dp + 16dp + 1.25 diff --git a/XYZReader/src/main/res/values/strings.xml b/XYZReader/src/main/res/values/strings.xml index 4b537b209..70ec0ddbd 100755 --- a/XYZReader/src/main/res/values/strings.xml +++ b/XYZReader/src/main/res/values/strings.xml @@ -9,5 +9,94 @@ Up Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + + "Material is the metaphor.\n\n" + + "A material metaphor is the unifying theory of a rationalized space and a system of motion." + "The material is grounded in tactile reality, inspired by the study of paper and ink, yet " + "technologically advanced and open to imagination and magic.\n" + "Surfaces and edges of the material provide visual cues that are grounded in reality. The " + "use of familiar tactile attributes helps users quickly understand affordances. Yet the " + "flexibility of the material creates new affordances that supercede those in the physical " + "world, without breaking the rules of physics.\n" + "The fundamentals of light, surface, and movement are key to conveying how objects move, " + "interact, and exist in space and in relation to each other. Realistic lighting shows " + "seams, divides space, and indicates moving parts.\n\n" + + "Bold, graphic, intentional.\n\n" + + "The foundational elements of print based design typography, grids, space, scale, color, " + "and use of imagery guide visual treatments. These elements do far more than please the " + "eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge " + "imagery, large scale typography, and intentional white space create a bold and graphic " + "interface that immerse the user in the experience.\n" + "An emphasis on user actions makes core functionality immediately apparent and provides " + "waypoints for the user.\n\n" + + "Motion provides meaning.\n\n" + + "Motion respects and reinforces the user as the prime mover. Primary user actions are " + "inflection points that initiate motion, transforming the whole design.\n" + "All action takes place in a single environment. Objects are presented to the user without " + "breaking the continuity of experience even as they transform and reorganize.\n" + "Motion is meaningful and appropriate, serving to focus attention and maintain continuity. " + "Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n" + + "3D world.\n\n" + + "The material environment is a 3D space, which means all objects have x, y, and z " + "dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the " + "positive z-axis extending towards the viewer. Every sheet of material occupies a single " + "position along the z-axis and has a standard 1dp thickness.\n" + "On the web, the z-axis is used for layering and not for perspective. The 3D world is " + "emulated by manipulating the y-axis.\n\n" + + "Light and shadow.\n\n" + + "Within the material environment, virtual lights illuminate the scene. Key lights create " + "directional shadows, while ambient light creates soft shadows from all angles.\n" + "Shadows in the material environment are cast by these two light sources. In Android " + "development, shadows occur when light sources are blocked by sheets of material at " + "various positions along the z-axis. On the web, shadows are depicted by manipulating the " + "y-axis only. The following example shows the card with a height of 6dp.\n\n" + + "Resting elevation.\n\n" + + "All material objects, regardless of size, have a resting elevation, or default elevation " + "that does not change. If an object changes elevation, it should return to its resting " + "elevation as soon as possible.\n\n" + + "Component elevations.\n\n" + + "The resting elevation for a component type is consistent across apps (e.g., FAB elevation " + "does not vary from 6dp in one app to 16dp in another app).\n" + "Components may have different resting elevations across platforms, depending on the depth " + "of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n" + + "Responsive elevation and dynamic elevation offsets.\n\n" + + "Some component types have responsive elevation, meaning they change elevation in response " + "to user input (e.g., normal, focused, and pressed) or system events. These elevation " + "changes are consistently implemented using dynamic elevation offsets.\n" + "Dynamic elevation offsets are the goal elevation that a component moves towards, relative " + "to the component’s resting state. They ensure that elevation changes are consistent " + "across actions and component types. For example, all components that lift on press have " + "the same elevation change relative to their resting elevation.\n" + "Once the input event is completed or cancelled, the component will return to its resting " + "elevation.\n\n" + + "Avoiding elevation interference.\n\n" + + "Components with responsive elevations may encounter other components as they move between " + "their resting elevations and dynamic elevation offsets. Because material cannot pass " + "through other material, components avoid interfering with one another any number of ways, " + "whether on a per component basis or using the entire app layout.\n" + "On a component level, components can move or be removed before they cause interference. " + "For example, a floating action button (FAB) can disappear or move off screen before a " + "user picks up a card, or it can move if a snackbar appears.\n" + "On the layout level, design your app layout to minimize opportunities for interference. " + "For example, position the FAB to one side of stream of a cards so the FAB won’t interfere " + "when a user tries to pick up one of cards.\n\n" + From 4e7bd53d1384179f27ee40e85254c983c2a9389a Mon Sep 17 00:00:00 2001 From: "David R. Smith" Date: Fri, 31 Jul 2020 09:28:14 -0400 Subject: [PATCH 6/6] design update --- XYZReader/src/main/AndroidManifest.xml | 6 +- .../xyzreader/ui/ArticleDetailFragment.java | 16 ++---- .../xyzreader/ui/ArticleListActivity.java | 17 ++++-- .../main/res/layout/activity_article_list.xml | 56 +++++++++---------- .../res/layout/fragment_article_detail.xml | 48 ++++++++-------- .../src/main/res/layout/list_item_article.xml | 5 +- XYZReader/src/main/res/values/dimens.xml | 2 +- XYZReader/src/main/res/values/strings.xml | 1 + XYZReader/src/main/res/values/styles.xml | 6 +- 9 files changed, 86 insertions(+), 71 deletions(-) diff --git a/XYZReader/src/main/AndroidManifest.xml b/XYZReader/src/main/AndroidManifest.xml index a39bf74f8..267d13cb7 100755 --- a/XYZReader/src/main/AndroidManifest.xml +++ b/XYZReader/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:label="@string/app_name" + android:theme="@style/Theme.Bacon"> @@ -27,7 +28,8 @@ + android:parentActivityName=".ui.ArticleListActivity" + android:theme="@style/Theme.Bacon.Detail"> diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java index 6f9bd9d8a..6e81f1172 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleDetailFragment.java @@ -261,17 +261,13 @@ public void onLoaderReset(Loader cursorLoader) { } public int getUpButtonFloor() { - try { - if (binding.photo.getHeight() == 0) { - return Integer.MAX_VALUE; - } - - // account for parallax - return mIsCard - ? (int) binding.photoContainer.getTranslationY() + binding.photo.getHeight() - mScrollY - : binding.photo.getHeight() - mScrollY; - } catch (NullPointerException ignored) { + if (binding == null || binding.photo.getHeight() == 0) { return Integer.MAX_VALUE; } + + // account for parallax + return mIsCard + ? (int) binding.photoContainer.getTranslationY() + binding.photo.getHeight() - mScrollY + : binding.photo.getHeight() - mScrollY; } } diff --git a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleListActivity.java b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleListActivity.java index f879c9541..3f81b7200 100755 --- a/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleListActivity.java +++ b/XYZReader/src/main/java/com/example/xyzreader/ui/ArticleListActivity.java @@ -1,5 +1,6 @@ package com.example.xyzreader.ui; +import android.app.ActivityOptions; import android.app.LoaderManager; import android.content.BroadcastReceiver; import android.content.Context; @@ -13,6 +14,7 @@ import android.util.Log; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; @@ -142,11 +144,16 @@ public long getItemId(int position) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = getLayoutInflater().inflate(R.layout.list_item_article, parent, false); final ViewHolder vh = new ViewHolder(view); - view.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(Intent.ACTION_VIEW, - ItemsContract.Items.buildItemUri(getItemId(vh.getAdapterPosition())))); + view.setOnClickListener(innerView -> { + Intent intent = new Intent(Intent.ACTION_VIEW, + ItemsContract.Items.buildItemUri(getItemId(vh.getAdapterPosition()))); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { + ImageView image = innerView.findViewById(R.id.thumbnail); + Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(ArticleListActivity.this, + image, getString(R.string.transition_name)).toBundle(); + startActivity(intent, bundle); + } else { + startActivity(intent); } }); return vh; diff --git a/XYZReader/src/main/res/layout/activity_article_list.xml b/XYZReader/src/main/res/layout/activity_article_list.xml index c7437316d..155ba23bf 100755 --- a/XYZReader/src/main/res/layout/activity_article_list.xml +++ b/XYZReader/src/main/res/layout/activity_article_list.xml @@ -1,43 +1,25 @@ - - - - - - - + android:layout_height="wrap_content" + app:elevation="16dp" + tools:targetApi="lollipop" + style="@style/action_bar_style"> + android:layout_marginRight="@dimen/list_toolbar_side_margin"> - + + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/XYZReader/src/main/res/layout/fragment_article_detail.xml b/XYZReader/src/main/res/layout/fragment_article_detail.xml index e2f0a8beb..ffd38c1c1 100755 --- a/XYZReader/src/main/res/layout/fragment_article_detail.xml +++ b/XYZReader/src/main/res/layout/fragment_article_detail.xml @@ -22,9 +22,11 @@ + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:transitionName="@string/transition_name" + tools:targetApi="lollipop" /> + android:orientation="vertical"> + android:paddingRight="@dimen/detail_inner_horiz_margin" + android:paddingEnd="@dimen/detail_inner_horiz_margin" + android:paddingBottom="@dimen/detail_metabar_vert_padding"> + android:textStyle="bold" + tools:text="Test title" /> + android:textColor="@color/dark_grey_subtitle" + tools:text="pls ignore" /> + android:textSize="@dimen/detail_body_text_size" + tools:text="@string/lorem_ipsum_test" /> @@ -99,15 +103,15 @@ + app:elevation="@dimen/fab_elevation" + app:useCompatPadding="true" + tools:targetApi="lollipop" /> diff --git a/XYZReader/src/main/res/layout/list_item_article.xml b/XYZReader/src/main/res/layout/list_item_article.xml index 4fa56ab2a..cfe27a27a 100755 --- a/XYZReader/src/main/res/layout/list_item_article.xml +++ b/XYZReader/src/main/res/layout/list_item_article.xml @@ -1,5 +1,4 @@ + android:background="@color/photo_placeholder" + tools:targetApi="lollipop" /> 32sp 18sp - 2dp + 8dp 6dp 24dp diff --git a/XYZReader/src/main/res/values/strings.xml b/XYZReader/src/main/res/values/strings.xml index 70ec0ddbd..15e72fa80 100755 --- a/XYZReader/src/main/res/values/strings.xml +++ b/XYZReader/src/main/res/values/strings.xml @@ -98,5 +98,6 @@ "For example, position the FAB to one side of stream of a cards so the FAB won’t interfere " "when a user tries to pick up one of cards.\n\n" + com.example.xyzreader.article_thumbnail diff --git a/XYZReader/src/main/res/values/styles.xml b/XYZReader/src/main/res/values/styles.xml index ebea3f655..c1899c815 100755 --- a/XYZReader/src/main/res/values/styles.xml +++ b/XYZReader/src/main/res/values/styles.xml @@ -15,12 +15,16 @@ limitations under the License. --> - + +