2525import android .content .Intent ;
2626import android .os .Bundle ;
2727
28- import com .heinrichreimersoftware . materialintro . app . IntroActivity ;
29- import com .heinrichreimersoftware . materialintro . slide . FragmentSlide ;
30- import com .heinrichreimersoftware . materialintro . slide . SimpleSlide ;
28+ import com .github . paolorotolo . appintro . AppIntro2 ;
29+ import com .github . paolorotolo . appintro . AppIntroFragment ;
30+ import com .github . paolorotolo . appintro . model . SliderPage ;
3131
32- import androidx .viewpager .widget .ViewPager ;
32+ import androidx .annotation .Nullable ;
33+ import androidx .fragment .app .Fragment ;
3334import nl .hnogames .domoticz .R ;
3435import nl .hnogames .domoticz .Utils .SharedPrefUtil ;
3536import nl .hnogames .domoticz .Utils .UsefulBits ;
3637
37- public class WelcomeViewActivity extends IntroActivity {
38-
38+ public class WelcomeViewActivity extends AppIntro2 {
3939 private static final int WELCOME_WIZARD = 1 ;
4040 private int p = 0 ;
4141
@@ -45,66 +45,47 @@ protected void onCreate(Bundle savedInstanceState) {
4545 if (!UsefulBits .isEmpty (mSharedPrefs .getDisplayLanguage ()))
4646 UsefulBits .setDisplayLanguage (this , mSharedPrefs .getDisplayLanguage ());
4747
48- setFullscreen (true );
4948 super .onCreate (savedInstanceState );
50-
51- setFinishEnabled (false );
52- setSkipEnabled (false );
49+ skipButtonEnabled = false ;
5350 UsefulBits .checkAPK (this , new SharedPrefUtil (this ));
5451
55- addSlide (new SimpleSlide .Builder ()
56- .image (R .mipmap .ic_launcher )
57- .title (R .string .app_name_domoticz )
58- .description (R .string .welcome_info_domoticz )
59- .background (R .color .black )
60- .build ());
61-
62- addSlide (new FragmentSlide .Builder ()
63- .background (R .color .welcome2_background )
64- .fragment (WelcomePage2 .newInstance ())
65- .build ());
66-
67- addSlide (new FragmentSlide .Builder ()
68- .background (!mSharedPrefs .darkThemeEnabled () ? R .color .welcome4_background : R .color .primary_dark )
69- .fragment (WelcomePage3 .newInstance (WELCOME_WIZARD ))
70- .build ());
71-
72- addSlide (new FragmentSlide .Builder ()
73- .background (!mSharedPrefs .darkThemeEnabled () ? R .color .welcome4_background : R .color .primary_dark )
74- .fragment (WelcomePage4 .newInstance ())
75- .build ());
76-
77- addOnPageChangeListener (new ViewPager .OnPageChangeListener () {
78- @ Override
79- public void onPageScrolled (int position , float positionOffset , int positionOffsetPixels ) {
80- }
81-
82- @ Override
83- public void onPageSelected (int position ) {
84- p = position ;
85- if (position == 3 ) {
86- setFinishEnabled (true );
87- } else {
88- setFinishEnabled (false );
89- }
90- }
91-
92- @ Override
93- public void onPageScrollStateChanged (int state ) {
94- }
95- });
52+ SliderPage sliderPage = new SliderPage ();
53+ sliderPage .setTitle (getString (R .string .app_name_domoticz ));
54+ sliderPage .setDescription (getString (R .string .welcome_info_domoticz ));
55+ sliderPage .setImageDrawable (R .mipmap .ic_launcher );
56+ sliderPage .setBgColor (R .color .black );
57+ addSlide (AppIntroFragment .newInstance (sliderPage ));
58+
59+ addSlide (WelcomePage2 .newInstance ());
60+ addSlide (WelcomePage3 .newInstance (WELCOME_WIZARD ));
61+ addSlide (WelcomePage4 .newInstance ());
9662 }
9763
9864 @ Override
9965 public void onBackPressed () {
10066 if (p > 0 ) {
101- previousSlide ();
102- disableFinishButton (false );
67+ setProgressButtonEnabled (false );
10368 } else {
10469 finishWithResult (false );
10570 }
10671 }
10772
73+ @ Override
74+ public void onDonePressed (Fragment currentFragment ) {
75+ super .onDonePressed (currentFragment );
76+ finishWithResult (true );
77+ }
78+
79+ @ Override
80+ public void onSlideChanged (@ Nullable Fragment oldFragment , @ Nullable Fragment newFragment ) {
81+ super .onSlideChanged (oldFragment , newFragment );
82+ if (newFragment instanceof WelcomePage4 ) {
83+ setProgressButtonEnabled (false );
84+ } else {
85+ setProgressButtonEnabled (true );
86+ }
87+ }
88+
10889 public void finishWithResult (boolean success ) {
10990 Bundle conData = new Bundle ();
11091 conData .putBoolean ("RESULT" , success );
@@ -115,7 +96,7 @@ public void finishWithResult(boolean success) {
11596 }
11697
11798 public void disableFinishButton (boolean disable ) {
118- setFinishEnabled (!disable );
99+ setProgressButtonEnabled (!disable );
119100 }
120101
121102 private void endWelcomeWizard () {
0 commit comments