25
25
import android .content .Intent ;
26
26
import android .os .Bundle ;
27
27
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 ;
31
31
32
- import androidx .viewpager .widget .ViewPager ;
32
+ import androidx .annotation .Nullable ;
33
+ import androidx .fragment .app .Fragment ;
33
34
import nl .hnogames .domoticz .R ;
34
35
import nl .hnogames .domoticz .Utils .SharedPrefUtil ;
35
36
import nl .hnogames .domoticz .Utils .UsefulBits ;
36
37
37
- public class WelcomeViewActivity extends IntroActivity {
38
-
38
+ public class WelcomeViewActivity extends AppIntro2 {
39
39
private static final int WELCOME_WIZARD = 1 ;
40
40
private int p = 0 ;
41
41
@@ -45,66 +45,47 @@ protected void onCreate(Bundle savedInstanceState) {
45
45
if (!UsefulBits .isEmpty (mSharedPrefs .getDisplayLanguage ()))
46
46
UsefulBits .setDisplayLanguage (this , mSharedPrefs .getDisplayLanguage ());
47
47
48
- setFullscreen (true );
49
48
super .onCreate (savedInstanceState );
50
-
51
- setFinishEnabled (false );
52
- setSkipEnabled (false );
49
+ skipButtonEnabled = false ;
53
50
UsefulBits .checkAPK (this , new SharedPrefUtil (this ));
54
51
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 ());
96
62
}
97
63
98
64
@ Override
99
65
public void onBackPressed () {
100
66
if (p > 0 ) {
101
- previousSlide ();
102
- disableFinishButton (false );
67
+ setProgressButtonEnabled (false );
103
68
} else {
104
69
finishWithResult (false );
105
70
}
106
71
}
107
72
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
+
108
89
public void finishWithResult (boolean success ) {
109
90
Bundle conData = new Bundle ();
110
91
conData .putBoolean ("RESULT" , success );
@@ -115,7 +96,7 @@ public void finishWithResult(boolean success) {
115
96
}
116
97
117
98
public void disableFinishButton (boolean disable ) {
118
- setFinishEnabled (!disable );
99
+ setProgressButtonEnabled (!disable );
119
100
}
120
101
121
102
private void endWelcomeWizard () {
0 commit comments