diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index d656b1fbd1..f0f31733e0 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -758,7 +758,7 @@ Java_com_mapswithme_maps_Framework_nativeGetOutdatedCountries(JNIEnv * env, jcla vector ids; class Storage const & storage = g_framework->GetStorage(); storage.GetOutdatedCountries(countries); - for (auto country: countries) + for (auto country : countries) ids.push_back(country->Name()); return jni::ToJavaStringArray(env, ids); diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 263e62e4f3..b99ab0987d 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -56,6 +56,7 @@ import com.mapswithme.maps.editor.ReportFragment; import com.mapswithme.maps.editor.ViralFragment; import com.mapswithme.maps.location.CompassData; import com.mapswithme.maps.location.LocationHelper; +import com.mapswithme.maps.news.BaseNewsFragment; import com.mapswithme.maps.news.FirstStartFragment; import com.mapswithme.maps.news.NewsFragment; import com.mapswithme.maps.routing.NavigationController; @@ -1025,23 +1026,24 @@ public class MwmActivity extends BaseMwmFragmentActivity if (!RoutingController.get().isNavigating()) { - mFirstStart = FirstStartFragment.showOn(this); + mFirstStart = FirstStartFragment.showOn(this, null); if (mFirstStart) return; - if (!NewsFragment.showOn(this)) + BaseNewsFragment.NewsDialogListener listener = new BaseNewsFragment.NewsDialogListener() + { + @Override + public void onDialogDone() + { + UpdaterDialogFragment.showOn(MwmActivity.this); + } + }; + if (!NewsFragment.showOn(this, listener)) { if (ViralFragment.shouldDisplay()) - { new ViralFragment().show(getSupportFragmentManager(), ""); - } else - { - if (UpdaterDialogFragment.showOn(this)) - return; - LikesManager.INSTANCE.showDialogs(this); - } } } diff --git a/android/src/com/mapswithme/maps/news/BaseNewsFragment.java b/android/src/com/mapswithme/maps/news/BaseNewsFragment.java index ab904358fe..3560c071d4 100644 --- a/android/src/com/mapswithme/maps/news/BaseNewsFragment.java +++ b/android/src/com/mapswithme/maps/news/BaseNewsFragment.java @@ -6,6 +6,7 @@ import android.content.res.TypedArray; import android.os.Bundle; import android.support.annotation.ArrayRes; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; @@ -29,7 +30,7 @@ import com.mapswithme.maps.base.BaseMwmDialogFragment; import com.mapswithme.util.ThemeUtils; import com.mapswithme.util.UiUtils; -abstract class BaseNewsFragment extends BaseMwmDialogFragment +public abstract class BaseNewsFragment extends BaseMwmDialogFragment { private ViewPager mPager; private View mPrevButton; @@ -39,6 +40,9 @@ abstract class BaseNewsFragment extends BaseMwmDialogFragment private int mPageCount; + @Nullable + private NewsDialogListener mListener; + abstract class Adapter extends PagerAdapter { private final int[] mImages; @@ -288,15 +292,23 @@ abstract class BaseNewsFragment extends BaseMwmDialogFragment protected void onDoneClick() { dismissAllowingStateLoss(); + if (mListener != null) + mListener.onDialogDone(); } @SuppressWarnings("TryWithIdenticalCatches") - static void create(FragmentActivity activity, Class clazz) + static void create(@NonNull FragmentActivity activity, + @NonNull Class clazz, + @Nullable NewsDialogListener listener) { try { final BaseNewsFragment fragment = clazz.newInstance(); - fragment.show(activity.getSupportFragmentManager(), clazz.getName()); + fragment.mListener = listener; + activity.getSupportFragmentManager() + .beginTransaction() + .add(fragment, clazz.getName()) + .commitAllowingStateLoss(); } catch (java.lang.InstantiationException ignored) {} catch (IllegalAccessException ignored) @@ -317,4 +329,9 @@ abstract class BaseNewsFragment extends BaseMwmDialogFragment fm.executePendingTransactions(); return true; } + + public interface NewsDialogListener + { + void onDialogDone(); + } } diff --git a/android/src/com/mapswithme/maps/news/FirstStartFragment.java b/android/src/com/mapswithme/maps/news/FirstStartFragment.java index a5ac214b5f..edeb1a3e9b 100644 --- a/android/src/com/mapswithme/maps/news/FirstStartFragment.java +++ b/android/src/com/mapswithme/maps/news/FirstStartFragment.java @@ -3,6 +3,7 @@ package com.mapswithme.maps.news; import android.app.Dialog; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; @@ -73,7 +74,8 @@ public class FirstStartFragment extends BaseNewsFragment LocationHelper.INSTANCE.onExitFromFirstRun(); } - public static boolean showOn(FragmentActivity activity) + public static boolean showOn(@NonNull FragmentActivity activity, + @Nullable NewsDialogListener listener) { if (Config.getFirstInstallVersion() < BuildConfig.VERSION_CODE) return false; @@ -86,7 +88,7 @@ public class FirstStartFragment extends BaseNewsFragment !recreate(activity, FirstStartFragment.class)) return false; - create(activity, FirstStartFragment.class); + create(activity, FirstStartFragment.class, listener); Config.setFirstStartDialogSeen(); return true; diff --git a/android/src/com/mapswithme/maps/news/NewsFragment.java b/android/src/com/mapswithme/maps/news/NewsFragment.java index afdf02a39d..254fbae887 100644 --- a/android/src/com/mapswithme/maps/news/NewsFragment.java +++ b/android/src/com/mapswithme/maps/news/NewsFragment.java @@ -1,5 +1,7 @@ package com.mapswithme.maps.news; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; @@ -58,7 +60,8 @@ public class NewsFragment extends BaseNewsFragment * Displays "What's new" dialog on given {@code activity}. Or not. * @return whether "What's new" dialog should be shown. */ - public static boolean showOn(FragmentActivity activity) + public static boolean showOn(@NonNull FragmentActivity activity, + @Nullable NewsDialogListener listener) { if (Config.getFirstInstallVersion() >= BuildConfig.VERSION_CODE) return false; @@ -71,7 +74,7 @@ public class NewsFragment extends BaseNewsFragment !recreate(activity, NewsFragment.class)) return false; - create(activity, NewsFragment.class); + create(activity, NewsFragment.class, listener); Config.setWhatsNewShown(); return true;