2020 * License along with this program. If not, see <http://www.gnu.org/licenses/>.
2121 */
2222
23- package com .owncloud . android . ui . activity ;
23+ package com .nextcloud . client . whatsnew ;
2424
25- import android .content .Context ;
26- import android .content .Intent ;
2725import android .os .Build ;
2826import android .os .Bundle ;
2927import android .view .View ;
3028import android .widget .Button ;
3129import android .widget .ImageButton ;
3230import android .widget .TextView ;
3331
32+ import com .nextcloud .client .appinfo .AppInfo ;
3433import com .nextcloud .client .di .Injectable ;
3534import com .nextcloud .client .preferences .AppPreferences ;
36- import com .owncloud .android .MainApp ;
3735import com .owncloud .android .R ;
38- import com .owncloud .android .authentication .AccountUtils ;
39- import com .owncloud .android .features .FeatureItem ;
4036import com .owncloud .android .ui .adapter .FeaturesViewAdapter ;
4137import com .owncloud .android .ui .adapter .FeaturesWebViewAdapter ;
4238import com .owncloud .android .ui .whatsnew .ProgressIndicator ;
@@ -57,6 +53,8 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
5753 private ProgressIndicator mProgress ;
5854 private ViewPager mPager ;
5955 @ Inject AppPreferences preferences ;
56+ @ Inject AppInfo appInfo ;
57+ @ Inject WhatsNewService whatsNew ;
6058
6159 @ Override
6260 protected void onCreate (Bundle savedInstanceState ) {
@@ -73,12 +71,12 @@ protected void onCreate(Bundle savedInstanceState) {
7371
7472 if (showWebView ) {
7573 FeaturesWebViewAdapter featuresWebViewAdapter = new FeaturesWebViewAdapter (getSupportFragmentManager (),
76- urls );
74+ urls );
7775 mProgress .setNumberOfSteps (featuresWebViewAdapter .getCount ());
7876 mPager .setAdapter (featuresWebViewAdapter );
7977 } else {
8078 FeaturesViewAdapter featuresViewAdapter = new FeaturesViewAdapter (getSupportFragmentManager (),
81- getWhatsNew (this , preferences ));
79+ whatsNew . getWhatsNew ());
8280 mProgress .setNumberOfSteps (featuresViewAdapter .getCount ());
8381 mPager .setAdapter (featuresViewAdapter );
8482 }
@@ -117,7 +115,7 @@ protected void onCreate(Bundle savedInstanceState) {
117115 if (showWebView ) {
118116 tv .setText (R .string .app_name );
119117 } else {
120- tv .setText (String .format (getString (R .string .whats_new_title ), MainApp .getVersionName ()));
118+ tv .setText (String .format (getString (R .string .whats_new_title ), appInfo .getVersionName ()));
121119 }
122120
123121 updateNextButtonIfNeeded ();
@@ -140,21 +138,7 @@ private void updateNextButtonIfNeeded() {
140138 }
141139
142140 private void onFinish () {
143- preferences .setLastSeenVersionCode (MainApp .getVersionCode ());
144- }
145-
146- public static void runIfNeeded (Context context , AppPreferences preferences ) {
147- if (!context .getResources ().getBoolean (R .bool .show_whats_new ) || context instanceof WhatsNewActivity ) {
148- return ;
149- }
150-
151- if (shouldShow (context , preferences )) {
152- context .startActivity (new Intent (context , WhatsNewActivity .class ));
153- }
154- }
155-
156- private static boolean shouldShow (Context context , AppPreferences preferences ) {
157- return !(context instanceof PassCodeActivity ) && getWhatsNew (context , preferences ).length > 0 ;
141+ preferences .setLastSeenVersionCode (appInfo .getVersionCode ());
158142 }
159143
160144 @ Override
@@ -172,21 +156,6 @@ public void onPageSelected(int position) {
172156 public void onPageScrollStateChanged (int state ) {
173157 // unused but to be implemented due to abstract parent
174158 }
159+ }
175160
176- static private boolean isFirstRun (Context context ) {
177- return AccountUtils .getCurrentOwnCloudAccount (context ) == null ;
178- }
179-
180- private static FeatureItem [] getWhatsNew (Context context , AppPreferences preferences ) {
181- int itemVersionCode = 30030099 ;
182161
183- if (!isFirstRun (context ) && MainApp .getVersionCode () >= itemVersionCode
184- && preferences .getLastSeenVersionCode () < itemVersionCode ) {
185- return new FeatureItem []{new FeatureItem (R .drawable .whats_new_device_credentials ,
186- R .string .whats_new_device_credentials_title , R .string .whats_new_device_credentials_content ,
187- false , false )};
188- } else {
189- return new FeatureItem [0 ];
190- }
191- }
192- }
0 commit comments