From c8da5e81fd7d4505df70211e6cf8229074b4e98f Mon Sep 17 00:00:00 2001 From: Karim Abou Zeid Date: Tue, 31 May 2016 16:57:21 +0200 Subject: [PATCH] Updated material intro. Note: Waiting for version 1.5.2 to fix a crash. --- app/build.gradle | 2 +- .../ui/activities/intro/AppIntroActivity.java | 20 ++- .../intro/PhonographSimpleSlide.java | 151 ------------------ .../fragment_simple_slide_large_image.xml | 53 ++++++ ... => fragment_simple_slide_large_image.xml} | 36 ++--- 5 files changed, 87 insertions(+), 175 deletions(-) delete mode 100644 app/src/main/java/com/kabouzeid/gramophone/ui/activities/intro/PhonographSimpleSlide.java create mode 100644 app/src/main/res/layout-land/fragment_simple_slide_large_image.xml rename app/src/main/res/layout/{fragment_intro_slide.xml => fragment_simple_slide_large_image.xml} (70%) diff --git a/app/build.gradle b/app/build.gradle index 600b9c0a..a7a3a9a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -145,6 +145,6 @@ dependencies { compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar' compile 'com.github.kabouzeid:RecyclerView-FastScroll:1.8-kmod' - compile 'com.heinrichreimersoftware:material-intro:b8ec16d3d6' + compile 'com.heinrichreimersoftware:material-intro:1.5.1' compile 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5' } diff --git a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/intro/AppIntroActivity.java b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/intro/AppIntroActivity.java index f26dad9c..c7937b3c 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/intro/AppIntroActivity.java +++ b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/intro/AppIntroActivity.java @@ -3,6 +3,7 @@ package com.kabouzeid.gramophone.ui.activities.intro; import android.os.Bundle; import com.heinrichreimersoftware.materialintro.app.IntroActivity; +import com.heinrichreimersoftware.materialintro.slide.SimpleSlide; import com.kabouzeid.gramophone.R; /** @@ -14,26 +15,35 @@ public class AppIntroActivity extends IntroActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - addSlide(new PhonographSimpleSlide.Builder() + setButtonCtaVisible(true); + setButtonNextVisible(false); + setButtonBackVisible(false); + + setButtonCtaTintMode(BUTTON_CTA_TINT_MODE_TEXT); + + addSlide(new SimpleSlide.Builder() .title(R.string.app_name) .description(R.string.welcome_to_phonograph) .image(R.drawable.icon_web) - .background(R.color.md_amber_500) - .backgroundDark(R.color.md_amber_600) + .background(R.color.md_blue_grey_100) + .backgroundDark(R.color.md_blue_grey_200) + .layout(R.layout.fragment_simple_slide_large_image) .build()); - addSlide(new PhonographSimpleSlide.Builder() + addSlide(new SimpleSlide.Builder() .title(R.string.label_playing_queue) .description(R.string.open_playing_queue_instruction) .image(R.drawable.tutorial_queue_swipe_up) .background(R.color.md_deep_purple_500) .backgroundDark(R.color.md_deep_purple_600) + .layout(R.layout.fragment_simple_slide_large_image) .build()); - addSlide(new PhonographSimpleSlide.Builder() + addSlide(new SimpleSlide.Builder() .title(R.string.label_playing_queue) .description(R.string.rearrange_playing_queue_instruction) .image(R.drawable.tutorial_rearrange_queue) .background(R.color.md_indigo_500) .backgroundDark(R.color.md_indigo_600) + .layout(R.layout.fragment_simple_slide_large_image) .build()); } } diff --git a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/intro/PhonographSimpleSlide.java b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/intro/PhonographSimpleSlide.java deleted file mode 100644 index 43128666..00000000 --- a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/intro/PhonographSimpleSlide.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.kabouzeid.gramophone.ui.activities.intro; - -import android.os.Bundle; -import android.support.annotation.ColorRes; -import android.support.annotation.DrawableRes; -import android.support.annotation.StringRes; -import android.support.v4.content.ContextCompat; -import android.support.v4.graphics.ColorUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import com.heinrichreimersoftware.materialintro.slide.Slide; -import com.kabouzeid.gramophone.R; - -public class PhonographSimpleSlide extends Slide { - - private final Fragment fragment; - @ColorRes - private final int background; - @ColorRes - private final int backgroundDark; - - private PhonographSimpleSlide(Builder builder) { - fragment = Fragment.newInstance(builder.title, builder.description, builder.image, builder.background); - background = builder.background; - backgroundDark = builder.backgroundDark; - } - - @Override - public Fragment getFragment() { - return fragment; - } - - @Override - public int getBackground() { - return background; - } - - @Override - public int getBackgroundDark() { - return backgroundDark; - } - - public static class Builder { - @ColorRes - private int background = 0; - @ColorRes - private int backgroundDark = 0; - @StringRes - private int title = 0; - @StringRes - private int description = 0; - @DrawableRes - private int image = 0; - - public Builder background(int background) { - this.background = background; - return this; - } - - public Builder backgroundDark(int backgroundDark) { - this.backgroundDark = backgroundDark; - return this; - } - - public Builder title(int title) { - this.title = title; - return this; - } - - public Builder description(int description) { - this.description = description; - return this; - } - - public Builder image(int image) { - this.image = image; - return this; - } - - public PhonographSimpleSlide build() { - if (background == 0 || title == 0) - throw new IllegalArgumentException("You must set at least a title and background."); - return new PhonographSimpleSlide(this); - } - } - - public static class Fragment extends android.support.v4.app.Fragment { - private static final String ARGUMENT_TITLE_RES = - "com.kabouzeid.gramophone.SimpleFragment.ARGUMENT_TITLE_RES"; - private static final String ARGUMENT_DESCRIPTION_RES = - "com.kabouzeid.gramophone.SimpleFragment.ARGUMENT_DESCRIPTION_RES"; - private static final String ARGUMENT_IMAGE_RES = - "com.kabouzeid.gramophone.SimpleFragment.ARGUMENT_IMAGE_RES"; - private static final String ARGUMENT_BACKGROUND_RES = - "com.kabouzeid.gramophone.SimpleFragment.ARGUMENT_BACKGROUND_RES"; - - public static Fragment newInstance(@StringRes int title, @StringRes int description, @DrawableRes int image, @ColorRes int background) { - Fragment fragment = new Fragment(); - - Bundle arguments = new Bundle(); - arguments.putInt(ARGUMENT_TITLE_RES, title); - arguments.putInt(ARGUMENT_DESCRIPTION_RES, description); - arguments.putInt(ARGUMENT_IMAGE_RES, image); - arguments.putInt(ARGUMENT_BACKGROUND_RES, background); - fragment.setArguments(arguments); - - return fragment; - } - - public Fragment() { - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View fragment = inflater.inflate(R.layout.fragment_intro_slide, container, false); - - TextView title = (TextView) fragment.findViewById(R.id.mi_title); - TextView description = (TextView) fragment.findViewById(R.id.mi_description); - ImageView image = (ImageView) fragment.findViewById(R.id.mi_image); - - Bundle arguments = getArguments(); - - title.setText(arguments.getInt(ARGUMENT_TITLE_RES)); - description.setText(arguments.getInt(ARGUMENT_DESCRIPTION_RES)); - image.setImageResource(arguments.getInt(ARGUMENT_IMAGE_RES)); - - int background = ContextCompat.getColor(getContext(), - arguments.getInt(ARGUMENT_BACKGROUND_RES)); - if (ColorUtils.calculateLuminance(background) > 0.4) { - //Use dark text color - title.setTextColor(ContextCompat.getColor(getContext(), - R.color.mi_text_color_primary_light)); - description.setTextColor(ContextCompat.getColor(getContext(), - R.color.mi_text_color_secondary_light)); - } else { - //Use light text color - title.setTextColor(ContextCompat.getColor(getContext(), - R.color.mi_text_color_primary_dark)); - description.setTextColor(ContextCompat.getColor(getContext(), - R.color.mi_text_color_secondary_dark)); - } - - return fragment; - } - } -} diff --git a/app/src/main/res/layout-land/fragment_simple_slide_large_image.xml b/app/src/main/res/layout-land/fragment_simple_slide_large_image.xml new file mode 100644 index 00000000..a6ee0103 --- /dev/null +++ b/app/src/main/res/layout-land/fragment_simple_slide_large_image.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_intro_slide.xml b/app/src/main/res/layout/fragment_simple_slide_large_image.xml similarity index 70% rename from app/src/main/res/layout/fragment_intro_slide.xml rename to app/src/main/res/layout/fragment_simple_slide_large_image.xml index 9c3e76fc..b7fe9c24 100644 --- a/app/src/main/res/layout/fragment_intro_slide.xml +++ b/app/src/main/res/layout/fragment_simple_slide_large_image.xml @@ -2,20 +2,31 @@ + + @@ -23,20 +34,9 @@ android:id="@id/mi_description" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="@dimen/mi_baseline" + android:layout_marginTop="@dimen/mi_baseline" android:gravity="center" - android:textAppearance="@style/TextAppearance.AppCompat.Body1" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" tools:text="Lorem ipsum dolor sit amet, consectetur, adipisci velit, …" /> - - \ No newline at end of file