Merge branch 'materialintroupdate'

This commit is contained in:
Karim Abou Zeid 2016-06-02 21:05:36 +02:00
commit c555556d36
5 changed files with 87 additions and 175 deletions

View file

@ -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.2'
compile 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5'
}

View file

@ -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());
}
}

View file

@ -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;
}
}
}

View file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:clipToPadding="false"
android:fitsSystemWindows="false"
android:padding="@dimen/mi_baseline">
<ImageView
android:id="@id/mi_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:gravity="center"
tools:ignore="ContentDescription"
tools:src="@drawable/tutorial_queue_swipe_up" />
<android.support.v4.widget.Space
android:layout_width="@dimen/mi_baseline"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@id/mi_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:fontFamily="sans-serif-medium"
tools:ignore="UnusedAttribute"
tools:text="Lorem ipsum" />
<TextView
android:id="@id/mi_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/mi_baseline"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
tools:text="Lorem ipsum dolor sit amet, consectetur, adipisci velit, …" />
</LinearLayout>
</LinearLayout>

View file

@ -2,20 +2,31 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fitsSystemWindows="false"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/mi_baseline">
<ImageView
android:id="@id/mi_image"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginBottom="@dimen/mi_baseline"
android:layout_weight="1"
android:gravity="center"
tools:ignore="ContentDescription"
tools:src="@drawable/tutorial_queue_swipe_up" />
<TextView
android:id="@id/mi_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/mi_baseline"
android:fontFamily="sans-serif-light"
android:layout_marginTop="@dimen/mi_baseline"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
tools:ignore="UnusedAttribute"
tools:text="Lorem ipsum" />
@ -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, …" />
<ImageView
android:id="@id/mi_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/mi_baseline"
android:gravity="center"
tools:ignore="ContentDescription"
android:paddingBottom="@dimen/mi_pager_margin_bottom"
tools:src="@drawable/tutorial_queue_swipe_up" />
</LinearLayout>