diff --git a/app/build.gradle b/app/build.gradle index 2b12065..0d9094f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" @@ -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' } diff --git a/app/src/main/java/za/co/riggaroo/helptut/helptutorialexample/MainActivity.java b/app/src/main/java/za/co/riggaroo/helptut/helptutorialexample/MainActivity.java index 2db9947..86d9cb7 100644 --- a/app/src/main/java/za/co/riggaroo/helptut/helptutorialexample/MainActivity.java +++ b/app/src/main/java/za/co/riggaroo/helptut/helptutorialexample/MainActivity.java @@ -39,6 +39,8 @@ public void loadTutorial() { } private ArrayList 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); @@ -52,6 +54,7 @@ private ArrayList getTutorialItems(Context context) { R.color.slide_4, R.drawable.tut_page_4_foreground, R.drawable.tut_page_4_background); ArrayList tutorialItems = new ArrayList<>(); + tutorialItems.add(tutorialItem); tutorialItems.add(tutorialItem1); tutorialItems.add(tutorialItem2); tutorialItems.add(tutorialItem3); diff --git a/build.gradle b/build.gradle index a0ab9e2..082f8d1 100644 --- a/build.gradle +++ b/build.gradle @@ -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 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 380e3c7..52fd58d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/materialhelptutorial/.gitignore b/materialhelptutorial-library/.gitignore similarity index 100% rename from materialhelptutorial/.gitignore rename to materialhelptutorial-library/.gitignore diff --git a/materialhelptutorial/build.gradle b/materialhelptutorial-library/build.gradle similarity index 97% rename from materialhelptutorial/build.gradle rename to materialhelptutorial-library/build.gradle index e2eb28d..1f3c472 100644 --- a/materialhelptutorial/build.gradle +++ b/materialhelptutorial-library/build.gradle @@ -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 diff --git a/materialhelptutorial/src/androidTest/java/za/co/riggaroo/materialhelptutorial/ApplicationTest.java b/materialhelptutorial-library/src/androidTest/java/za/co/riggaroo/materialhelptutorial/ApplicationTest.java similarity index 100% rename from materialhelptutorial/src/androidTest/java/za/co/riggaroo/materialhelptutorial/ApplicationTest.java rename to materialhelptutorial-library/src/androidTest/java/za/co/riggaroo/materialhelptutorial/ApplicationTest.java diff --git a/materialhelptutorial/src/main/AndroidManifest.xml b/materialhelptutorial-library/src/main/AndroidManifest.xml similarity index 100% rename from materialhelptutorial/src/main/AndroidManifest.xml rename to materialhelptutorial-library/src/main/AndroidManifest.xml diff --git a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/MaterialTutorialFragment.java b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/MaterialTutorialFragment.java similarity index 73% rename from materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/MaterialTutorialFragment.java rename to materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/MaterialTutorialFragment.java index 98e237b..e53bb08 100644 --- a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/MaterialTutorialFragment.java +++ b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/MaterialTutorialFragment.java @@ -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; @@ -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(); @@ -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); @@ -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); @@ -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(); + } } diff --git a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/TutorialItem.java b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/TutorialItem.java similarity index 78% rename from materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/TutorialItem.java rename to materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/TutorialItem.java index 5e6587a..37b0c11 100644 --- a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/TutorialItem.java +++ b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/TutorialItem.java @@ -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) { @@ -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; } @@ -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; @@ -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) { @@ -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 CREATOR = new Parcelable.Creator() { + public static final Creator CREATOR = new Creator() { + @Override public TutorialItem createFromParcel(Parcel source) { return new TutorialItem(source); } + @Override public TutorialItem[] newArray(int size) { return new TutorialItem[size]; } diff --git a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/adapter/MaterialTutorialAdapter.java b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/adapter/MaterialTutorialAdapter.java similarity index 100% rename from materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/adapter/MaterialTutorialAdapter.java rename to materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/adapter/MaterialTutorialAdapter.java diff --git a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialActivity.java b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialActivity.java similarity index 95% rename from materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialActivity.java rename to materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialActivity.java index 58c75ce..c644d2a 100644 --- a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialActivity.java +++ b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialActivity.java @@ -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"; @@ -152,4 +152,14 @@ public void transformPage(View page, float position) { ); } + + @Override + public Button getDoneButton() { + return mDoneButton; + } + + @Override + public TextView getSkipButton() { + return mTextViewSkip; + } } diff --git a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialContract.java b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialContract.java similarity index 100% rename from materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialContract.java rename to materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialContract.java diff --git a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialPresenter.java b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialPresenter.java similarity index 100% rename from materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialPresenter.java rename to materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/tutorial/MaterialTutorialPresenter.java diff --git a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/view/CirclePageIndicator.java b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/view/CirclePageIndicator.java similarity index 100% rename from materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/view/CirclePageIndicator.java rename to materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/view/CirclePageIndicator.java diff --git a/materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/view/PageIndicator.java b/materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/view/PageIndicator.java similarity index 100% rename from materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/view/PageIndicator.java rename to materialhelptutorial-library/src/main/java/za/co/riggaroo/materialhelptutorial/view/PageIndicator.java diff --git a/materialhelptutorial/src/main/res/drawable-hdpi/ic_navigate_next.png b/materialhelptutorial-library/src/main/res/drawable-hdpi/ic_navigate_next.png similarity index 100% rename from materialhelptutorial/src/main/res/drawable-hdpi/ic_navigate_next.png rename to materialhelptutorial-library/src/main/res/drawable-hdpi/ic_navigate_next.png diff --git a/materialhelptutorial/src/main/res/drawable-mdpi/ic_navigate_next.png b/materialhelptutorial-library/src/main/res/drawable-mdpi/ic_navigate_next.png similarity index 100% rename from materialhelptutorial/src/main/res/drawable-mdpi/ic_navigate_next.png rename to materialhelptutorial-library/src/main/res/drawable-mdpi/ic_navigate_next.png diff --git a/materialhelptutorial/src/main/res/drawable-xhdpi/ic_navigate_next.png b/materialhelptutorial-library/src/main/res/drawable-xhdpi/ic_navigate_next.png similarity index 100% rename from materialhelptutorial/src/main/res/drawable-xhdpi/ic_navigate_next.png rename to materialhelptutorial-library/src/main/res/drawable-xhdpi/ic_navigate_next.png diff --git a/materialhelptutorial/src/main/res/drawable-xxhdpi/ic_navigate_next.png b/materialhelptutorial-library/src/main/res/drawable-xxhdpi/ic_navigate_next.png similarity index 100% rename from materialhelptutorial/src/main/res/drawable-xxhdpi/ic_navigate_next.png rename to materialhelptutorial-library/src/main/res/drawable-xxhdpi/ic_navigate_next.png diff --git a/materialhelptutorial/src/main/res/drawable-xxxhdpi/ic_navigate_next.png b/materialhelptutorial-library/src/main/res/drawable-xxxhdpi/ic_navigate_next.png similarity index 100% rename from materialhelptutorial/src/main/res/drawable-xxxhdpi/ic_navigate_next.png rename to materialhelptutorial-library/src/main/res/drawable-xxxhdpi/ic_navigate_next.png diff --git a/materialhelptutorial/src/main/res/layout-land/fragment_help_tutorial_image.xml b/materialhelptutorial-library/src/main/res/layout-land/fragment_help_tutorial_image.xml similarity index 100% rename from materialhelptutorial/src/main/res/layout-land/fragment_help_tutorial_image.xml rename to materialhelptutorial-library/src/main/res/layout-land/fragment_help_tutorial_image.xml diff --git a/materialhelptutorial/src/main/res/layout/activity_help_tutorial.xml b/materialhelptutorial-library/src/main/res/layout/activity_help_tutorial.xml similarity index 100% rename from materialhelptutorial/src/main/res/layout/activity_help_tutorial.xml rename to materialhelptutorial-library/src/main/res/layout/activity_help_tutorial.xml diff --git a/materialhelptutorial/src/main/res/layout/fragment_help_tutorial_image.xml b/materialhelptutorial-library/src/main/res/layout/fragment_help_tutorial_image.xml similarity index 80% rename from materialhelptutorial/src/main/res/layout/fragment_help_tutorial_image.xml rename to materialhelptutorial-library/src/main/res/layout/fragment_help_tutorial_image.xml index 1651e95..cb3095e 100644 --- a/materialhelptutorial/src/main/res/layout/fragment_help_tutorial_image.xml +++ b/materialhelptutorial-library/src/main/res/layout/fragment_help_tutorial_image.xml @@ -1,13 +1,13 @@ + 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"> + android:scaleType="centerCrop" /> + android:scaleType="fitCenter" + android:visibility="gone" + /> \ No newline at end of file diff --git a/materialhelptutorial/src/main/res/values/attrs.xml b/materialhelptutorial-library/src/main/res/values/attrs.xml similarity index 100% rename from materialhelptutorial/src/main/res/values/attrs.xml rename to materialhelptutorial-library/src/main/res/values/attrs.xml diff --git a/materialhelptutorial-library/src/main/res/values/strings.xml b/materialhelptutorial-library/src/main/res/values/strings.xml new file mode 100644 index 0000000..12c84f7 --- /dev/null +++ b/materialhelptutorial-library/src/main/res/values/strings.xml @@ -0,0 +1,5 @@ + + help tutorial app + CERRAR + OMITIR + diff --git a/materialhelptutorial/src/main/res/values/values.xml b/materialhelptutorial-library/src/main/res/values/values.xml similarity index 100% rename from materialhelptutorial/src/main/res/values/values.xml rename to materialhelptutorial-library/src/main/res/values/values.xml diff --git a/materialhelptutorial/src/test/java/za/co/riggaroo/materialhelptutorial/ExampleUnitTest.java b/materialhelptutorial-library/src/test/java/za/co/riggaroo/materialhelptutorial/ExampleUnitTest.java similarity index 100% rename from materialhelptutorial/src/test/java/za/co/riggaroo/materialhelptutorial/ExampleUnitTest.java rename to materialhelptutorial-library/src/test/java/za/co/riggaroo/materialhelptutorial/ExampleUnitTest.java diff --git a/materialhelptutorial/materialhelptutorial.iml b/materialhelptutorial/materialhelptutorial.iml deleted file mode 100644 index 1e0b66a..0000000 --- a/materialhelptutorial/materialhelptutorial.iml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/materialhelptutorial/src/main/res/values/strings.xml b/materialhelptutorial/src/main/res/values/strings.xml deleted file mode 100644 index f94ba33..0000000 --- a/materialhelptutorial/src/main/res/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - help tutorial app - DONE - SKIP - diff --git a/settings.gradle b/settings.gradle index 90bf81b..27027d2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,3 @@ -include ':app', "materialhelptutorial" +include ':app', "materialhelptutorial-library" rootProject.name = 'materialhelptutorial'