diff --git a/app/build.gradle b/app/build.gradle index ffede2a..5b00ef3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -155,7 +155,7 @@ tasks.withType(Test) { systemProperty "robolectric.logging", "stdout" } ext { - supportLibVersion = '25.1.0' + supportLibVersion = '25.3.1' } //noinspection GroovyAssignabilityCheck configurations.all { diff --git a/app/src/main/java/subreddit/android/appstore/screens/details/AppDetailsFragment.java b/app/src/main/java/subreddit/android/appstore/screens/details/AppDetailsFragment.java index 410473f..3984aef 100644 --- a/app/src/main/java/subreddit/android/appstore/screens/details/AppDetailsFragment.java +++ b/app/src/main/java/subreddit/android/appstore/screens/details/AppDetailsFragment.java @@ -9,6 +9,8 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.customtabs.CustomTabsIntent; +import android.support.design.widget.AppBarLayout; +import android.support.design.widget.CollapsingToolbarLayout; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; @@ -54,16 +56,19 @@ public class AppDetailsFragment extends BasePresenterFragment implements AppDetailsContract.View, ScreenshotsAdapter.ScreenshotClickedListener, View.OnClickListener, Toolbar.OnMenuItemClickListener { - @BindView(R.id.description) TextView description; - @BindView(R.id.tag_container) FlowLayout tagContainer; @BindView(R.id.download_fab) FloatingActionButton downloadButton; @BindView(R.id.details_toolbar) Toolbar toolbar; + @BindView(R.id.collapsingToolbar) CollapsingToolbarLayout collapsingToolbar; + @BindView(R.id.appbar) AppBarLayout appBar; + @BindView(R.id.icon_frame) View iconFrame; @BindView(R.id.icon_image) ImageView iconImage; @BindView(R.id.icon_placeholder) View iconPlaceholder; - @BindView(R.id.title_primary) TextView primaryTitle; @BindView(R.id.title_secondary) TextView secondaryTitle; + @BindView(R.id.tag_container) FlowLayout tagContainer; + @BindView(R.id.screenshot_pager) ViewPager screenshotPager; + @BindView(R.id.description) TextView description; private static final String REDDIT_MSG_URL_HEADER="https://www.reddit.com/message/compose/?to=/r/Android&subject=**RAS Flag Report**&message="; @@ -116,7 +121,7 @@ public void onClick(DialogInterface dialogInterface, int i) { if (flagMessage.getText().toString().isEmpty()) { Toast.makeText(getContext(), getContext().getResources().getString(R.string.no_message), Toast.LENGTH_LONG).show(); } else { - openInChrome(REDDIT_MSG_URL_HEADER + "*****" + toolbar.getSubtitle() +" REPORT" + "*****" + "%0A" +(flagMessage.getText().toString().trim())); + openInChrome(REDDIT_MSG_URL_HEADER + "*****" + collapsingToolbar.getTitle() +" REPORT" + "*****" + "%0A" +(flagMessage.getText().toString().trim())); } } }) @@ -132,13 +137,23 @@ public void onClick(DialogInterface dialogInterface, int i) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.fragment_appdetails_layout, container, false); unbinder = ButterKnife.bind(this, layout); + toolbar.setContentInsetStartWithNavigation(0); + + appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { + @Override + public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { + float scrollRange = (float) appBarLayout.getTotalScrollRange(); + fadeHeaderItems(scrollRange, verticalOffset); + } + }); + return layout; } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_48px); + toolbar.setNavigationIcon(R.drawable.ic_close_white_24dp); toolbar.setNavigationOnClickListener(this); toolbar.inflateMenu(R.menu.appdetails_fragment); toolbar.setOnMenuItemClickListener(this); @@ -223,7 +238,7 @@ public void displayDetails(@Nullable AppInfo appInfo) { getActivity().finish(); return; } - primaryTitle.setText(appInfo.getAppName()); + collapsingToolbar.setTitle(appInfo.getAppName()); secondaryTitle.setText(appInfo.getSecondaryCategory()); downloads = new ArrayList<>(appInfo.getDownloads()); contacts = new ArrayList<>(appInfo.getContacts()); @@ -245,7 +260,6 @@ public void displayDetails(@Nullable AppInfo appInfo) { tagContainer.addView(tv); } tagContainer.setVisibility(appInfo.getTags().isEmpty() ? View.GONE : View.VISIBLE); - toolbar.setSubtitle(appInfo.getAppName()); createMenus(); } @@ -317,4 +331,11 @@ public void displayIcon(@Nullable AppInfo appInfo) { public void onScreenshotClicked(String url) { new ScreenshotDialog(getContext(), screenshotUrls, screenshotUrls.indexOf(url)).show(); } + + private void fadeHeaderItems(float scrollRange, int verticalOffset) { + float fadeFactor = 1.0f - Math.abs(2 * verticalOffset / scrollRange); + secondaryTitle.setAlpha(fadeFactor); + tagContainer.setAlpha(fadeFactor); + iconFrame.setAlpha(fadeFactor); + } } diff --git a/app/src/main/res/drawable/ic_close_white_24dp.xml b/app/src/main/res/drawable/ic_close_white_24dp.xml new file mode 100644 index 0000000..1e2d044 --- /dev/null +++ b/app/src/main/res/drawable/ic_close_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/fragment_appdetails_layout.xml b/app/src/main/res/layout/fragment_appdetails_layout.xml index 047bf33..98d8540 100644 --- a/app/src/main/res/layout/fragment_appdetails_layout.xml +++ b/app/src/main/res/layout/fragment_appdetails_layout.xml @@ -1,121 +1,141 @@ - - - + + - - - - - - + android:fitsSystemWindows="true"> - + android:fitsSystemWindows="true" + app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" + app:expandedTitleMarginStart="8dp" + app:expandedTitleMarginEnd="8dp" + app:expandedTitleMarginBottom="124dp" + app:expandedTitleGravity="center_horizontal|bottom" + app:expandedTitleTextAppearance="@style/TextAppearance.AppCompat.Title"> + + + android:orientation="vertical" + app:layout_collapseMode="parallax" + app:layout_collapseParallaxMultiplier="0.7"> - + android:layout_width="160dp" + android:layout_height="160dp" + android:layout_gravity="center" + android:visibility="gone" + android:gravity="center" + android:paddingBottom="40dp"> - - + android:gravity="center" + tools:text="Lorem ipsum"/> - - - - + - + + - + + + - - - + android:orientation="vertical"> + + + + + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/menu/appdetails_fragment.xml b/app/src/main/res/menu/appdetails_fragment.xml index de019ce..7312725 100644 --- a/app/src/main/res/menu/appdetails_fragment.xml +++ b/app/src/main/res/menu/appdetails_fragment.xml @@ -3,9 +3,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> + app:showAsAction="never"/> Filter Search Details - Contact + Contact developer Download Google Play F-Droid