Skip to content
This repository was archived by the owner on Jun 19, 2021. It is now read-only.

Improve layout #18

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
buildToolsVersion '25.0.0'

defaultConfig {
applicationId "za.co.riggaroo.helptut.helptutorialexample"
Expand All @@ -22,6 +22,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':materialhelptutorial')
compile project(':materialhelptutorial-library')
compile 'com.android.support:appcompat-v7:24.2.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public void loadTutorial() {
}

private ArrayList<TutorialItem> getTutorialItems(Context context) {
TutorialItem tutorialItem = new TutorialItem("", "", R.color.slide_1, R.drawable.tut_page_1_front, R.drawable.tut_page_1_front, "SALTEAR", "TERMINAR");

TutorialItem tutorialItem1 = new TutorialItem(R.string.slide_1_african_story_books, R.string.slide_1_african_story_books,
R.color.slide_1, R.drawable.tut_page_1_front, R.drawable.tut_page_1_background);

Expand All @@ -52,6 +54,7 @@ private ArrayList<TutorialItem> getTutorialItems(Context context) {
R.color.slide_4, R.drawable.tut_page_4_foreground, R.drawable.tut_page_4_background);

ArrayList<TutorialItem> tutorialItems = new ArrayList<>();
tutorialItems.add(tutorialItem);
tutorialItems.add(tutorialItem1);
tutorialItems.add(tutorialItem2);
tutorialItems.add(tutorialItem3);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Oct 09 10:46:48 SAST 2016
#Thu Apr 20 10:39:34 UYT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

version = "1.4.0"
group = "za.co.riggaroo"
version = "1.5.0"
group = 'com.github.isaintmartin'

def siteUrl = 'https://github.com/spongebobrf/MaterialIntroTutorial'
def gitUrl = 'https://github.com/spongebobrf/MaterialIntroTutorial.git'

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
buildToolsVersion '25.0.0'

defaultConfig {
minSdkVersion 11
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package za.co.riggaroo.materialhelptutorial;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

Expand All @@ -21,6 +23,8 @@ public class MaterialTutorialFragment extends Fragment {
private static final String TAG = "MaterialTutFragment";
private static final String ARG_PAGE = "arg_page";

private OnFragmentInteractionListener mInteractionCallback;

public static MaterialTutorialFragment newInstance(TutorialItem tutorialItem, int page) {
MaterialTutorialFragment helpTutorialImageFragment = new MaterialTutorialFragment();
Bundle args = new Bundle();
Expand All @@ -33,6 +37,18 @@ public static MaterialTutorialFragment newInstance(TutorialItem tutorialItem, in
private TutorialItem tutorialItem;
int page;

@Override
public void onAttach(Context context) {
super.onAttach(context);

if (context instanceof OnFragmentInteractionListener) {
mInteractionCallback = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -51,17 +67,23 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
ImageView imageViewFront = (ImageView) v.findViewById(R.id.fragment_help_tutorial_imageview);
ImageView imageViewBack = (ImageView) v.findViewById(R.id.fragment_help_tutorial_imageview_background);
TextView textViewSubTitle = (TextView) v.findViewById(R.id.fragment_help_tutorial_subtitle_text);
TextView skipTextView = mInteractionCallback.getSkipButton();
Button doneButton = mInteractionCallback.getDoneButton();

TextView textView = (TextView) v.findViewById(R.id.fragment_help_tutorial_text);
if (!TextUtils.isEmpty(tutorialItem.getTitleText())) {
textView.setText(tutorialItem.getTitleText());
} else if (tutorialItem.getTitleTextRes() != -1) {
textView.setText(tutorialItem.getTitleTextRes());
} else {
textView.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(tutorialItem.getSubTitleText())) {
textViewSubTitle.setText(tutorialItem.getSubTitleText());
} else if (tutorialItem.getSubTitleTextRes() != -1) {
textViewSubTitle.setText(tutorialItem.getSubTitleTextRes());
} else {
textView.setVisibility(View.GONE);
}
if (tutorialItem.getBackgroundImageRes() != -1) {
Glide.with(this).load(tutorialItem.getBackgroundImageRes()).into(imageViewBack);
Expand All @@ -72,23 +94,19 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
if (tutorialItem.getForegroundImageRes() != -1 && tutorialItem.isGif()){
Glide.with(this).load(tutorialItem.getForegroundImageRes()).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageViewFront);
}
return v;
}

/* public void onTranform(int pageNumber, float transformation) {
Log.d(TAG, "onTransform:" + transformation);
if (!isAdded()) {
return;
if (!TextUtils.isEmpty(tutorialItem.getSkipButtonText())) {
skipTextView.setText(tutorialItem.getSkipButtonText());
}
if (transformation == 0){
imageViewBack.setTranslationX(0);
return;
if (!TextUtils.isEmpty(tutorialItem.getDoneButtonText())) {
doneButton.setText(tutorialItem.getDoneButtonText());
}
int pageWidth = getView().getWidth();
Log.d(TAG, "onTransform Added page Width:" + pageWidth);

imageViewBack.setTranslationX(-transformation * (pageWidth / 2)); //Half the normal speed
return v;
}

}*/
public interface OnFragmentInteractionListener {
Button getDoneButton();
TextView getSkipButton();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class TutorialItem implements Parcelable {
private int backgroundImageRes = -1;
private int titleTextRes = -1;
private int subTitleTextRes = -1;
private String skipButtonText;
private String doneButtonText;
private boolean isGif = false;

public TutorialItem(@NonNull String titleText, @Nullable String subTitleText, @ColorRes int backgroundColor, @DrawableRes int foregroundImageRes, @DrawableRes int backgroundImageRes) {
Expand Down Expand Up @@ -57,6 +59,16 @@ public TutorialItem(@StringRes int titleTextRes, @StringRes int subTitleTextRes,
this.foregroundImageRes = foregroundImageRes;
}

public TutorialItem(@Nullable String titleText, @Nullable String subTitleText, int backgroundColor, int foregroundImageRes, int backgroundImageRes, @Nullable String skipButtonText, @Nullable String doneButtonText) {
this.titleText = titleText;
this.subTitleText = subTitleText;
this.backgroundColor = backgroundColor;
this.foregroundImageRes = foregroundImageRes;
this.backgroundImageRes = backgroundImageRes;
this.skipButtonText = skipButtonText;
this.doneButtonText = doneButtonText;
}

public String getTitleText() {
return titleText;
}
Expand Down Expand Up @@ -89,6 +101,14 @@ public boolean isGif() {
return isGif;
}

public String getSkipButtonText() {
return skipButtonText;
}

public String getDoneButtonText() {
return doneButtonText;
}

@Override
public int describeContents() {
return 0;
Expand All @@ -103,7 +123,9 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.backgroundImageRes);
dest.writeInt(this.titleTextRes);
dest.writeInt(this.subTitleTextRes);
dest.writeInt(this.isGif ? 1:0);
dest.writeString(this.skipButtonText);
dest.writeString(this.doneButtonText);
dest.writeByte(this.isGif ? (byte) 1 : (byte) 0);
}

protected TutorialItem(Parcel in) {
Expand All @@ -114,14 +136,18 @@ protected TutorialItem(Parcel in) {
this.backgroundImageRes = in.readInt();
this.titleTextRes = in.readInt();
this.subTitleTextRes = in.readInt();
this.isGif = in.readInt() == 1;
this.skipButtonText = in.readString();
this.doneButtonText = in.readString();
this.isGif = in.readByte() != 0;
}

public static final Parcelable.Creator<TutorialItem> CREATOR = new Parcelable.Creator<TutorialItem>() {
public static final Creator<TutorialItem> CREATOR = new Creator<TutorialItem>() {
@Override
public TutorialItem createFromParcel(Parcel source) {
return new TutorialItem(source);
}

@Override
public TutorialItem[] newArray(int size) {
return new TutorialItem[size];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import za.co.riggaroo.materialhelptutorial.view.CirclePageIndicator;


public class MaterialTutorialActivity extends AppCompatActivity implements MaterialTutorialContract.View {
public class MaterialTutorialActivity extends AppCompatActivity implements MaterialTutorialContract.View, MaterialTutorialFragment.OnFragmentInteractionListener {

private static final String TAG = "MaterialTutActivity";
public static final String MATERIAL_TUTORIAL_ARG_TUTORIAL_ITEMS = "tutorial_items";
Expand Down Expand Up @@ -152,4 +152,14 @@ public void transformPage(View page, float position) {

);
}

@Override
public Button getDoneButton() {
return mDoneButton;
}

@Override
public TextView getSkipButton() {
return mTextViewSkip;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 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:orientation="vertical"
android:clipToPadding="false"
android:clipChildren="false"
tools:background="#000000">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:clipToPadding="false"
android:clipChildren="false"
tools:background="#000000">

<TextView
android:id="@+id/fragment_help_tutorial_subtitle_text"
Expand All @@ -24,6 +24,7 @@
android:padding="8dp"
android:textColor="@color/tutorial_subtitleTextColor"
android:textSize="16sp"
android:visibility="gone"
tools:text="Line 2 of this description" />

<TextView
Expand All @@ -41,6 +42,7 @@
android:layout_marginLeft="36dp"
android:layout_marginRight="36dp"
android:textSize="24sp"
android:visibility="gone"
tools:text="Browse this wonderful tutorial." />

<ImageView
Expand All @@ -50,7 +52,7 @@
android:layout_above="@id/fragment_help_tutorial_text"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scaleType="fitCenter" />
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/fragment_help_tutorial_imageview"
android:layout_width="match_parent"
Expand All @@ -59,5 +61,7 @@
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
tools:src="@drawable/ic_navigate_next"
android:scaleType="fitCenter" />
android:scaleType="fitCenter"
android:visibility="gone"
/>
</RelativeLayout>
5 changes: 5 additions & 0 deletions materialhelptutorial-library/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<resources>
<string name="app_name">help tutorial app</string>
<string name="tutorial_done">CERRAR</string>
<string name="tutorial_skip">OMITIR</string>
</resources>
21 changes: 0 additions & 21 deletions materialhelptutorial/materialhelptutorial.iml

This file was deleted.

5 changes: 0 additions & 5 deletions materialhelptutorial/src/main/res/values/strings.xml

This file was deleted.

2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include ':app', "materialhelptutorial"
include ':app', "materialhelptutorial-library"

rootProject.name = 'materialhelptutorial'