forked from organicmaps/organicmaps
[android] Show updater dialog only when “whats new” dialog shown
This commit is contained in:
parent
723a0c06f7
commit
1f8fe4ea35
5 changed files with 41 additions and 17 deletions
|
@ -758,7 +758,7 @@ Java_com_mapswithme_maps_Framework_nativeGetOutdatedCountries(JNIEnv * env, jcla
|
|||
vector<string> 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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<? extends BaseNewsFragment> clazz)
|
||||
static void create(@NonNull FragmentActivity activity,
|
||||
@NonNull Class<? extends BaseNewsFragment> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue